OLD | NEW |
| (Empty) |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CC_TEST_LAYER_TREE_PIXEL_TEST_H_ | |
6 #define CC_TEST_LAYER_TREE_PIXEL_TEST_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/files/file_path.h" | |
11 #include "base/memory/ref_counted.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "cc/resources/single_release_callback.h" | |
14 #include "cc/test/layer_tree_test.h" | |
15 #include "ui/gl/gl_implementation.h" | |
16 | |
17 class SkBitmap; | |
18 | |
19 namespace gpu { | |
20 class GLInProcessContext; | |
21 } | |
22 | |
23 namespace cc { | |
24 class CopyOutputRequest; | |
25 class CopyOutputResult; | |
26 class LayerTreeHost; | |
27 class PixelComparator; | |
28 class SolidColorLayer; | |
29 class TextureLayer; | |
30 class TextureMailbox; | |
31 | |
32 class LayerTreePixelTest : public LayerTreeTest { | |
33 public: | |
34 enum PixelTestType { | |
35 PIXEL_TEST_GL, | |
36 PIXEL_TEST_SOFTWARE, | |
37 }; | |
38 | |
39 protected: | |
40 LayerTreePixelTest(); | |
41 ~LayerTreePixelTest() override; | |
42 | |
43 scoped_ptr<OutputSurface> CreateOutputSurface() override; | |
44 void WillActivateTreeOnThread(LayerTreeHostImpl* impl) override; | |
45 | |
46 virtual scoped_ptr<CopyOutputRequest> CreateCopyOutputRequest(); | |
47 | |
48 void ReadbackResult(scoped_ptr<CopyOutputResult> result); | |
49 | |
50 void BeginTest() override; | |
51 void SetupTree() override; | |
52 void AfterTest() override; | |
53 void EndTest() override; | |
54 | |
55 void TryEndTest(); | |
56 | |
57 scoped_refptr<SolidColorLayer> CreateSolidColorLayer(const gfx::Rect& rect, | |
58 SkColor color); | |
59 scoped_refptr<SolidColorLayer> CreateSolidColorLayerWithBorder( | |
60 const gfx::Rect& rect, | |
61 SkColor color, | |
62 int border_width, | |
63 SkColor border_color); | |
64 scoped_refptr<TextureLayer> CreateTextureLayer(const gfx::Rect& rect, | |
65 const SkBitmap& bitmap); | |
66 | |
67 void RunPixelTest(PixelTestType type, | |
68 scoped_refptr<Layer> content_root, | |
69 base::FilePath file_name); | |
70 | |
71 void RunSingleThreadedPixelTest(PixelTestType test_type, | |
72 scoped_refptr<Layer> content_root, | |
73 base::FilePath file_name); | |
74 | |
75 void RunPixelTestWithReadbackTarget(PixelTestType type, | |
76 scoped_refptr<Layer> content_root, | |
77 Layer* target, | |
78 base::FilePath file_name); | |
79 | |
80 scoped_ptr<SkBitmap> CopyTextureMailboxToBitmap( | |
81 const gfx::Size& size, | |
82 const TextureMailbox& texture_mailbox); | |
83 | |
84 void CopyBitmapToTextureMailboxAsTexture( | |
85 const SkBitmap& bitmap, | |
86 TextureMailbox* texture_mailbox, | |
87 scoped_ptr<SingleReleaseCallback>* release_callback); | |
88 | |
89 void ReleaseTextureMailbox(scoped_ptr<gpu::GLInProcessContext> context, | |
90 uint32 texture, | |
91 uint32 sync_point, | |
92 bool lost_resource); | |
93 | |
94 void set_enlarge_texture_amount(const gfx::Vector2d& enlarge_texture_amount) { | |
95 enlarge_texture_amount_ = enlarge_texture_amount; | |
96 } | |
97 | |
98 // Common CSS colors defined for tests to use. | |
99 static const SkColor kCSSOrange = 0xffffa500; | |
100 static const SkColor kCSSBrown = 0xffa52a2a; | |
101 static const SkColor kCSSGreen = 0xff008000; | |
102 | |
103 gfx::DisableNullDrawGLBindings enable_pixel_output_; | |
104 scoped_ptr<PixelComparator> pixel_comparator_; | |
105 PixelTestType test_type_; | |
106 scoped_refptr<Layer> content_root_; | |
107 Layer* readback_target_; | |
108 base::FilePath ref_file_; | |
109 scoped_ptr<SkBitmap> result_bitmap_; | |
110 std::vector<scoped_refptr<TextureLayer>> texture_layers_; | |
111 int pending_texture_mailbox_callbacks_; | |
112 bool impl_side_painting_; | |
113 gfx::Vector2d enlarge_texture_amount_; | |
114 }; | |
115 | |
116 } // namespace cc | |
117 | |
118 #endif // CC_TEST_LAYER_TREE_PIXEL_TEST_H_ | |
OLD | NEW |