本文整理汇总了C++中FloatRect::size方法的典型用法代码示例。如果您正苦于以下问题:C++ FloatRect::size方法的具体用法?C++ FloatRect::size怎么用?C++ FloatRect::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FloatRect
的用法示例。
在下文中一共展示了FloatRect::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintReplaced
void RenderEmbeddedObject::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
if (!pluginCrashedOrWasMissing())
return;
if (paintInfo.phase == PaintPhaseSelection)
return;
GraphicsContext* context = paintInfo.context;
if (context->paintingDisabled())
return;
FloatRect contentRect;
Path path;
FloatRect replacementTextRect;
Font font;
TextRun run("");
float textWidth;
if (!getReplacementTextGeometry(paintOffset, contentRect, path, replacementTextRect, font, run, textWidth))
return;
GraphicsContextStateSaver stateSaver(*context);
context->clip(contentRect);
context->setAlpha(m_missingPluginIndicatorIsPressed ? replacementTextPressedRoundedRectOpacity : replacementTextRoundedRectOpacity);
context->setFillColor(m_missingPluginIndicatorIsPressed ? replacementTextRoundedRectPressedColor() : Color::white, style()->colorSpace());
context->fillPath(path);
const FontMetrics& fontMetrics = font.fontMetrics();
float labelX = roundf(replacementTextRect.location().x() + (replacementTextRect.size().width() - textWidth) / 2);
float labelY = roundf(replacementTextRect.location().y() + (replacementTextRect.size().height() - fontMetrics.height()) / 2 + fontMetrics.ascent());
context->setAlpha(m_missingPluginIndicatorIsPressed ? replacementTextPressedTextOpacity : replacementTextTextOpacity);
context->setFillColor(Color::black, style()->colorSpace());
context->drawBidiText(font, run, FloatPoint(labelX, labelY));
}
示例2: paintReplaced
void RenderEmbeddedObject::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
if (!showsUnavailablePluginIndicator())
return;
if (paintInfo.phase == PaintPhaseSelection)
return;
FloatRect contentRect;
Path path;
FloatRect replacementTextRect;
Font font;
TextRun run("");
float textWidth;
if (!getReplacementTextGeometry(paintOffset, contentRect, path, replacementTextRect, font, run, textWidth))
return;
GraphicsContext* context = paintInfo.context;
GraphicsContextStateSaver stateSaver(*context);
context->clip(contentRect);
context->setAlphaAsFloat(replacementTextRoundedRectOpacity);
context->setFillColor(Color::white);
context->fillPath(path);
const FontMetrics& fontMetrics = font.fontMetrics();
float labelX = roundf(replacementTextRect.location().x() + (replacementTextRect.size().width() - textWidth) / 2);
float labelY = roundf(replacementTextRect.location().y() + (replacementTextRect.size().height() - fontMetrics.height()) / 2 + fontMetrics.ascent());
TextRunPaintInfo runInfo(run);
runInfo.bounds = replacementTextRect;
context->setAlphaAsFloat(replacementTextTextOpacity);
context->setFillColor(Color::black);
context->drawBidiText(font, runInfo, FloatPoint(labelX, labelY));
}
示例3: getReplacementTextGeometry
bool RenderEmbeddedObject::getReplacementTextGeometry(const LayoutPoint& accumulatedOffset, FloatRect& contentRect, Path& path, FloatRect& replacementTextRect, Font& font, TextRun& run, float& textWidth) const
{
contentRect = contentBoxRect();
contentRect.moveBy(roundedIntPoint(accumulatedOffset));
FontDescription fontDescription;
RenderTheme::theme().systemFont(CSSValueWebkitSmallControl, fontDescription);
fontDescription.setWeight(FontWeightBold);
Settings* settings = document().settings();
ASSERT(settings);
if (!settings)
return false;
fontDescription.setComputedSize(fontDescription.specifiedSize());
font = Font(fontDescription, 0, 0);
font.update(0);
run = TextRun(m_unavailablePluginReplacementText);
textWidth = font.width(run);
replacementTextRect.setSize(FloatSize(textWidth + replacementTextRoundedRectLeftRightTextMargin * 2, replacementTextRoundedRectHeight));
float x = (contentRect.size().width() / 2 - replacementTextRect.size().width() / 2) + contentRect.location().x();
float y = (contentRect.size().height() / 2 - replacementTextRect.size().height() / 2) + contentRect.location().y();
replacementTextRect.setLocation(FloatPoint(x, y));
path.addRoundedRect(replacementTextRect, FloatSize(replacementTextRoundedRectRadius, replacementTextRoundedRectRadius));
return true;
}
示例4: drawNativeImage
void drawNativeImage(const NativeImagePtr& image, GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, const IntSize&, CompositeOperator op, BlendMode mode, const ImageOrientation& orientation)
{
context.save();
// Set the compositing operation.
if (op == CompositeSourceOver && mode == BlendModeNormal && !nativeImageHasAlpha(image))
context.setCompositeOperation(CompositeCopy);
else
context.setCompositeOperation(op, mode);
#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
IntSize scaledSize = nativeImageSize(image);
FloatRect adjustedSrcRect = adjustSourceRectForDownSampling(srcRect, scaledSize);
#else
FloatRect adjustedSrcRect(srcRect);
#endif
FloatRect adjustedDestRect = destRect;
if (orientation != DefaultImageOrientation) {
// ImageOrientation expects the origin to be at (0, 0).
context.translate(destRect.x(), destRect.y());
adjustedDestRect.setLocation(FloatPoint());
context.concatCTM(orientation.transformFromDefault(adjustedDestRect.size()));
if (orientation.usesWidthAsHeight()) {
// The destination rectangle will have it's width and height already reversed for the orientation of
// the image, as it was needed for page layout, so we need to reverse it back here.
adjustedDestRect.setSize(adjustedDestRect.size().transposedSize());
}
}
context.platformContext()->drawSurfaceToContext(image.get(), adjustedDestRect, adjustedSrcRect, context);
context.restore();
}
示例5: bufferForeground
bool SVGRenderingContext::bufferForeground(std::unique_ptr<ImageBuffer>& imageBuffer)
{
ASSERT(m_paintInfo);
ASSERT(is<RenderSVGImage>(*m_renderer));
FloatRect boundingBox = m_renderer->objectBoundingBox();
// Invalidate an existing buffer if the scale is not correct.
if (imageBuffer) {
AffineTransform transform = m_paintInfo->context().getCTM(GraphicsContext::DefinitelyIncludeDeviceScale);
IntSize expandedBoundingBox = expandedIntSize(boundingBox.size());
IntSize bufferSize(static_cast<int>(ceil(expandedBoundingBox.width() * transform.xScale())), static_cast<int>(ceil(expandedBoundingBox.height() * transform.yScale())));
if (bufferSize != imageBuffer->internalSize())
imageBuffer.reset();
}
// Create a new buffer and paint the foreground into it.
if (!imageBuffer) {
if ((imageBuffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(boundingBox.size()), ColorSpaceSRGB, m_paintInfo->context()))) {
GraphicsContext& bufferedRenderingContext = imageBuffer->context();
bufferedRenderingContext.translate(-boundingBox.x(), -boundingBox.y());
PaintInfo bufferedInfo(*m_paintInfo);
bufferedInfo.setContext(bufferedRenderingContext);
downcast<RenderSVGImage>(*m_renderer).paintForeground(bufferedInfo);
} else
return false;
}
m_paintInfo->context().drawImageBuffer(*imageBuffer, boundingBox);
return true;
}
示例6: getReplacementTextGeometry
bool RenderEmbeddedObject::getReplacementTextGeometry(const LayoutPoint& accumulatedOffset, FloatRect& contentRect, FloatRect& indicatorRect, FloatRect& replacementTextRect, FloatRect& arrowRect, FontCascade& font, TextRun& run, float& textWidth) const
{
bool includesArrow = shouldUnavailablePluginMessageBeButton(document(), m_pluginUnavailabilityReason);
contentRect = contentBoxRect();
contentRect.moveBy(roundedIntPoint(accumulatedOffset));
FontCascadeDescription fontDescription;
RenderTheme::defaultTheme()->systemFont(CSSValueWebkitSmallControl, fontDescription);
fontDescription.setWeight(FontWeightBold);
fontDescription.setRenderingMode(frame().settings().fontRenderingMode());
fontDescription.setComputedSize(12);
font = FontCascade(fontDescription, 0, 0);
font.update(0);
run = TextRun(m_unavailablePluginReplacementText);
textWidth = font.width(run);
replacementTextRect.setSize(FloatSize(textWidth + replacementTextRoundedRectLeftTextMargin + (includesArrow ? replacementTextRoundedRectRightTextMarginWithArrow : replacementTextRoundedRectRightTextMargin), replacementTextRoundedRectHeight));
float x = (contentRect.size().width() / 2 - replacementTextRect.size().width() / 2) + contentRect.location().x();
float y = (contentRect.size().height() / 2 - replacementTextRect.size().height() / 2) + contentRect.location().y();
replacementTextRect.setLocation(FloatPoint(x, y));
indicatorRect = replacementTextRect;
// Expand the background rect to include the arrow, if it will be used.
if (includesArrow) {
arrowRect = indicatorRect;
arrowRect.setX(ceilf(arrowRect.maxX() + replacementArrowLeftMargin));
arrowRect.setWidth(arrowRect.height());
indicatorRect.unite(arrowRect);
}
return true;
}
示例7: getReplacementTextGeometry
bool RenderEmbeddedObject::getReplacementTextGeometry(int tx, int ty, FloatRect& contentRect, Path& path, FloatRect& replacementTextRect, Font& font, TextRun& run, float& textWidth)
{
contentRect = contentBoxRect();
contentRect.move(tx, ty);
FontDescription fontDescription;
RenderTheme::defaultTheme()->systemFont(CSSValueWebkitSmallControl, fontDescription);
fontDescription.setWeight(FontWeightBold);
Settings* settings = document()->settings();
ASSERT(settings);
if (!settings)
return false;
fontDescription.setRenderingMode(settings->fontRenderingMode());
fontDescription.setComputedSize(fontDescription.specifiedSize());
font = Font(fontDescription, 0, 0);
font.update(0);
run = TextRun(m_replacementText.characters(), m_replacementText.length());
run.disableRoundingHacks();
textWidth = font.floatWidth(run);
replacementTextRect.setSize(FloatSize(textWidth + replacementTextRoundedRectLeftRightTextMargin * 2, replacementTextRoundedRectHeight));
float x = (contentRect.size().width() / 2 - replacementTextRect.size().width() / 2) + contentRect.location().x();
float y = (contentRect.size().height() / 2 - replacementTextRect.size().height() / 2) + contentRect.location().y();
replacementTextRect.setLocation(FloatPoint(x, y));
path.addRoundedRect(replacementTextRect, FloatSize(replacementTextRoundedRectRadius, replacementTextRoundedRectRadius));
return true;
}
示例8: drawDeferredFilter
static void drawDeferredFilter(GraphicsContext* context, FilterData* filterData, SVGFilterElement* filterElement)
{
SkiaImageFilterBuilder builder(context);
SourceGraphic* sourceGraphic = static_cast<SourceGraphic*>(filterData->builder->getEffectById(SourceGraphic::effectName()));
ASSERT(sourceGraphic);
builder.setSourceGraphic(sourceGraphic);
RefPtr<ImageFilter> imageFilter = builder.build(filterData->builder->lastEffect(), ColorSpaceDeviceRGB);
FloatRect boundaries = filterData->boundaries;
context->save();
FloatSize deviceSize = context->getCTM().mapSize(boundaries.size());
float scaledArea = deviceSize.width() * deviceSize.height();
// If area of scaled size is bigger than the upper limit, adjust the scale
// to fit. Note that this only really matters in the non-impl-side painting
// case, since the impl-side case never allocates a full-sized backing
// store, only tile-sized.
// FIXME: remove this once all platforms are using impl-side painting.
// crbug.com/169282.
if (scaledArea > FilterEffect::maxFilterArea()) {
float scale = sqrtf(FilterEffect::maxFilterArea() / scaledArea);
context->scale(scale, scale);
}
// Clip drawing of filtered image to the minimum required paint rect.
FilterEffect* lastEffect = filterData->builder->lastEffect();
context->clipRect(lastEffect->determineAbsolutePaintRect(lastEffect->maxEffectRect()));
if (filterElement->hasAttribute(SVGNames::filterResAttr)) {
// Get boundaries in device coords.
// FIXME: See crbug.com/382491. Is the use of getCTM OK here, given it does not include device
// zoom or High DPI adjustments?
FloatSize size = context->getCTM().mapSize(boundaries.size());
// Compute the scale amount required so that the resulting offscreen is exactly filterResX by filterResY pixels.
float filterResScaleX = filterElement->filterResX()->currentValue()->value() / size.width();
float filterResScaleY = filterElement->filterResY()->currentValue()->value() / size.height();
// Scale the CTM so the primitive is drawn to filterRes.
context->scale(filterResScaleX, filterResScaleY);
// Create a resize filter with the inverse scale.
AffineTransform resizeMatrix;
resizeMatrix.scale(1 / filterResScaleX, 1 / filterResScaleY);
imageFilter = builder.buildTransform(resizeMatrix, imageFilter.get());
}
// If the CTM contains rotation or shearing, apply the filter to
// the unsheared/unrotated matrix, and do the shearing/rotation
// as a final pass.
AffineTransform ctm = context->getCTM();
if (ctm.b() || ctm.c()) {
AffineTransform scaleAndTranslate;
scaleAndTranslate.translate(ctm.e(), ctm.f());
scaleAndTranslate.scale(ctm.xScale(), ctm.yScale());
ASSERT(scaleAndTranslate.isInvertible());
AffineTransform shearAndRotate = scaleAndTranslate.inverse();
shearAndRotate.multiply(ctm);
context->setCTM(scaleAndTranslate);
imageFilter = builder.buildTransform(shearAndRotate, imageFilter.get());
}
context->beginLayer(1, CompositeSourceOver, &boundaries, ColorFilterNone, imageFilter.get());
context->endLayer();
context->restore();
}
示例9: drawNamedImage
void Theme::drawNamedImage(const String& name, GraphicsContext& context, const FloatRect& rect) const
{
// We only handle one icon at the moment.
if (name != "wireless-playback")
return;
GraphicsContextStateSaver stateSaver(context);
context.setFillColor(Color::black, ColorSpaceDeviceRGB);
// Draw a generic Wireless Playback icon.
context.scale(FloatSize(rect.size().width() / 100, rect.size().height() / 100));
context.translate(8, 1);
Path outline;
outline.moveTo(FloatPoint(59, 58.7));
outline.addBezierCurveTo(FloatPoint(58.1, 58.7), FloatPoint(57.2, 58.4), FloatPoint(56.4, 57.7));
outline.addLineTo(FloatPoint(42, 45.5));
outline.addLineTo(FloatPoint(27.6, 57.8));
outline.addBezierCurveTo(FloatPoint(25.9, 59.2), FloatPoint(23.4, 59), FloatPoint(22, 57.3));
outline.addBezierCurveTo(FloatPoint(20.6, 55.6), FloatPoint(20.8, 53.1), FloatPoint(22.5, 51.7));
outline.addLineTo(FloatPoint(39.5, 37.3));
outline.addBezierCurveTo(FloatPoint(41, 36), FloatPoint(43.2, 36), FloatPoint(44.7, 37.3));
outline.addLineTo(FloatPoint(61.7, 51.7));
outline.addBezierCurveTo(FloatPoint(63.4, 53.1), FloatPoint(63.6, 55.7), FloatPoint(62.2, 57.3));
outline.addBezierCurveTo(FloatPoint(61.3, 58.2), FloatPoint(60.1, 58.7), FloatPoint(59, 58.7));
outline.addLineTo(FloatPoint(59, 58.7));
outline.closeSubpath();
outline.moveTo(FloatPoint(42, 98));
outline.addBezierCurveTo(FloatPoint(39.8, 98), FloatPoint(38, 96.3), FloatPoint(38, 94.2));
outline.addLineTo(FloatPoint(38, 43.6));
outline.addBezierCurveTo(FloatPoint(38, 41.5), FloatPoint(39.8, 39.8), FloatPoint(42, 39.8));
outline.addBezierCurveTo(FloatPoint(44.2, 39.8), FloatPoint(46, 41.5), FloatPoint(46, 43.6));
outline.addLineTo(FloatPoint(46, 94.2));
outline.addBezierCurveTo(FloatPoint(46, 96.3), FloatPoint(44.2, 98), FloatPoint(42, 98));
outline.addLineTo(FloatPoint(42, 98));
outline.closeSubpath();
outline.moveTo(FloatPoint(83.6, 41.6));
outline.addBezierCurveTo(FloatPoint(83.6, 18.6), FloatPoint(65, 0), FloatPoint(42, 0));
outline.addBezierCurveTo(FloatPoint(19, 0), FloatPoint(0.4, 18.6), FloatPoint(0.4, 41.6));
outline.addBezierCurveTo(FloatPoint(0.4, 62.2), FloatPoint(15, 79.2), FloatPoint(35, 82.6));
outline.addLineTo(FloatPoint(35, 74.5));
outline.addBezierCurveTo(FloatPoint(20, 71.2), FloatPoint(8.4, 57.7), FloatPoint(8.4, 41.6));
outline.addBezierCurveTo(FloatPoint(8.4, 23.1), FloatPoint(23.5, 8), FloatPoint(42, 8));
outline.addBezierCurveTo(FloatPoint(60.5, 8), FloatPoint(75.5, 23.1), FloatPoint(75.5, 41.6));
outline.addBezierCurveTo(FloatPoint(75.6, 57.7), FloatPoint(64, 71.2), FloatPoint(49, 74.5));
outline.addLineTo(FloatPoint(49, 82.6));
outline.addBezierCurveTo(FloatPoint(69, 79.3), FloatPoint(83.6, 62.2), FloatPoint(83.6, 41.6));
outline.addLineTo(FloatPoint(83.6, 41.6));
outline.closeSubpath();
context.fillPath(outline);
}
示例10: draw
void GeneratorGeneratedImage::draw(GraphicsContext* destContext, const FloatRect& destRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp, BlendMode blendMode)
{
GraphicsContextStateSaver stateSaver(*destContext);
destContext->setCompositeOperation(compositeOp, blendMode);
destContext->clip(destRect);
destContext->translate(destRect.x(), destRect.y());
if (destRect.size() != srcRect.size())
destContext->scale(FloatSize(destRect.width() / srcRect.width(), destRect.height() / srcRect.height()));
destContext->translate(-srcRect.x(), -srcRect.y());
destContext->fillRect(FloatRect(FloatPoint(), m_size), *m_gradient.get());
}
示例11: draw
void GeneratorGeneratedImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp)
{
GraphicsContextStateSaver stateSaver(*context);
context->setCompositeOperation(compositeOp);
context->clip(dstRect);
context->translate(dstRect.x(), dstRect.y());
if (dstRect.size() != srcRect.size())
context->scale(FloatSize(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height()));
context->translate(-srcRect.x(), -srcRect.y());
context->fillRect(FloatRect(FloatPoint(), m_size), *m_generator.get());
}
示例12: draw
void GradientImage::draw(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator compositeOp, BlendMode blendMode, ImageOrientationDescription)
{
GraphicsContextStateSaver stateSaver(destContext);
destContext.setCompositeOperation(compositeOp, blendMode);
destContext.clip(destRect);
destContext.translate(destRect.x(), destRect.y());
if (destRect.size() != srcRect.size())
destContext.scale(FloatSize(destRect.width() / srcRect.width(), destRect.height() / srcRect.height()));
destContext.translate(-srcRect.x(), -srcRect.y());
destContext.fillRect(FloatRect(FloatPoint(), size()), *m_gradient.get());
}
示例13: path
void BasicShapeCircle::path(Path& path, const FloatRect& boundingBox)
{
ASSERT(path.isEmpty());
FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boundingBox.size());
float radius = floatValueForRadiusInBox(boundingBox.size());
path.addEllipse(FloatRect(
center.x() - radius + boundingBox.x(),
center.y() - radius + boundingBox.y(),
radius * 2,
radius * 2
));
}
示例14: draw
void GradientGeneratedImage::draw(SkCanvas* canvas, const SkPaint& paint, const FloatRect& destRect, const FloatRect& srcRect, RespectImageOrientationEnum, ImageClampingMode)
{
SkAutoCanvasRestore ar(canvas, true);
canvas->clipRect(destRect);
canvas->translate(destRect.x(), destRect.y());
if (destRect.size() != srcRect.size())
canvas->scale(destRect.width() / srcRect.width(), destRect.height() / srcRect.height());
canvas->translate(-srcRect.x(), -srcRect.y());
SkPaint gradientPaint(paint);
gradientPaint.setShader(m_gradient->shader());
canvas->drawRect(SkRect::MakeWH(m_size.width(), m_size.height()), gradientPaint);
}
示例15: draw
void CrossfadeGeneratedImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp, BlendMode blendMode, ImageOrientationDescription)
{
GraphicsContextStateSaver stateSaver(*context);
context->setCompositeOperation(compositeOp, blendMode);
context->clip(dstRect);
context->translate(dstRect.x(), dstRect.y());
if (dstRect.size() != srcRect.size())
context->scale(FloatSize(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height()));
context->translate(-srcRect.x(), -srcRect.y());
drawCrossfade(context);
}