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/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
10 #include "cc/output/compositor_frame_metadata.h" | 10 #include "cc/output/compositor_frame_metadata.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 using WebKit::WGC3Dint; | 50 using WebKit::WGC3Dint; |
51 using WebKit::WGC3Dintptr; | 51 using WebKit::WGC3Dintptr; |
52 using WebKit::WGC3Dsizei; | 52 using WebKit::WGC3Dsizei; |
53 using WebKit::WGC3Dsizeiptr; | 53 using WebKit::WGC3Dsizeiptr; |
54 using WebKit::WGC3Duint; | 54 using WebKit::WGC3Duint; |
55 | 55 |
56 namespace cc { | 56 namespace cc { |
57 | 57 |
58 #define EXPECT_PROGRAM_VALID(program_binding) \ | 58 #define EXPECT_PROGRAM_VALID(program_binding) \ |
59 do { \ | 59 do { \ |
60 EXPECT_TRUE(program_binding->program()); \ | 60 EXPECT_TRUE((program_binding)->program()); \ |
61 EXPECT_TRUE(program_binding->initialized()); \ | 61 EXPECT_TRUE((program_binding)->initialized()); \ |
62 } while (false) | 62 } while (false) |
63 | 63 |
64 // Explicitly named to be a friend in GLRenderer for shader access. | 64 // Explicitly named to be a friend in GLRenderer for shader access. |
65 class GLRendererShaderPixelTest : public GLRendererPixelTest { | 65 class GLRendererShaderPixelTest : public GLRendererPixelTest { |
66 public: | 66 public: |
67 void TestShaders() { | 67 void TestShaders() { |
68 ASSERT_FALSE(renderer()->IsContextLost()); | 68 ASSERT_FALSE(renderer()->IsContextLost()); |
69 EXPECT_PROGRAM_VALID(renderer()->GetTileCheckerboardProgram()); | 69 EXPECT_PROGRAM_VALID(renderer()->GetTileCheckerboardProgram()); |
70 EXPECT_PROGRAM_VALID(renderer()->GetDebugBorderProgram()); | 70 EXPECT_PROGRAM_VALID(renderer()->GetDebugBorderProgram()); |
71 EXPECT_PROGRAM_VALID(renderer()->GetSolidColorProgram()); | 71 EXPECT_PROGRAM_VALID(renderer()->GetSolidColorProgram()); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 resource_provider_ = ResourceProvider::Create( | 255 resource_provider_ = ResourceProvider::Create( |
256 output_surface_.get(), NULL, 0, false, 1).Pass(); | 256 output_surface_.get(), NULL, 0, false, 1).Pass(); |
257 renderer_.reset(new FakeRendererGL(&renderer_client_, | 257 renderer_.reset(new FakeRendererGL(&renderer_client_, |
258 &settings_, | 258 &settings_, |
259 output_surface_.get(), | 259 output_surface_.get(), |
260 resource_provider_.get())); | 260 resource_provider_.get())); |
261 renderer_->Initialize(); | 261 renderer_->Initialize(); |
262 } | 262 } |
263 | 263 |
264 void TestRenderPassProgram() { | 264 void TestRenderPassProgram() { |
265 EXPECT_PROGRAM_VALID(renderer_->render_pass_program_); | 265 EXPECT_PROGRAM_VALID(&renderer_->render_pass_program_); |
266 EXPECT_EQ(renderer_->render_pass_program_->program(), | 266 EXPECT_EQ(renderer_->render_pass_program_.program(), |
267 renderer_->program_shadow_); | 267 renderer_->program_shadow_); |
268 } | 268 } |
269 | 269 |
270 void TestRenderPassColorMatrixProgram() { | 270 void TestRenderPassColorMatrixProgram() { |
271 EXPECT_PROGRAM_VALID(renderer_->render_pass_color_matrix_program_); | 271 EXPECT_PROGRAM_VALID(&renderer_->render_pass_color_matrix_program_); |
272 EXPECT_EQ(renderer_->render_pass_color_matrix_program_->program(), | 272 EXPECT_EQ(renderer_->render_pass_color_matrix_program_.program(), |
273 renderer_->program_shadow_); | 273 renderer_->program_shadow_); |
274 } | 274 } |
275 | 275 |
276 void TestRenderPassMaskProgram() { | 276 void TestRenderPassMaskProgram() { |
277 EXPECT_PROGRAM_VALID(renderer_->render_pass_mask_program_); | 277 EXPECT_PROGRAM_VALID(&renderer_->render_pass_mask_program_); |
278 EXPECT_EQ(renderer_->render_pass_mask_program_->program(), | 278 EXPECT_EQ(renderer_->render_pass_mask_program_.program(), |
279 renderer_->program_shadow_); | 279 renderer_->program_shadow_); |
280 } | 280 } |
281 | 281 |
282 void TestRenderPassMaskColorMatrixProgram() { | 282 void TestRenderPassMaskColorMatrixProgram() { |
283 EXPECT_PROGRAM_VALID(renderer_->render_pass_mask_color_matrix_program_); | 283 EXPECT_PROGRAM_VALID(&renderer_->render_pass_mask_color_matrix_program_); |
284 EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_->program(), | 284 EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_.program(), |
285 renderer_->program_shadow_); | 285 renderer_->program_shadow_); |
286 } | 286 } |
287 | 287 |
288 void TestRenderPassProgramAA() { | 288 void TestRenderPassProgramAA() { |
289 EXPECT_PROGRAM_VALID(renderer_->render_pass_program_aa_); | 289 EXPECT_PROGRAM_VALID(&renderer_->render_pass_program_aa_); |
290 EXPECT_EQ(renderer_->render_pass_program_aa_->program(), | 290 EXPECT_EQ(renderer_->render_pass_program_aa_.program(), |
291 renderer_->program_shadow_); | 291 renderer_->program_shadow_); |
292 } | 292 } |
293 | 293 |
294 void TestRenderPassColorMatrixProgramAA() { | 294 void TestRenderPassColorMatrixProgramAA() { |
295 EXPECT_PROGRAM_VALID(renderer_->render_pass_color_matrix_program_aa_); | 295 EXPECT_PROGRAM_VALID(&renderer_->render_pass_color_matrix_program_aa_); |
296 EXPECT_EQ(renderer_->render_pass_color_matrix_program_aa_->program(), | 296 EXPECT_EQ(renderer_->render_pass_color_matrix_program_aa_.program(), |
297 renderer_->program_shadow_); | 297 renderer_->program_shadow_); |
298 } | 298 } |
299 | 299 |
300 void TestRenderPassMaskProgramAA() { | 300 void TestRenderPassMaskProgramAA() { |
301 EXPECT_PROGRAM_VALID(renderer_->render_pass_mask_program_aa_); | 301 EXPECT_PROGRAM_VALID(&renderer_->render_pass_mask_program_aa_); |
302 EXPECT_EQ(renderer_->render_pass_mask_program_aa_->program(), | 302 EXPECT_EQ(renderer_->render_pass_mask_program_aa_.program(), |
303 renderer_->program_shadow_); | 303 renderer_->program_shadow_); |
304 } | 304 } |
305 | 305 |
306 void TestRenderPassMaskColorMatrixProgramAA() { | 306 void TestRenderPassMaskColorMatrixProgramAA() { |
307 EXPECT_PROGRAM_VALID(renderer_->render_pass_mask_color_matrix_program_aa_); | 307 EXPECT_PROGRAM_VALID(&renderer_->render_pass_mask_color_matrix_program_aa_); |
308 EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_aa_->program(), | 308 EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_aa_.program(), |
309 renderer_->program_shadow_); | 309 renderer_->program_shadow_); |
310 } | 310 } |
311 | 311 |
312 void TestSolidColorProgramAA() { | 312 void TestSolidColorProgramAA() { |
313 EXPECT_PROGRAM_VALID(renderer_->solid_color_program_aa_); | 313 EXPECT_PROGRAM_VALID(&renderer_->solid_color_program_aa_); |
314 EXPECT_EQ(renderer_->solid_color_program_aa_->program(), | 314 EXPECT_EQ(renderer_->solid_color_program_aa_.program(), |
315 renderer_->program_shadow_); | 315 renderer_->program_shadow_); |
316 } | 316 } |
317 | 317 |
318 LayerTreeSettings settings_; | 318 LayerTreeSettings settings_; |
319 FakeOutputSurfaceClient output_surface_client_; | 319 FakeOutputSurfaceClient output_surface_client_; |
320 scoped_ptr<FakeOutputSurface> output_surface_; | 320 scoped_ptr<FakeOutputSurface> output_surface_; |
321 FakeRendererClient renderer_client_; | 321 FakeRendererClient renderer_client_; |
322 scoped_ptr<ResourceProvider> resource_provider_; | 322 scoped_ptr<ResourceProvider> resource_provider_; |
323 scoped_ptr<FakeRendererGL> renderer_; | 323 scoped_ptr<FakeRendererGL> renderer_; |
324 }; | 324 }; |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 FakeRendererGL renderer(&renderer_client, | 563 FakeRendererGL renderer(&renderer_client, |
564 &settings, | 564 &settings, |
565 output_surface.get(), | 565 output_surface.get(), |
566 resource_provider.get()); | 566 resource_provider.get()); |
567 | 567 |
568 EXPECT_TRUE(renderer.Initialize()); | 568 EXPECT_TRUE(renderer.Initialize()); |
569 } | 569 } |
570 | 570 |
571 class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D { | 571 class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D { |
572 public: | 572 public: |
573 LoseContextOnFirstGetContext() : context_lost_(false) {} | 573 LoseContextOnFirstGetContext() {} |
574 | |
575 virtual bool makeContextCurrent() OVERRIDE { return !context_lost_; } | |
576 | 574 |
577 virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value) | 575 virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value) |
578 OVERRIDE { | 576 OVERRIDE { |
579 context_lost_ = true; | 577 context_lost_ = true; |
580 *value = 0; | 578 *value = 0; |
581 } | 579 } |
582 | 580 |
583 virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value) | 581 virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value) |
584 OVERRIDE { | 582 OVERRIDE { |
585 context_lost_ = true; | 583 context_lost_ = true; |
586 *value = 0; | 584 *value = 0; |
587 } | 585 } |
588 | |
589 virtual WGC3Denum getGraphicsResetStatusARB() OVERRIDE { | |
590 return context_lost_ ? 1 : 0; | |
591 } | |
592 | |
593 private: | |
594 bool context_lost_; | |
595 }; | 586 }; |
596 | 587 |
597 TEST(GLRendererTest2, InitializationWithQuicklyLostContextDoesNotAssert) { | 588 TEST(GLRendererTest2, InitializationWithQuicklyLostContextDoesNotAssert) { |
598 FakeOutputSurfaceClient output_surface_client; | 589 FakeOutputSurfaceClient output_surface_client; |
599 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 590 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
600 scoped_ptr<TestWebGraphicsContext3D>(new LoseContextOnFirstGetContext))); | 591 scoped_ptr<TestWebGraphicsContext3D>(new LoseContextOnFirstGetContext))); |
601 CHECK(output_surface->BindToClient(&output_surface_client)); | 592 CHECK(output_surface->BindToClient(&output_surface_client)); |
602 | 593 |
603 scoped_ptr<ResourceProvider> resource_provider( | 594 scoped_ptr<ResourceProvider> resource_provider( |
604 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 595 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); |
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1785 base::MessageLoop::current()->Run(); | 1776 base::MessageLoop::current()->Run(); |
1786 | 1777 |
1787 // The sync point should have happened. | 1778 // The sync point should have happened. |
1788 EXPECT_EQ(1, sync_point_callback_count); | 1779 EXPECT_EQ(1, sync_point_callback_count); |
1789 EXPECT_EQ(1, other_callback_count); | 1780 EXPECT_EQ(1, other_callback_count); |
1790 } | 1781 } |
1791 #endif // OS_ANDROID | 1782 #endif // OS_ANDROID |
1792 | 1783 |
1793 } // namespace | 1784 } // namespace |
1794 } // namespace cc | 1785 } // namespace cc |
OLD | NEW |