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