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 14 matching lines...) Expand all Loading... |
25 #include <memory> | 25 #include <memory> |
26 #include "core/layout/svg/LayoutSVGResourcePaintServer.h" | 26 #include "core/layout/svg/LayoutSVGResourcePaintServer.h" |
27 #include "core/svg/PatternAttributes.h" | 27 #include "core/svg/PatternAttributes.h" |
28 #include "platform/heap/Handle.h" | 28 #include "platform/heap/Handle.h" |
29 #include "platform/wtf/HashMap.h" | 29 #include "platform/wtf/HashMap.h" |
30 #include "third_party/skia/include/core/SkRefCnt.h" | 30 #include "third_party/skia/include/core/SkRefCnt.h" |
31 | 31 |
32 namespace blink { | 32 namespace blink { |
33 | 33 |
34 class AffineTransform; | 34 class AffineTransform; |
35 class FloatRect; | |
36 class SVGPatternElement; | 35 class SVGPatternElement; |
37 struct PatternData; | 36 struct PatternData; |
38 | 37 |
39 class LayoutSVGResourcePattern final : public LayoutSVGResourcePaintServer { | 38 class LayoutSVGResourcePattern final : public LayoutSVGResourcePaintServer { |
40 public: | 39 public: |
41 explicit LayoutSVGResourcePattern(SVGPatternElement*); | 40 explicit LayoutSVGResourcePattern(SVGPatternElement*); |
42 | 41 |
43 const char* GetName() const override { return "LayoutSVGResourcePattern"; } | 42 const char* GetName() const override { return "LayoutSVGResourcePattern"; } |
44 | 43 |
45 void RemoveAllClientsFromCache(bool mark_for_invalidation = true) override; | 44 void RemoveAllClientsFromCache(bool mark_for_invalidation = true) override; |
46 void RemoveClientFromCache(LayoutObject*, | 45 void RemoveClientFromCache(LayoutObject*, |
47 bool mark_for_invalidation = true) override; | 46 bool mark_for_invalidation = true) override; |
48 | 47 |
49 SVGPaintServer PreparePaintServer(const LayoutObject&) override; | 48 SVGPaintServer PreparePaintServer(const LayoutObject&) override; |
50 | 49 |
51 static const LayoutSVGResourceType kResourceType = kPatternResourceType; | 50 static const LayoutSVGResourceType kResourceType = kPatternResourceType; |
52 LayoutSVGResourceType ResourceType() const override { return kResourceType; } | 51 LayoutSVGResourceType ResourceType() const override { return kResourceType; } |
53 | 52 |
54 private: | 53 private: |
55 std::unique_ptr<PatternData> BuildPatternData(const LayoutObject&); | 54 std::unique_ptr<PatternData> BuildPatternData(const LayoutObject&); |
56 sk_sp<PaintRecord> AsPaintRecord(const FloatRect& tile, | 55 sk_sp<PaintRecord> AsPaintRecord(const FloatSize&, |
57 const AffineTransform&) const; | 56 const AffineTransform&) const; |
58 PatternData* PatternForLayoutObject(const LayoutObject&); | 57 PatternData* PatternForLayoutObject(const LayoutObject&); |
59 | 58 |
60 const LayoutSVGResourceContainer* ResolveContentElement() const; | 59 const LayoutSVGResourceContainer* ResolveContentElement() const; |
61 | 60 |
62 bool should_collect_pattern_attributes_ : 1; | 61 bool should_collect_pattern_attributes_ : 1; |
63 Persistent<PatternAttributesWrapper> attributes_wrapper_; | 62 Persistent<PatternAttributesWrapper> attributes_wrapper_; |
64 | 63 |
65 PatternAttributes& MutableAttributes() { | 64 PatternAttributes& MutableAttributes() { |
66 return attributes_wrapper_->Attributes(); | 65 return attributes_wrapper_->Attributes(); |
67 } | 66 } |
68 const PatternAttributes& Attributes() const { | 67 const PatternAttributes& Attributes() const { |
69 return attributes_wrapper_->Attributes(); | 68 return attributes_wrapper_->Attributes(); |
70 } | 69 } |
71 | 70 |
72 // FIXME: we can almost do away with this per-object map, but not quite: the | 71 // FIXME: we can almost do away with this per-object map, but not quite: the |
73 // tile size can be relative to the client bounding box, and it gets captured | 72 // tile size can be relative to the client bounding box, and it gets captured |
74 // in the cached Pattern shader. | 73 // in the cached Pattern shader. |
75 // Hence, we need one Pattern shader per client. The display list OTOH is the | 74 // Hence, we need one Pattern shader per client. The display list OTOH is the |
76 // same => we should be able to cache a single display list per | 75 // same => we should be able to cache a single display list per |
77 // LayoutSVGResourcePattern + one Pattern(shader) for each client -- this | 76 // LayoutSVGResourcePattern + one Pattern(shader) for each client -- this |
78 // would avoid re-recording when multiple clients share the same pattern. | 77 // would avoid re-recording when multiple clients share the same pattern. |
79 HashMap<const LayoutObject*, std::unique_ptr<PatternData>> pattern_map_; | 78 HashMap<const LayoutObject*, std::unique_ptr<PatternData>> pattern_map_; |
80 }; | 79 }; |
81 | 80 |
82 } // namespace blink | 81 } // namespace blink |
83 | 82 |
84 #endif | 83 #endif |
OLD | NEW |