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

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

Issue 547723003: Change RenderSVGResourceClipper's ClipperContext class into an enum (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Variables have to be initialized?!? 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 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20 #ifndef RenderSVGResourceClipper_h 20 #ifndef RenderSVGResourceClipper_h
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 blink { 26 namespace blink {
27 27
28 class DisplayList; 28 class DisplayList;
29 29
30 struct ClipperContext {
31 WTF_MAKE_FAST_ALLOCATED;
32 public:
33 enum ClipperState { NotAppliedState, AppliedPathState, AppliedMaskState };
34
35 ClipperContext()
36 : state(NotAppliedState)
37 {
38 }
39
40 ClipperState state;
41 };
42
43 class RenderSVGResourceClipper FINAL : public RenderSVGResourceContainer { 30 class RenderSVGResourceClipper FINAL : public RenderSVGResourceContainer {
44 public: 31 public:
32 enum ClipperState {
33 ClipperNotApplied,
34 ClipperAppliedPath,
35 ClipperAppliedMask
36 };
37
45 explicit RenderSVGResourceClipper(SVGClipPathElement*); 38 explicit RenderSVGResourceClipper(SVGClipPathElement*);
46 virtual ~RenderSVGResourceClipper(); 39 virtual ~RenderSVGResourceClipper();
47 40
48 virtual const char* renderName() const OVERRIDE { return "RenderSVGResourceC lipper"; } 41 virtual const char* renderName() const OVERRIDE { return "RenderSVGResourceC lipper"; }
49 42
50 virtual void removeAllClientsFromCache(bool markForInvalidation = true) OVER RIDE; 43 virtual void removeAllClientsFromCache(bool markForInvalidation = true) OVER RIDE;
51 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true) OVERRIDE; 44 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true) OVERRIDE;
52 45
53 virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, u nsigned short resourceMode) OVERRIDE; 46 virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, u nsigned short resourceMode) OVERRIDE;
54 virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned sh ort, const Path*, const RenderSVGShape*) OVERRIDE; 47 virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned sh ort, const Path*, const RenderSVGShape*) OVERRIDE;
55 48
56 // FIXME: Filters are also stateful resources that could benefit from having their state managed 49 // FIXME: Filters are also stateful resources that could benefit from having their state managed
57 // on the caller stack instead of the current hashmap. We should look at refactoring these 50 // on the caller stack instead of the current hashmap. We should look at refactoring these
58 // into a general interface that can be shared. 51 // into a general interface that can be shared.
59 bool applyStatefulResource(RenderObject*, GraphicsContext*&, ClipperContext& ); 52 bool applyStatefulResource(RenderObject*, GraphicsContext*&, ClipperState&);
60 void postApplyStatefulResource(RenderObject*, GraphicsContext*&, ClipperCont ext&); 53 void postApplyStatefulResource(RenderObject*, GraphicsContext*&, ClipperStat e&);
61 54
62 // clipPath can be clipped too, but don't have a boundingBox or paintInvalid ationRect. So we can't call 55 // clipPath can be clipped too, but don't have a boundingBox or paintInvalid ationRect. So we can't call
63 // applyResource directly and use the rects from the object, since they are empty for RenderSVGResources 56 // applyResource directly and use the rects from the object, since they are empty for RenderSVGResources
64 // FIXME: We made applyClippingToContext public because we cannot call apply Resource on HTML elements (it asserts on RenderObject::objectBoundingBox) 57 // FIXME: We made applyClippingToContext public because we cannot call apply Resource on HTML elements (it asserts on RenderObject::objectBoundingBox)
65 bool applyClippingToContext(RenderObject*, const FloatRect&, const FloatRect &, GraphicsContext*, ClipperContext&); 58 bool applyClippingToContext(RenderObject*, const FloatRect&, const FloatRect &, GraphicsContext*, ClipperState&);
66 59
67 FloatRect resourceBoundingBox(const RenderObject*); 60 FloatRect resourceBoundingBox(const RenderObject*);
68 61
69 virtual RenderSVGResourceType resourceType() const OVERRIDE { return s_resou rceType; } 62 virtual RenderSVGResourceType resourceType() const OVERRIDE { return s_resou rceType; }
70 63
71 bool hitTestClipContent(const FloatRect&, const FloatPoint&); 64 bool hitTestClipContent(const FloatRect&, const FloatPoint&);
72 65
73 SVGUnitTypes::SVGUnitType clipPathUnits() const { return toSVGClipPathElemen t(element())->clipPathUnits()->currentValue()->enumValue(); } 66 SVGUnitTypes::SVGUnitType clipPathUnits() const { return toSVGClipPathElemen t(element())->clipPathUnits()->currentValue()->enumValue(); }
74 67
75 static const RenderSVGResourceType s_resourceType; 68 static const RenderSVGResourceType s_resourceType;
76 private: 69 private:
77 bool tryPathOnlyClipping(GraphicsContext*, const AffineTransform&, const Flo atRect&); 70 bool tryPathOnlyClipping(GraphicsContext*, const AffineTransform&, const Flo atRect&);
78 void drawClipMaskContent(GraphicsContext*, const FloatRect& targetBoundingBo x); 71 void drawClipMaskContent(GraphicsContext*, const FloatRect& targetBoundingBo x);
79 void createDisplayList(GraphicsContext*, const AffineTransform&); 72 void createDisplayList(GraphicsContext*, const AffineTransform&);
80 void calculateClipContentPaintInvalidationRect(); 73 void calculateClipContentPaintInvalidationRect();
81 74
82 RefPtr<DisplayList> m_clipContentDisplayList; 75 RefPtr<DisplayList> m_clipContentDisplayList;
83 FloatRect m_clipBoundaries; 76 FloatRect m_clipBoundaries;
84 77
85 // Reference cycle detection. 78 // Reference cycle detection.
86 bool m_inClipExpansion; 79 bool m_inClipExpansion;
87 }; 80 };
88 81
89 DEFINE_RENDER_SVG_RESOURCE_TYPE_CASTS(RenderSVGResourceClipper, ClipperResourceT ype); 82 DEFINE_RENDER_SVG_RESOURCE_TYPE_CASTS(RenderSVGResourceClipper, ClipperResourceT ype);
90 83
91 } 84 }
92 85
93 #endif 86 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderLayer.cpp ('k') | Source/core/rendering/svg/RenderSVGResourceClipper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698