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

Side by Side Diff: Source/core/rendering/svg/RenderSVGResourceClipper.h

Issue 23643003: ImageBuffer-less SVG masking and clipping. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix the Win build. Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 10 matching lines...) Expand all
21 #define RenderSVGResourceClipper_h 21 #define RenderSVGResourceClipper_h
22 22
23 #include "core/rendering/svg/RenderSVGResourceContainer.h" 23 #include "core/rendering/svg/RenderSVGResourceContainer.h"
24 #include "core/svg/SVGClipPathElement.h" 24 #include "core/svg/SVGClipPathElement.h"
25 25
26 namespace WebCore { 26 namespace WebCore {
27 27
28 struct ClipperData { 28 struct ClipperData {
29 WTF_MAKE_FAST_ALLOCATED; 29 WTF_MAKE_FAST_ALLOCATED;
30 public: 30 public:
31 OwnPtr<ImageBuffer> clipMaskImage; 31 enum ClipMode { PathOnlyClipMode, MaskClipMode };
32
33 // We should eventually cache the combined clip path here, when switching to path ops clipping.
34 // For now we only cache a marker to let postApply know whether it needs to perform any work.
35 ClipMode clipMode;
32 }; 36 };
33 37
34 class RenderSVGResourceClipper FINAL : public RenderSVGResourceContainer { 38 class RenderSVGResourceClipper FINAL : public RenderSVGResourceContainer {
35 public: 39 public:
36 RenderSVGResourceClipper(SVGClipPathElement*); 40 RenderSVGResourceClipper(SVGClipPathElement*);
37 virtual ~RenderSVGResourceClipper(); 41 virtual ~RenderSVGResourceClipper();
38 42
39 virtual const char* renderName() const { return "RenderSVGResourceClipper"; } 43 virtual const char* renderName() const { return "RenderSVGResourceClipper"; }
40 44
41 virtual void removeAllClientsFromCache(bool markForInvalidation = true); 45 virtual void removeAllClientsFromCache(bool markForInvalidation = true);
42 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true); 46 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true);
43 47
44 virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, u nsigned short resourceMode); 48 virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, u nsigned short resourceMode) OVERRIDE;
49 virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned sh ort, const Path*, const RenderSVGShape*) OVERRIDE;
45 // clipPath can be clipped too, but don't have a boundingBox or repaintRect. So we can't call 50 // clipPath can be clipped too, but don't have a boundingBox or repaintRect. So we can't call
46 // applyResource directly and use the rects from the object, since they are empty for RenderSVGResources 51 // applyResource directly and use the rects from the object, since they are empty for RenderSVGResources
47 // FIXME: We made applyClippingToContext public because we cannot call apply Resource on HTML elements (it asserts on RenderObject::objectBoundingBox) 52 // FIXME: We made applyClippingToContext public because we cannot call apply Resource on HTML elements (it asserts on RenderObject::objectBoundingBox)
48 bool applyClippingToContext(RenderObject*, const FloatRect&, const FloatRect &, GraphicsContext*); 53 bool applyClippingToContext(RenderObject*, const FloatRect&, const FloatRect &, GraphicsContext*);
54
49 virtual FloatRect resourceBoundingBox(RenderObject*); 55 virtual FloatRect resourceBoundingBox(RenderObject*);
50 56
51 virtual RenderSVGResourceType resourceType() const { return ClipperResourceT ype; } 57 virtual RenderSVGResourceType resourceType() const { return ClipperResourceT ype; }
52 58
53 bool hitTestClipContent(const FloatRect&, const FloatPoint&); 59 bool hitTestClipContent(const FloatRect&, const FloatPoint&);
54 60
55 SVGUnitTypes::SVGUnitType clipPathUnits() const { return toSVGClipPathElemen t(node())->clipPathUnitsCurrentValue(); } 61 SVGUnitTypes::SVGUnitType clipPathUnits() const { return toSVGClipPathElemen t(node())->clipPathUnitsCurrentValue(); }
56 62
57 static RenderSVGResourceType s_resourceType; 63 static RenderSVGResourceType s_resourceType;
58 private: 64 private:
59 bool pathOnlyClipping(GraphicsContext*, const AffineTransform&, const FloatR ect&); 65 bool tryPathOnlyClipping(GraphicsContext*, const AffineTransform&, const Flo atRect&);
60 bool drawContentIntoMaskImage(ClipperData*, const FloatRect& objectBoundingB ox); 66 void drawMaskContent(GraphicsContext*, const FloatRect& targetBoundingBox);
61 void calculateClipContentRepaintRect(); 67 void calculateClipContentRepaintRect();
62 68
63 FloatRect m_clipBoundaries; 69 FloatRect m_clipBoundaries;
64 HashMap<RenderObject*, ClipperData*> m_clipper; 70 HashMap<const RenderObject*, OwnPtr<ClipperData> > m_rendererToClipperMap;
71
72 // Reference cycle detection.
73 bool m_inClipExpansion;
65 }; 74 };
66 75
67 } 76 }
68 77
69 #endif 78 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderObject.cpp ('k') | Source/core/rendering/svg/RenderSVGResourceClipper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698