Chromium Code Reviews| Index: Source/core/rendering/svg/SVGRenderingContext.cpp |
| diff --git a/Source/core/rendering/svg/SVGRenderingContext.cpp b/Source/core/rendering/svg/SVGRenderingContext.cpp |
| index 33f2a3c8d34d884b23243ecb614f369a949c2f09..1d3579466fbe53eb186f8f4f28c53fdda84f6c30 100644 |
| --- a/Source/core/rendering/svg/SVGRenderingContext.cpp |
| +++ b/Source/core/rendering/svg/SVGRenderingContext.cpp |
| @@ -58,16 +58,17 @@ SVGRenderingContext::~SVGRenderingContext() |
| if (m_renderingFlags & EndFilterLayer) { |
| ASSERT(m_filter); |
| - m_filter->postApplyResource(m_object, m_paintInfo->context, ApplyToDefaultMode, 0, 0); |
| - m_paintInfo->context = m_savedContext; |
| - m_paintInfo->rect = m_savedPaintRect; |
| + GraphicsContext* context = m_paintInfo->getContext(); |
|
do-not-use
2013/08/01 18:50:14
Why this new variable?
|
| + m_filter->postApplyResource(m_object, context, ApplyToDefaultMode, 0, 0); |
| + m_paintInfo->setContext(m_savedContext); |
| + m_paintInfo->setRect(m_savedPaintRect); |
| } |
| if (m_renderingFlags & EndOpacityLayer) |
| - m_paintInfo->context->endTransparencyLayer(); |
| + m_paintInfo->getContext()->endTransparencyLayer(); |
| if (m_renderingFlags & RestoreGraphicsContext) |
| - m_paintInfo->context->restore(); |
| + m_paintInfo->getContext()->restore(); |
| } |
| void SVGRenderingContext::prepareToRenderSVGContent(RenderObject* object, PaintInfo& paintInfo, NeedsGraphicsContextSave needsGraphicsContextSave) |
| @@ -86,7 +87,7 @@ void SVGRenderingContext::prepareToRenderSVGContent(RenderObject* object, PaintI |
| // We need to save / restore the context even if the initialization failed. |
| if (needsGraphicsContextSave == SaveGraphicsContext) { |
| - m_paintInfo->context->save(); |
| + m_paintInfo->getContext()->save(); |
| m_renderingFlags |= RestoreGraphicsContext; |
| } |
| @@ -104,15 +105,15 @@ void SVGRenderingContext::prepareToRenderSVGContent(RenderObject* object, PaintI |
| FloatRect repaintRect = m_object->repaintRectInLocalCoordinates(); |
| if (opacity < 1 || blendMode != BlendModeNormal) { |
| - m_paintInfo->context->clip(repaintRect); |
| + m_paintInfo->getContext()->clip(repaintRect); |
| if (blendMode != BlendModeNormal) { |
| if (!(m_renderingFlags & RestoreGraphicsContext)) { |
| - m_paintInfo->context->save(); |
| + m_paintInfo->getContext()->save(); |
| m_renderingFlags |= RestoreGraphicsContext; |
| } |
| - m_paintInfo->context->setCompositeOperation(CompositeSourceOver, blendMode); |
| + m_paintInfo->getContext()->setCompositeOperation(CompositeSourceOver, blendMode); |
| } |
| - m_paintInfo->context->beginTransparencyLayer(opacity); |
| + m_paintInfo->getContext()->beginTransparencyLayer(opacity); |
| m_renderingFlags |= EndOpacityLayer; |
| } |
| } |
| @@ -120,7 +121,7 @@ void SVGRenderingContext::prepareToRenderSVGContent(RenderObject* object, PaintI |
| ClipPathOperation* clipPathOperation = style->clipPath(); |
| if (clipPathOperation && clipPathOperation->getOperationType() == ClipPathOperation::SHAPE) { |
| ShapeClipPathOperation* clipPath = static_cast<ShapeClipPathOperation*>(clipPathOperation); |
| - m_paintInfo->context->clipPath(clipPath->path(object->objectBoundingBox()), clipPath->windRule()); |
| + m_paintInfo->getContext()->clipPath(clipPath->path(object->objectBoundingBox()), clipPath->windRule()); |
| } |
| SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(m_object); |
| @@ -134,33 +135,45 @@ void SVGRenderingContext::prepareToRenderSVGContent(RenderObject* object, PaintI |
| if (!isRenderingMask) { |
| if (RenderSVGResourceMasker* masker = resources->masker()) { |
| - if (!masker->applyResource(m_object, style, m_paintInfo->context, ApplyToDefaultMode)) |
| + GraphicsContext* context = m_paintInfo->getContext(); |
| + if (!masker->applyResource(m_object, style, context, ApplyToDefaultMode)) { |
| + m_paintInfo->setContext(context); |
| return; |
| + } |
| + m_paintInfo->setContext(context); |
| } |
| } |
| RenderSVGResourceClipper* clipper = resources->clipper(); |
| if (!clipPathOperation && clipper) { |
| - if (!clipper->applyResource(m_object, style, m_paintInfo->context, ApplyToDefaultMode)) |
| + GraphicsContext* context = m_paintInfo->getContext(); |
| + if (!clipper->applyResource(m_object, style, context, ApplyToDefaultMode)) { |
| + m_paintInfo->setContext(context); |
|
do-not-use
2013/08/01 18:50:14
Why these new calls to setContext()? Since applyRe
|
| return; |
| + } |
| + m_paintInfo->setContext(context); |
| } |
| if (!isRenderingMask) { |
| m_filter = resources->filter(); |
| if (m_filter) { |
| - m_savedContext = m_paintInfo->context; |
| - m_savedPaintRect = m_paintInfo->rect; |
| + m_savedContext = m_paintInfo->getContext(); |
| + m_savedPaintRect = m_paintInfo->getRect(); |
| // Return with false here may mean that we don't need to draw the content |
| // (because it was either drawn before or empty) but we still need to apply the filter. |
| m_renderingFlags |= EndFilterLayer; |
| - if (!m_filter->applyResource(m_object, style, m_paintInfo->context, ApplyToDefaultMode)) |
| + GraphicsContext* context = m_paintInfo->getContext(); |
| + if (!m_filter->applyResource(m_object, style, context, ApplyToDefaultMode)) { |
| + m_paintInfo->setContext(context); |
| return; |
| + } |
| + m_paintInfo->setContext(context); |
| // Since we're caching the resulting bitmap and do not invalidate it on repaint rect |
| // changes, we need to paint the whole filter region. Otherwise, elements not visible |
| // at the time of the initial paint (due to scrolling, window size, etc.) will never |
| // be drawn. |
| - m_paintInfo->rect = IntRect(m_filter->drawingRegion(m_object)); |
| + m_paintInfo->setRect(IntRect(m_filter->drawingRegion(m_object))); |
| } |
| } |
| @@ -321,7 +334,7 @@ bool SVGRenderingContext::bufferForeground(OwnPtr<ImageBuffer>& imageBuffer) |
| // Invalidate an existing buffer if the scale is not correct. |
| if (imageBuffer) { |
| - AffineTransform transform = m_paintInfo->context->getCTM(GraphicsContext::DefinitelyIncludeDeviceScale); |
| + AffineTransform transform = m_paintInfo->getContext()->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()) |
| @@ -330,17 +343,17 @@ bool SVGRenderingContext::bufferForeground(OwnPtr<ImageBuffer>& imageBuffer) |
| // Create a new buffer and paint the foreground into it. |
| if (!imageBuffer) { |
| - if ((imageBuffer = m_paintInfo->context->createCompatibleBuffer(expandedIntSize(boundingBox.size()), true))) { |
| + if ((imageBuffer = m_paintInfo->getContext()->createCompatibleBuffer(expandedIntSize(boundingBox.size()), true))) { |
| GraphicsContext* bufferedRenderingContext = imageBuffer->context(); |
| bufferedRenderingContext->translate(-boundingBox.x(), -boundingBox.y()); |
| PaintInfo bufferedInfo(*m_paintInfo); |
| - bufferedInfo.context = bufferedRenderingContext; |
| + bufferedInfo.setContext(bufferedRenderingContext); |
| toRenderSVGImage(m_object)->paintForeground(bufferedInfo); |
| } else |
| return false; |
| } |
| - m_paintInfo->context->drawImageBuffer(imageBuffer.get(), boundingBox); |
| + m_paintInfo->getContext()->drawImageBuffer(imageBuffer.get(), boundingBox); |
| return true; |
| } |