OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "cc/test/layer_tree_pixel_test.h" | 5 #include "cc/test/layer_tree_pixel_test.h" |
6 | 6 |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "cc/output/copy_output_request.h" | 8 #include "cc/output/copy_output_request.h" |
9 #include "cc/output/copy_output_result.h" | 9 #include "cc/output/copy_output_result.h" |
10 #include "cc/resources/texture_mailbox.h" | 10 #include "cc/resources/texture_mailbox.h" |
11 #include "cc/test/paths.h" | 11 #include "cc/test/paths.h" |
12 #include "cc/test/pixel_comparator.h" | 12 #include "cc/test/pixel_comparator.h" |
13 #include "cc/test/pixel_test_output_surface.h" | 13 #include "cc/test/pixel_test_output_surface.h" |
14 #include "cc/test/pixel_test_software_output_device.h" | 14 #include "cc/test/pixel_test_software_output_device.h" |
15 #include "cc/test/pixel_test_utils.h" | 15 #include "cc/test/pixel_test_utils.h" |
16 #include "cc/trees/layer_tree_impl.h" | 16 #include "cc/trees/layer_tree_impl.h" |
17 #include "ui/gl/gl_implementation.h" | 17 #include "ui/gl/gl_implementation.h" |
18 #include "webkit/common/gpu/context_provider_in_process.h" | 18 #include "webkit/common/gpu/context_provider_in_process.h" |
19 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" | 19 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" |
20 | 20 |
21 namespace cc { | 21 namespace cc { |
22 | 22 |
23 LayerTreePixelTest::LayerTreePixelTest() | 23 LayerTreePixelTest::LayerTreePixelTest() |
24 : pixel_comparator_(new ExactPixelComparator(true)), use_gl_(true) {} | 24 : pixel_comparator_(new ExactPixelComparator(true)), |
| 25 test_type_(GL_WITH_DEFAULT) {} |
25 | 26 |
26 LayerTreePixelTest::~LayerTreePixelTest() {} | 27 LayerTreePixelTest::~LayerTreePixelTest() {} |
27 | 28 |
28 scoped_ptr<OutputSurface> LayerTreePixelTest::CreateOutputSurface() { | 29 scoped_ptr<OutputSurface> LayerTreePixelTest::CreateOutputSurface() { |
29 gfx::Vector2d viewport_offset(20, 10); | 30 gfx::Vector2d viewport_offset(20, 10); |
30 gfx::Size surface_expansion_size(40, 60); | 31 gfx::Size surface_expansion_size(40, 60); |
31 scoped_ptr<PixelTestOutputSurface> output_surface; | 32 scoped_ptr<PixelTestOutputSurface> output_surface; |
32 | 33 |
33 if (!use_gl_) { | 34 switch (test_type_) { |
34 scoped_ptr<PixelTestSoftwareOutputDevice> software_output_device( | 35 case SOFTWARE_WITH_DEFAULT: |
35 new PixelTestSoftwareOutputDevice); | 36 case SOFTWARE_WITH_BITMAP: { |
36 software_output_device->set_surface_expansion_size(surface_expansion_size); | 37 scoped_ptr<PixelTestSoftwareOutputDevice> software_output_device( |
37 output_surface = make_scoped_ptr( | 38 new PixelTestSoftwareOutputDevice); |
38 new PixelTestOutputSurface( | 39 software_output_device->set_surface_expansion_size( |
39 software_output_device.PassAs<SoftwareOutputDevice>())); | 40 surface_expansion_size); |
40 } else { | 41 output_surface = make_scoped_ptr( |
41 CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL)); | 42 new PixelTestOutputSurface( |
| 43 software_output_device.PassAs<SoftwareOutputDevice>())); |
| 44 break; |
| 45 } |
42 | 46 |
43 using WebKit::WebGraphicsContext3D; | 47 case GL_WITH_DEFAULT: |
44 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; | 48 case GL_WITH_BITMAP: { |
45 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d( | 49 CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL)); |
46 WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( | 50 |
47 WebGraphicsContext3D::Attributes())); | 51 using WebKit::WebGraphicsContext3D; |
48 output_surface = make_scoped_ptr( | 52 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; |
49 new PixelTestOutputSurface(context3d.PassAs<WebGraphicsContext3D>())); | 53 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d( |
| 54 WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 55 CreateOffscreenContext(WebGraphicsContext3D::Attributes())); |
| 56 output_surface = make_scoped_ptr( |
| 57 new PixelTestOutputSurface(context3d.PassAs<WebGraphicsContext3D>())); |
| 58 break; |
| 59 } |
50 } | 60 } |
51 | 61 |
52 output_surface->set_viewport_offset(viewport_offset); | 62 output_surface->set_viewport_offset(viewport_offset); |
53 output_surface->set_surface_expansion_size(surface_expansion_size); | 63 output_surface->set_surface_expansion_size(surface_expansion_size); |
54 return output_surface.PassAs<OutputSurface>(); | 64 return output_surface.PassAs<OutputSurface>(); |
55 } | 65 } |
56 | 66 |
57 scoped_refptr<cc::ContextProvider> | 67 scoped_refptr<cc::ContextProvider> |
58 LayerTreePixelTest::OffscreenContextProviderForMainThread() { | 68 LayerTreePixelTest::OffscreenContextProviderForMainThread() { |
59 scoped_refptr<webkit::gpu::ContextProviderInProcess> provider = | 69 scoped_refptr<webkit::gpu::ContextProviderInProcess> provider = |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 gfx::Rect(0, rect.height() - border_width, rect.width(), border_width), | 144 gfx::Rect(0, rect.height() - border_width, rect.width(), border_width), |
135 border_color); | 145 border_color); |
136 layer->AddChild(border_top); | 146 layer->AddChild(border_top); |
137 layer->AddChild(border_left); | 147 layer->AddChild(border_left); |
138 layer->AddChild(border_right); | 148 layer->AddChild(border_right); |
139 layer->AddChild(border_bottom); | 149 layer->AddChild(border_bottom); |
140 return layer; | 150 return layer; |
141 } | 151 } |
142 | 152 |
143 void LayerTreePixelTest::RunPixelTest( | 153 void LayerTreePixelTest::RunPixelTest( |
| 154 PixelTestType test_type, |
144 scoped_refptr<Layer> content_root, | 155 scoped_refptr<Layer> content_root, |
145 base::FilePath file_name) { | 156 base::FilePath file_name) { |
| 157 test_type_ = test_type; |
146 content_root_ = content_root; | 158 content_root_ = content_root; |
147 readback_target_ = NULL; | 159 readback_target_ = NULL; |
148 ref_file_ = file_name; | 160 ref_file_ = file_name; |
149 RunTest(true, false, true); | 161 RunTest(true, false, true); |
150 } | 162 } |
151 | 163 |
152 void LayerTreePixelTest::RunPixelTestWithReadbackTarget( | 164 void LayerTreePixelTest::RunPixelTestWithReadbackTarget( |
| 165 PixelTestType test_type, |
153 scoped_refptr<Layer> content_root, | 166 scoped_refptr<Layer> content_root, |
154 Layer* target, | 167 Layer* target, |
155 base::FilePath file_name) { | 168 base::FilePath file_name) { |
| 169 test_type_ = test_type; |
156 content_root_ = content_root; | 170 content_root_ = content_root; |
157 readback_target_ = target; | 171 readback_target_ = target; |
158 ref_file_ = file_name; | 172 ref_file_ = file_name; |
159 RunTest(true, false, true); | 173 RunTest(true, false, true); |
160 } | 174 } |
161 | 175 |
162 void LayerTreePixelTest::SetupTree() { | 176 void LayerTreePixelTest::SetupTree() { |
163 scoped_refptr<Layer> root = Layer::Create(); | 177 scoped_refptr<Layer> root = Layer::Create(); |
164 root->SetBounds(content_root_->bounds()); | 178 root->SetBounds(content_root_->bounds()); |
165 root->AddChild(content_root_); | 179 root->AddChild(content_root_); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 out_pixels[dest_y + x + SK_G32_SHIFT/8] = pixels.get()[src_y + x + 1]; | 252 out_pixels[dest_y + x + SK_G32_SHIFT/8] = pixels.get()[src_y + x + 1]; |
239 out_pixels[dest_y + x + SK_B32_SHIFT/8] = pixels.get()[src_y + x + 2]; | 253 out_pixels[dest_y + x + SK_B32_SHIFT/8] = pixels.get()[src_y + x + 2]; |
240 out_pixels[dest_y + x + SK_A32_SHIFT/8] = pixels.get()[src_y + x + 3]; | 254 out_pixels[dest_y + x + SK_A32_SHIFT/8] = pixels.get()[src_y + x + 3]; |
241 } | 255 } |
242 } | 256 } |
243 | 257 |
244 return bitmap.Pass(); | 258 return bitmap.Pass(); |
245 } | 259 } |
246 | 260 |
247 } // namespace cc | 261 } // namespace cc |
OLD | NEW |