本文整理汇总了C++中FloatSize类的典型用法代码示例。如果您正苦于以下问题:C++ FloatSize类的具体用法?C++ FloatSize怎么用?C++ FloatSize使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FloatSize类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: translate
void Path::translate(const FloatSize& size)
{
QTransform matrix;
matrix.translate(size.width(), size.height());
m_path = m_path * matrix;
}
示例2: addBeziersForRoundedRect
void Path::addBeziersForRoundedRect(const FloatRect& rect, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius)
{
moveTo(FloatPoint(rect.x() + topLeftRadius.width(), rect.y()));
addLineTo(FloatPoint(rect.maxX() - topRightRadius.width(), rect.y()));
if (topRightRadius.width() > 0 || topRightRadius.height() > 0)
addBezierCurveTo(FloatPoint(rect.maxX() - topRightRadius.width() * gCircleControlPoint, rect.y()),
FloatPoint(rect.maxX(), rect.y() + topRightRadius.height() * gCircleControlPoint),
FloatPoint(rect.maxX(), rect.y() + topRightRadius.height()));
addLineTo(FloatPoint(rect.maxX(), rect.maxY() - bottomRightRadius.height()));
if (bottomRightRadius.width() > 0 || bottomRightRadius.height() > 0)
addBezierCurveTo(FloatPoint(rect.maxX(), rect.maxY() - bottomRightRadius.height() * gCircleControlPoint),
FloatPoint(rect.maxX() - bottomRightRadius.width() * gCircleControlPoint, rect.maxY()),
FloatPoint(rect.maxX() - bottomRightRadius.width(), rect.maxY()));
addLineTo(FloatPoint(rect.x() + bottomLeftRadius.width(), rect.maxY()));
if (bottomLeftRadius.width() > 0 || bottomLeftRadius.height() > 0)
addBezierCurveTo(FloatPoint(rect.x() + bottomLeftRadius.width() * gCircleControlPoint, rect.maxY()),
FloatPoint(rect.x(), rect.maxY() - bottomLeftRadius.height() * gCircleControlPoint),
FloatPoint(rect.x(), rect.maxY() - bottomLeftRadius.height()));
addLineTo(FloatPoint(rect.x(), rect.y() + topLeftRadius.height()));
if (topLeftRadius.width() > 0 || topLeftRadius.height() > 0)
addBezierCurveTo(FloatPoint(rect.x(), rect.y() + topLeftRadius.height() * gCircleControlPoint),
FloatPoint(rect.x() + topLeftRadius.width() * gCircleControlPoint, rect.y()),
FloatPoint(rect.x() + topLeftRadius.width(), rect.y()));
closeSubpath();
}
示例3: computeMinimumScaleFactorForContentContained
float computeMinimumScaleFactorForContentContained(const ViewportAttributes& result, const IntSize& visibleViewport, const IntSize& contentsSize, float devicePixelRatio)
{
FloatSize viewportSize = convertToUserSpace(visibleViewport, devicePixelRatio);
return max<float>(result.minimumScale, max(viewportSize.width() / contentsSize.width(), viewportSize.height() / contentsSize.height()));
}
示例4: resolveHeightForRatio
static inline int resolveHeightForRatio(int width, const FloatSize& intrinsicRatio)
{
return ceilf(width * intrinsicRatio.height() / intrinsicRatio.width());
}
示例5: computeIntrinsicDimensions
void Image::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
{
intrinsicRatio = size();
intrinsicWidth = Length(intrinsicRatio.width(), Fixed);
intrinsicHeight = Length(intrinsicRatio.height(), Fixed);
}
示例6: createEllipseShape
static PassOwnPtr<Shape> createEllipseShape(const FloatPoint& center, const FloatSize& radii)
{
ASSERT(radii.width() >= 0 && radii.height() >= 0);
return adoptPtr(new RectangleShape(FloatRect(center.x() - radii.width(), center.y() - radii.height(), radii.width()*2, radii.height()*2), radii));
}
示例7: computePageRectsWithPageSizeInternal
void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSizeInPixels, bool allowInlineDirectionTiling)
{
if (!m_frame->document() || !m_frame->view() || !m_frame->document()->renderView())
return;
RenderView* view = m_frame->document()->renderView();
IntRect docRect = view->documentRect();
int pageWidth = pageSizeInPixels.width();
int pageHeight = pageSizeInPixels.height();
bool isHorizontal = view->style()->isHorizontalWritingMode();
int docLogicalHeight = isHorizontal ? docRect.height() : docRect.width();
int pageLogicalHeight = isHorizontal ? pageHeight : pageWidth;
int pageLogicalWidth = isHorizontal ? pageWidth : pageHeight;
int inlineDirectionStart;
int inlineDirectionEnd;
int blockDirectionStart;
int blockDirectionEnd;
if (isHorizontal) {
if (view->style()->isFlippedBlocksWritingMode()) {
blockDirectionStart = docRect.maxY();
blockDirectionEnd = docRect.y();
} else {
blockDirectionStart = docRect.y();
blockDirectionEnd = docRect.maxY();
}
inlineDirectionStart = view->style()->isLeftToRightDirection() ? docRect.x() : docRect.maxX();
inlineDirectionEnd = view->style()->isLeftToRightDirection() ? docRect.maxX() : docRect.x();
} else {
if (view->style()->isFlippedBlocksWritingMode()) {
blockDirectionStart = docRect.maxX();
blockDirectionEnd = docRect.x();
} else {
blockDirectionStart = docRect.x();
blockDirectionEnd = docRect.maxX();
}
inlineDirectionStart = view->style()->isLeftToRightDirection() ? docRect.y() : docRect.maxY();
inlineDirectionEnd = view->style()->isLeftToRightDirection() ? docRect.maxY() : docRect.y();
}
unsigned pageCount = ceilf((float)docLogicalHeight / pageLogicalHeight);
for (unsigned i = 0; i < pageCount; ++i) {
int pageLogicalTop = blockDirectionEnd > blockDirectionStart ?
blockDirectionStart + i * pageLogicalHeight :
blockDirectionStart - (i + 1) * pageLogicalHeight;
if (allowInlineDirectionTiling) {
for (int currentInlinePosition = inlineDirectionStart;
inlineDirectionEnd > inlineDirectionStart ? currentInlinePosition < inlineDirectionEnd : currentInlinePosition > inlineDirectionEnd;
currentInlinePosition += (inlineDirectionEnd > inlineDirectionStart ? pageLogicalWidth : -pageLogicalWidth)) {
int pageLogicalLeft = inlineDirectionEnd > inlineDirectionStart ? currentInlinePosition : currentInlinePosition - pageLogicalWidth;
IntRect pageRect(pageLogicalLeft, pageLogicalTop, pageLogicalWidth, pageLogicalHeight);
if (!isHorizontal)
pageRect = pageRect.transposedRect();
m_pageRects.append(pageRect);
}
} else {
int pageLogicalLeft = inlineDirectionEnd > inlineDirectionStart ? inlineDirectionStart : inlineDirectionStart - pageLogicalWidth;
IntRect pageRect(pageLogicalLeft, pageLogicalTop, pageLogicalWidth, pageLogicalHeight);
if (!isHorizontal)
pageRect = pageRect.transposedRect();
m_pageRects.append(pageRect);
}
}
}
示例8: perpProduct
inline static float perpProduct(const FloatSize& u, const FloatSize& v)
{
return u.width() * v.height() - u.height() * v.width();
}
示例9: innerProduct
inline static float innerProduct(const FloatSize& u, const FloatSize& v)
{
return u.width() * v.width() + u.height() * v.height();
}
示例10: translate
void Path::translate(const FloatSize& size)
{
AffineTransform transformation;
transformation.translate(size.width(), size.height());
transform(transformation);
}
示例11: createWindow
static Frame* createWindow(Frame* openerFrame, Frame* lookupFrame, const FrameLoadRequest& request, const WindowFeatures& features, NavigationPolicy policy, ShouldSendReferrer shouldSendReferrer, bool& created)
{
ASSERT(!features.dialog || request.frameName().isEmpty());
if (!request.frameName().isEmpty() && request.frameName() != "_blank" && policy == NavigationPolicyIgnore) {
if (Frame* frame = lookupFrame->loader().findFrameForNavigation(request.frameName(), openerFrame->document())) {
if (request.frameName() != "_self")
frame->page()->focusController().setFocusedFrame(frame);
created = false;
return frame;
}
}
// Sandboxed frames cannot open new auxiliary browsing contexts.
if (openerFrame->document()->isSandboxed(SandboxPopups)) {
// FIXME: This message should be moved off the console once a solution to https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
openerFrame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Blocked opening '" + request.resourceRequest().url().elidedString() + "' in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set.");
return 0;
}
if (openerFrame->settings() && !openerFrame->settings()->supportsMultipleWindows()) {
created = false;
return openerFrame->tree().top();
}
Page* oldPage = openerFrame->page();
if (!oldPage)
return 0;
Page* page = oldPage->chrome().client().createWindow(openerFrame, request, features, policy, shouldSendReferrer);
if (!page)
return 0;
FrameHost* host = &page->frameHost();
Frame* frame = page->mainFrame();
frame->loader().forceSandboxFlags(openerFrame->document()->sandboxFlags());
if (request.frameName() != "_blank")
frame->tree().setName(request.frameName());
host->chrome().setWindowFeatures(features);
// 'x' and 'y' specify the location of the window, while 'width' and 'height'
// specify the size of the viewport. We can only resize the window, so adjust
// for the difference between the window size and the viewport size.
FloatRect windowRect = host->chrome().windowRect();
FloatSize viewportSize = host->chrome().pageRect().size();
if (features.xSet)
windowRect.setX(features.x);
if (features.ySet)
windowRect.setY(features.y);
if (features.widthSet)
windowRect.setWidth(features.width + (windowRect.width() - viewportSize.width()));
if (features.heightSet)
windowRect.setHeight(features.height + (windowRect.height() - viewportSize.height()));
// Ensure non-NaN values, minimum size as well as being within valid screen area.
FloatRect newWindowRect = DOMWindow::adjustWindowRect(frame, windowRect);
host->chrome().setWindowRect(newWindowRect);
host->chrome().show(policy);
created = true;
return frame;
}
示例12: ceilf
FloatSize HTMLCanvasElement::convertDeviceToLogical(const FloatSize& deviceSize) const
{
float width = ceilf(deviceSize.width() / m_deviceScaleFactor);
float height = ceilf(deviceSize.height() / m_deviceScaleFactor);
return FloatSize(width, height);
}
示例13: determinant
static inline float determinant(const FloatSize& a, const FloatSize& b)
{
return a.width() * b.height() - a.height() * b.width();
}
示例14: resolve
PageScaleConstraints ViewportDescription::resolve(const FloatSize& initialViewportSize, Length legacyFallbackWidth) const
{
float resultWidth = ValueAuto;
Length copyMaxWidth = maxWidth;
Length copyMinWidth = minWidth;
// In case the width (used for min- and max-width) is undefined.
if (isLegacyViewportType() && maxWidth.isAuto()) {
// The width viewport META property is translated into 'width' descriptors, setting
// the 'min' value to 'extend-to-zoom' and the 'max' value to the intended length.
// In case the UA-defines a min-width, use that as length.
if (zoom == ViewportDescription::ValueAuto) {
copyMinWidth = Length(ExtendToZoom);
copyMaxWidth = legacyFallbackWidth;
} else if (maxHeight.isAuto()) {
copyMinWidth = Length(ExtendToZoom);
copyMaxWidth = Length(ExtendToZoom);
}
}
float resultMaxWidth = resolveViewportLength(copyMaxWidth, initialViewportSize, Horizontal);
float resultMinWidth = resolveViewportLength(copyMinWidth, initialViewportSize, Horizontal);
float resultHeight = ValueAuto;
float resultMaxHeight = resolveViewportLength(maxHeight, initialViewportSize, Vertical);
float resultMinHeight = resolveViewportLength(minHeight, initialViewportSize, Vertical);
float resultZoom = zoom;
float resultMinZoom = minZoom;
float resultMaxZoom = maxZoom;
bool resultUserZoom = userZoom;
// 1. Resolve min-zoom and max-zoom values.
if (resultMinZoom != ViewportDescription::ValueAuto && resultMaxZoom != ViewportDescription::ValueAuto)
resultMaxZoom = std::max(resultMinZoom, resultMaxZoom);
// 2. Constrain zoom value to the [min-zoom, max-zoom] range.
if (resultZoom != ViewportDescription::ValueAuto)
resultZoom = compareIgnoringAuto(resultMinZoom, compareIgnoringAuto(resultMaxZoom, resultZoom, std::min), std::max);
float extendZoom = compareIgnoringAuto(resultZoom, resultMaxZoom, std::min);
// 3. Resolve non-"auto" lengths to pixel lengths.
if (extendZoom == ViewportDescription::ValueAuto) {
if (resultMaxWidth == ViewportDescription::ValueExtendToZoom)
resultMaxWidth = ViewportDescription::ValueAuto;
if (resultMaxHeight == ViewportDescription::ValueExtendToZoom)
resultMaxHeight = ViewportDescription::ValueAuto;
if (resultMinWidth == ViewportDescription::ValueExtendToZoom)
resultMinWidth = resultMaxWidth;
if (resultMinHeight == ViewportDescription::ValueExtendToZoom)
resultMinHeight = resultMaxHeight;
} else {
float extendWidth = initialViewportSize.width() / extendZoom;
float extendHeight = initialViewportSize.height() / extendZoom;
if (resultMaxWidth == ViewportDescription::ValueExtendToZoom)
resultMaxWidth = extendWidth;
if (resultMaxHeight == ViewportDescription::ValueExtendToZoom)
resultMaxHeight = extendHeight;
if (resultMinWidth == ViewportDescription::ValueExtendToZoom)
resultMinWidth = compareIgnoringAuto(extendWidth, resultMaxWidth, std::max);
if (resultMinHeight == ViewportDescription::ValueExtendToZoom)
resultMinHeight = compareIgnoringAuto(extendHeight, resultMaxHeight, std::max);
}
// 4. Resolve initial width from min/max descriptors.
if (resultMinWidth != ViewportDescription::ValueAuto || resultMaxWidth != ViewportDescription::ValueAuto)
resultWidth = compareIgnoringAuto(resultMinWidth, compareIgnoringAuto(resultMaxWidth, initialViewportSize.width(), std::min), std::max);
// 5. Resolve initial height from min/max descriptors.
if (resultMinHeight != ViewportDescription::ValueAuto || resultMaxHeight != ViewportDescription::ValueAuto)
resultHeight = compareIgnoringAuto(resultMinHeight, compareIgnoringAuto(resultMaxHeight, initialViewportSize.height(), std::min), std::max);
// 6-7. Resolve width value.
if (resultWidth == ViewportDescription::ValueAuto) {
if (resultHeight == ViewportDescription::ValueAuto || !initialViewportSize.height())
resultWidth = initialViewportSize.width();
else
resultWidth = resultHeight * (initialViewportSize.width() / initialViewportSize.height());
}
// 8. Resolve height value.
if (resultHeight == ViewportDescription::ValueAuto) {
if (!initialViewportSize.width())
resultHeight = initialViewportSize.height();
else
resultHeight = resultWidth * initialViewportSize.height() / initialViewportSize.width();
}
// Resolve initial-scale value.
if (resultZoom == ViewportDescription::ValueAuto) {
if (resultWidth != ViewportDescription::ValueAuto && resultWidth > 0)
resultZoom = initialViewportSize.width() / resultWidth;
//.........这里部分代码省略.........
示例15: resolve
ViewportAttributes ViewportArguments::resolve(const FloatSize& initialViewportSize, const FloatSize& deviceSize, int defaultWidth) const
{
float resultWidth = width;
float resultMaxWidth = maxWidth;
float resultMinWidth = minWidth;
float resultHeight = height;
float resultMinHeight = minHeight;
float resultMaxHeight = maxHeight;
float resultZoom = zoom;
float resultMinZoom = minZoom;
float resultMaxZoom = maxZoom;
float resultUserZoom = userZoom;
switch (int(resultWidth)) {
case ViewportArguments::ValueDeviceWidth:
resultWidth = deviceSize.width();
break;
case ViewportArguments::ValueDeviceHeight:
resultWidth = deviceSize.height();
break;
}
switch (int(resultHeight)) {
case ViewportArguments::ValueDeviceWidth:
resultHeight = deviceSize.width();
break;
case ViewportArguments::ValueDeviceHeight:
resultHeight = deviceSize.height();
break;
}
if (type == ViewportArguments::CSSDeviceAdaptation) {
switch (int(resultMinWidth)) {
case ViewportArguments::ValueDeviceWidth:
resultMinWidth = deviceSize.width();
break;
case ViewportArguments::ValueDeviceHeight:
resultMinWidth = deviceSize.height();
break;
}
switch (int(resultMaxWidth)) {
case ViewportArguments::ValueDeviceWidth:
resultMaxWidth = deviceSize.width();
break;
case ViewportArguments::ValueDeviceHeight:
resultMaxWidth = deviceSize.height();
break;
}
switch (int(resultMinHeight)) {
case ViewportArguments::ValueDeviceWidth:
resultMinHeight = deviceSize.width();
break;
case ViewportArguments::ValueDeviceHeight:
resultMinHeight = deviceSize.height();
break;
}
switch (int(resultMaxHeight)) {
case ViewportArguments::ValueDeviceWidth:
resultMaxHeight = deviceSize.width();
break;
case ViewportArguments::ValueDeviceHeight:
resultMaxHeight = deviceSize.height();
break;
}
if (resultMinWidth != ViewportArguments::ValueAuto || resultMaxWidth != ViewportArguments::ValueAuto)
resultWidth = compareIgnoringAuto(resultMinWidth, compareIgnoringAuto(resultMaxWidth, deviceSize.width(), std::min), std::max);
if (resultMinHeight != ViewportArguments::ValueAuto || resultMaxHeight != ViewportArguments::ValueAuto)
resultHeight = compareIgnoringAuto(resultMinHeight, compareIgnoringAuto(resultMaxHeight, deviceSize.height(), std::min), std::max);
if (resultMinZoom != ViewportArguments::ValueAuto && resultMaxZoom != ViewportArguments::ValueAuto)
resultMaxZoom = std::max(resultMinZoom, resultMaxZoom);
if (resultZoom != ViewportArguments::ValueAuto)
resultZoom = compareIgnoringAuto(resultMinZoom, compareIgnoringAuto(resultMaxZoom, resultZoom, std::min), std::max);
if (resultWidth == ViewportArguments::ValueAuto && resultZoom == ViewportArguments::ValueAuto)
resultWidth = deviceSize.width();
if (resultWidth == ViewportArguments::ValueAuto && resultHeight == ViewportArguments::ValueAuto)
resultWidth = deviceSize.width() / resultZoom;
if (resultWidth == ViewportArguments::ValueAuto)
resultWidth = resultHeight * deviceSize.width() / deviceSize.height();
if (resultHeight == ViewportArguments::ValueAuto)
resultHeight = resultWidth * deviceSize.height() / deviceSize.width();
if (resultZoom != ViewportArguments::ValueAuto || resultMaxZoom != ViewportArguments::ValueAuto) {
resultWidth = compareIgnoringAuto(resultWidth, deviceSize.width() / compareIgnoringAuto(resultZoom, resultMaxZoom, std::min), std::max);
resultHeight = compareIgnoringAuto(resultHeight, deviceSize.height() / compareIgnoringAuto(resultZoom, resultMaxZoom, std::min), std::max);
}
resultWidth = std::max<float>(1, resultWidth);
resultHeight = std::max<float>(1, resultHeight);
}
//.........这里部分代码省略.........