本文整理汇总了C++中FloatRect::height方法的典型用法代码示例。如果您正苦于以下问题:C++ FloatRect::height方法的具体用法?C++ FloatRect::height怎么用?C++ FloatRect::height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FloatRect
的用法示例。
在下文中一共展示了FloatRect::height方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: 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());
}
}
}
示例4: addRect
void Path::addRect(const FloatRect& rect)
{
static const VGubyte pathSegments[] = {
VG_MOVE_TO_ABS,
VG_HLINE_TO_REL,
VG_VLINE_TO_REL,
VG_HLINE_TO_REL,
VG_CLOSE_PATH
};
const VGfloat pathData[] = {
rect.x(), rect.y(),
rect.width(),
rect.height(),
-rect.width()
};
m_path->makeCompatibleContextCurrent();
vgAppendPathData(m_path->vgPath(), 5, pathSegments, pathData);
ASSERT_VG_NO_ERROR();
m_path->m_currentPoint = m_path->m_subpathStartPoint = rect.location();
}
示例5: drawContentIntoMaskImage
bool RenderSVGResourceMasker::drawContentIntoMaskImage(MaskerData* maskerData, ColorSpace colorSpace, RenderObject* object)
{
GraphicsContext& maskImageContext = maskerData->maskImage->context();
// 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;
}
示例6: 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();
}
示例7: 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;
}
示例8: 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();
}
示例9: 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;
}
示例10: computePageRects
void PrintContext::computePageRects(const FloatRect& printRect,
float headerHeight,
float footerHeight,
float userScaleFactor,
float& outPageHeight) {
m_pageRects.clear();
outPageHeight = 0;
if (!m_frame->document() || !m_frame->view() ||
m_frame->document()->layoutViewItem().isNull())
return;
if (userScaleFactor <= 0) {
DLOG(ERROR) << "userScaleFactor has bad value " << userScaleFactor;
return;
}
LayoutViewItem view = m_frame->document()->layoutViewItem();
const IntRect& documentRect = view.documentRect();
FloatSize pageSize = m_frame->resizePageRectsKeepingRatio(
FloatSize(printRect.width(), printRect.height()),
FloatSize(documentRect.width(), documentRect.height()));
float pageWidth = pageSize.width();
float pageHeight = pageSize.height();
outPageHeight =
pageHeight; // this is the height of the page adjusted by margins
pageHeight -= headerHeight + footerHeight;
if (pageHeight <= 0) {
DLOG(ERROR) << "pageHeight has bad value " << pageHeight;
return;
}
computePageRectsWithPageSizeInternal(
FloatSize(pageWidth / userScaleFactor, pageHeight / userScaleFactor));
}
示例11: drawPatternToCairoContext
void drawPatternToCairoContext(cairo_t* cr, cairo_surface_t* image, const IntSize& imageSize, const FloatRect& tileRect,
const AffineTransform& patternTransform, const FloatPoint& phase, cairo_operator_t op, const FloatRect& destRect)
{
// Avoid NaN
if (!isfinite(phase.x()) || !isfinite(phase.y()))
return;
cairo_save(cr);
RefPtr<cairo_surface_t> clippedImageSurface = 0;
if (tileRect.size() != imageSize) {
IntRect imageRect = enclosingIntRect(tileRect);
clippedImageSurface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, imageRect.width(), imageRect.height()));
RefPtr<cairo_t> clippedImageContext = adoptRef(cairo_create(clippedImageSurface.get()));
cairo_set_source_surface(clippedImageContext.get(), image, -tileRect.x(), -tileRect.y());
cairo_paint(clippedImageContext.get());
image = clippedImageSurface.get();
}
cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image);
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
cairo_matrix_t patternMatrix = cairo_matrix_t(patternTransform);
cairo_matrix_t phaseMatrix = {1, 0, 0, 1, phase.x() + tileRect.x() * patternTransform.a(), phase.y() + tileRect.y() * patternTransform.d()};
cairo_matrix_t combined;
cairo_matrix_multiply(&combined, &patternMatrix, &phaseMatrix);
cairo_matrix_invert(&combined);
cairo_pattern_set_matrix(pattern, &combined);
cairo_set_operator(cr, op);
cairo_set_source(cr, pattern);
cairo_pattern_destroy(pattern);
cairo_rectangle(cr, destRect.x(), destRect.y(), destRect.width(), destRect.height());
cairo_fill(cr);
cairo_restore(cr);
}
示例12: drawContentIntoMaskImage
bool RenderSVGResourceMasker::drawContentIntoMaskImage(MaskerData* maskerData, ColorSpace colorSpace, const SVGMaskElement* maskElement, 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 (Node* node = maskElement->firstChild(); node; node = node->nextSibling()) {
RenderObject* renderer = node->renderer();
if (!node->isSVGElement() || !static_cast<SVGElement*>(node)->isStyled() || !renderer)
continue;
if (renderer->needsLayout())
return false;
RenderStyle* style = renderer->style();
if (!style || style->display() == NONE || style->visibility() != VISIBLE)
continue;
SVGImageBufferTools::renderSubtreeToImageBuffer(maskerData->maskImage.get(), renderer, maskContentTransformation);
}
#if !USE(CG)
maskerData->maskImage->transformColorSpace(ColorSpaceDeviceRGB, colorSpace);
#else
UNUSED_PARAM(colorSpace);
#endif
// Create the luminance mask.
maskerData->maskImage->convertToLuminanceMask();
return true;
}
示例13: shadowOffset
ShadowApplier::ShadowApplier(GraphicsContext& context, const ShadowData* shadow, const FloatRect& textRect, bool lastShadowIterationShouldDrawText, bool opaque, FontOrientation orientation)
: m_context(context)
, m_shadow(shadow)
, m_onlyDrawsShadow(!isLastShadowIteration() || !lastShadowIterationShouldDrawText)
, m_avoidDrawingShadow(shadowIsCompletelyCoveredByText(opaque))
, m_nothingToDraw(shadow && m_avoidDrawingShadow && m_onlyDrawsShadow)
, m_didSaveContext(false)
{
if (!shadow || m_nothingToDraw) {
m_shadow = nullptr;
return;
}
int shadowX = orientation == Horizontal ? shadow->x() : shadow->y();
int shadowY = orientation == Horizontal ? shadow->y() : -shadow->x();
FloatSize shadowOffset(shadowX, shadowY);
int shadowRadius = shadow->radius();
const Color& shadowColor = shadow->color();
// When drawing shadows, we usually clip the context to the area the shadow will reside, and then
// draw the text itself outside the clipped area (so only the shadow shows up). However, we can
// often draw the *last* shadow and the text itself in a single call.
if (m_onlyDrawsShadow) {
FloatRect shadowRect(textRect);
shadowRect.inflate(shadow->paintingExtent());
shadowRect.move(shadowOffset);
context.save();
context.clip(shadowRect);
m_didSaveContext = true;
m_extraOffset = FloatSize(0, 2 * textRect.height() + std::max(0.0f, shadowOffset.height()) + shadowRadius);
shadowOffset -= m_extraOffset;
}
if (!m_avoidDrawingShadow)
context.setShadow(shadowOffset, shadowRadius, shadowColor, context.fillColorSpace());
}
示例14: findInPageRectFromAbsoluteRect
FloatRect findInPageRectFromAbsoluteRect(const FloatRect& inputRect, const RenderObject* renderer)
{
if (!renderer || inputRect.isEmpty())
return FloatRect();
// Normalize the input rect to its container, saving the container bounding box for the incoming loop.
FloatRect rendererBoundingBox;
FloatRect normalizedRect = toNormalizedRect(inputRect, renderer, rendererBoundingBox);
renderer = renderer->container();
// Go up across frames.
while (renderer) {
// Go up the render tree until we reach the root of the current frame (the RenderView).
for (const RenderObject* container = renderer->container(); container; renderer = container, container = container->container()) {
// Compose the normalized rects. The absolute bounding box of the container is calculated in toNormalizedRect
// and can be reused for the next iteration of the loop.
FloatRect normalizedBoxRect = toNormalizedRect(rendererBoundingBox, renderer, rendererBoundingBox);
normalizedRect.scale(normalizedBoxRect.width(), normalizedBoxRect.height());
normalizedRect.moveBy(normalizedBoxRect.location());
if (normalizedRect.isEmpty())
return normalizedRect;
}
// Jump to the renderer owning the frame, if any.
ASSERT(renderer->isRenderView());
renderer = renderer->frame() ? renderer->frame()->ownerRenderer() : 0;
// Update the absolute coordinates to the new frame.
if (renderer)
rendererBoundingBox = renderer->absoluteBoundingBoxRect();
}
return normalizedRect;
}
示例15: roundToDevicePixels
FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect, RoundingMode)
{
FloatRect result;
double x = frect.x();
double y = frect.y();
cairo_t* cr = platformContext()->cr();
cairo_user_to_device(cr, &x, &y);
x = round(x);
y = round(y);
cairo_device_to_user(cr, &x, &y);
result.setX(narrowPrecisionToFloat(x));
result.setY(narrowPrecisionToFloat(y));
// We must ensure width and height are at least 1 (or -1) when
// we're given float values in the range between 0 and 1 (or -1 and 0).
double width = frect.width();
double height = frect.height();
cairo_user_to_device_distance(cr, &width, &height);
if (width > -1 && width < 0)
width = -1;
else if (width > 0 && width < 1)
width = 1;
else
width = round(width);
if (height > -1 && width < 0)
height = -1;
else if (height > 0 && height < 1)
height = 1;
else
height = round(height);
cairo_device_to_user_distance(cr, &width, &height);
result.setWidth(narrowPrecisionToFloat(width));
result.setHeight(narrowPrecisionToFloat(height));
return result;
}