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 |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 #include "core/layout/svg/LayoutSVGResourceContainer.h" | 23 #include "core/layout/svg/LayoutSVGResourceContainer.h" |
24 #include "core/svg/SVGClipPathElement.h" | 24 #include "core/svg/SVGClipPathElement.h" |
25 | 25 |
26 class SkPicture; | 26 class SkPicture; |
27 | 27 |
28 namespace blink { | 28 namespace blink { |
29 | 29 |
30 class LayoutSVGResourceClipper final : public LayoutSVGResourceContainer { | 30 class LayoutSVGResourceClipper final : public LayoutSVGResourceContainer { |
31 public: | 31 public: |
32 enum ClipperState { | |
33 ClipperNotApplied, | |
34 ClipperAppliedPath, | |
35 ClipperAppliedMask | |
36 }; | |
37 | |
38 explicit LayoutSVGResourceClipper(SVGClipPathElement*); | 32 explicit LayoutSVGResourceClipper(SVGClipPathElement*); |
39 virtual ~LayoutSVGResourceClipper(); | 33 virtual ~LayoutSVGResourceClipper(); |
40 | 34 |
41 virtual const char* name() const override { return "LayoutSVGResourceClipper
"; } | 35 virtual const char* name() const override { return "LayoutSVGResourceClipper
"; } |
42 | 36 |
43 virtual void removeAllClientsFromCache(bool markForInvalidation = true) over
ride; | 37 virtual void removeAllClientsFromCache(bool markForInvalidation = true) over
ride; |
44 virtual void removeClientFromCache(LayoutObject*, bool markForInvalidation =
true) override; | 38 virtual void removeClientFromCache(LayoutObject*, bool markForInvalidation =
true) override; |
45 | 39 |
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 | |
48 // into a general interface that can be shared. | |
49 bool applyStatefulResource(LayoutObject*, GraphicsContext*&, ClipperState&); | |
50 void postApplyStatefulResource(LayoutObject*, GraphicsContext*&, ClipperStat
e&); | |
51 | |
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 LayoutSVGResources | |
54 // FIXME: We made applyClippingToContext public because we cannot call apply
Resource on HTML elements (it asserts on LayoutObject::objectBoundingBox) | |
55 bool applyClippingToContext(LayoutObject*, const FloatRect&, const FloatRect
&, GraphicsContext*, ClipperState&); | |
56 | |
57 FloatRect resourceBoundingBox(const LayoutObject*); | 40 FloatRect resourceBoundingBox(const LayoutObject*); |
58 | 41 |
59 static const LayoutSVGResourceType s_resourceType = ClipperResourceType; | 42 static const LayoutSVGResourceType s_resourceType = ClipperResourceType; |
60 virtual LayoutSVGResourceType resourceType() const override { return s_resou
rceType; } | 43 virtual LayoutSVGResourceType resourceType() const override { return s_resou
rceType; } |
61 | 44 |
62 bool hitTestClipContent(const FloatRect&, const FloatPoint&); | 45 bool hitTestClipContent(const FloatRect&, const FloatPoint&); |
63 | 46 |
64 SVGUnitTypes::SVGUnitType clipPathUnits() const { return toSVGClipPathElemen
t(element())->clipPathUnits()->currentValue()->enumValue(); } | 47 SVGUnitTypes::SVGUnitType clipPathUnits() const { return toSVGClipPathElemen
t(element())->clipPathUnits()->currentValue()->enumValue(); } |
65 | 48 |
| 49 bool tryPathOnlyClipping(DisplayItemClient, GraphicsContext*, const AffineTr
ansform&, const FloatRect&); |
| 50 PassRefPtr<const SkPicture> createContentPicture(AffineTransform&, const Flo
atRect&); |
| 51 |
| 52 bool hasCycle() { return m_inClipExpansion; } |
| 53 void beginClipExpansion() { ASSERT(!m_inClipExpansion); m_inClipExpansion =
true; } |
| 54 void endClipExpansion() { ASSERT(m_inClipExpansion); m_inClipExpansion = fal
se; } |
66 private: | 55 private: |
67 bool tryPathOnlyClipping(DisplayItemClient, GraphicsContext*, const AffineTr
ansform&, const FloatRect&); | |
68 void drawClipMaskContent(GraphicsContext*, DisplayItemClient, const FloatRec
t& targetBoundingBox); | |
69 PassRefPtr<const SkPicture> createPicture(); | |
70 void calculateClipContentPaintInvalidationRect(); | 56 void calculateClipContentPaintInvalidationRect(); |
71 | 57 |
72 RefPtr<const SkPicture> m_clipContentPicture; | 58 RefPtr<const SkPicture> m_clipContentPicture; |
73 FloatRect m_clipBoundaries; | 59 FloatRect m_clipBoundaries; |
74 | 60 |
75 // Reference cycle detection. | 61 // Reference cycle detection. |
76 bool m_inClipExpansion; | 62 bool m_inClipExpansion; |
77 }; | 63 }; |
78 | 64 |
79 DEFINE_LAYOUT_SVG_RESOURCE_TYPE_CASTS(LayoutSVGResourceClipper, ClipperResourceT
ype); | 65 DEFINE_LAYOUT_SVG_RESOURCE_TYPE_CASTS(LayoutSVGResourceClipper, ClipperResourceT
ype); |
80 | 66 |
81 } | 67 } |
82 | 68 |
83 #endif | 69 #endif |
OLD | NEW |