本文整理汇总了C++中GraphicsContext::concatCTM方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsContext::concatCTM方法的具体用法?C++ GraphicsContext::concatCTM怎么用?C++ GraphicsContext::concatCTM使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsContext
的用法示例。
在下文中一共展示了GraphicsContext::concatCTM方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createMaskAndSwapContextForTextGradient
static inline bool createMaskAndSwapContextForTextGradient(GraphicsContext*& context,
GraphicsContext*& savedContext,
OwnPtr<ImageBuffer>& imageBuffer,
RenderObject* object)
{
RenderObject* textRootBlock = RenderSVGText::locateRenderSVGTextAncestor(object);
ASSERT(textRootBlock);
AffineTransform absoluteTransform;
SVGImageBufferTools::calculateTransformationToOutermostSVGCoordinateSystem(textRootBlock, absoluteTransform);
FloatRect absoluteTargetRect = absoluteTransform.mapRect(textRootBlock->repaintRectInLocalCoordinates());
FloatRect clampedAbsoluteTargetRect = SVGImageBufferTools::clampedAbsoluteTargetRectForRenderer(textRootBlock, absoluteTargetRect);
if (clampedAbsoluteTargetRect.isEmpty())
return false;
OwnPtr<ImageBuffer> maskImage;
if (!SVGImageBufferTools::createImageBuffer(absoluteTargetRect, clampedAbsoluteTargetRect, maskImage, ColorSpaceDeviceRGB))
return false;
GraphicsContext* maskImageContext = maskImage->context();
ASSERT(maskImageContext);
maskImageContext->translate(-clampedAbsoluteTargetRect.x(), -clampedAbsoluteTargetRect.y());
maskImageContext->concatCTM(absoluteTransform);
ASSERT(maskImage);
savedContext = context;
context = maskImageContext;
imageBuffer = maskImage.release();
return true;
}
示例2: transform
void BeginTransform3DDisplayItem::replay(GraphicsContext& context) const
{
TransformationMatrix transform(m_transform);
transform.applyTransformOrigin(m_transformOrigin);
context.save();
context.concatCTM(transform.toAffineTransform());
}
示例3: lengthContext
PassRefPtr<SkImageFilter> FEImage::createImageFilterForRenderer(RenderObject* renderer, SkiaImageFilterBuilder* builder)
{
FloatRect dstRect = filterPrimitiveSubregion();
AffineTransform transform;
SVGElement* contextNode = toSVGElement(renderer->node());
if (contextNode->hasRelativeLengths()) {
SVGLengthContext lengthContext(contextNode);
FloatSize viewportSize;
// If we're referencing an element with percentage units, eg. <rect with="30%"> those values were resolved against the viewport.
// Build up a transformation that maps from the viewport space to the filter primitive subregion.
if (lengthContext.determineViewport(viewportSize))
transform = makeMapBetweenRects(FloatRect(FloatPoint(), viewportSize), dstRect);
} else {
transform.translate(dstRect.x(), dstRect.y());
}
GraphicsContext* context = builder->context();
if (!context)
return adoptRef(SkBitmapSource::Create(SkBitmap()));
AffineTransform contentTransformation;
context->save();
context->beginRecording(FloatRect(FloatPoint(), dstRect.size()));
context->concatCTM(transform);
SVGRenderingContext::renderSubtree(context, renderer, contentTransformation);
RefPtr<DisplayList> displayList = context->endRecording();
context->restore();
RefPtr<SkImageFilter> result = adoptRef(SkPictureImageFilter::Create(displayList->picture(), dstRect));
return result.release();
}
示例4: maskSize
static inline bool createMaskAndSwapContextForTextGradient(
GraphicsContext*& context, GraphicsContext*& savedContext,
OwnPtr<ImageBuffer>& imageBuffer, const RenderObject* object)
{
FloatRect maskBBox = const_cast<RenderObject*>(findTextRootObject(object))->relativeBBox(false);
IntRect maskRect = enclosingIntRect(object->absoluteTransform().mapRect(maskBBox));
IntSize maskSize(maskRect.width(), maskRect.height());
clampImageBufferSizeToViewport(object->document()->renderer(), maskSize);
auto_ptr<ImageBuffer> maskImage = ImageBuffer::create(maskSize, false);
if (!maskImage.get())
return false;
GraphicsContext* maskImageContext = maskImage->context();
maskImageContext->save();
maskImageContext->translate(-maskRect.x(), -maskRect.y());
maskImageContext->concatCTM(object->absoluteTransform());
imageBuffer.set(maskImage.release());
savedContext = context;
context = maskImageContext;
return true;
}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:28,代码来源:SVGPaintServerGradient.cpp
示例5: drawTexture
void TextureMapperImageBuffer::drawTexture(const BitmapTexture& texture, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, const BitmapTexture* maskTexture, unsigned /* exposedEdges */)
{
GraphicsContext* context = currentContext();
if (!context)
return;
const BitmapTextureImageBuffer& textureImageBuffer = static_cast<const BitmapTextureImageBuffer&>(texture);
ImageBuffer* image = textureImageBuffer.m_image.get();
OwnPtr<ImageBuffer> maskedImage;
if (maskTexture && maskTexture->isValid()) {
const BitmapTextureImageBuffer* mask = static_cast<const BitmapTextureImageBuffer*>(maskTexture);
maskedImage = ImageBuffer::create(maskTexture->contentSize());
GraphicsContext* maskContext = maskedImage->context();
maskContext->drawImageBuffer(image, ColorSpaceDeviceRGB, IntPoint::zero(), CompositeCopy);
if (opacity < 1) {
maskContext->setAlpha(opacity);
opacity = 1;
}
maskContext->drawImageBuffer(mask->m_image.get(), ColorSpaceDeviceRGB, IntPoint::zero(), CompositeDestinationIn);
image = maskedImage.get();
}
context->save();
context->setAlpha(opacity);
#if ENABLE(3D_RENDERING)
context->concat3DTransform(matrix);
#else
context->concatCTM(matrix.toAffineTransform());
#endif
context->drawImageBuffer(image, ColorSpaceDeviceRGB, targetRect);
context->restore();
}
示例6: paint
void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
{
GraphicsContext* context = paintInfo.context;
RenderStyle* style = renderer().style(isFirstLineStyle());
const Font& font = style->font();
FloatPoint boxOrigin = locationIncludingFlipping();
boxOrigin.moveBy(FloatPoint(paintOffset));
if (!isHorizontal())
boxOrigin.move(0, -virtualLogicalHeight());
FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), virtualLogicalHeight()));
GraphicsContextStateSaver stateSaver(*context);
if (!isHorizontal())
context->concatCTM(InlineTextBox::rotation(boxRect, InlineTextBox::Clockwise));
FloatPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().ascent());
bool isPrinting = renderer().document().printing();
bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip && selectionState() != RenderObject::SelectionNone;
if (haveSelection)
paintSelection(context, boxOrigin, style, font);
else if (paintInfo.phase == PaintPhaseSelection)
return;
TextPainter::Style textStyle = TextPainter::textPaintingStyle(renderer(), style, paintInfo.forceBlackText(), isPrinting);
if (haveSelection)
textStyle = TextPainter::selectionPaintingStyle(renderer(), true, paintInfo.forceBlackText(), isPrinting, textStyle);
TextRun textRun = constructTextRun(&renderer(), font, m_str, style, TextRun::AllowTrailingExpansion);
TextPainter textPainter(context, font, textRun, textOrigin, boxRect, isHorizontal());
textPainter.paint(0, m_str.length(), m_str.length(), textStyle);
paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, style);
}
示例7: createMaskAndSwapContextForTextGradient
static inline bool createMaskAndSwapContextForTextGradient(GraphicsContext*& context,
GraphicsContext*& savedContext,
OwnPtr<ImageBuffer>& imageBuffer,
const RenderObject* object)
{
const RenderObject* textRootBlock = findTextRootObject(object);
AffineTransform transform = absoluteTransformForRenderer(textRootBlock);
FloatRect maskAbsoluteBoundingBox = transform.mapRect(textRootBlock->repaintRectInLocalCoordinates());
IntRect maskImageRect = enclosingIntRect(maskAbsoluteBoundingBox);
if (maskImageRect.isEmpty())
return false;
// Allocate an image buffer as big as the absolute unclipped size of the object
OwnPtr<ImageBuffer> maskImage = ImageBuffer::create(maskImageRect.size());
if (!maskImage)
return false;
GraphicsContext* maskImageContext = maskImage->context();
// Transform the mask image coordinate system to absolute screen coordinates
maskImageContext->translate(-maskAbsoluteBoundingBox.x(), -maskAbsoluteBoundingBox.y());
maskImageContext->concatCTM(transform);
imageBuffer.set(maskImage.release());
savedContext = context;
context = maskImageContext;
return true;
}
示例8: 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();
}
示例9: paint
void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
{
GraphicsContext* context = paintInfo.context;
RenderStyle* style = renderer().style(isFirstLineStyle());
const Font& font = style->font();
FloatPoint boxOrigin = locationIncludingFlipping();
boxOrigin.moveBy(FloatPoint(paintOffset));
if (!isHorizontal())
boxOrigin.move(0, -virtualLogicalHeight());
FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), virtualLogicalHeight()));
GraphicsContextStateSaver stateSaver(*context);
if (!isHorizontal())
context->concatCTM(InlineTextBox::rotation(boxRect, InlineTextBox::Clockwise));
FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().ascent());
Color styleTextColor = renderer().resolveColor(style, CSSPropertyWebkitTextFillColor);
if (styleTextColor != context->fillColor())
context->setFillColor(styleTextColor);
if (selectionState() != RenderObject::SelectionNone) {
paintSelection(context, boxOrigin, style, font);
// Select the correct color for painting the text.
Color foreground = paintInfo.forceBlackText() ? Color::black : renderer().selectionForegroundColor();
if (foreground != styleTextColor)
context->setFillColor(foreground);
}
// Text shadows are disabled when printing. http://crbug.com/258321
const ShadowList* shadowList = context->printing() ? 0 : style->textShadow();
bool hasShadow = shadowList;
if (hasShadow) {
OwnPtr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::create();
for (size_t i = shadowList->shadows().size(); i--; ) {
const ShadowData& shadow = shadowList->shadows()[i];
float shadowX = isHorizontal() ? shadow.x() : shadow.y();
float shadowY = isHorizontal() ? shadow.y() : -shadow.x();
FloatSize offset(shadowX, shadowY);
drawLooperBuilder->addShadow(offset, shadow.blur(), shadow.color(),
DrawLooperBuilder::ShadowRespectsTransforms, DrawLooperBuilder::ShadowIgnoresAlpha);
}
drawLooperBuilder->addUnmodifiedContent();
context->setDrawLooper(drawLooperBuilder.release());
}
TextRun textRun = RenderBlockFlow::constructTextRun(&renderer(), font, m_str, style, TextRun::AllowTrailingExpansion);
TextRunPaintInfo textRunPaintInfo(textRun);
textRunPaintInfo.bounds = boxRect;
context->drawText(font, textRunPaintInfo, textOrigin);
// Restore the regular fill color.
if (styleTextColor != context->fillColor())
context->setFillColor(styleTextColor);
if (hasShadow)
context->clearDrawLooper();
paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, style);
}
示例10: beginClip
void TextureMapperImageBuffer::beginClip(const TransformationMatrix& matrix, const FloatRect& rect)
{
GraphicsContext* context = currentContext();
if (!context)
return;
#if ENABLE(3D_RENDERING)
TransformationMatrix previousTransform = context->get3DTransform();
#else
AffineTransform previousTransform = context->getCTM();
#endif
context->save();
#if ENABLE(3D_RENDERING)
context->concat3DTransform(matrix);
#else
context->concatCTM(matrix.toAffineTransform());
#endif
context->clip(rect);
#if ENABLE(3D_RENDERING)
context->set3DTransform(previousTransform);
#else
context->setCTM(previousTransform);
#endif
}
示例11: draw
void BitmapImage::draw(GraphicsContext& context, const FloatRect& dst, const FloatRect& src, CompositeOperator op,
BlendMode blendMode, ImageOrientationDescription description)
{
if (!dst.width() || !dst.height() || !src.width() || !src.height())
return;
startAnimation();
auto surface = frameImageAtIndex(m_currentFrame);
if (!surface) // If it's too early we won't have an image yet.
return;
Color color = singlePixelSolidColor();
if (color.isValid()) {
fillWithSolidColor(context, dst, color, op);
return;
}
context.save();
// Set the compositing operation.
if (op == CompositeSourceOver && blendMode == BlendModeNormal && !frameHasAlphaAtIndex(m_currentFrame))
context.setCompositeOperation(CompositeCopy);
else
context.setCompositeOperation(op, blendMode);
#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
IntSize scaledSize = cairoSurfaceSize(surface.get());
FloatRect adjustedSrcRect = adjustSourceRectForDownSampling(src, scaledSize);
#else
FloatRect adjustedSrcRect(src);
#endif
ImageOrientation frameOrientation(description.imageOrientation());
if (description.respectImageOrientation() == RespectImageOrientation)
frameOrientation = frameOrientationAtIndex(m_currentFrame);
FloatRect dstRect = dst;
if (frameOrientation != DefaultImageOrientation) {
// ImageOrientation expects the origin to be at (0, 0).
context.translate(dstRect.x(), dstRect.y());
dstRect.setLocation(FloatPoint());
context.concatCTM(frameOrientation.transformFromDefault(dstRect.size()));
if (frameOrientation.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.
dstRect = FloatRect(dstRect.x(), dstRect.y(), dstRect.height(), dstRect.width());
}
}
context.platformContext()->drawSurfaceToContext(surface.get(), dstRect, adjustedSrcRect, context);
context.restore();
if (imageObserver())
imageObserver()->didDraw(this);
}
示例12: imageFromRect
WebBitmap* Frame::imageFromRect(const FloatRect& rect) const
{
// We should not try to create a bitmap of zero height or width as it is not supported.
IntRect irect(rect);
if(irect.size().width() == 0 || irect.size().height() == 0)
return NULL;
FrameLoaderClientApollo* const clientApollo = FrameLoaderClientApollo::clientApollo(this);
WebHost* webHost = clientApollo->webHost();
ASSERT(webHost);
WebBitmap* resultBitmap = webHost->m_pVTable->createBitmap(webHost, irect.size().width(), irect.size().height());
// clear pixels with transparent black (0)
void *pixelData = resultBitmap->m_pVTable->getPixelData(resultBitmap);
unsigned long stride = resultBitmap->m_pVTable->getStride(resultBitmap);
memset( pixelData, 0, stride * irect.height() );
// now, paint the selection in a graphics context
WebIntRect sourceRect;
sourceRect.m_left = 0;
sourceRect.m_top = 0;
sourceRect.m_right = irect.width();
sourceRect.m_bottom = irect.height();
GraphicsContext gc (resultBitmap,&sourceRect);
IntSize offset = view()->scrollOffset();
irect.move(-offset.width(), -offset.height());
irect = view()->convertToContainingWindow(irect);
#if OS(WINDOWS) || OS(DARWIN)
// changing origin from top-left to bottom-left
gc.concatCTM(TransformationMatrix(1, 0, 0, -1, 0, irect.height()).toAffineTransform());
#endif
// this transformation moves the clip into the origin of the user space
gc.concatCTM(TransformationMatrix().translate(-irect.x(), -irect.y()).toAffineTransform());
view()->paint(&gc,irect);
return resultBitmap;
}
示例13: clipToImageBuffer
void SVGRenderingContext::clipToImageBuffer(GraphicsContext& context, const AffineTransform& absoluteTransform, const FloatRect& targetRect, std::unique_ptr<ImageBuffer>& imageBuffer, bool safeToClear)
{
if (!imageBuffer)
return;
FloatRect absoluteTargetRect = calculateImageBufferRect(targetRect, absoluteTransform);
// The mask image has been created in the absolute coordinate space, as the image should not be scaled.
// So the actual masking process has to be done in the absolute coordinate space as well.
context.concatCTM(absoluteTransform.inverse().valueOr(AffineTransform()));
context.clipToImageBuffer(*imageBuffer, absoluteTargetRect);
context.concatCTM(absoluteTransform);
// When nesting resources, with objectBoundingBox as content unit types, there's no use in caching the
// resulting image buffer as the parent resource already caches the result.
if (safeToClear && !currentContentTransformation().isIdentity())
imageBuffer.reset();
}
示例14: applyClippingToContext
bool RenderSVGResourceClipper::applyClippingToContext(RenderObject* object, const FloatRect& objectBoundingBox,
const FloatRect& repaintRect, GraphicsContext* context)
{
bool missingClipperData = !m_clipper.contains(object);
if (missingClipperData)
m_clipper.set(object, new ClipperData);
bool shouldCreateClipData = false;
AffineTransform animatedLocalTransform = static_cast<SVGClipPathElement*>(node())->animatedLocalTransform();
ClipperData* clipperData = m_clipper.get(object);
if (!clipperData->clipMaskImage) {
if (pathOnlyClipping(context, animatedLocalTransform, objectBoundingBox))
return true;
shouldCreateClipData = true;
}
AffineTransform absoluteTransform;
SVGRenderingContext::calculateTransformationToOutermostCoordinateSystem(object, absoluteTransform);
if (shouldCreateClipData && !repaintRect.isEmpty()) {
if (!SVGRenderingContext::createImageBuffer(repaintRect, absoluteTransform, clipperData->clipMaskImage, ColorSpaceDeviceRGB, Unaccelerated))
return false;
GraphicsContext* maskContext = clipperData->clipMaskImage->context();
ASSERT(maskContext);
maskContext->concatCTM(animatedLocalTransform);
// clipPath can also be clipped by another clipPath.
SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(this);
RenderSVGResourceClipper* clipper;
bool succeeded;
if (resources && (clipper = resources->clipper())) {
GraphicsContextStateSaver stateSaver(*maskContext);
if (!clipper->applyClippingToContext(this, objectBoundingBox, repaintRect, maskContext))
return false;
succeeded = drawContentIntoMaskImage(clipperData, objectBoundingBox);
// The context restore applies the clipping on non-CG platforms.
} else
succeeded = drawContentIntoMaskImage(clipperData, objectBoundingBox);
if (!succeeded)
clipperData->clipMaskImage.clear();
}
if (!clipperData->clipMaskImage)
return false;
SVGRenderingContext::clipToImageBuffer(context, absoluteTransform, repaintRect, clipperData->clipMaskImage, missingClipperData);
return true;
}
示例15: drawingContext
void CanvasRenderingContext2D::setTransform(float m11, float m12, float m21, float m22, float dx, float dy)
{
GraphicsContext* c = drawingContext();
if (!c)
return;
if (!isfinite(m11) | !isfinite(m21) | !isfinite(dx) |
!isfinite(m12) | !isfinite(m22) | !isfinite(dy))
return;
AffineTransform ctm = state().m_transform;
if (!ctm.isInvertible())
return;
c->concatCTM(c->getCTM().inverse());
c->concatCTM(canvas()->baseTransform());
state().m_transform.multiply(ctm.inverse());
m_path.transform(ctm);
state().m_invertibleCTM = true;
transform(m11, m12, m21, m22, dx, dy);
}