| 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 LayoutSVGResourceClipper_h | 20 #ifndef LayoutSVGResourceClipper_h |
| 21 #define LayoutSVGResourceClipper_h | 21 #define LayoutSVGResourceClipper_h |
| 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 #include "skia/ext/cdl_common.h" |
| 25 #include "third_party/skia/include/core/SkRefCnt.h" | 26 #include "third_party/skia/include/core/SkRefCnt.h" |
| 26 | 27 |
| 27 class SkPicture; | |
| 28 | |
| 29 namespace blink { | 28 namespace blink { |
| 30 | 29 |
| 31 class LayoutSVGResourceClipper final : public LayoutSVGResourceContainer { | 30 class LayoutSVGResourceClipper final : public LayoutSVGResourceContainer { |
| 32 public: | 31 public: |
| 33 explicit LayoutSVGResourceClipper(SVGClipPathElement*); | 32 explicit LayoutSVGResourceClipper(SVGClipPathElement*); |
| 34 ~LayoutSVGResourceClipper() override; | 33 ~LayoutSVGResourceClipper() override; |
| 35 | 34 |
| 36 const char* name() const override { return "LayoutSVGResourceClipper"; } | 35 const char* name() const override { return "LayoutSVGResourceClipper"; } |
| 37 | 36 |
| 38 void removeAllClientsFromCache(bool markForInvalidation = true) override; | 37 void removeAllClientsFromCache(bool markForInvalidation = true) override; |
| 39 void removeClientFromCache(LayoutObject*, | 38 void removeClientFromCache(LayoutObject*, |
| 40 bool markForInvalidation = true) override; | 39 bool markForInvalidation = true) override; |
| 41 | 40 |
| 42 FloatRect resourceBoundingBox(const FloatRect& referenceBox); | 41 FloatRect resourceBoundingBox(const FloatRect& referenceBox); |
| 43 | 42 |
| 44 static const LayoutSVGResourceType s_resourceType = ClipperResourceType; | 43 static const LayoutSVGResourceType s_resourceType = ClipperResourceType; |
| 45 LayoutSVGResourceType resourceType() const override { return s_resourceType; } | 44 LayoutSVGResourceType resourceType() const override { return s_resourceType; } |
| 46 | 45 |
| 47 bool hitTestClipContent(const FloatRect&, const FloatPoint&); | 46 bool hitTestClipContent(const FloatRect&, const FloatPoint&); |
| 48 | 47 |
| 49 SVGUnitTypes::SVGUnitType clipPathUnits() const { | 48 SVGUnitTypes::SVGUnitType clipPathUnits() const { |
| 50 return toSVGClipPathElement(element()) | 49 return toSVGClipPathElement(element()) |
| 51 ->clipPathUnits() | 50 ->clipPathUnits() |
| 52 ->currentValue() | 51 ->currentValue() |
| 53 ->enumValue(); | 52 ->enumValue(); |
| 54 } | 53 } |
| 55 | 54 |
| 56 bool asPath(const AffineTransform&, const FloatRect& referenceBox, Path&); | 55 bool asPath(const AffineTransform&, const FloatRect& referenceBox, Path&); |
| 57 sk_sp<const SkPicture> createContentPicture(); | 56 sk_sp<const CdlPicture> createContentPicture(); |
| 58 | 57 |
| 59 bool hasCycle() { return m_inClipExpansion; } | 58 bool hasCycle() { return m_inClipExpansion; } |
| 60 void beginClipExpansion() { | 59 void beginClipExpansion() { |
| 61 ASSERT(!m_inClipExpansion); | 60 ASSERT(!m_inClipExpansion); |
| 62 m_inClipExpansion = true; | 61 m_inClipExpansion = true; |
| 63 } | 62 } |
| 64 void endClipExpansion() { | 63 void endClipExpansion() { |
| 65 ASSERT(m_inClipExpansion); | 64 ASSERT(m_inClipExpansion); |
| 66 m_inClipExpansion = false; | 65 m_inClipExpansion = false; |
| 67 } | 66 } |
| 68 | 67 |
| 69 private: | 68 private: |
| 70 void calculateLocalClipBounds(); | 69 void calculateLocalClipBounds(); |
| 71 | 70 |
| 72 // Return true if the clip path was calculated or a cached value is available. | 71 // Return true if the clip path was calculated or a cached value is available. |
| 73 bool calculateClipContentPathIfNeeded(); | 72 bool calculateClipContentPathIfNeeded(); |
| 74 | 73 |
| 75 // Cache of the clip path when using path clipping. | 74 // Cache of the clip path when using path clipping. |
| 76 Path m_clipContentPath; | 75 Path m_clipContentPath; |
| 77 | 76 |
| 78 // Cache of the clip path picture when falling back to masking for clipping. | 77 // Cache of the clip path picture when falling back to masking for clipping. |
| 79 sk_sp<const SkPicture> m_clipContentPicture; | 78 sk_sp<const CdlPicture> m_clipContentPicture; |
| 80 | 79 |
| 81 FloatRect m_localClipBounds; | 80 FloatRect m_localClipBounds; |
| 82 | 81 |
| 83 // Reference cycle detection. | 82 // Reference cycle detection. |
| 84 bool m_inClipExpansion; | 83 bool m_inClipExpansion; |
| 85 }; | 84 }; |
| 86 | 85 |
| 87 DEFINE_LAYOUT_SVG_RESOURCE_TYPE_CASTS(LayoutSVGResourceClipper, | 86 DEFINE_LAYOUT_SVG_RESOURCE_TYPE_CASTS(LayoutSVGResourceClipper, |
| 88 ClipperResourceType); | 87 ClipperResourceType); |
| 89 | 88 |
| 90 } // namespace blink | 89 } // namespace blink |
| 91 | 90 |
| 92 #endif | 91 #endif |
| OLD | NEW |