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 * |
(...skipping 11 matching lines...) Expand all Loading... |
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 "wtf/HashMap.h" | 29 #include "wtf/HashMap.h" |
30 #include <memory> | 30 #include <memory> |
31 | 31 |
32 class SkPicture; | |
33 | |
34 namespace blink { | 32 namespace blink { |
35 | 33 |
36 class AffineTransform; | 34 class AffineTransform; |
37 class FloatRect; | 35 class FloatRect; |
38 class SVGPatternElement; | 36 class SVGPatternElement; |
39 struct PatternData; | 37 struct PatternData; |
40 | 38 |
41 class LayoutSVGResourcePattern final : public LayoutSVGResourcePaintServer { | 39 class LayoutSVGResourcePattern final : public LayoutSVGResourcePaintServer { |
42 public: | 40 public: |
43 explicit LayoutSVGResourcePattern(SVGPatternElement*); | 41 explicit LayoutSVGResourcePattern(SVGPatternElement*); |
44 | 42 |
45 const char* name() const override { return "LayoutSVGResourcePattern"; } | 43 const char* name() const override { return "LayoutSVGResourcePattern"; } |
46 | 44 |
47 void removeAllClientsFromCache(bool markForInvalidation = true) override; | 45 void removeAllClientsFromCache(bool markForInvalidation = true) override; |
48 void removeClientFromCache(LayoutObject*, | 46 void removeClientFromCache(LayoutObject*, |
49 bool markForInvalidation = true) override; | 47 bool markForInvalidation = true) override; |
50 | 48 |
51 SVGPaintServer preparePaintServer(const LayoutObject&) override; | 49 SVGPaintServer preparePaintServer(const LayoutObject&) override; |
52 | 50 |
53 static const LayoutSVGResourceType s_resourceType = PatternResourceType; | 51 static const LayoutSVGResourceType s_resourceType = PatternResourceType; |
54 LayoutSVGResourceType resourceType() const override { return s_resourceType; } | 52 LayoutSVGResourceType resourceType() const override { return s_resourceType; } |
55 | 53 |
56 private: | 54 private: |
57 std::unique_ptr<PatternData> buildPatternData(const LayoutObject&); | 55 std::unique_ptr<PatternData> buildPatternData(const LayoutObject&); |
58 sk_sp<SkPicture> asPicture(const FloatRect& tile, | 56 sk_sp<PaintRecord> asPicture(const FloatRect& tile, |
59 const AffineTransform&) const; | 57 const AffineTransform&) const; |
60 PatternData* patternForLayoutObject(const LayoutObject&); | 58 PatternData* patternForLayoutObject(const LayoutObject&); |
61 | 59 |
62 const LayoutSVGResourceContainer* resolveContentElement() const; | 60 const LayoutSVGResourceContainer* resolveContentElement() const; |
63 | 61 |
64 bool m_shouldCollectPatternAttributes : 1; | 62 bool m_shouldCollectPatternAttributes : 1; |
65 Persistent<PatternAttributesWrapper> m_attributesWrapper; | 63 Persistent<PatternAttributesWrapper> m_attributesWrapper; |
66 | 64 |
67 PatternAttributes& mutableAttributes() { | 65 PatternAttributes& mutableAttributes() { |
68 return m_attributesWrapper->attributes(); | 66 return m_attributesWrapper->attributes(); |
69 } | 67 } |
70 const PatternAttributes& attributes() const { | 68 const PatternAttributes& attributes() const { |
71 return m_attributesWrapper->attributes(); | 69 return m_attributesWrapper->attributes(); |
72 } | 70 } |
73 | 71 |
74 // FIXME: we can almost do away with this per-object map, but not quite: the | 72 // 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 | 73 // tile size can be relative to the client bounding box, and it gets captured |
76 // in the cached Pattern shader. | 74 // in the cached Pattern shader. |
77 // Hence, we need one Pattern shader per client. The display list OTOH is the | 75 // 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 | 76 // same => we should be able to cache a single display list per |
79 // LayoutSVGResourcePattern + one Pattern(shader) for each client -- this | 77 // LayoutSVGResourcePattern + one Pattern(shader) for each client -- this |
80 // would avoid re-recording when multiple clients share the same pattern. | 78 // would avoid re-recording when multiple clients share the same pattern. |
81 HashMap<const LayoutObject*, std::unique_ptr<PatternData>> m_patternMap; | 79 HashMap<const LayoutObject*, std::unique_ptr<PatternData>> m_patternMap; |
82 }; | 80 }; |
83 | 81 |
84 } // namespace blink | 82 } // namespace blink |
85 | 83 |
86 #endif | 84 #endif |
OLD | NEW |