Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1118)

Unified Diff: Source/core/rendering/svg/RenderSVGImage.cpp

Issue 603053002: Move RenderSVGImage's paint code to SVGImagePainter (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/svg/RenderSVGImage.cpp
diff --git a/Source/core/rendering/svg/RenderSVGImage.cpp b/Source/core/rendering/svg/RenderSVGImage.cpp
index 292f2614835de40828487e1c23e9cf517cf315f9..e1f2d20fc3199e3d324a50f7c7d6e6adb21df2d3 100644
--- a/Source/core/rendering/svg/RenderSVGImage.cpp
+++ b/Source/core/rendering/svg/RenderSVGImage.cpp
@@ -27,18 +27,16 @@
#include "core/rendering/svg/RenderSVGImage.h"
-#include "core/rendering/GraphicsContextAnnotator.h"
+#include "core/paint/SVGImagePainter.h"
#include "core/rendering/ImageQualityController.h"
#include "core/rendering/PointerEventsHitRules.h"
#include "core/rendering/RenderImageResource.h"
#include "core/rendering/svg/RenderSVGResource.h"
#include "core/rendering/svg/SVGRenderSupport.h"
-#include "core/rendering/svg/SVGRenderingContext.h"
#include "core/rendering/svg/SVGResources.h"
#include "core/rendering/svg/SVGResourcesCache.h"
#include "core/svg/SVGImageElement.h"
#include "platform/LengthFunctions.h"
-#include "platform/graphics/GraphicsContextStateSaver.h"
namespace blink {
@@ -148,58 +146,7 @@ void RenderSVGImage::layout()
void RenderSVGImage::paint(PaintInfo& paintInfo, const LayoutPoint&)
{
- ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this);
-
- if (paintInfo.phase != PaintPhaseForeground
- || style()->visibility() == HIDDEN
- || !m_imageResource->hasImage())
- return;
-
- FloatRect boundingBox = paintInvalidationRectInLocalCoordinates();
- if (!SVGRenderSupport::paintInfoIntersectsPaintInvalidationRect(boundingBox, m_localTransform, paintInfo))
- return;
-
- PaintInfo childPaintInfo(paintInfo);
- GraphicsContextStateSaver stateSaver(*childPaintInfo.context, false);
-
- if (!m_localTransform.isIdentity()) {
- stateSaver.save();
- childPaintInfo.applyTransform(m_localTransform, false);
- }
- if (!m_objectBoundingBox.isEmpty()) {
- // SVGRenderingContext may taint the state - make sure we're always saving.
- SVGRenderingContext renderingContext(this, childPaintInfo, stateSaver.saved() ?
- SVGRenderingContext::DontSaveGraphicsContext : SVGRenderingContext::SaveGraphicsContext);
-
- if (renderingContext.isRenderingPrepared()) {
- if (style()->svgStyle().bufferedRendering() == BR_STATIC && renderingContext.bufferForeground(m_bufferedForeground))
- return;
-
- paintForeground(childPaintInfo);
- }
- }
-
- if (style()->outlineWidth())
- paintOutline(childPaintInfo, IntRect(boundingBox));
-}
-
-void RenderSVGImage::paintForeground(PaintInfo& paintInfo)
-{
- RefPtr<Image> image = m_imageResource->image();
- FloatRect destRect = m_objectBoundingBox;
- FloatRect srcRect(0, 0, image->width(), image->height());
-
- SVGImageElement* imageElement = toSVGImageElement(element());
- imageElement->preserveAspectRatio()->currentValue()->transformRect(destRect, srcRect);
-
- InterpolationQuality interpolationQuality = InterpolationDefault;
- if (style()->svgStyle().bufferedRendering() != BR_STATIC)
- interpolationQuality = ImageQualityController::imageQualityController()->chooseInterpolationQuality(paintInfo.context, this, image.get(), image.get(), LayoutSize(destRect.size()));
-
- InterpolationQuality previousInterpolationQuality = paintInfo.context->imageInterpolationQuality();
- paintInfo.context->setImageInterpolationQuality(interpolationQuality);
- paintInfo.context->drawImage(image.get(), destRect, srcRect, CompositeSourceOver);
- paintInfo.context->setImageInterpolationQuality(previousInterpolationQuality);
+ SVGImagePainter(*this).paint(paintInfo);
}
void RenderSVGImage::invalidateBufferedForeground()

Powered by Google App Engine
This is Rietveld 408576698