Commit 3f453a3e authored by fs@opera.com's avatar fs@opera.com

Remove applyStatefulResource interface from SVGClipPainter

applyClippingToContext is equally "stateful", so the two entrypoints
does not seem warranted.
Fold applyClippingToContext into applyStatefulResource and then rename
it to prepareEffect (to match mask and filter). Similarly rename
postApplyStatefulResource to finishEffect.

Review URL: https://codereview.chromium.org/1308223003

git-svn-id: svn://svn.chromium.org/blink/trunk@201262 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent fe8efcad
...@@ -146,7 +146,7 @@ public: ...@@ -146,7 +146,7 @@ public:
} }
m_resourceClipper = toLayoutSVGResourceClipper(toLayoutSVGResourceContainer(element->layoutObject())); m_resourceClipper = toLayoutSVGResourceClipper(toLayoutSVGResourceContainer(element->layoutObject()));
if (!SVGClipPainter(*m_resourceClipper).applyClippingToContext(*paintLayer.layoutObject(), rootRelativeBounds, if (!SVGClipPainter(*m_resourceClipper).prepareEffect(*paintLayer.layoutObject(), rootRelativeBounds,
paintingInfo.paintDirtyRect, context, m_clipperState)) { paintingInfo.paintDirtyRect, context, m_clipperState)) {
// No need to post-apply the clipper if this failed. // No need to post-apply the clipper if this failed.
m_resourceClipper = 0; m_resourceClipper = 0;
...@@ -158,7 +158,7 @@ public: ...@@ -158,7 +158,7 @@ public:
~ClipPathHelper() ~ClipPathHelper()
{ {
if (m_resourceClipper) if (m_resourceClipper)
SVGClipPainter(*m_resourceClipper).postApplyStatefulResource(*m_paintLayer.layoutObject(), m_context, m_clipperState); SVGClipPainter(*m_resourceClipper).finishEffect(*m_paintLayer.layoutObject(), m_context, m_clipperState);
} }
private: private:
LayoutSVGResourceClipper* m_resourceClipper; LayoutSVGResourceClipper* m_resourceClipper;
......
...@@ -17,18 +17,10 @@ ...@@ -17,18 +17,10 @@
#include "platform/graphics/paint/CompositingDisplayItem.h" #include "platform/graphics/paint/CompositingDisplayItem.h"
#include "platform/graphics/paint/DisplayItemList.h" #include "platform/graphics/paint/DisplayItemList.h"
#include "platform/graphics/paint/DrawingDisplayItem.h" #include "platform/graphics/paint/DrawingDisplayItem.h"
#include "wtf/TemporaryChange.h"
namespace blink { namespace blink {
bool SVGClipPainter::applyStatefulResource(const LayoutObject& object, GraphicsContext* context, ClipperState& clipperState) namespace {
{
ASSERT(context);
m_clip.clearInvalidationMask();
return applyClippingToContext(object, object.objectBoundingBox(), object.paintInvalidationRectInLocalCoordinates(), context, clipperState);
}
class SVGClipExpansionCycleHelper { class SVGClipExpansionCycleHelper {
public: public:
...@@ -38,13 +30,17 @@ private: ...@@ -38,13 +30,17 @@ private:
LayoutSVGResourceClipper& m_clip; LayoutSVGResourceClipper& m_clip;
}; };
bool SVGClipPainter::applyClippingToContext(const LayoutObject& target, const FloatRect& targetBoundingBox, }
bool SVGClipPainter::prepareEffect(const LayoutObject& target, const FloatRect& targetBoundingBox,
const FloatRect& paintInvalidationRect, GraphicsContext* context, ClipperState& clipperState) const FloatRect& paintInvalidationRect, GraphicsContext* context, ClipperState& clipperState)
{ {
ASSERT(context); ASSERT(context);
ASSERT(clipperState == ClipperNotApplied); ASSERT(clipperState == ClipperNotApplied);
ASSERT_WITH_SECURITY_IMPLICATION(!m_clip.needsLayout()); ASSERT_WITH_SECURITY_IMPLICATION(!m_clip.needsLayout());
m_clip.clearInvalidationMask();
if (paintInvalidationRect.isEmpty() || m_clip.hasCycle()) if (paintInvalidationRect.isEmpty() || m_clip.hasCycle())
return false; return false;
...@@ -85,7 +81,7 @@ bool SVGClipPainter::applyClippingToContext(const LayoutObject& target, const Fl ...@@ -85,7 +81,7 @@ bool SVGClipPainter::applyClippingToContext(const LayoutObject& target, const Fl
SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(&m_clip); SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(&m_clip);
LayoutSVGResourceClipper* clipPathClipper = resources ? resources->clipper() : 0; LayoutSVGResourceClipper* clipPathClipper = resources ? resources->clipper() : 0;
ClipperState clipPathClipperState = ClipperNotApplied; ClipperState clipPathClipperState = ClipperNotApplied;
if (clipPathClipper && !SVGClipPainter(*clipPathClipper).applyClippingToContext(m_clip, targetBoundingBox, paintInvalidationRect, context, clipPathClipperState)) { if (clipPathClipper && !SVGClipPainter(*clipPathClipper).prepareEffect(m_clip, targetBoundingBox, paintInvalidationRect, context, clipPathClipperState)) {
// End the clip mask's compositor. // End the clip mask's compositor.
CompositingRecorder::endCompositing(*context, target); CompositingRecorder::endCompositing(*context, target);
return false; return false;
...@@ -94,7 +90,7 @@ bool SVGClipPainter::applyClippingToContext(const LayoutObject& target, const Fl ...@@ -94,7 +90,7 @@ bool SVGClipPainter::applyClippingToContext(const LayoutObject& target, const Fl
drawClipMaskContent(context, target, targetBoundingBox, paintInvalidationRect); drawClipMaskContent(context, target, targetBoundingBox, paintInvalidationRect);
if (clipPathClipper) if (clipPathClipper)
SVGClipPainter(*clipPathClipper).postApplyStatefulResource(m_clip, context, clipPathClipperState); SVGClipPainter(*clipPathClipper).finishEffect(m_clip, context, clipPathClipperState);
} }
// Masked content layer start. // Masked content layer start.
...@@ -103,7 +99,7 @@ bool SVGClipPainter::applyClippingToContext(const LayoutObject& target, const Fl ...@@ -103,7 +99,7 @@ bool SVGClipPainter::applyClippingToContext(const LayoutObject& target, const Fl
return true; return true;
} }
void SVGClipPainter::postApplyStatefulResource(const LayoutObject& target, GraphicsContext* context, ClipperState& clipperState) void SVGClipPainter::finishEffect(const LayoutObject& target, GraphicsContext* context, ClipperState& clipperState)
{ {
switch (clipperState) { switch (clipperState) {
case ClipperAppliedPath: case ClipperAppliedPath:
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
namespace blink { namespace blink {
class AffineTransform;
class GraphicsContext; class GraphicsContext;
class LayoutObject; class LayoutObject;
class LayoutSVGResourceClipper; class LayoutSVGResourceClipper;
...@@ -28,13 +27,8 @@ public: ...@@ -28,13 +27,8 @@ public:
// FIXME: Filters are also stateful resources that could benefit from having their state managed // FIXME: Filters are also stateful resources that could benefit from having their state managed
// on the caller stack instead of the current hashmap. We should look at refactoring these // on the caller stack instead of the current hashmap. We should look at refactoring these
// into a general interface that can be shared. // into a general interface that can be shared.
bool applyStatefulResource(const LayoutObject&, GraphicsContext*, ClipperState&); bool prepareEffect(const LayoutObject&, const FloatRect&, const FloatRect&, GraphicsContext*, ClipperState&);
void postApplyStatefulResource(const LayoutObject&, GraphicsContext*, ClipperState&); void finishEffect(const LayoutObject&, GraphicsContext*, ClipperState&);
// clipPath can be clipped too, but don't have a boundingBox or paintInvalidationRect. So we can't call
// applyResource directly and use the rects from the object, since they are empty for LayoutSVGResources
// FIXME: We made applyClippingToContext public because we cannot call applyResource on HTML elements (it asserts on LayoutObject::objectBoundingBox)
bool applyClippingToContext(const LayoutObject&, const FloatRect&, const FloatRect&, GraphicsContext*, ClipperState&);
private: private:
void drawClipMaskContent(GraphicsContext*, const LayoutObject&, const FloatRect& targetBoundingBox, const FloatRect& targetPaintInvalidationRect); void drawClipMaskContent(GraphicsContext*, const LayoutObject&, const FloatRect& targetBoundingBox, const FloatRect& targetPaintInvalidationRect);
......
...@@ -60,7 +60,7 @@ SVGPaintContext::~SVGPaintContext() ...@@ -60,7 +60,7 @@ SVGPaintContext::~SVGPaintContext()
if (m_clipper) { if (m_clipper) {
ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(m_object)); ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(m_object));
ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(m_object)->clipper() == m_clipper); ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(m_object)->clipper() == m_clipper);
SVGClipPainter(*m_clipper).postApplyStatefulResource(*m_object, m_paintInfo.context, m_clipperState); SVGClipPainter(*m_clipper).finishEffect(*m_object, m_paintInfo.context, m_clipperState);
} }
} }
...@@ -123,7 +123,7 @@ bool SVGPaintContext::applyClipIfNecessary(SVGResources* resources) ...@@ -123,7 +123,7 @@ bool SVGPaintContext::applyClipIfNecessary(SVGResources* resources)
// m_object->style()->clipPath() corresponds to '-webkit-clip-path'. // m_object->style()->clipPath() corresponds to '-webkit-clip-path'.
// FIXME: We should unify the clip-path and -webkit-clip-path codepaths. // FIXME: We should unify the clip-path and -webkit-clip-path codepaths.
if (LayoutSVGResourceClipper* clipper = resources ? resources->clipper() : nullptr) { if (LayoutSVGResourceClipper* clipper = resources ? resources->clipper() : nullptr) {
if (!SVGClipPainter(*clipper).applyStatefulResource(*m_object, m_paintInfo.context, m_clipperState)) if (!SVGClipPainter(*clipper).prepareEffect(*m_object, m_object->objectBoundingBox(), m_object->paintInvalidationRectInLocalCoordinates(), m_paintInfo.context, m_clipperState))
return false; return false;
m_clipper = clipper; m_clipper = clipper;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment