本文整理汇总了C++中FloatRect::width方法的典型用法代码示例。如果您正苦于以下问题:C++ FloatRect::width方法的具体用法?C++ FloatRect::width怎么用?C++ FloatRect::width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FloatRect
的用法示例。
在下文中一共展示了FloatRect::width方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: roundToDevicePixels
FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect)
{
FloatRect result;
double x = frect.x();
double y = frect.y();
cairo_t* cr = m_data->cr;
cairo_user_to_device(cr, &x, &y);
x = round(x);
y = round(y);
cairo_device_to_user(cr, &x, &y);
result.setX(static_cast<float>(x));
result.setY(static_cast<float>(y));
x = frect.width();
y = frect.height();
cairo_user_to_device_distance(cr, &x, &y);
x = round(x);
y = round(y);
cairo_device_to_user_distance(cr, &x, &y);
result.setWidth(static_cast<float>(x));
result.setHeight(static_cast<float>(y));
return result;
}
示例2: drawClipAsMask
bool SVGClipPainter::drawClipAsMask(GraphicsContext& context, const LayoutObject& layoutObject, const FloatRect& targetBoundingBox, const FloatRect& targetPaintInvalidationRect, const AffineTransform& localTransform)
{
if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutObject, DisplayItem::SVGClip))
return true;
SkPictureBuilder maskPictureBuilder(targetPaintInvalidationRect, nullptr, &context);
GraphicsContext& maskContext = maskPictureBuilder.context();
{
TransformRecorder recorder(maskContext, layoutObject, localTransform);
// Create a clipPathClipper if this clipPath is clipped by another clipPath.
SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(&m_clip);
LayoutSVGResourceClipper* clipPathClipper = resources ? resources->clipper() : nullptr;
ClipperState clipPathClipperState = ClipperNotApplied;
if (clipPathClipper && !SVGClipPainter(*clipPathClipper).prepareEffect(m_clip, targetBoundingBox, targetPaintInvalidationRect, maskContext, clipPathClipperState))
return false;
{
AffineTransform contentTransform;
if (m_clip.clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
contentTransform.translate(targetBoundingBox.x(), targetBoundingBox.y());
contentTransform.scaleNonUniform(targetBoundingBox.width(), targetBoundingBox.height());
}
SubtreeContentTransformScope contentTransformScope(contentTransform);
TransformRecorder contentTransformRecorder(maskContext, layoutObject, contentTransform);
RefPtr<const SkPicture> clipContentPicture = m_clip.createContentPicture();
maskContext.getPaintController().createAndAppend<DrawingDisplayItem>(layoutObject, DisplayItem::SVGClip, clipContentPicture.get());
}
if (clipPathClipper)
SVGClipPainter(*clipPathClipper).finishEffect(m_clip, maskContext, clipPathClipperState);
}
LayoutObjectDrawingRecorder drawingRecorder(context, layoutObject, DisplayItem::SVGClip, targetPaintInvalidationRect);
RefPtr<SkPicture> maskPicture = maskPictureBuilder.endRecording();
context.drawPicture(maskPicture.get());
return true;
}
示例3: drawContentIntoMaskImage
bool RenderSVGResourceMasker::drawContentIntoMaskImage(MaskerData* maskerData, ColorSpace colorSpace, RenderObject* object)
{
GraphicsContext* maskImageContext = maskerData->maskImage->context();
ASSERT(maskImageContext);
// Eventually adjust the mask image context according to the target objectBoundingBox.
AffineTransform maskContentTransformation;
if (maskElement().maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
FloatRect objectBoundingBox = object->objectBoundingBox();
maskContentTransformation.translate(objectBoundingBox.x(), objectBoundingBox.y());
maskContentTransformation.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.height());
maskImageContext->concatCTM(maskContentTransformation);
}
// Draw the content into the ImageBuffer.
for (auto& child : childrenOfType<SVGElement>(maskElement())) {
auto renderer = child.renderer();
if (!renderer)
continue;
if (renderer->needsLayout())
return false;
const RenderStyle& style = renderer->style();
if (style.display() == NONE || style.visibility() != VISIBLE)
continue;
SVGRenderingContext::renderSubtreeToImageBuffer(maskerData->maskImage.get(), *renderer, maskContentTransformation);
}
#if !USE(CG)
maskerData->maskImage->transformColorSpace(ColorSpaceDeviceRGB, colorSpace);
#else
UNUSED_PARAM(colorSpace);
#endif
// Create the luminance mask.
if (style().svgStyle().maskType() == MT_LUMINANCE)
maskerData->maskImage->convertToLuminanceMask();
return true;
}
示例4: createImageBuffer
bool SVGImageBufferTools::createImageBuffer(const FloatRect& absoluteTargetRect, const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>& imageBuffer, ColorSpace colorSpace, RenderingMode renderingMode)
{
IntSize imageSize(roundedImageBufferSize(clampedAbsoluteTargetRect.size()));
IntSize unclampedImageSize(SVGImageBufferTools::roundedImageBufferSize(absoluteTargetRect.size()));
// Don't create empty ImageBuffers.
if (imageSize.isEmpty())
return false;
OwnPtr<ImageBuffer> image = ImageBuffer::create(imageSize, colorSpace, renderingMode);
if (!image)
return false;
GraphicsContext* imageContext = image->context();
ASSERT(imageContext);
// Compensate rounding effects, as the absolute target rect is using floating-point numbers and the image buffer size is integer.
imageContext->scale(FloatSize(unclampedImageSize.width() / absoluteTargetRect.width(), unclampedImageSize.height() / absoluteTargetRect.height()));
imageBuffer = image.release();
return true;
}
示例5: asPath
bool LayoutSVGResourceClipper::asPath(
const AffineTransform& animatedLocalTransform,
const FloatRect& referenceBox,
Path& clipPath) {
if (!calculateClipContentPathIfNeeded())
return false;
clipPath = m_clipContentPath;
// We are able to represent the clip as a path. Continue with direct clipping,
// and transform the content to userspace if necessary.
if (clipPathUnits() == SVGUnitTypes::kSvgUnitTypeObjectboundingbox) {
AffineTransform transform;
transform.translate(referenceBox.x(), referenceBox.y());
transform.scaleNonUniform(referenceBox.width(), referenceBox.height());
clipPath.transform(transform);
}
// Transform path by animatedLocalTransform.
clipPath.transform(animatedLocalTransform);
return true;
}
示例6: contentTransformScope
PassRefPtr<const SkPicture> LayoutSVGResourceMasker::createContentPicture(AffineTransform& contentTransformation, const FloatRect& targetBoundingBox,
GraphicsContext& context)
{
SVGUnitTypes::SVGUnitType contentUnits = toSVGMaskElement(element())->maskContentUnits()->currentValue()->enumValue();
if (contentUnits == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
contentTransformation.translate(targetBoundingBox.x(), targetBoundingBox.y());
contentTransformation.scaleNonUniform(targetBoundingBox.width(), targetBoundingBox.height());
}
if (m_maskContentPicture)
return m_maskContentPicture;
SubtreeContentTransformScope contentTransformScope(contentTransformation);
// Using strokeBoundingBox (instead of paintInvalidationRectInLocalCoordinates) to avoid the intersection
// with local clips/mask, which may yield incorrect results when mixing objectBoundingBox and
// userSpaceOnUse units (http://crbug.com/294900).
FloatRect bounds = strokeBoundingBox();
SkPictureBuilder pictureBuilder(bounds, nullptr, &context);
ColorFilter maskContentFilter = style()->svgStyle().colorInterpolation() == CI_LINEARRGB
? ColorFilterSRGBToLinearRGB : ColorFilterNone;
pictureBuilder.context().setColorFilter(maskContentFilter);
for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement)) {
LayoutObject* layoutObject = childElement->layoutObject();
if (!layoutObject)
continue;
const ComputedStyle* style = layoutObject->style();
if (!style || style->display() == NONE || style->visibility() != VISIBLE)
continue;
SVGPaintContext::paintSubtree(pictureBuilder.context(), layoutObject);
}
m_maskContentPicture = pictureBuilder.endRecording();
return m_maskContentPicture;
}
示例7: paint
void RenderPath::paint(PaintInfo& paintInfo, int, int)
{
if (paintInfo.context->paintingDisabled() || style()->visibility() == HIDDEN || m_path.isEmpty())
return;
FloatRect boundingBox = repaintRectInLocalCoordinates();
if (!SVGRenderSupport::paintInfoIntersectsRepaintRect(boundingBox, m_localTransform, paintInfo))
return;
PaintInfo childPaintInfo(paintInfo);
bool drawsOutline = style()->outlineWidth() && (childPaintInfo.phase == PaintPhaseOutline || childPaintInfo.phase == PaintPhaseSelfOutline);
if (drawsOutline || childPaintInfo.phase == PaintPhaseForeground) {
childPaintInfo.context->save();
childPaintInfo.applyTransform(m_localTransform);
if (childPaintInfo.phase == PaintPhaseForeground) {
PaintInfo savedInfo(childPaintInfo);
if (SVGRenderSupport::prepareToRenderSVGContent(this, childPaintInfo)) {
const SVGRenderStyle* svgStyle = style()->svgStyle();
if (svgStyle->shapeRendering() == SR_CRISPEDGES)
childPaintInfo.context->setShouldAntialias(false);
fillAndStrokePath(childPaintInfo.context);
if (svgStyle->hasMarkers())
m_markerLayoutInfo.drawMarkers(childPaintInfo);
}
SVGRenderSupport::finishRenderSVGContent(this, childPaintInfo, savedInfo.context);
}
if (drawsOutline)
paintOutline(childPaintInfo.context, static_cast<int>(boundingBox.x()), static_cast<int>(boundingBox.y()),
static_cast<int>(boundingBox.width()), static_cast<int>(boundingBox.height()));
childPaintInfo.context->restore();
}
}
示例8: showLineLayoutForFlow
void showLineLayoutForFlow(const RenderBlockFlow& flow, const Layout& layout, int depth)
{
int printedCharacters = 0;
printPrefix(printedCharacters, depth);
fprintf(stderr, "SimpleLineLayout (%u lines, %u runs) (%p)\n", layout.lineCount(), layout.runCount(), &layout);
++depth;
auto resolver = runResolver(flow, layout);
for (auto it = resolver.begin(), end = resolver.end(); it != end; ++it) {
const auto& run = *it;
FloatRect rect = run.rect();
printPrefix(printedCharacters, depth);
if (run.start() < run.end()) {
fprintf(stderr, "line %u run(%u, %u) (%.2f, %.2f) (%.2f, %.2f) \"%s\"\n", run.lineIndex(), run.start(), run.end(),
rect.x(), rect.y(), rect.width(), rect.height(), run.text().toStringWithoutCopying().utf8().data());
} else {
ASSERT(run.start() == run.end());
fprintf(stderr, "line break %u run(%u, %u) (%.2f, %.2f) (%.2f, %.2f)\n", run.lineIndex(), run.start(), run.end(), rect.x(), rect.y(), rect.width(), rect.height());
}
}
}
示例9: clipForPatternFilling
void PlatformContextCairo::clipForPatternFilling(const GraphicsContextState& state)
{
ASSERT(state.fillPattern);
// Hold current cairo path in a variable for restoring it after configuring the pattern clip rectangle.
auto currentPath = cairo_copy_path(m_cr.get());
cairo_new_path(m_cr.get());
// Initialize clipping extent from current cairo clip extents, then shrink if needed according to pattern.
// Inspired by GraphicsContextQt::drawRepeatPattern.
double x1, y1, x2, y2;
cairo_clip_extents(m_cr.get(), &x1, &y1, &x2, &y2);
FloatRect clipRect(x1, y1, x2 - x1, y2 - y1);
Image* patternImage = state.fillPattern->tileImage();
ASSERT(patternImage);
const AffineTransform& patternTransform = state.fillPattern->getPatternSpaceTransform();
FloatRect patternRect = patternTransform.mapRect(FloatRect(0, 0, patternImage->width(), patternImage->height()));
bool repeatX = state.fillPattern->repeatX();
bool repeatY = state.fillPattern->repeatY();
if (!repeatX) {
clipRect.setX(patternRect.x());
clipRect.setWidth(patternRect.width());
}
if (!repeatY) {
clipRect.setY(patternRect.y());
clipRect.setHeight(patternRect.height());
}
if (!repeatX || !repeatY) {
cairo_rectangle(m_cr.get(), clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height());
cairo_clip(m_cr.get());
}
// Restoring cairo path.
cairo_append_path(m_cr.get(), currentPath);
cairo_path_destroy(currentPath);
}
示例10: drawTiled
void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& destRect, const FloatPoint& srcPoint, const FloatSize& scaledTileSize, CompositeOperator op)
{
if (mayFillWithSolidColor()) {
fillWithSolidColor(ctxt, destRect, solidColor(), op);
return;
}
FloatSize intrinsicTileSize = size();
if (hasRelativeWidth())
intrinsicTileSize.setWidth(scaledTileSize.width());
if (hasRelativeHeight())
intrinsicTileSize.setHeight(scaledTileSize.height());
FloatSize scale(scaledTileSize.width() / intrinsicTileSize.width(),
scaledTileSize.height() / intrinsicTileSize.height());
AffineTransform patternTransform = AffineTransform().scale(scale.width(), scale.height());
FloatRect oneTileRect;
oneTileRect.setX(destRect.x() + fmodf(fmodf(-srcPoint.x(), scaledTileSize.width()) - scaledTileSize.width(), scaledTileSize.width()));
oneTileRect.setY(destRect.y() + fmodf(fmodf(-srcPoint.y(), scaledTileSize.height()) - scaledTileSize.height(), scaledTileSize.height()));
oneTileRect.setSize(scaledTileSize);
// Check and see if a single draw of the image can cover the entire area we are supposed to tile.
if (oneTileRect.contains(destRect)) {
FloatRect visibleSrcRect;
visibleSrcRect.setX((destRect.x() - oneTileRect.x()) / scale.width());
visibleSrcRect.setY((destRect.y() - oneTileRect.y()) / scale.height());
visibleSrcRect.setWidth(destRect.width() / scale.width());
visibleSrcRect.setHeight(destRect.height() / scale.height());
draw(ctxt, destRect, visibleSrcRect, op);
return;
}
FloatRect tileRect(FloatPoint(), intrinsicTileSize);
drawPattern(ctxt, tileRect, patternTransform, oneTileRect.location(), op, destRect);
startAnimation();
}
示例11: paintCharacter
LayoutRect RenderMathMLOperator::paintCharacter(PaintInfo& info, UChar character, const LayoutPoint& origin, CharacterPaintTrimming trim)
{
GlyphData data = style()->font().glyphDataForCharacter(character, false);
FloatRect glyphBounds = data.fontData->boundsForGlyph(data.glyph);
LayoutRect glyphPaintRect(origin, LayoutSize(glyphBounds.x() + glyphBounds.width(), glyphBounds.height()));
glyphPaintRect.setY(origin.y() + glyphBounds.y());
// In order to have glyphs fit snugly with one another we snap the connecting edges to pixel boundaries
// and trim off one pixel. The pixel trim is to account for fonts that have edge pixels that have less
// than full coverage. These edge pixels can introduce small seams between connected glyphs
FloatRect clipBounds = info.rect;
switch (trim) {
case TrimTop:
glyphPaintRect.shiftYEdgeTo(glyphPaintRect.y().ceil() + 1);
clipBounds.shiftYEdgeTo(glyphPaintRect.y());
break;
case TrimBottom:
glyphPaintRect.shiftMaxYEdgeTo(glyphPaintRect.maxY().floor() - 1);
clipBounds.shiftMaxYEdgeTo(glyphPaintRect.maxY());
break;
case TrimTopAndBottom:
LayoutUnit temp = glyphPaintRect.y() + 1;
glyphPaintRect.shiftYEdgeTo(temp.ceil());
glyphPaintRect.shiftMaxYEdgeTo(glyphPaintRect.maxY().floor() - 1);
clipBounds.shiftYEdgeTo(glyphPaintRect.y());
clipBounds.shiftMaxYEdgeTo(glyphPaintRect.maxY());
break;
}
// Clipping the enclosing IntRect avoids any potential issues at joined edges.
GraphicsContextStateSaver stateSaver(*info.context);
info.context->clip(clipBounds);
info.context->drawText(style()->font(), TextRun(&character, 1), origin);
return glyphPaintRect;
}
示例12: paint
void RenderPath::paint(PaintInfo& paintInfo, int, int)
{
if (paintInfo.context->paintingDisabled() || style()->visibility() == HIDDEN || m_path.isEmpty())
return;
FloatRect boundingBox = repaintRectInLocalCoordinates();
FloatRect nonLocalBoundingBox = m_localTransform.mapRect(boundingBox);
// FIXME: The empty rect check is to deal with incorrect initial clip in renderSubtreeToImage
// unfortunately fixing that problem is fairly complex unless we were willing to just futz the
// rect to something "close enough"
if (!nonLocalBoundingBox.intersects(paintInfo.rect) && !paintInfo.rect.isEmpty())
return;
PaintInfo childPaintInfo(paintInfo);
childPaintInfo.context->save();
applyTransformToPaintInfo(childPaintInfo, m_localTransform);
SVGResourceFilter* filter = 0;
if (childPaintInfo.phase == PaintPhaseForeground) {
PaintInfo savedInfo(childPaintInfo);
if (prepareToRenderSVGContent(this, childPaintInfo, boundingBox, filter)) {
if (style()->svgStyle()->shapeRendering() == SR_CRISPEDGES)
childPaintInfo.context->setShouldAntialias(false);
fillAndStrokePath(m_path, childPaintInfo.context, style(), this);
if (static_cast<SVGStyledElement*>(node())->supportsMarkers())
m_markerLayoutInfo.drawMarkers(childPaintInfo);
}
finishRenderSVGContent(this, childPaintInfo, filter, savedInfo.context);
}
if ((childPaintInfo.phase == PaintPhaseOutline || childPaintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth())
paintOutline(childPaintInfo.context, static_cast<int>(boundingBox.x()), static_cast<int>(boundingBox.y()),
static_cast<int>(boundingBox.width()), static_cast<int>(boundingBox.height()), style());
childPaintInfo.context->restore();
}
示例13: determineFilterPrimitiveSubregion
FloatRect FilterEffect::determineFilterPrimitiveSubregion()
{
ASSERT(filter());
// FETile, FETurbulence, FEFlood don't have input effects, take the filter region as unite rect.
FloatRect subregion;
if (unsigned numberOfInputEffects = inputEffects().size()) {
subregion = inputEffect(0)->determineFilterPrimitiveSubregion();
for (unsigned i = 1; i < numberOfInputEffects; ++i)
subregion.unite(inputEffect(i)->determineFilterPrimitiveSubregion());
} else
subregion = filter()->filterRegion();
// After calling determineFilterPrimitiveSubregion on the target effect, reset the subregion again for <feTile>.
if (filterEffectType() == FilterEffectTypeTile)
subregion = filter()->filterRegion();
subregion = mapRect(subregion);
FloatRect boundaries = effectBoundaries();
if (hasX())
subregion.setX(boundaries.x());
if (hasY())
subregion.setY(boundaries.y());
if (hasWidth())
subregion.setWidth(boundaries.width());
if (hasHeight())
subregion.setHeight(boundaries.height());
setFilterPrimitiveSubregion(subregion);
FloatRect absoluteSubregion = filter()->absoluteTransform().mapRect(subregion);
FloatSize filterResolution = filter()->filterResolution();
absoluteSubregion.scale(filterResolution.width(), filterResolution.height());
setMaxEffectRect(absoluteSubregion);
return subregion;
}
示例14: resourceBoundingBox
FloatRect RenderSVGResourceMasker::resourceBoundingBox(const RenderObject& object)
{
FloatRect objectBoundingBox = object.objectBoundingBox();
FloatRect maskBoundaries = SVGLengthContext::resolveRectangle<SVGMaskElement>(&maskElement(), maskElement().maskUnits(), objectBoundingBox);
// Resource was not layouted yet. Give back clipping rect of the mask.
if (selfNeedsLayout())
return maskBoundaries;
if (m_maskContentBoundaries.isEmpty())
calculateMaskContentRepaintRect();
FloatRect maskRect = m_maskContentBoundaries;
if (maskElement().maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
AffineTransform transform;
transform.translate(objectBoundingBox.x(), objectBoundingBox.y());
transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.height());
maskRect = transform.mapRect(maskRect);
}
maskRect.intersect(maskBoundaries);
return maskRect;
}
示例15: paintMediaPlayButton
bool RenderThemeWinCE::paintMediaPlayButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
{
bool rc = paintButton(o, paintInfo, r);
FloatRect imRect = r;
imRect.inflate(-3);
paintInfo.context->save();
paintInfo.context->setStrokeColor(Color::black);
paintInfo.context->setFillColor(Color::black);
HTMLMediaElement* mediaElement = mediaElementParent(o->node());
bool paused = !mediaElement || mediaElement->paused();
if (paused) {
float width = imRect.width();
imRect.setWidth(width / 3.0);
paintInfo.context->fillRect(imRect);
imRect.move(2.0 * width / 3.0, 0);
paintInfo.context->fillRect(imRect);
} else {
FloatPoint pts[3] = { FloatPoint(imRect.x(), imRect.y()), FloatPoint(imRect.maxX(), (imRect.y() + imRect.maxY()) / 2.0), FloatPoint(imRect.x(), imRect.maxY()) };
paintInfo.context->drawConvexPolygon(3, pts);
}
paintInfo.context->restore();
return rc;
}