| 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 "platform/graphics/paint/ScrollPaintPropertyNode.h" |
| 12 #include "wtf/Allocator.h" | 13 #include "wtf/Allocator.h" |
| 13 #include "wtf/PassRefPtr.h" | 14 #include "wtf/PassRefPtr.h" |
| 14 #include "wtf/Vector.h" | 15 #include "wtf/Vector.h" |
| 15 #include <memory> | 16 #include <memory> |
| 16 | 17 |
| 17 namespace cc { | 18 namespace cc { |
| 18 class Layer; | 19 class Layer; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace blink { | 22 namespace blink { |
| 22 | 23 |
| 23 class ClipPaintPropertyNode; | 24 class ClipPaintPropertyNode; |
| 24 class EffectPaintPropertyNode; | 25 class EffectPaintPropertyNode; |
| 25 class FloatRect; | 26 class FloatRect; |
| 26 class PaintArtifact; | 27 class PaintArtifact; |
| 27 class ScrollPaintPropertyNode; | |
| 28 class TransformPaintPropertyNode; | 28 class TransformPaintPropertyNode; |
| 29 | 29 |
| 30 // Useful for quickly making a paint artifact in unit tests. | 30 // Useful for quickly making a paint artifact in unit tests. |
| 31 // 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 |
| 32 // display item clients. | 32 // display item clients. |
| 33 // | 33 // |
| 34 // Usage: | 34 // Usage: |
| 35 // TestPaintArtifact artifact; | 35 // TestPaintArtifact artifact; |
| 36 // artifact.chunk(paintProperties) | 36 // artifact.chunk(paintProperties) |
| 37 // .rectDrawing(bounds, color) | 37 // .rectDrawing(bounds, color) |
| 38 // .rectDrawing(bounds2, color2); | 38 // .rectDrawing(bounds2, color2); |
| 39 // artifact.chunk(otherPaintProperties) | 39 // artifact.chunk(otherPaintProperties) |
| 40 // .rectDrawing(bounds3, color3); | 40 // .rectDrawing(bounds3, color3); |
| 41 // doSomethingWithArtifact(artifact); | 41 // doSomethingWithArtifact(artifact); |
| 42 class TestPaintArtifact { | 42 class TestPaintArtifact { |
| 43 STACK_ALLOCATED(); | 43 STACK_ALLOCATED(); |
| 44 | 44 |
| 45 public: | 45 public: |
| 46 TestPaintArtifact(); | 46 TestPaintArtifact(); |
| 47 ~TestPaintArtifact(); | 47 ~TestPaintArtifact(); |
| 48 | 48 |
| 49 // Add to the artifact. | 49 // Add to the artifact. |
| 50 TestPaintArtifact& chunk(PassRefPtr<TransformPaintPropertyNode>, | 50 TestPaintArtifact& chunk( |
| 51 PassRefPtr<ClipPaintPropertyNode>, | 51 PassRefPtr<TransformPaintPropertyNode>, |
| 52 PassRefPtr<EffectPaintPropertyNode>, | 52 PassRefPtr<ClipPaintPropertyNode>, |
| 53 PassRefPtr<ScrollPaintPropertyNode> = nullptr); | 53 PassRefPtr<EffectPaintPropertyNode>, |
| 54 PassRefPtr<ScrollPaintPropertyNode> = ScrollPaintPropertyNode::root()); |
| 54 TestPaintArtifact& chunk(const PaintChunkProperties&); | 55 TestPaintArtifact& chunk(const PaintChunkProperties&); |
| 55 TestPaintArtifact& rectDrawing(const FloatRect& bounds, Color); | 56 TestPaintArtifact& rectDrawing(const FloatRect& bounds, Color); |
| 56 TestPaintArtifact& foreignLayer(const FloatPoint&, | 57 TestPaintArtifact& foreignLayer(const FloatPoint&, |
| 57 const IntSize&, | 58 const IntSize&, |
| 58 scoped_refptr<cc::Layer>); | 59 scoped_refptr<cc::Layer>); |
| 59 | 60 |
| 60 // Can't add more things once this is called. | 61 // Can't add more things once this is called. |
| 61 const PaintArtifact& build(); | 62 const PaintArtifact& build(); |
| 62 | 63 |
| 63 private: | 64 private: |
| 64 class DummyRectClient; | 65 class DummyRectClient; |
| 65 Vector<std::unique_ptr<DummyRectClient>> m_dummyClients; | 66 Vector<std::unique_ptr<DummyRectClient>> m_dummyClients; |
| 66 | 67 |
| 67 // Exists if m_built is false. | 68 // Exists if m_built is false. |
| 68 DisplayItemList m_displayItemList; | 69 DisplayItemList m_displayItemList; |
| 69 Vector<PaintChunk> m_paintChunks; | 70 Vector<PaintChunk> m_paintChunks; |
| 70 | 71 |
| 71 // Exists if m_built is true. | 72 // Exists if m_built is true. |
| 72 PaintArtifact m_paintArtifact; | 73 PaintArtifact m_paintArtifact; |
| 73 | 74 |
| 74 bool m_built; | 75 bool m_built; |
| 75 }; | 76 }; |
| 76 | 77 |
| 77 } // namespace blink | 78 } // namespace blink |
| 78 | 79 |
| 79 #endif // TestPaintArtifact_h | 80 #endif // TestPaintArtifact_h |
| OLD | NEW |