OLD | NEW |
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 class RenderSVGResourceClipper FINAL : public RenderSVGResourceContainer { | 30 class RenderSVGResourceClipper final : public RenderSVGResourceContainer { |
31 public: | 31 public: |
32 enum ClipperState { | 32 enum ClipperState { |
33 ClipperNotApplied, | 33 ClipperNotApplied, |
34 ClipperAppliedPath, | 34 ClipperAppliedPath, |
35 ClipperAppliedMask | 35 ClipperAppliedMask |
36 }; | 36 }; |
37 | 37 |
38 explicit RenderSVGResourceClipper(SVGClipPathElement*); | 38 explicit RenderSVGResourceClipper(SVGClipPathElement*); |
39 virtual ~RenderSVGResourceClipper(); | 39 virtual ~RenderSVGResourceClipper(); |
40 | 40 |
41 virtual const char* renderName() const OVERRIDE { return "RenderSVGResourceC
lipper"; } | 41 virtual const char* renderName() const override { return "RenderSVGResourceC
lipper"; } |
42 | 42 |
43 virtual void removeAllClientsFromCache(bool markForInvalidation = true) OVER
RIDE; | 43 virtual void removeAllClientsFromCache(bool markForInvalidation = true) over
ride; |
44 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation =
true) OVERRIDE; | 44 virtual void removeClientFromCache(RenderObject*, bool markForInvalidation =
true) override; |
45 | 45 |
46 // FIXME: Filters are also stateful resources that could benefit from having
their state managed | 46 // FIXME: Filters are also stateful resources that could benefit from having
their state managed |
47 // on the caller stack instead of the current hashmap. We should look
at refactoring these | 47 // on the caller stack instead of the current hashmap. We should look
at refactoring these |
48 // into a general interface that can be shared. | 48 // into a general interface that can be shared. |
49 bool applyStatefulResource(RenderObject*, GraphicsContext*&, ClipperState&); | 49 bool applyStatefulResource(RenderObject*, GraphicsContext*&, ClipperState&); |
50 void postApplyStatefulResource(RenderObject*, GraphicsContext*&, ClipperStat
e&); | 50 void postApplyStatefulResource(RenderObject*, GraphicsContext*&, ClipperStat
e&); |
51 | 51 |
52 // clipPath can be clipped too, but don't have a boundingBox or paintInvalid
ationRect. So we can't call | 52 // clipPath can be clipped too, but don't have a boundingBox or paintInvalid
ationRect. So we can't call |
53 // applyResource directly and use the rects from the object, since they are
empty for RenderSVGResources | 53 // applyResource directly and use the rects from the object, since they are
empty for RenderSVGResources |
54 // FIXME: We made applyClippingToContext public because we cannot call apply
Resource on HTML elements (it asserts on RenderObject::objectBoundingBox) | 54 // FIXME: We made applyClippingToContext public because we cannot call apply
Resource on HTML elements (it asserts on RenderObject::objectBoundingBox) |
55 bool applyClippingToContext(RenderObject*, const FloatRect&, const FloatRect
&, GraphicsContext*, ClipperState&); | 55 bool applyClippingToContext(RenderObject*, const FloatRect&, const FloatRect
&, GraphicsContext*, ClipperState&); |
56 | 56 |
57 FloatRect resourceBoundingBox(const RenderObject*); | 57 FloatRect resourceBoundingBox(const RenderObject*); |
58 | 58 |
59 virtual RenderSVGResourceType resourceType() const OVERRIDE { return s_resou
rceType; } | 59 virtual RenderSVGResourceType resourceType() const override { return s_resou
rceType; } |
60 | 60 |
61 bool hitTestClipContent(const FloatRect&, const FloatPoint&); | 61 bool hitTestClipContent(const FloatRect&, const FloatPoint&); |
62 | 62 |
63 SVGUnitTypes::SVGUnitType clipPathUnits() const { return toSVGClipPathElemen
t(element())->clipPathUnits()->currentValue()->enumValue(); } | 63 SVGUnitTypes::SVGUnitType clipPathUnits() const { return toSVGClipPathElemen
t(element())->clipPathUnits()->currentValue()->enumValue(); } |
64 | 64 |
65 static const RenderSVGResourceType s_resourceType; | 65 static const RenderSVGResourceType s_resourceType; |
66 private: | 66 private: |
67 bool tryPathOnlyClipping(GraphicsContext*, const AffineTransform&, const Flo
atRect&); | 67 bool tryPathOnlyClipping(GraphicsContext*, const AffineTransform&, const Flo
atRect&); |
68 void drawClipMaskContent(GraphicsContext*, const FloatRect& targetBoundingBo
x); | 68 void drawClipMaskContent(GraphicsContext*, const FloatRect& targetBoundingBo
x); |
69 void createDisplayList(GraphicsContext*, const AffineTransform&); | 69 void createDisplayList(GraphicsContext*, const AffineTransform&); |
70 void calculateClipContentPaintInvalidationRect(); | 70 void calculateClipContentPaintInvalidationRect(); |
71 | 71 |
72 RefPtr<DisplayList> m_clipContentDisplayList; | 72 RefPtr<DisplayList> m_clipContentDisplayList; |
73 FloatRect m_clipBoundaries; | 73 FloatRect m_clipBoundaries; |
74 | 74 |
75 // Reference cycle detection. | 75 // Reference cycle detection. |
76 bool m_inClipExpansion; | 76 bool m_inClipExpansion; |
77 }; | 77 }; |
78 | 78 |
79 DEFINE_RENDER_SVG_RESOURCE_TYPE_CASTS(RenderSVGResourceClipper, ClipperResourceT
ype); | 79 DEFINE_RENDER_SVG_RESOURCE_TYPE_CASTS(RenderSVGResourceClipper, ClipperResourceT
ype); |
80 | 80 |
81 } | 81 } |
82 | 82 |
83 #endif | 83 #endif |
OLD | NEW |