| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 4 * Copyright 2014 The Chromium Authors. All rights reserved. | 4 * Copyright 2014 The Chromium Authors. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| 11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
| 15 * | 15 * |
| 16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
| 17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
| 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 #ifndef LayoutSVGResourcePattern_h | 22 #ifndef LayoutSVGResourcePattern_h |
| 23 #define LayoutSVGResourcePattern_h | 23 #define LayoutSVGResourcePattern_h |
| 24 | 24 |
| 25 #include "core/layout/svg/LayoutSVGResourcePaintServer.h" | 25 #include "core/layout/svg/LayoutSVGResourcePaintServer.h" |
| 26 #include "core/svg/PatternAttributes.h" | 26 #include "core/svg/PatternAttributes.h" |
| 27 #include "platform/heap/Handle.h" | 27 #include "platform/heap/Handle.h" |
| 28 #include "third_party/skia/include/core/SkRefCnt.h" | 28 #include "third_party/skia/include/core/SkRefCnt.h" |
| 29 #include "skia/ext/cdl_common.h" |
| 29 #include "wtf/HashMap.h" | 30 #include "wtf/HashMap.h" |
| 30 #include <memory> | 31 #include <memory> |
| 31 | 32 |
| 32 class SkPicture; | |
| 33 | |
| 34 namespace blink { | 33 namespace blink { |
| 35 | 34 |
| 36 class AffineTransform; | 35 class AffineTransform; |
| 37 class FloatRect; | 36 class FloatRect; |
| 38 class SVGPatternElement; | 37 class SVGPatternElement; |
| 39 struct PatternData; | 38 struct PatternData; |
| 40 | 39 |
| 41 class LayoutSVGResourcePattern final : public LayoutSVGResourcePaintServer { | 40 class LayoutSVGResourcePattern final : public LayoutSVGResourcePaintServer { |
| 42 public: | 41 public: |
| 43 explicit LayoutSVGResourcePattern(SVGPatternElement*); | 42 explicit LayoutSVGResourcePattern(SVGPatternElement*); |
| 44 | 43 |
| 45 const char* name() const override { return "LayoutSVGResourcePattern"; } | 44 const char* name() const override { return "LayoutSVGResourcePattern"; } |
| 46 | 45 |
| 47 void removeAllClientsFromCache(bool markForInvalidation = true) override; | 46 void removeAllClientsFromCache(bool markForInvalidation = true) override; |
| 48 void removeClientFromCache(LayoutObject*, | 47 void removeClientFromCache(LayoutObject*, |
| 49 bool markForInvalidation = true) override; | 48 bool markForInvalidation = true) override; |
| 50 | 49 |
| 51 SVGPaintServer preparePaintServer(const LayoutObject&) override; | 50 SVGPaintServer preparePaintServer(const LayoutObject&) override; |
| 52 | 51 |
| 53 static const LayoutSVGResourceType s_resourceType = PatternResourceType; | 52 static const LayoutSVGResourceType s_resourceType = PatternResourceType; |
| 54 LayoutSVGResourceType resourceType() const override { return s_resourceType; } | 53 LayoutSVGResourceType resourceType() const override { return s_resourceType; } |
| 55 | 54 |
| 56 private: | 55 private: |
| 57 std::unique_ptr<PatternData> buildPatternData(const LayoutObject&); | 56 std::unique_ptr<PatternData> buildPatternData(const LayoutObject&); |
| 58 sk_sp<SkPicture> asPicture(const FloatRect& tile, | 57 sk_sp<CdlPicture> asPicture(const FloatRect& tile, |
| 59 const AffineTransform&) const; | 58 const AffineTransform&) const; |
| 60 PatternData* patternForLayoutObject(const LayoutObject&); | 59 PatternData* patternForLayoutObject(const LayoutObject&); |
| 61 | 60 |
| 62 const LayoutSVGResourceContainer* resolveContentElement() const; | 61 const LayoutSVGResourceContainer* resolveContentElement() const; |
| 63 | 62 |
| 64 bool m_shouldCollectPatternAttributes : 1; | 63 bool m_shouldCollectPatternAttributes : 1; |
| 65 Persistent<PatternAttributesWrapper> m_attributesWrapper; | 64 Persistent<PatternAttributesWrapper> m_attributesWrapper; |
| 66 | 65 |
| 67 PatternAttributes& mutableAttributes() { | 66 PatternAttributes& mutableAttributes() { |
| 68 return m_attributesWrapper->attributes(); | 67 return m_attributesWrapper->attributes(); |
| 69 } | 68 } |
| 70 const PatternAttributes& attributes() const { | 69 const PatternAttributes& attributes() const { |
| 71 return m_attributesWrapper->attributes(); | 70 return m_attributesWrapper->attributes(); |
| 72 } | 71 } |
| 73 | 72 |
| 74 // FIXME: we can almost do away with this per-object map, but not quite: the | 73 // FIXME: we can almost do away with this per-object map, but not quite: the |
| 75 // tile size can be relative to the client bounding box, and it gets captured | 74 // tile size can be relative to the client bounding box, and it gets captured |
| 76 // in the cached Pattern shader. | 75 // in the cached Pattern shader. |
| 77 // Hence, we need one Pattern shader per client. The display list OTOH is the | 76 // Hence, we need one Pattern shader per client. The display list OTOH is the |
| 78 // same => we should be able to cache a single display list per | 77 // same => we should be able to cache a single display list per |
| 79 // LayoutSVGResourcePattern + one Pattern(shader) for each client -- this | 78 // LayoutSVGResourcePattern + one Pattern(shader) for each client -- this |
| 80 // would avoid re-recording when multiple clients share the same pattern. | 79 // would avoid re-recording when multiple clients share the same pattern. |
| 81 HashMap<const LayoutObject*, std::unique_ptr<PatternData>> m_patternMap; | 80 HashMap<const LayoutObject*, std::unique_ptr<PatternData>> m_patternMap; |
| 82 }; | 81 }; |
| 83 | 82 |
| 84 } // namespace blink | 83 } // namespace blink |
| 85 | 84 |
| 86 #endif | 85 #endif |
| OLD | NEW |