OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/gl_renderer.h" | 5 #include "cc/gl_renderer.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "cc/compositor_frame_metadata.h" | 9 #include "cc/compositor_frame_metadata.h" |
10 #include "cc/draw_quad.h" | 10 #include "cc/draw_quad.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 virtual void SetUp() { | 54 virtual void SetUp() { |
55 gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL); | 55 gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL); |
56 output_surface_ = PixelTestOutputSurface::create(); | 56 output_surface_ = PixelTestOutputSurface::create(); |
57 resource_provider_ = ResourceProvider::create(output_surface_.get()); | 57 resource_provider_ = ResourceProvider::create(output_surface_.get()); |
58 renderer_ = GLRenderer::create(&fake_client_, | 58 renderer_ = GLRenderer::create(&fake_client_, |
59 output_surface_.get(), | 59 output_surface_.get(), |
60 resource_provider_.get()); | 60 resource_provider_.get()); |
61 } | 61 } |
62 | 62 |
63 bool PixelsMatchReference(FilePath ref_file, gfx::Rect viewport_rect) { | 63 bool PixelsMatchReference(base::FilePath ref_file, gfx::Rect viewport_rect) { |
64 SkBitmap bitmap; | 64 SkBitmap bitmap; |
65 bitmap.setConfig(SkBitmap::kARGB_8888_Config, | 65 bitmap.setConfig(SkBitmap::kARGB_8888_Config, |
66 viewport_rect.width(), viewport_rect.height()); | 66 viewport_rect.width(), viewport_rect.height()); |
67 bitmap.allocPixels(); | 67 bitmap.allocPixels(); |
68 unsigned char* pixels = static_cast<unsigned char*>(bitmap.getPixels()); | 68 unsigned char* pixels = static_cast<unsigned char*>(bitmap.getPixels()); |
69 renderer_->getFramebufferPixels(pixels, viewport_rect); | 69 renderer_->getFramebufferPixels(pixels, viewport_rect); |
70 | 70 |
71 FilePath test_data_dir; | 71 base::FilePath test_data_dir; |
72 if (!PathService::Get(cc::DIR_TEST_DATA, &test_data_dir)) | 72 if (!PathService::Get(cc::DIR_TEST_DATA, &test_data_dir)) |
73 return false; | 73 return false; |
74 | 74 |
75 return IsSameAsPNGFile(bitmap, test_data_dir.Append(ref_file)); | 75 return IsSameAsPNGFile(bitmap, test_data_dir.Append(ref_file)); |
76 } | 76 } |
77 | 77 |
78 scoped_ptr<OutputSurface> output_surface_; | 78 scoped_ptr<OutputSurface> output_surface_; |
79 FakeRendererClient fake_client_; | 79 FakeRendererClient fake_client_; |
80 scoped_ptr<ResourceProvider> resource_provider_; | 80 scoped_ptr<ResourceProvider> resource_provider_; |
81 scoped_ptr<GLRenderer> renderer_; | 81 scoped_ptr<GLRenderer> renderer_; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); | 137 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); |
138 color_quad->SetNew(shared_state.get(), rect, SK_ColorGREEN); | 138 color_quad->SetNew(shared_state.get(), rect, SK_ColorGREEN); |
139 | 139 |
140 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); | 140 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); |
141 | 141 |
142 RenderPassList pass_list; | 142 RenderPassList pass_list; |
143 pass_list.push_back(pass.Pass()); | 143 pass_list.push_back(pass.Pass()); |
144 | 144 |
145 renderer_->drawFrame(pass_list); | 145 renderer_->drawFrame(pass_list); |
146 | 146 |
147 EXPECT_TRUE(PixelsMatchReference(FilePath(FILE_PATH_LITERAL("green.png")), | 147 EXPECT_TRUE(PixelsMatchReference( |
148 rect)); | 148 base::FilePath(FILE_PATH_LITERAL("green.png")), |
| 149 rect)); |
149 } | 150 } |
150 | 151 |
151 TEST_F(GLRendererPixelTest, RenderPassChangesSize) { | 152 TEST_F(GLRendererPixelTest, RenderPassChangesSize) { |
152 gfx::Rect viewport_rect(200, 200); | 153 gfx::Rect viewport_rect(200, 200); |
153 | 154 |
154 RenderPass::Id root_pass_id(1, 1); | 155 RenderPass::Id root_pass_id(1, 1); |
155 scoped_ptr<RenderPass> root_pass = | 156 scoped_ptr<RenderPass> root_pass = |
156 CreateTestRenderPass(root_pass_id, viewport_rect); | 157 CreateTestRenderPass(root_pass_id, viewport_rect); |
157 | 158 |
158 RenderPass::Id child_pass_id(2, 2); | 159 RenderPass::Id child_pass_id(2, 2); |
(...skipping 22 matching lines...) Expand all Loading... |
181 | 182 |
182 RenderPassList pass_list; | 183 RenderPassList pass_list; |
183 pass_list.push_back(child_pass.Pass()); | 184 pass_list.push_back(child_pass.Pass()); |
184 pass_list.push_back(root_pass.Pass()); | 185 pass_list.push_back(root_pass.Pass()); |
185 | 186 |
186 renderer_->setEnlargePassTextureAmountForTesting(gfx::Vector2d(50, 75)); | 187 renderer_->setEnlargePassTextureAmountForTesting(gfx::Vector2d(50, 75)); |
187 renderer_->decideRenderPassAllocationsForFrame(pass_list); | 188 renderer_->decideRenderPassAllocationsForFrame(pass_list); |
188 renderer_->drawFrame(pass_list); | 189 renderer_->drawFrame(pass_list); |
189 | 190 |
190 EXPECT_TRUE(PixelsMatchReference( | 191 EXPECT_TRUE(PixelsMatchReference( |
191 FilePath(FILE_PATH_LITERAL("blue_yellow.png")), viewport_rect)); | 192 base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")), viewport_rect)); |
192 } | 193 } |
193 #endif | 194 #endif |
194 | 195 |
195 } // namespace | 196 } // namespace |
196 } // namespace cc | 197 } // namespace cc |
OLD | NEW |