OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef TestPaintArtifact_h | 5 #ifndef TestPaintArtifact_h |
6 #define TestPaintArtifact_h | 6 #define TestPaintArtifact_h |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "platform/graphics/Color.h" | 9 #include "platform/graphics/Color.h" |
10 #include "platform/graphics/paint/DisplayItemList.h" | 10 #include "platform/graphics/paint/DisplayItemList.h" |
11 #include "platform/graphics/paint/PaintArtifact.h" | 11 #include "platform/graphics/paint/PaintArtifact.h" |
12 #include "wtf/Allocator.h" | 12 #include "wtf/Allocator.h" |
13 #include "wtf/PassRefPtr.h" | 13 #include "wtf/PassRefPtr.h" |
14 #include "wtf/Vector.h" | 14 #include "wtf/Vector.h" |
15 #include <memory> | 15 #include <memory> |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 class Layer; | 18 class Layer; |
19 } | 19 } |
20 | 20 |
21 namespace blink { | 21 namespace blink { |
22 | 22 |
23 class ClipPaintPropertyNode; | 23 class ClipPaintPropertyNode; |
24 class EffectPaintPropertyNode; | 24 class EffectPaintPropertyNode; |
25 class FloatRect; | 25 class FloatRect; |
26 class PaintArtifact; | 26 class PaintArtifact; |
| 27 class ScrollPaintPropertyNode; |
27 class TransformPaintPropertyNode; | 28 class TransformPaintPropertyNode; |
28 | 29 |
29 // Useful for quickly making a paint artifact in unit tests. | 30 // Useful for quickly making a paint artifact in unit tests. |
30 // Must remain in scope while the paint artifact is used, because it owns the | 31 // Must remain in scope while the paint artifact is used, because it owns the |
31 // display item clients. | 32 // display item clients. |
32 // | 33 // |
33 // Usage: | 34 // Usage: |
34 // TestPaintArtifact artifact; | 35 // TestPaintArtifact artifact; |
35 // artifact.chunk(paintProperties) | 36 // artifact.chunk(paintProperties) |
36 // .rectDrawing(bounds, color) | 37 // .rectDrawing(bounds, color) |
37 // .rectDrawing(bounds2, color2); | 38 // .rectDrawing(bounds2, color2); |
38 // artifact.chunk(otherPaintProperties) | 39 // artifact.chunk(otherPaintProperties) |
39 // .rectDrawing(bounds3, color3); | 40 // .rectDrawing(bounds3, color3); |
40 // doSomethingWithArtifact(artifact); | 41 // doSomethingWithArtifact(artifact); |
41 class TestPaintArtifact { | 42 class TestPaintArtifact { |
42 STACK_ALLOCATED(); | 43 STACK_ALLOCATED(); |
43 public: | 44 public: |
44 TestPaintArtifact(); | 45 TestPaintArtifact(); |
45 ~TestPaintArtifact(); | 46 ~TestPaintArtifact(); |
46 | 47 |
47 // Add to the artifact. | 48 // Add to the artifact. |
48 TestPaintArtifact& chunk(PassRefPtr<TransformPaintPropertyNode>, PassRefPtr<
ClipPaintPropertyNode>, PassRefPtr<EffectPaintPropertyNode>); | 49 TestPaintArtifact& chunk(PassRefPtr<TransformPaintPropertyNode>, PassRefPtr<
ClipPaintPropertyNode>, PassRefPtr<EffectPaintPropertyNode>, PassRefPtr<ScrollPa
intPropertyNode>); |
49 TestPaintArtifact& chunk(const PaintChunkProperties&); | 50 TestPaintArtifact& chunk(const PaintChunkProperties&); |
50 TestPaintArtifact& rectDrawing(const FloatRect& bounds, Color); | 51 TestPaintArtifact& rectDrawing(const FloatRect& bounds, Color); |
51 TestPaintArtifact& foreignLayer(const FloatPoint&, const IntSize&, scoped_re
fptr<cc::Layer>); | 52 TestPaintArtifact& foreignLayer(const FloatPoint&, const IntSize&, scoped_re
fptr<cc::Layer>); |
52 | 53 |
53 // Can't add more things once this is called. | 54 // Can't add more things once this is called. |
54 const PaintArtifact& build(); | 55 const PaintArtifact& build(); |
55 | 56 |
56 private: | 57 private: |
57 class DummyRectClient; | 58 class DummyRectClient; |
58 Vector<std::unique_ptr<DummyRectClient>> m_dummyClients; | 59 Vector<std::unique_ptr<DummyRectClient>> m_dummyClients; |
59 | 60 |
60 // Exists if m_built is false. | 61 // Exists if m_built is false. |
61 DisplayItemList m_displayItemList; | 62 DisplayItemList m_displayItemList; |
62 Vector<PaintChunk> m_paintChunks; | 63 Vector<PaintChunk> m_paintChunks; |
63 | 64 |
64 // Exists if m_built is true. | 65 // Exists if m_built is true. |
65 PaintArtifact m_paintArtifact; | 66 PaintArtifact m_paintArtifact; |
66 | 67 |
67 bool m_built; | 68 bool m_built; |
68 }; | 69 }; |
69 | 70 |
70 } // namespace blink | 71 } // namespace blink |
71 | 72 |
72 #endif // TestPaintArtifact_h | 73 #endif // TestPaintArtifact_h |
OLD | NEW |