本文整理汇总了C++中FloatSize::height方法的典型用法代码示例。如果您正苦于以下问题:C++ FloatSize::height方法的具体用法?C++ FloatSize::height怎么用?C++ FloatSize::height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FloatSize
的用法示例。
在下文中一共展示了FloatSize::height方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addShadow
void DrawLooperBuilder::addShadow(const FloatSize& offset, float blur, const Color& color,
ShadowTransformMode shadowTransformMode, ShadowAlphaMode shadowAlphaMode)
{
// Detect when there's no effective shadow.
if (!color.alpha())
return;
SkColor skColor = color.rgb();
SkLayerDrawLooper::LayerInfo info;
switch (shadowAlphaMode) {
case ShadowRespectsAlpha:
info.fColorMode = SkBlendMode::kDst;
break;
case ShadowIgnoresAlpha:
info.fColorMode = SkBlendMode::kSrc;
break;
default:
ASSERT_NOT_REACHED();
}
if (blur)
info.fPaintBits |= SkLayerDrawLooper::kMaskFilter_Bit; // our blur
info.fPaintBits |= SkLayerDrawLooper::kColorFilter_Bit;
info.fOffset.set(offset.width(), offset.height());
info.fPostTranslate = (shadowTransformMode == ShadowIgnoresTransforms);
SkPaint* paint = m_skDrawLooperBuilder.addLayerOnTop(info);
if (blur) {
const SkScalar sigma = RadiusToSigma(blur / 2);
uint32_t mfFlags = SkBlurMaskFilter::kHighQuality_BlurFlag;
if (shadowTransformMode == ShadowIgnoresTransforms)
mfFlags |= SkBlurMaskFilter::kIgnoreTransform_BlurFlag;
paint->setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, sigma, mfFlags));
}
paint->setColorFilter(SkColorFilter::MakeModeFilter(skColor, SkBlendMode::kSrcIn));
}
示例2: localCoordinateSpaceTransform
AffineTransform SVGSVGElement::localCoordinateSpaceTransform(SVGLocatable::CTMScope mode) const
{
AffineTransform viewBoxTransform;
if (hasAttribute(SVGNames::viewBoxAttr)) {
FloatSize size = currentViewportSize();
viewBoxTransform = viewBoxToViewTransform(size.width(), size.height());
}
AffineTransform transform;
if (!isOutermostSVGSVGElement()) {
SVGLengthContext lengthContext(this);
transform.translate(x().value(lengthContext), y().value(lengthContext));
} else if (mode == SVGLocatable::ScreenScope) {
if (RenderObject* renderer = this->renderer()) {
FloatPoint location;
// At the SVG/HTML boundary (aka RenderSVGRoot), we apply the localToBorderBoxTransform
// to map an element from SVG viewport coordinates to CSS box coordinates.
// RenderSVGRoot's localToAbsolute method expects CSS box coordinates.
if (renderer->isSVGRoot())
location = toRenderSVGRoot(renderer)->localToBorderBoxTransform().mapPoint(location);
// Translate in our CSS parent coordinate space
// FIXME: This doesn't work correctly with CSS transforms.
location = renderer->localToAbsolute(location, false, true);
// Be careful here! localToBorderBoxTransform() included the x/y offset coming from the viewBoxToViewTransform(),
// so we have to subtract it here (original cause of bug #27183)
transform.translate(location.x() - viewBoxTransform.e(), location.y() - viewBoxTransform.f());
// Respect scroll offset.
if (FrameView* view = document()->view()) {
LayoutSize scrollOffset = view->scrollOffset();
transform.translate(-scrollOffset.width(), -scrollOffset.height());
}
}
}
return transform.multiply(viewBoxTransform);
}
示例3: addToSVGTransform
SVGTransform SVGTransformDistance::addToSVGTransform(const SVGTransform& transform) const
{
ASSERT(m_type == transform.type() || transform == SVGTransform());
SVGTransform newTransform(transform);
switch (m_type) {
case SVGTransform::SVG_TRANSFORM_MATRIX:
ASSERT_NOT_REACHED();
case SVGTransform::SVG_TRANSFORM_UNKNOWN:
return SVGTransform();
case SVGTransform::SVG_TRANSFORM_TRANSLATE: {
FloatPoint translation = transform.translate();
translation += FloatSize::narrowPrecision(m_transform.e(), m_transform.f());
newTransform.setTranslate(translation.x(), translation.y());
return newTransform;
}
case SVGTransform::SVG_TRANSFORM_SCALE: {
FloatSize scale = transform.scale();
scale += FloatSize::narrowPrecision(m_transform.a(), m_transform.d());
newTransform.setScale(scale.width(), scale.height());
return newTransform;
}
case SVGTransform::SVG_TRANSFORM_ROTATE: {
FloatPoint center = transform.rotationCenter();
newTransform.setRotate(transform.angle() + m_angle, center.x() + m_cx, center.y() + m_cy);
return newTransform;
}
case SVGTransform::SVG_TRANSFORM_SKEWX:
newTransform.setSkewX(transform.angle() + m_angle);
return newTransform;
case SVGTransform::SVG_TRANSFORM_SKEWY:
newTransform.setSkewY(transform.angle() + m_angle);
return newTransform;
}
ASSERT_NOT_REACHED();
return SVGTransform();
}
示例4: rightMostCornerToVector
static inline FloatPoint rightMostCornerToVector(const FloatRect& rect, const FloatSize& vector)
{
// Return the corner of the rectangle that if it is to the left of the vector
// would mean all of the rectangle is to the left of the vector.
// The vector here represents the side between two points in a clockwise convex polygon.
//
// Q XXX
// QQQ XXX If the lower left corner of X is left of the vector that goes from the top corner of Q to
// QQQ the right corner of Q, then all of X is left of the vector, and intersection impossible.
// Q
//
FloatPoint point;
if (vector.width() >= 0)
point.setY(rect.maxY());
else
point.setY(rect.y());
if (vector.height() >= 0)
point.setX(rect.x());
else
point.setX(rect.maxX());
return point;
}
示例5: calculateAnimatedValue
void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, unsigned, SVGSMILElement*)
{
SVGElement* targetElement = this->targetElement();
if (!targetElement)
return;
AffineTransform* transform = targetElement->supplementalTransform();
if (!transform)
return;
if (RenderObject* targetRenderer = targetElement->renderer())
targetRenderer->setNeedsTransformUpdate();
if (!isAdditive())
transform->makeIdentity();
// FIXME: Implement accumulate.
if (animationMode() == PathAnimation) {
ASSERT(!animationPath().isEmpty());
Path path = animationPath();
float positionOnPath = path.length() * percentage;
bool ok;
FloatPoint position = path.pointAtLength(positionOnPath, ok);
if (ok) {
transform->translate(position.x(), position.y());
RotateMode rotateMode = this->rotateMode();
if (rotateMode == RotateAuto || rotateMode == RotateAutoReverse) {
float angle = path.normalAngleAtLength(positionOnPath, ok);
if (rotateMode == RotateAutoReverse)
angle += 180;
transform->rotate(angle);
}
}
return;
}
FloatSize diff = m_toPoint - m_fromPoint;
transform->translate(diff.width() * percentage + m_fromPoint.x(), diff.height() * percentage + m_fromPoint.y());
}
示例6: 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;
}
示例7: addSVGTransforms
SVGTransform SVGTransformDistance::addSVGTransforms(const SVGTransform& first, const SVGTransform& second, unsigned repeatCount)
{
ASSERT(first.type() == second.type());
SVGTransform transform;
switch (first.type()) {
case SVGTransform::SVG_TRANSFORM_MATRIX:
ASSERT_NOT_REACHED();
case SVGTransform::SVG_TRANSFORM_UNKNOWN:
return SVGTransform();
case SVGTransform::SVG_TRANSFORM_ROTATE: {
transform.setRotate(first.angle() + second.angle() * repeatCount, first.rotationCenter().x() + second.rotationCenter().x() * repeatCount, first.rotationCenter().y() + second.rotationCenter().y() * repeatCount);
return transform;
}
case SVGTransform::SVG_TRANSFORM_TRANSLATE: {
float dx = first.translate().x() + second.translate().x() * repeatCount;
float dy = first.translate().y() + second.translate().y() * repeatCount;
transform.setTranslate(dx, dy);
return transform;
}
case SVGTransform::SVG_TRANSFORM_SCALE: {
FloatSize scale = second.scale();
scale.scale(repeatCount);
scale += first.scale();
transform.setScale(scale.width(), scale.height());
return transform;
}
case SVGTransform::SVG_TRANSFORM_SKEWX:
transform.setSkewX(first.angle() + second.angle() * repeatCount);
return transform;
case SVGTransform::SVG_TRANSFORM_SKEWY:
transform.setSkewY(first.angle() + second.angle() * repeatCount);
return transform;
}
ASSERT_NOT_REACHED();
return SVGTransform();
}
示例8: convertLogicalToDevice
IntSize HTMLCanvasElement::convertLogicalToDevice(const FloatSize& logicalSize) const
{
#if PLATFORM(ANDROID)
/* In Android we capture the drawing into a displayList, and then
replay that list at various scale factors (sometimes zoomed out, other
times zoomed in for "normal" reading, yet other times at arbitrary
zoom values based on the user's choice). In all of these cases, we do
not re-record the displayList, hence it is usually harmful to perform
any pre-rounding, since we just don't know the actual drawing resolution
at record time.
*/
float pageScaleFactor = 1.0f;
#else
float pageScaleFactor = document()->frame() ? document()->frame()->page()->chrome()->scaleFactor() : 1.0f;
#endif
float wf = ceilf(logicalSize.width() * pageScaleFactor);
float hf = ceilf(logicalSize.height() * pageScaleFactor);
if (!(wf >= 1 && hf >= 1 && wf * hf <= MaxCanvasArea))
return IntSize();
return IntSize(static_cast<unsigned>(wf), static_cast<unsigned>(hf));
}
示例9: drawCrossfadeSubimage
static void drawCrossfadeSubimage(GraphicsContext& context, Image* image, CompositeOperator operation, float opacity, const FloatSize& targetSize)
{
FloatSize imageSize = image->size();
// SVGImage resets the opacity when painting, so we have to use transparency layers to accurately paint one at a given opacity.
bool useTransparencyLayer = image->isSVGImage();
GraphicsContextStateSaver stateSaver(context);
context.setCompositeOperation(operation);
if (useTransparencyLayer)
context.beginTransparencyLayer(opacity);
else
context.setAlpha(opacity);
if (targetSize != imageSize)
context.scale(FloatSize(targetSize.width() / imageSize.width(), targetSize.height() / imageSize.height()));
context.drawImage(image, ColorSpaceDeviceRGB, IntPoint());
if (useTransparencyLayer)
context.endTransparencyLayer();
}
示例10: nearestFindMatch
int TextFinder::nearestFindMatch(const FloatPoint& point,
float* distanceSquared) {
updateFindMatchRects();
int nearest = -1;
float nearestDistanceSquared = FLT_MAX;
for (size_t i = 0; i < m_findMatchesCache.size(); ++i) {
DCHECK(!m_findMatchesCache[i].m_rect.isEmpty());
FloatSize offset = point - m_findMatchesCache[i].m_rect.center();
float width = offset.width();
float height = offset.height();
float currentDistanceSquared = width * width + height * height;
if (currentDistanceSquared < nearestDistanceSquared) {
nearest = i;
nearestDistanceSquared = currentDistanceSquared;
}
}
if (distanceSquared)
*distanceSquared = nearestDistanceSquared;
return nearest;
}
示例11: 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));
}
示例12: valueForLength
float SVGLengthContext::valueForLength(const Length& length, SVGLengthMode mode)
{
if (length.isPercent()) {
auto result = convertValueFromPercentageToUserUnits(length.value() / 100, mode);
if (result.hasException())
return 0;
return result.releaseReturnValue();
}
if (length.isAuto() || !length.isSpecified())
return 0;
FloatSize viewportSize;
determineViewport(viewportSize);
switch (mode) {
case LengthModeWidth:
return floatValueForLength(length, viewportSize.width());
case LengthModeHeight:
return floatValueForLength(length, viewportSize.height());
case LengthModeOther:
return floatValueForLength(length, std::sqrt(viewportSize.diagonalLengthSquared() / 2));
};
return 0;
}
示例13: drawPatternForContainer
void SVGImage::drawPatternForContainer(GraphicsContext& context, const FloatSize containerSize,
float zoom, const FloatRect& srcRect, const FloatSize& tileScale, const FloatPoint& phase,
SkXfermode::Mode compositeOp, const FloatRect& dstRect,
const FloatSize& repeatSpacing, const KURL& url)
{
// Tile adjusted for scaling/stretch.
FloatRect tile(srcRect);
tile.scale(tileScale.width(), tileScale.height());
// Expand the tile to account for repeat spacing.
FloatRect spacedTile(tile);
spacedTile.expand(FloatSize(repeatSpacing));
SkPictureBuilder patternPicture(spacedTile, nullptr, &context);
if (!DrawingRecorder::useCachedDrawingIfPossible(patternPicture.context(), *this, DisplayItem::Type::SVGImage)) {
DrawingRecorder patternPictureRecorder(patternPicture.context(), *this, DisplayItem::Type::SVGImage, spacedTile);
// When generating an expanded tile, make sure we don't draw into the spacing area.
if (tile != spacedTile)
patternPicture.context().clip(tile);
SkPaint paint;
drawForContainer(patternPicture.context().canvas(), paint, containerSize, zoom, tile, srcRect, url);
}
RefPtr<const SkPicture> tilePicture = patternPicture.endRecording();
SkMatrix patternTransform;
patternTransform.setTranslate(phase.x() + spacedTile.x(), phase.y() + spacedTile.y());
RefPtr<SkShader> patternShader = adoptRef(SkShader::CreatePictureShader(
tilePicture.get(), SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode,
&patternTransform, nullptr));
SkPaint paint;
paint.setShader(patternShader.get());
paint.setXfermodeMode(compositeOp);
paint.setColorFilter(context.colorFilter());
context.drawRect(dstRect, paint);
}
示例14: 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()));
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()));
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()));
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()));
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();
}
示例15: 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);
}
}
}