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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 resource_provider_ = ResourceProvider::Create( | 315 resource_provider_ = ResourceProvider::Create( |
316 output_surface_.get(), NULL, 0, false, 1).Pass(); | 316 output_surface_.get(), NULL, 0, false, 1).Pass(); |
317 renderer_.reset(new FakeRendererGL(&renderer_client_, | 317 renderer_.reset(new FakeRendererGL(&renderer_client_, |
318 &settings_, | 318 &settings_, |
319 output_surface_.get(), | 319 output_surface_.get(), |
320 resource_provider_.get())); | 320 resource_provider_.get())); |
321 renderer_->Initialize(); | 321 renderer_->Initialize(); |
322 } | 322 } |
323 | 323 |
324 void TestRenderPassProgram() { | 324 void TestRenderPassProgram() { |
325 EXPECT_PROGRAM_VALID(renderer_->render_pass_program_); | 325 EXPECT_PROGRAM_VALID(&renderer_->render_pass_program_); |
326 EXPECT_EQ(renderer_->render_pass_program_->program(), | 326 EXPECT_EQ(renderer_->render_pass_program_.program(), |
327 renderer_->program_shadow_); | 327 renderer_->program_shadow_); |
328 } | 328 } |
329 | 329 |
330 void TestRenderPassColorMatrixProgram() { | 330 void TestRenderPassColorMatrixProgram() { |
331 EXPECT_PROGRAM_VALID(renderer_->render_pass_color_matrix_program_); | 331 EXPECT_PROGRAM_VALID(&renderer_->render_pass_color_matrix_program_); |
332 EXPECT_EQ(renderer_->render_pass_color_matrix_program_->program(), | 332 EXPECT_EQ(renderer_->render_pass_color_matrix_program_.program(), |
333 renderer_->program_shadow_); | 333 renderer_->program_shadow_); |
334 } | 334 } |
335 | 335 |
336 void TestRenderPassMaskProgram() { | 336 void TestRenderPassMaskProgram() { |
337 EXPECT_PROGRAM_VALID(renderer_->render_pass_mask_program_); | 337 EXPECT_PROGRAM_VALID(&renderer_->render_pass_mask_program_); |
338 EXPECT_EQ(renderer_->render_pass_mask_program_->program(), | 338 EXPECT_EQ(renderer_->render_pass_mask_program_.program(), |
339 renderer_->program_shadow_); | 339 renderer_->program_shadow_); |
340 } | 340 } |
341 | 341 |
342 void TestRenderPassMaskColorMatrixProgram() { | 342 void TestRenderPassMaskColorMatrixProgram() { |
343 EXPECT_PROGRAM_VALID(renderer_->render_pass_mask_color_matrix_program_); | 343 EXPECT_PROGRAM_VALID(&renderer_->render_pass_mask_color_matrix_program_); |
344 EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_->program(), | 344 EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_.program(), |
345 renderer_->program_shadow_); | 345 renderer_->program_shadow_); |
346 } | 346 } |
347 | 347 |
348 void TestRenderPassProgramAA() { | 348 void TestRenderPassProgramAA() { |
349 EXPECT_PROGRAM_VALID(renderer_->render_pass_program_aa_); | 349 EXPECT_PROGRAM_VALID(&renderer_->render_pass_program_aa_); |
350 EXPECT_EQ(renderer_->render_pass_program_aa_->program(), | 350 EXPECT_EQ(renderer_->render_pass_program_aa_.program(), |
351 renderer_->program_shadow_); | 351 renderer_->program_shadow_); |
352 } | 352 } |
353 | 353 |
354 void TestRenderPassColorMatrixProgramAA() { | 354 void TestRenderPassColorMatrixProgramAA() { |
355 EXPECT_PROGRAM_VALID(renderer_->render_pass_color_matrix_program_aa_); | 355 EXPECT_PROGRAM_VALID(&renderer_->render_pass_color_matrix_program_aa_); |
356 EXPECT_EQ(renderer_->render_pass_color_matrix_program_aa_->program(), | 356 EXPECT_EQ(renderer_->render_pass_color_matrix_program_aa_.program(), |
357 renderer_->program_shadow_); | 357 renderer_->program_shadow_); |
358 } | 358 } |
359 | 359 |
360 void TestRenderPassMaskProgramAA() { | 360 void TestRenderPassMaskProgramAA() { |
361 EXPECT_PROGRAM_VALID(renderer_->render_pass_mask_program_aa_); | 361 EXPECT_PROGRAM_VALID(&renderer_->render_pass_mask_program_aa_); |
362 EXPECT_EQ(renderer_->render_pass_mask_program_aa_->program(), | 362 EXPECT_EQ(renderer_->render_pass_mask_program_aa_.program(), |
363 renderer_->program_shadow_); | 363 renderer_->program_shadow_); |
364 } | 364 } |
365 | 365 |
366 void TestRenderPassMaskColorMatrixProgramAA() { | 366 void TestRenderPassMaskColorMatrixProgramAA() { |
367 EXPECT_PROGRAM_VALID(renderer_->render_pass_mask_color_matrix_program_aa_); | 367 EXPECT_PROGRAM_VALID(&renderer_->render_pass_mask_color_matrix_program_aa_); |
368 EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_aa_->program(), | 368 EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_aa_.program(), |
369 renderer_->program_shadow_); | 369 renderer_->program_shadow_); |
370 } | 370 } |
371 | 371 |
372 void TestSolidColorProgramAA() { | 372 void TestSolidColorProgramAA() { |
373 EXPECT_PROGRAM_VALID(renderer_->solid_color_program_aa_); | 373 EXPECT_PROGRAM_VALID(&renderer_->solid_color_program_aa_); |
374 EXPECT_EQ(renderer_->solid_color_program_aa_->program(), | 374 EXPECT_EQ(renderer_->solid_color_program_aa_.program(), |
375 renderer_->program_shadow_); | 375 renderer_->program_shadow_); |
376 } | 376 } |
377 | 377 |
378 LayerTreeSettings settings_; | 378 LayerTreeSettings settings_; |
379 FakeOutputSurfaceClient output_surface_client_; | 379 FakeOutputSurfaceClient output_surface_client_; |
380 scoped_ptr<FakeOutputSurface> output_surface_; | 380 scoped_ptr<FakeOutputSurface> output_surface_; |
381 FakeRendererClient renderer_client_; | 381 FakeRendererClient renderer_client_; |
382 scoped_ptr<ResourceProvider> resource_provider_; | 382 scoped_ptr<ResourceProvider> resource_provider_; |
383 scoped_ptr<FakeRendererGL> renderer_; | 383 scoped_ptr<FakeRendererGL> renderer_; |
384 }; | 384 }; |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 FakeRendererGL renderer(&renderer_client, | 623 FakeRendererGL renderer(&renderer_client, |
624 &settings, | 624 &settings, |
625 output_surface.get(), | 625 output_surface.get(), |
626 resource_provider.get()); | 626 resource_provider.get()); |
627 | 627 |
628 EXPECT_TRUE(renderer.Initialize()); | 628 EXPECT_TRUE(renderer.Initialize()); |
629 } | 629 } |
630 | 630 |
631 class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D { | 631 class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D { |
632 public: | 632 public: |
633 LoseContextOnFirstGetContext() : context_lost_(false) {} | 633 LoseContextOnFirstGetContext() {} |
634 | |
635 virtual bool makeContextCurrent() OVERRIDE { return !context_lost_; } | |
636 | 634 |
637 virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value) | 635 virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value) |
638 OVERRIDE { | 636 OVERRIDE { |
639 context_lost_ = true; | 637 context_lost_ = true; |
640 *value = 0; | 638 *value = 0; |
641 } | 639 } |
642 | 640 |
643 virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value) | 641 virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value) |
644 OVERRIDE { | 642 OVERRIDE { |
645 context_lost_ = true; | 643 context_lost_ = true; |
646 *value = 0; | 644 *value = 0; |
647 } | 645 } |
648 | |
649 virtual WGC3Denum getGraphicsResetStatusARB() OVERRIDE { | |
650 return context_lost_ ? 1 : 0; | |
651 } | |
652 | |
653 private: | |
654 bool context_lost_; | |
655 }; | 646 }; |
656 | 647 |
657 TEST(GLRendererTest2, InitializationWithQuicklyLostContextDoesNotAssert) { | 648 TEST(GLRendererTest2, InitializationWithQuicklyLostContextDoesNotAssert) { |
658 FakeOutputSurfaceClient output_surface_client; | 649 FakeOutputSurfaceClient output_surface_client; |
659 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 650 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
660 scoped_ptr<TestWebGraphicsContext3D>(new LoseContextOnFirstGetContext))); | 651 scoped_ptr<TestWebGraphicsContext3D>(new LoseContextOnFirstGetContext))); |
661 CHECK(output_surface->BindToClient(&output_surface_client)); | 652 CHECK(output_surface->BindToClient(&output_surface_client)); |
662 | 653 |
663 scoped_ptr<ResourceProvider> resource_provider( | 654 scoped_ptr<ResourceProvider> resource_provider( |
664 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 655 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); |
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1845 base::MessageLoop::current()->Run(); | 1836 base::MessageLoop::current()->Run(); |
1846 | 1837 |
1847 // The sync point should have happened. | 1838 // The sync point should have happened. |
1848 EXPECT_EQ(1, sync_point_callback_count); | 1839 EXPECT_EQ(1, sync_point_callback_count); |
1849 EXPECT_EQ(1, other_callback_count); | 1840 EXPECT_EQ(1, other_callback_count); |
1850 } | 1841 } |
1851 #endif // OS_ANDROID | 1842 #endif // OS_ANDROID |
1852 | 1843 |
1853 } // namespace | 1844 } // namespace |
1854 } // namespace cc | 1845 } // namespace cc |
OLD | NEW |