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/debug/test_web_graphics_context_3d.h" | 10 #include "cc/debug/test_web_graphics_context_3d.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 private: | 134 private: |
135 int frame_; | 135 int frame_; |
136 }; | 136 }; |
137 | 137 |
138 class FakeRendererClient : public RendererClient { | 138 class FakeRendererClient : public RendererClient { |
139 public: | 139 public: |
140 FakeRendererClient() | 140 FakeRendererClient() |
141 : host_impl_(&proxy_), | 141 : host_impl_(&proxy_), |
142 set_full_root_layer_damage_count_(0), | 142 set_full_root_layer_damage_count_(0), |
143 root_layer_(LayerImpl::Create(host_impl_.active_tree(), 1)), | 143 root_layer_(LayerImpl::Create(host_impl_.active_tree(), 1)), |
144 viewport_size_(gfx::Size(1, 1)), | 144 viewport_size_(gfx::Size(1, 1)) { |
145 scale_factor_(1.f), | |
146 external_stencil_test_enabled_(false) { | |
147 root_layer_->CreateRenderSurface(); | 145 root_layer_->CreateRenderSurface(); |
148 RenderPass::Id render_pass_id = | 146 RenderPass::Id render_pass_id = |
149 root_layer_->render_surface()->RenderPassId(); | 147 root_layer_->render_surface()->RenderPassId(); |
150 scoped_ptr<RenderPass> root_render_pass = RenderPass::Create(); | 148 scoped_ptr<RenderPass> root_render_pass = RenderPass::Create(); |
151 root_render_pass->SetNew( | 149 root_render_pass->SetNew( |
152 render_pass_id, gfx::Rect(), gfx::Rect(), gfx::Transform()); | 150 render_pass_id, gfx::Rect(), gfx::Rect(), gfx::Transform()); |
153 render_passes_in_draw_order_.push_back(root_render_pass.Pass()); | 151 render_passes_in_draw_order_.push_back(root_render_pass.Pass()); |
154 } | 152 } |
155 | 153 |
156 // RendererClient methods. | 154 // RendererClient methods. |
157 virtual gfx::Rect DeviceViewport() const OVERRIDE { | 155 virtual gfx::Rect DeviceViewport() const OVERRIDE { |
158 static gfx::Size fake_size(1, 1); | 156 static gfx::Size fake_size(1, 1); |
159 return gfx::Rect(fake_size); | 157 return gfx::Rect(fake_size); |
160 } | 158 } |
161 virtual gfx::Rect DeviceClip() const OVERRIDE { | 159 virtual gfx::Rect DeviceClip() const OVERRIDE { return DeviceViewport(); } |
162 return DeviceViewport(); | |
163 } | |
164 virtual float DeviceScaleFactor() const OVERRIDE { | |
165 return scale_factor_; | |
166 } | |
167 virtual const LayerTreeSettings& Settings() const OVERRIDE { | |
168 static LayerTreeSettings fake_settings; | |
169 return fake_settings; | |
170 } | |
171 virtual void SetFullRootLayerDamage() OVERRIDE { | 160 virtual void SetFullRootLayerDamage() OVERRIDE { |
172 set_full_root_layer_damage_count_++; | 161 set_full_root_layer_damage_count_++; |
173 } | 162 } |
174 virtual bool HasImplThread() const OVERRIDE { return false; } | |
175 virtual bool ShouldClearRootRenderPass() const OVERRIDE { return true; } | |
176 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const OVERRIDE { | 163 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const OVERRIDE { |
177 return CompositorFrameMetadata(); | 164 return CompositorFrameMetadata(); |
178 } | 165 } |
179 virtual bool AllowPartialSwap() const OVERRIDE { | |
180 return true; | |
181 } | |
182 virtual bool ExternalStencilTestEnabled() const OVERRIDE { | |
183 return external_stencil_test_enabled_; | |
184 } | |
185 | |
186 void EnableExternalStencilTest() { | |
187 external_stencil_test_enabled_ = true; | |
188 } | |
189 | 166 |
190 // Methods added for test. | 167 // Methods added for test. |
191 int set_full_root_layer_damage_count() const { | 168 int set_full_root_layer_damage_count() const { |
192 return set_full_root_layer_damage_count_; | 169 return set_full_root_layer_damage_count_; |
193 } | 170 } |
194 void set_viewport_and_scale( | 171 void set_viewport(gfx::Size viewport_size) { viewport_size_ = viewport_size; } |
195 gfx::Size viewport_size, float scale_factor) { | |
196 viewport_size_ = viewport_size; | |
197 scale_factor_ = scale_factor; | |
198 } | |
199 | 172 |
200 RenderPass* root_render_pass() { return render_passes_in_draw_order_.back(); } | 173 RenderPass* root_render_pass() { return render_passes_in_draw_order_.back(); } |
201 RenderPassList* render_passes_in_draw_order() { | 174 RenderPassList* render_passes_in_draw_order() { |
202 return &render_passes_in_draw_order_; | 175 return &render_passes_in_draw_order_; |
203 } | 176 } |
204 | 177 |
205 private: | 178 private: |
206 FakeImplProxy proxy_; | 179 FakeImplProxy proxy_; |
207 FakeLayerTreeHostImpl host_impl_; | 180 FakeLayerTreeHostImpl host_impl_; |
208 int set_full_root_layer_damage_count_; | 181 int set_full_root_layer_damage_count_; |
209 scoped_ptr<LayerImpl> root_layer_; | 182 scoped_ptr<LayerImpl> root_layer_; |
210 RenderPassList render_passes_in_draw_order_; | 183 RenderPassList render_passes_in_draw_order_; |
211 gfx::Size viewport_size_; | 184 gfx::Size viewport_size_; |
212 float scale_factor_; | |
213 bool external_stencil_test_enabled_; | |
214 }; | 185 }; |
215 | 186 |
216 class FakeRendererGL : public GLRenderer { | 187 class FakeRendererGL : public GLRenderer { |
217 public: | 188 public: |
218 FakeRendererGL(RendererClient* client, | 189 FakeRendererGL(RendererClient* client, |
| 190 const LayerTreeSettings* settings, |
219 OutputSurface* output_surface, | 191 OutputSurface* output_surface, |
220 ResourceProvider* resource_provider) | 192 ResourceProvider* resource_provider) |
221 : GLRenderer(client, output_surface, resource_provider, 0) {} | 193 : GLRenderer(client, settings, output_surface, resource_provider, 0) {} |
222 | 194 |
223 // GLRenderer methods. | 195 // GLRenderer methods. |
224 | 196 |
225 // Changing visibility to public. | 197 // Changing visibility to public. |
226 using GLRenderer::Initialize; | 198 using GLRenderer::Initialize; |
227 using GLRenderer::IsBackbufferDiscarded; | 199 using GLRenderer::IsBackbufferDiscarded; |
228 using GLRenderer::DoDrawQuad; | 200 using GLRenderer::DoDrawQuad; |
229 using GLRenderer::BeginDrawingFrame; | 201 using GLRenderer::BeginDrawingFrame; |
230 using GLRenderer::FinishDrawingQuadList; | 202 using GLRenderer::FinishDrawingQuadList; |
231 using GLRenderer::stencil_enabled; | 203 using GLRenderer::stencil_enabled; |
232 }; | 204 }; |
233 | 205 |
234 class GLRendererTest : public testing::Test { | 206 class GLRendererTest : public testing::Test { |
235 protected: | 207 protected: |
236 GLRendererTest() { | 208 GLRendererTest() { |
237 scoped_ptr<FrameCountingContext> context3d(new FrameCountingContext); | 209 scoped_ptr<FrameCountingContext> context3d(new FrameCountingContext); |
238 context3d_ = context3d.get(); | 210 context3d_ = context3d.get(); |
239 | 211 |
240 output_surface_ = FakeOutputSurface::Create3d( | 212 output_surface_ = FakeOutputSurface::Create3d( |
241 context3d.PassAs<TestWebGraphicsContext3D>()).Pass(); | 213 context3d.PassAs<TestWebGraphicsContext3D>()).Pass(); |
242 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 214 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
243 | 215 |
244 resource_provider_ = | 216 resource_provider_ = |
245 ResourceProvider::Create(output_surface_.get(), 0).Pass(); | 217 ResourceProvider::Create(output_surface_.get(), 0).Pass(); |
246 renderer_ = make_scoped_ptr(new FakeRendererGL( | 218 renderer_ = make_scoped_ptr(new FakeRendererGL(&renderer_client_, |
247 &renderer_client_, | 219 &settings_, |
248 output_surface_.get(), | 220 output_surface_.get(), |
249 resource_provider_.get())); | 221 resource_provider_.get())); |
250 } | 222 } |
251 | 223 |
252 virtual void SetUp() { renderer_->Initialize(); } | 224 virtual void SetUp() { renderer_->Initialize(); } |
253 | 225 |
254 void SwapBuffers() { renderer_->SwapBuffers(); } | 226 void SwapBuffers() { renderer_->SwapBuffers(); } |
255 | 227 |
| 228 LayerTreeSettings settings_; |
256 FrameCountingContext* context3d_; | 229 FrameCountingContext* context3d_; |
257 FakeOutputSurfaceClient output_surface_client_; | 230 FakeOutputSurfaceClient output_surface_client_; |
258 scoped_ptr<FakeOutputSurface> output_surface_; | 231 scoped_ptr<FakeOutputSurface> output_surface_; |
259 FakeRendererClient renderer_client_; | 232 FakeRendererClient renderer_client_; |
260 scoped_ptr<ResourceProvider> resource_provider_; | 233 scoped_ptr<ResourceProvider> resource_provider_; |
261 scoped_ptr<FakeRendererGL> renderer_; | 234 scoped_ptr<FakeRendererGL> renderer_; |
262 }; | 235 }; |
263 | 236 |
264 // Closing the namespace here so that GLRendererShaderTest can take advantage | 237 // Closing the namespace here so that GLRendererShaderTest can take advantage |
265 // of the friend relationship with GLRenderer and all of the mock classes | 238 // of the friend relationship with GLRenderer and all of the mock classes |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 protected: | 301 protected: |
329 GLRendererShaderTest() { | 302 GLRendererShaderTest() { |
330 output_surface_ = FakeOutputSurface::Create3d( | 303 output_surface_ = FakeOutputSurface::Create3d( |
331 scoped_ptr<TestWebGraphicsContext3D>( | 304 scoped_ptr<TestWebGraphicsContext3D>( |
332 new ShaderCreatorMockGraphicsContext())).Pass(); | 305 new ShaderCreatorMockGraphicsContext())).Pass(); |
333 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 306 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
334 | 307 |
335 resource_provider_ = ResourceProvider::Create(output_surface_.get(), | 308 resource_provider_ = ResourceProvider::Create(output_surface_.get(), |
336 0).Pass(); | 309 0).Pass(); |
337 renderer_.reset(new FakeRendererGL(&renderer_client_, | 310 renderer_.reset(new FakeRendererGL(&renderer_client_, |
| 311 &settings_, |
338 output_surface_.get(), | 312 output_surface_.get(), |
339 resource_provider_.get())); | 313 resource_provider_.get())); |
340 renderer_->Initialize(); | 314 renderer_->Initialize(); |
341 } | 315 } |
342 | 316 |
343 void TestRenderPassProgram() { | 317 void TestRenderPassProgram() { |
344 EXPECT_PROGRAM_VALID(renderer_->render_pass_program_); | 318 EXPECT_PROGRAM_VALID(renderer_->render_pass_program_); |
345 EXPECT_EQ(renderer_->render_pass_program_->program(), | 319 EXPECT_EQ(renderer_->render_pass_program_->program(), |
346 renderer_->program_shadow_); | 320 renderer_->program_shadow_); |
347 } | 321 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_aa_->program(), | 361 EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_aa_->program(), |
388 renderer_->program_shadow_); | 362 renderer_->program_shadow_); |
389 } | 363 } |
390 | 364 |
391 void TestSolidColorProgramAA() { | 365 void TestSolidColorProgramAA() { |
392 EXPECT_PROGRAM_VALID(renderer_->solid_color_program_aa_); | 366 EXPECT_PROGRAM_VALID(renderer_->solid_color_program_aa_); |
393 EXPECT_EQ(renderer_->solid_color_program_aa_->program(), | 367 EXPECT_EQ(renderer_->solid_color_program_aa_->program(), |
394 renderer_->program_shadow_); | 368 renderer_->program_shadow_); |
395 } | 369 } |
396 | 370 |
| 371 LayerTreeSettings settings_; |
397 FakeOutputSurfaceClient output_surface_client_; | 372 FakeOutputSurfaceClient output_surface_client_; |
398 scoped_ptr<FakeOutputSurface> output_surface_; | 373 scoped_ptr<FakeOutputSurface> output_surface_; |
399 FakeRendererClient renderer_client_; | 374 FakeRendererClient renderer_client_; |
400 scoped_ptr<ResourceProvider> resource_provider_; | 375 scoped_ptr<ResourceProvider> resource_provider_; |
401 scoped_ptr<FakeRendererGL> renderer_; | 376 scoped_ptr<FakeRendererGL> renderer_; |
402 }; | 377 }; |
403 | 378 |
404 namespace { | 379 namespace { |
405 | 380 |
406 // Test GLRenderer discardBackbuffer functionality: | 381 // Test GLRenderer discardBackbuffer functionality: |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 // Test GLRenderer DiscardBackbuffer functionality: | 430 // Test GLRenderer DiscardBackbuffer functionality: |
456 // Begin drawing a frame while a framebuffer is discarded. | 431 // Begin drawing a frame while a framebuffer is discarded. |
457 // Expected: will recreate framebuffer. | 432 // Expected: will recreate framebuffer. |
458 TEST_F(GLRendererTest, DiscardedBackbufferIsRecreatedForScopeDuration) { | 433 TEST_F(GLRendererTest, DiscardedBackbufferIsRecreatedForScopeDuration) { |
459 renderer_->SetVisible(false); | 434 renderer_->SetVisible(false); |
460 renderer_->SetDiscardBackBufferWhenNotVisible(true); | 435 renderer_->SetDiscardBackBufferWhenNotVisible(true); |
461 EXPECT_TRUE(renderer_->IsBackbufferDiscarded()); | 436 EXPECT_TRUE(renderer_->IsBackbufferDiscarded()); |
462 EXPECT_EQ(1, renderer_client_.set_full_root_layer_damage_count()); | 437 EXPECT_EQ(1, renderer_client_.set_full_root_layer_damage_count()); |
463 | 438 |
464 renderer_->SetVisible(true); | 439 renderer_->SetVisible(true); |
465 renderer_->DrawFrame(renderer_client_.render_passes_in_draw_order(), NULL); | 440 renderer_->DrawFrame( |
| 441 renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true); |
466 EXPECT_FALSE(renderer_->IsBackbufferDiscarded()); | 442 EXPECT_FALSE(renderer_->IsBackbufferDiscarded()); |
467 | 443 |
468 SwapBuffers(); | 444 SwapBuffers(); |
469 EXPECT_EQ(1, context3d_->frame_count()); | 445 EXPECT_EQ(1, context3d_->frame_count()); |
470 } | 446 } |
471 | 447 |
472 TEST_F(GLRendererTest, FramebufferDiscardedAfterReadbackWhenNotVisible) { | 448 TEST_F(GLRendererTest, FramebufferDiscardedAfterReadbackWhenNotVisible) { |
473 renderer_->SetVisible(false); | 449 renderer_->SetVisible(false); |
474 renderer_->SetDiscardBackBufferWhenNotVisible(true); | 450 renderer_->SetDiscardBackBufferWhenNotVisible(true); |
475 EXPECT_TRUE(renderer_->IsBackbufferDiscarded()); | 451 EXPECT_TRUE(renderer_->IsBackbufferDiscarded()); |
476 EXPECT_EQ(1, renderer_client_.set_full_root_layer_damage_count()); | 452 EXPECT_EQ(1, renderer_client_.set_full_root_layer_damage_count()); |
477 | 453 |
478 char pixels[4]; | 454 char pixels[4]; |
479 renderer_->DrawFrame(renderer_client_.render_passes_in_draw_order(), NULL); | 455 renderer_->DrawFrame( |
| 456 renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true); |
480 EXPECT_FALSE(renderer_->IsBackbufferDiscarded()); | 457 EXPECT_FALSE(renderer_->IsBackbufferDiscarded()); |
481 | 458 |
482 renderer_->GetFramebufferPixels(pixels, gfx::Rect(0, 0, 1, 1)); | 459 renderer_->GetFramebufferPixels(pixels, gfx::Rect(0, 0, 1, 1)); |
483 EXPECT_TRUE(renderer_->IsBackbufferDiscarded()); | 460 EXPECT_TRUE(renderer_->IsBackbufferDiscarded()); |
484 EXPECT_EQ(2, renderer_client_.set_full_root_layer_damage_count()); | 461 EXPECT_EQ(2, renderer_client_.set_full_root_layer_damage_count()); |
485 } | 462 } |
486 | 463 |
487 TEST_F(GLRendererTest, ExternalStencil) { | 464 TEST_F(GLRendererTest, ExternalStencil) { |
488 EXPECT_FALSE(renderer_->stencil_enabled()); | 465 EXPECT_FALSE(renderer_->stencil_enabled()); |
489 | 466 |
490 renderer_client_.EnableExternalStencilTest(); | 467 output_surface_->set_has_external_stencil_test(true); |
491 renderer_client_.root_render_pass()->has_transparent_background = false; | 468 renderer_client_.root_render_pass()->has_transparent_background = false; |
492 | 469 |
493 renderer_->DrawFrame(renderer_client_.render_passes_in_draw_order(), NULL); | 470 renderer_->DrawFrame( |
| 471 renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true); |
494 EXPECT_TRUE(renderer_->stencil_enabled()); | 472 EXPECT_TRUE(renderer_->stencil_enabled()); |
495 } | 473 } |
496 | 474 |
497 class ForbidSynchronousCallContext : public TestWebGraphicsContext3D { | 475 class ForbidSynchronousCallContext : public TestWebGraphicsContext3D { |
498 public: | 476 public: |
499 ForbidSynchronousCallContext() {} | 477 ForbidSynchronousCallContext() {} |
500 | 478 |
501 virtual bool getActiveAttrib(WebGLId program, | 479 virtual bool getActiveAttrib(WebGLId program, |
502 WGC3Duint index, | 480 WGC3Duint index, |
503 ActiveInfo& info) { | 481 ActiveInfo& info) { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 // TEST() and TEST_F() with the same name, Hence LRC2. | 622 // TEST() and TEST_F() with the same name, Hence LRC2. |
645 TEST(GLRendererTest2, InitializationDoesNotMakeSynchronousCalls) { | 623 TEST(GLRendererTest2, InitializationDoesNotMakeSynchronousCalls) { |
646 FakeOutputSurfaceClient output_surface_client; | 624 FakeOutputSurfaceClient output_surface_client; |
647 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 625 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
648 scoped_ptr<TestWebGraphicsContext3D>(new ForbidSynchronousCallContext))); | 626 scoped_ptr<TestWebGraphicsContext3D>(new ForbidSynchronousCallContext))); |
649 CHECK(output_surface->BindToClient(&output_surface_client)); | 627 CHECK(output_surface->BindToClient(&output_surface_client)); |
650 | 628 |
651 scoped_ptr<ResourceProvider> resource_provider( | 629 scoped_ptr<ResourceProvider> resource_provider( |
652 ResourceProvider::Create(output_surface.get(), 0)); | 630 ResourceProvider::Create(output_surface.get(), 0)); |
653 | 631 |
| 632 LayerTreeSettings settings; |
654 FakeRendererClient renderer_client; | 633 FakeRendererClient renderer_client; |
655 FakeRendererGL renderer( | 634 FakeRendererGL renderer(&renderer_client, |
656 &renderer_client, output_surface.get(), resource_provider.get()); | 635 &settings, |
| 636 output_surface.get(), |
| 637 resource_provider.get()); |
657 | 638 |
658 EXPECT_TRUE(renderer.Initialize()); | 639 EXPECT_TRUE(renderer.Initialize()); |
659 } | 640 } |
660 | 641 |
661 class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D { | 642 class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D { |
662 public: | 643 public: |
663 LoseContextOnFirstGetContext() : context_lost_(false) {} | 644 LoseContextOnFirstGetContext() : context_lost_(false) {} |
664 | 645 |
665 virtual bool makeContextCurrent() OVERRIDE { return !context_lost_; } | 646 virtual bool makeContextCurrent() OVERRIDE { return !context_lost_; } |
666 | 647 |
(...skipping 19 matching lines...) Expand all Loading... |
686 | 667 |
687 TEST(GLRendererTest2, InitializationWithQuicklyLostContextDoesNotAssert) { | 668 TEST(GLRendererTest2, InitializationWithQuicklyLostContextDoesNotAssert) { |
688 FakeOutputSurfaceClient output_surface_client; | 669 FakeOutputSurfaceClient output_surface_client; |
689 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 670 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
690 scoped_ptr<TestWebGraphicsContext3D>(new LoseContextOnFirstGetContext))); | 671 scoped_ptr<TestWebGraphicsContext3D>(new LoseContextOnFirstGetContext))); |
691 CHECK(output_surface->BindToClient(&output_surface_client)); | 672 CHECK(output_surface->BindToClient(&output_surface_client)); |
692 | 673 |
693 scoped_ptr<ResourceProvider> resource_provider( | 674 scoped_ptr<ResourceProvider> resource_provider( |
694 ResourceProvider::Create(output_surface.get(), 0)); | 675 ResourceProvider::Create(output_surface.get(), 0)); |
695 | 676 |
| 677 LayerTreeSettings settings; |
696 FakeRendererClient renderer_client; | 678 FakeRendererClient renderer_client; |
697 FakeRendererGL renderer( | 679 FakeRendererGL renderer(&renderer_client, |
698 &renderer_client, output_surface.get(), resource_provider.get()); | 680 &settings, |
| 681 output_surface.get(), |
| 682 resource_provider.get()); |
699 | 683 |
700 renderer.Initialize(); | 684 renderer.Initialize(); |
701 } | 685 } |
702 | 686 |
703 class ClearCountingContext : public TestWebGraphicsContext3D { | 687 class ClearCountingContext : public TestWebGraphicsContext3D { |
704 public: | 688 public: |
705 ClearCountingContext() { | 689 ClearCountingContext() { |
706 test_capabilities_.discard_framebuffer = true; | 690 test_capabilities_.discard_framebuffer = true; |
707 } | 691 } |
708 | 692 |
709 MOCK_METHOD3(discardFramebufferEXT, | 693 MOCK_METHOD3(discardFramebufferEXT, |
710 void(WGC3Denum target, | 694 void(WGC3Denum target, |
711 WGC3Dsizei numAttachments, | 695 WGC3Dsizei numAttachments, |
712 const WGC3Denum* attachments)); | 696 const WGC3Denum* attachments)); |
713 MOCK_METHOD1(clear, void(WGC3Dbitfield mask)); | 697 MOCK_METHOD1(clear, void(WGC3Dbitfield mask)); |
714 }; | 698 }; |
715 | 699 |
716 TEST(GLRendererTest2, OpaqueBackground) { | 700 TEST(GLRendererTest2, OpaqueBackground) { |
717 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); | 701 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); |
718 ClearCountingContext* context = context_owned.get(); | 702 ClearCountingContext* context = context_owned.get(); |
719 | 703 |
720 FakeOutputSurfaceClient output_surface_client; | 704 FakeOutputSurfaceClient output_surface_client; |
721 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 705 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
722 context_owned.PassAs<TestWebGraphicsContext3D>())); | 706 context_owned.PassAs<TestWebGraphicsContext3D>())); |
723 CHECK(output_surface->BindToClient(&output_surface_client)); | 707 CHECK(output_surface->BindToClient(&output_surface_client)); |
724 | 708 |
725 scoped_ptr<ResourceProvider> resource_provider( | 709 scoped_ptr<ResourceProvider> resource_provider( |
726 ResourceProvider::Create(output_surface.get(), 0)); | 710 ResourceProvider::Create(output_surface.get(), 0)); |
727 | 711 |
| 712 LayerTreeSettings settings; |
728 FakeRendererClient renderer_client; | 713 FakeRendererClient renderer_client; |
729 FakeRendererGL renderer( | 714 FakeRendererGL renderer(&renderer_client, |
730 &renderer_client, output_surface.get(), resource_provider.get()); | 715 &settings, |
| 716 output_surface.get(), |
| 717 resource_provider.get()); |
731 | 718 |
732 renderer_client.root_render_pass()->has_transparent_background = false; | 719 renderer_client.root_render_pass()->has_transparent_background = false; |
733 | 720 |
734 EXPECT_TRUE(renderer.Initialize()); | 721 EXPECT_TRUE(renderer.Initialize()); |
735 | 722 |
736 // On DEBUG builds, render passes with opaque background clear to blue to | 723 // On DEBUG builds, render passes with opaque background clear to blue to |
737 // easily see regions that were not drawn on the screen. | 724 // easily see regions that were not drawn on the screen. |
738 EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, 1, _)) | 725 EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, 1, _)) |
739 .Times(1); | 726 .Times(1); |
740 #ifdef NDEBUG | 727 #ifdef NDEBUG |
741 EXPECT_CALL(*context, clear(_)).Times(0); | 728 EXPECT_CALL(*context, clear(_)).Times(0); |
742 #else | 729 #else |
743 EXPECT_CALL(*context, clear(_)).Times(1); | 730 EXPECT_CALL(*context, clear(_)).Times(1); |
744 #endif | 731 #endif |
745 renderer.DrawFrame(renderer_client.render_passes_in_draw_order(), NULL); | 732 renderer.DrawFrame( |
| 733 renderer_client.render_passes_in_draw_order(), NULL, 1.f, true); |
746 Mock::VerifyAndClearExpectations(context); | 734 Mock::VerifyAndClearExpectations(context); |
747 } | 735 } |
748 | 736 |
749 TEST(GLRendererTest2, TransparentBackground) { | 737 TEST(GLRendererTest2, TransparentBackground) { |
750 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); | 738 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); |
751 ClearCountingContext* context = context_owned.get(); | 739 ClearCountingContext* context = context_owned.get(); |
752 | 740 |
753 FakeOutputSurfaceClient output_surface_client; | 741 FakeOutputSurfaceClient output_surface_client; |
754 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 742 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
755 context_owned.PassAs<TestWebGraphicsContext3D>())); | 743 context_owned.PassAs<TestWebGraphicsContext3D>())); |
756 CHECK(output_surface->BindToClient(&output_surface_client)); | 744 CHECK(output_surface->BindToClient(&output_surface_client)); |
757 | 745 |
758 scoped_ptr<ResourceProvider> resource_provider( | 746 scoped_ptr<ResourceProvider> resource_provider( |
759 ResourceProvider::Create(output_surface.get(), 0)); | 747 ResourceProvider::Create(output_surface.get(), 0)); |
760 | 748 |
| 749 LayerTreeSettings settings; |
761 FakeRendererClient renderer_client; | 750 FakeRendererClient renderer_client; |
762 FakeRendererGL renderer( | 751 FakeRendererGL renderer(&renderer_client, |
763 &renderer_client, output_surface.get(), resource_provider.get()); | 752 &settings, |
| 753 output_surface.get(), |
| 754 resource_provider.get()); |
764 | 755 |
765 renderer_client.root_render_pass()->has_transparent_background = true; | 756 renderer_client.root_render_pass()->has_transparent_background = true; |
766 | 757 |
767 EXPECT_TRUE(renderer.Initialize()); | 758 EXPECT_TRUE(renderer.Initialize()); |
768 | 759 |
769 EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, 1, _)) | 760 EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, 1, _)) |
770 .Times(1); | 761 .Times(1); |
771 EXPECT_CALL(*context, clear(_)).Times(1); | 762 EXPECT_CALL(*context, clear(_)).Times(1); |
772 renderer.DrawFrame(renderer_client.render_passes_in_draw_order(), NULL); | 763 renderer.DrawFrame( |
| 764 renderer_client.render_passes_in_draw_order(), NULL, 1.f, true); |
773 | 765 |
774 Mock::VerifyAndClearExpectations(context); | 766 Mock::VerifyAndClearExpectations(context); |
775 } | 767 } |
776 | 768 |
777 class VisibilityChangeIsLastCallTrackingContext | 769 class VisibilityChangeIsLastCallTrackingContext |
778 : public TestWebGraphicsContext3D { | 770 : public TestWebGraphicsContext3D { |
779 public: | 771 public: |
780 VisibilityChangeIsLastCallTrackingContext() | 772 VisibilityChangeIsLastCallTrackingContext() |
781 : last_call_was_set_visibility_(false) { | 773 : last_call_was_set_visibility_(false) { |
782 test_capabilities_.set_visibility = true; | 774 test_capabilities_.set_visibility = true; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 VisibilityChangeIsLastCallTrackingContext* context = context_owned.get(); | 817 VisibilityChangeIsLastCallTrackingContext* context = context_owned.get(); |
826 | 818 |
827 FakeOutputSurfaceClient output_surface_client; | 819 FakeOutputSurfaceClient output_surface_client; |
828 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 820 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
829 context_owned.PassAs<TestWebGraphicsContext3D>())); | 821 context_owned.PassAs<TestWebGraphicsContext3D>())); |
830 CHECK(output_surface->BindToClient(&output_surface_client)); | 822 CHECK(output_surface->BindToClient(&output_surface_client)); |
831 | 823 |
832 scoped_ptr<ResourceProvider> resource_provider( | 824 scoped_ptr<ResourceProvider> resource_provider( |
833 ResourceProvider::Create(output_surface.get(), 0)); | 825 ResourceProvider::Create(output_surface.get(), 0)); |
834 | 826 |
| 827 LayerTreeSettings settings; |
835 FakeRendererClient renderer_client; | 828 FakeRendererClient renderer_client; |
836 FakeRendererGL renderer( | 829 FakeRendererGL renderer(&renderer_client, |
837 &renderer_client, output_surface.get(), resource_provider.get()); | 830 &settings, |
| 831 output_surface.get(), |
| 832 resource_provider.get()); |
838 | 833 |
839 EXPECT_TRUE(renderer.Initialize()); | 834 EXPECT_TRUE(renderer.Initialize()); |
840 | 835 |
841 // Ensure that the call to setVisibilityCHROMIUM is the last call issue to the | 836 // Ensure that the call to setVisibilityCHROMIUM is the last call issue to the |
842 // GPU process, after glFlush is called, and after the RendererClient's | 837 // GPU process, after glFlush is called, and after the RendererClient's |
843 // SetManagedMemoryPolicy is called. Plumb this tracking between both the | 838 // SetManagedMemoryPolicy is called. Plumb this tracking between both the |
844 // RenderClient and the Context by giving them both a pointer to a variable on | 839 // RenderClient and the Context by giving them both a pointer to a variable on |
845 // the stack. | 840 // the stack. |
846 renderer.SetVisible(true); | 841 renderer.SetVisible(true); |
847 renderer.DrawFrame(renderer_client.render_passes_in_draw_order(), NULL); | 842 renderer.DrawFrame( |
| 843 renderer_client.render_passes_in_draw_order(), NULL, 1.f, true); |
848 renderer.SetVisible(false); | 844 renderer.SetVisible(false); |
849 EXPECT_TRUE(context->last_call_was_set_visibility()); | 845 EXPECT_TRUE(context->last_call_was_set_visibility()); |
850 } | 846 } |
851 | 847 |
852 class TextureStateTrackingContext : public TestWebGraphicsContext3D { | 848 class TextureStateTrackingContext : public TestWebGraphicsContext3D { |
853 public: | 849 public: |
854 TextureStateTrackingContext() | 850 TextureStateTrackingContext() |
855 : active_texture_(GL_INVALID_ENUM) { | 851 : active_texture_(GL_INVALID_ENUM) { |
856 test_capabilities_.egl_image_external = true; | 852 test_capabilities_.egl_image_external = true; |
857 } | 853 } |
(...skipping 23 matching lines...) Expand all Loading... |
881 TextureStateTrackingContext* context = context_owned.get(); | 877 TextureStateTrackingContext* context = context_owned.get(); |
882 | 878 |
883 FakeOutputSurfaceClient output_surface_client; | 879 FakeOutputSurfaceClient output_surface_client; |
884 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 880 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
885 context_owned.PassAs<TestWebGraphicsContext3D>())); | 881 context_owned.PassAs<TestWebGraphicsContext3D>())); |
886 CHECK(output_surface->BindToClient(&output_surface_client)); | 882 CHECK(output_surface->BindToClient(&output_surface_client)); |
887 | 883 |
888 scoped_ptr<ResourceProvider> resource_provider( | 884 scoped_ptr<ResourceProvider> resource_provider( |
889 ResourceProvider::Create(output_surface.get(), 0)); | 885 ResourceProvider::Create(output_surface.get(), 0)); |
890 | 886 |
| 887 LayerTreeSettings settings; |
891 FakeRendererClient renderer_client; | 888 FakeRendererClient renderer_client; |
892 FakeRendererGL renderer( | 889 FakeRendererGL renderer(&renderer_client, |
893 &renderer_client, output_surface.get(), resource_provider.get()); | 890 &settings, |
| 891 output_surface.get(), |
| 892 resource_provider.get()); |
894 | 893 |
895 // During initialization we are allowed to set any texture parameters. | 894 // During initialization we are allowed to set any texture parameters. |
896 EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber()); | 895 EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber()); |
897 EXPECT_TRUE(renderer.Initialize()); | 896 EXPECT_TRUE(renderer.Initialize()); |
898 | 897 |
899 cc::RenderPass::Id id(1, 1); | 898 cc::RenderPass::Id id(1, 1); |
900 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); | 899 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); |
901 pass->SetNew(id, | 900 pass->SetNew(id, |
902 gfx::Rect(0, 0, 100, 100), | 901 gfx::Rect(0, 0, 100, 100), |
903 gfx::Rect(0, 0, 100, 100), | 902 gfx::Rect(0, 0, 100, 100), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 it = pass->quad_list.BackToFrontBegin(); | 941 it = pass->quad_list.BackToFrontBegin(); |
943 it != pass->quad_list.BackToFrontEnd(); | 942 it != pass->quad_list.BackToFrontEnd(); |
944 ++it) { | 943 ++it) { |
945 renderer.DoDrawQuad(&drawing_frame, *it); | 944 renderer.DoDrawQuad(&drawing_frame, *it); |
946 } | 945 } |
947 renderer.FinishDrawingQuadList(); | 946 renderer.FinishDrawingQuadList(); |
948 EXPECT_EQ(static_cast<unsigned>(GL_TEXTURE0), context->active_texture()); | 947 EXPECT_EQ(static_cast<unsigned>(GL_TEXTURE0), context->active_texture()); |
949 Mock::VerifyAndClearExpectations(context); | 948 Mock::VerifyAndClearExpectations(context); |
950 } | 949 } |
951 | 950 |
952 class NoClearRootRenderPassFakeClient : public FakeRendererClient { | |
953 public: | |
954 virtual bool ShouldClearRootRenderPass() const OVERRIDE { return false; } | |
955 }; | |
956 | |
957 class NoClearRootRenderPassMockContext : public TestWebGraphicsContext3D { | 951 class NoClearRootRenderPassMockContext : public TestWebGraphicsContext3D { |
958 public: | 952 public: |
959 MOCK_METHOD1(clear, void(WGC3Dbitfield mask)); | 953 MOCK_METHOD1(clear, void(WGC3Dbitfield mask)); |
960 MOCK_METHOD4(drawElements, | 954 MOCK_METHOD4(drawElements, |
961 void(WGC3Denum mode, | 955 void(WGC3Denum mode, |
962 WGC3Dsizei count, | 956 WGC3Dsizei count, |
963 WGC3Denum type, | 957 WGC3Denum type, |
964 WGC3Dintptr offset)); | 958 WGC3Dintptr offset)); |
965 }; | 959 }; |
966 | 960 |
967 TEST(GLRendererTest2, ShouldClearRootRenderPass) { | 961 TEST(GLRendererTest2, ShouldClearRootRenderPass) { |
968 scoped_ptr<NoClearRootRenderPassMockContext> mock_context_owned( | 962 scoped_ptr<NoClearRootRenderPassMockContext> mock_context_owned( |
969 new NoClearRootRenderPassMockContext); | 963 new NoClearRootRenderPassMockContext); |
970 NoClearRootRenderPassMockContext* mock_context = mock_context_owned.get(); | 964 NoClearRootRenderPassMockContext* mock_context = mock_context_owned.get(); |
971 | 965 |
972 FakeOutputSurfaceClient output_surface_client; | 966 FakeOutputSurfaceClient output_surface_client; |
973 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 967 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
974 mock_context_owned.PassAs<TestWebGraphicsContext3D>())); | 968 mock_context_owned.PassAs<TestWebGraphicsContext3D>())); |
975 CHECK(output_surface->BindToClient(&output_surface_client)); | 969 CHECK(output_surface->BindToClient(&output_surface_client)); |
976 | 970 |
977 scoped_ptr<ResourceProvider> resource_provider( | 971 scoped_ptr<ResourceProvider> resource_provider( |
978 ResourceProvider::Create(output_surface.get(), 0)); | 972 ResourceProvider::Create(output_surface.get(), 0)); |
979 | 973 |
980 NoClearRootRenderPassFakeClient renderer_client; | 974 LayerTreeSettings settings; |
981 FakeRendererGL renderer( | 975 settings.should_clear_root_render_pass = false; |
982 &renderer_client, output_surface.get(), resource_provider.get()); | 976 |
| 977 FakeRendererClient renderer_client; |
| 978 FakeRendererGL renderer(&renderer_client, |
| 979 &settings, |
| 980 output_surface.get(), |
| 981 resource_provider.get()); |
983 EXPECT_TRUE(renderer.Initialize()); | 982 EXPECT_TRUE(renderer.Initialize()); |
984 | 983 |
985 gfx::Rect viewport_rect(renderer_client.DeviceViewport()); | 984 gfx::Rect viewport_rect(renderer_client.DeviceViewport()); |
986 ScopedPtrVector<RenderPass>& render_passes = | 985 ScopedPtrVector<RenderPass>& render_passes = |
987 *renderer_client.render_passes_in_draw_order(); | 986 *renderer_client.render_passes_in_draw_order(); |
988 render_passes.clear(); | 987 render_passes.clear(); |
989 | 988 |
990 RenderPass::Id root_pass_id(1, 0); | 989 RenderPass::Id root_pass_id(1, 0); |
991 TestRenderPass* root_pass = AddRenderPass( | 990 TestRenderPass* root_pass = AddRenderPass( |
992 &render_passes, root_pass_id, viewport_rect, gfx::Transform()); | 991 &render_passes, root_pass_id, viewport_rect, gfx::Transform()); |
(...skipping 20 matching lines...) Expand all Loading... |
1013 | 1012 |
1014 // The second render pass is the root one, clearing should be prevented. | 1013 // The second render pass is the root one, clearing should be prevented. |
1015 EXPECT_CALL(*mock_context, clear(clear_bits)).Times(0) | 1014 EXPECT_CALL(*mock_context, clear(clear_bits)).Times(0) |
1016 .After(first_render_pass); | 1015 .After(first_render_pass); |
1017 | 1016 |
1018 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)).Times(AnyNumber()) | 1017 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)).Times(AnyNumber()) |
1019 .After(first_render_pass); | 1018 .After(first_render_pass); |
1020 | 1019 |
1021 renderer.DecideRenderPassAllocationsForFrame( | 1020 renderer.DecideRenderPassAllocationsForFrame( |
1022 *renderer_client.render_passes_in_draw_order()); | 1021 *renderer_client.render_passes_in_draw_order()); |
1023 renderer.DrawFrame(renderer_client.render_passes_in_draw_order(), NULL); | 1022 renderer.DrawFrame( |
| 1023 renderer_client.render_passes_in_draw_order(), NULL, 1.f, true); |
1024 | 1024 |
1025 // In multiple render passes all but the root pass should clear the | 1025 // In multiple render passes all but the root pass should clear the |
1026 // framebuffer. | 1026 // framebuffer. |
1027 Mock::VerifyAndClearExpectations(&mock_context); | 1027 Mock::VerifyAndClearExpectations(&mock_context); |
1028 } | 1028 } |
1029 | 1029 |
1030 class ScissorTestOnClearCheckingContext : public TestWebGraphicsContext3D { | 1030 class ScissorTestOnClearCheckingContext : public TestWebGraphicsContext3D { |
1031 public: | 1031 public: |
1032 ScissorTestOnClearCheckingContext() : scissor_enabled_(false) {} | 1032 ScissorTestOnClearCheckingContext() : scissor_enabled_(false) {} |
1033 | 1033 |
(...skipping 18 matching lines...) Expand all Loading... |
1052 new ScissorTestOnClearCheckingContext); | 1052 new ScissorTestOnClearCheckingContext); |
1053 | 1053 |
1054 FakeOutputSurfaceClient output_surface_client; | 1054 FakeOutputSurfaceClient output_surface_client; |
1055 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 1055 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
1056 context_owned.PassAs<TestWebGraphicsContext3D>())); | 1056 context_owned.PassAs<TestWebGraphicsContext3D>())); |
1057 CHECK(output_surface->BindToClient(&output_surface_client)); | 1057 CHECK(output_surface->BindToClient(&output_surface_client)); |
1058 | 1058 |
1059 scoped_ptr<ResourceProvider> resource_provider( | 1059 scoped_ptr<ResourceProvider> resource_provider( |
1060 ResourceProvider::Create(output_surface.get(), 0)); | 1060 ResourceProvider::Create(output_surface.get(), 0)); |
1061 | 1061 |
| 1062 LayerTreeSettings settings; |
1062 FakeRendererClient renderer_client; | 1063 FakeRendererClient renderer_client; |
1063 FakeRendererGL renderer( | 1064 FakeRendererGL renderer(&renderer_client, |
1064 &renderer_client, output_surface.get(), resource_provider.get()); | 1065 &settings, |
| 1066 output_surface.get(), |
| 1067 resource_provider.get()); |
1065 EXPECT_TRUE(renderer.Initialize()); | 1068 EXPECT_TRUE(renderer.Initialize()); |
1066 EXPECT_FALSE(renderer.Capabilities().using_partial_swap); | 1069 EXPECT_FALSE(renderer.Capabilities().using_partial_swap); |
1067 | 1070 |
1068 gfx::Rect viewport_rect(renderer_client.DeviceViewport()); | 1071 gfx::Rect viewport_rect(renderer_client.DeviceViewport()); |
1069 ScopedPtrVector<RenderPass>& render_passes = | 1072 ScopedPtrVector<RenderPass>& render_passes = |
1070 *renderer_client.render_passes_in_draw_order(); | 1073 *renderer_client.render_passes_in_draw_order(); |
1071 render_passes.clear(); | 1074 render_passes.clear(); |
1072 | 1075 |
1073 gfx::Rect grand_child_rect(25, 25); | 1076 gfx::Rect grand_child_rect(25, 25); |
1074 RenderPass::Id grand_child_pass_id(3, 0); | 1077 RenderPass::Id grand_child_pass_id(3, 0); |
(...skipping 10 matching lines...) Expand all Loading... |
1085 RenderPass::Id root_pass_id(1, 0); | 1088 RenderPass::Id root_pass_id(1, 0); |
1086 TestRenderPass* root_pass = AddRenderPass( | 1089 TestRenderPass* root_pass = AddRenderPass( |
1087 &render_passes, root_pass_id, viewport_rect, gfx::Transform()); | 1090 &render_passes, root_pass_id, viewport_rect, gfx::Transform()); |
1088 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); | 1091 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); |
1089 | 1092 |
1090 AddRenderPassQuad(root_pass, child_pass); | 1093 AddRenderPassQuad(root_pass, child_pass); |
1091 AddRenderPassQuad(child_pass, grand_child_pass); | 1094 AddRenderPassQuad(child_pass, grand_child_pass); |
1092 | 1095 |
1093 renderer.DecideRenderPassAllocationsForFrame( | 1096 renderer.DecideRenderPassAllocationsForFrame( |
1094 *renderer_client.render_passes_in_draw_order()); | 1097 *renderer_client.render_passes_in_draw_order()); |
1095 renderer.DrawFrame(renderer_client.render_passes_in_draw_order(), NULL); | 1098 renderer.DrawFrame( |
| 1099 renderer_client.render_passes_in_draw_order(), NULL, 1.f, true); |
1096 } | 1100 } |
1097 | 1101 |
1098 class NonReshapableOutputSurface : public FakeOutputSurface { | 1102 class NonReshapableOutputSurface : public FakeOutputSurface { |
1099 public: | 1103 public: |
1100 explicit NonReshapableOutputSurface( | 1104 explicit NonReshapableOutputSurface( |
1101 scoped_ptr<TestWebGraphicsContext3D> context3d) | 1105 scoped_ptr<TestWebGraphicsContext3D> context3d) |
1102 : FakeOutputSurface( | 1106 : FakeOutputSurface( |
1103 TestContextProvider::Create(context3d.Pass()), | 1107 TestContextProvider::Create(context3d.Pass()), |
1104 false) {} | 1108 false) {} |
1105 virtual gfx::Size SurfaceSize() const OVERRIDE { return gfx::Size(500, 500); } | 1109 virtual gfx::Size SurfaceSize() const OVERRIDE { return gfx::Size(500, 500); } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 new FlippedScissorAndViewportContext); | 1155 new FlippedScissorAndViewportContext); |
1152 | 1156 |
1153 FakeOutputSurfaceClient output_surface_client; | 1157 FakeOutputSurfaceClient output_surface_client; |
1154 scoped_ptr<OutputSurface> output_surface(new NonReshapableOutputSurface( | 1158 scoped_ptr<OutputSurface> output_surface(new NonReshapableOutputSurface( |
1155 context_owned.PassAs<TestWebGraphicsContext3D>())); | 1159 context_owned.PassAs<TestWebGraphicsContext3D>())); |
1156 CHECK(output_surface->BindToClient(&output_surface_client)); | 1160 CHECK(output_surface->BindToClient(&output_surface_client)); |
1157 | 1161 |
1158 scoped_ptr<ResourceProvider> resource_provider( | 1162 scoped_ptr<ResourceProvider> resource_provider( |
1159 ResourceProvider::Create(output_surface.get(), 0)); | 1163 ResourceProvider::Create(output_surface.get(), 0)); |
1160 | 1164 |
| 1165 LayerTreeSettings settings; |
1161 OffsetViewportRendererClient renderer_client; | 1166 OffsetViewportRendererClient renderer_client; |
1162 FakeRendererGL renderer( | 1167 FakeRendererGL renderer(&renderer_client, |
1163 &renderer_client, output_surface.get(), resource_provider.get()); | 1168 &settings, |
| 1169 output_surface.get(), |
| 1170 resource_provider.get()); |
1164 EXPECT_TRUE(renderer.Initialize()); | 1171 EXPECT_TRUE(renderer.Initialize()); |
1165 EXPECT_FALSE(renderer.Capabilities().using_partial_swap); | 1172 EXPECT_FALSE(renderer.Capabilities().using_partial_swap); |
1166 | 1173 |
1167 gfx::Rect viewport_rect(renderer_client.DeviceViewport().size()); | 1174 gfx::Rect viewport_rect(renderer_client.DeviceViewport().size()); |
1168 gfx::Rect quad_rect = gfx::Rect(20, 20, 20, 20); | 1175 gfx::Rect quad_rect = gfx::Rect(20, 20, 20, 20); |
1169 ScopedPtrVector<RenderPass>& render_passes = | 1176 ScopedPtrVector<RenderPass>& render_passes = |
1170 *renderer_client.render_passes_in_draw_order(); | 1177 *renderer_client.render_passes_in_draw_order(); |
1171 render_passes.clear(); | 1178 render_passes.clear(); |
1172 | 1179 |
1173 RenderPass::Id root_pass_id(1, 0); | 1180 RenderPass::Id root_pass_id(1, 0); |
1174 TestRenderPass* root_pass = AddRenderPass( | 1181 TestRenderPass* root_pass = AddRenderPass( |
1175 &render_passes, root_pass_id, viewport_rect, gfx::Transform()); | 1182 &render_passes, root_pass_id, viewport_rect, gfx::Transform()); |
1176 AddClippedQuad(root_pass, quad_rect, SK_ColorGREEN); | 1183 AddClippedQuad(root_pass, quad_rect, SK_ColorGREEN); |
1177 | 1184 |
1178 renderer.DecideRenderPassAllocationsForFrame( | 1185 renderer.DecideRenderPassAllocationsForFrame( |
1179 *renderer_client.render_passes_in_draw_order()); | 1186 *renderer_client.render_passes_in_draw_order()); |
1180 renderer.DrawFrame(renderer_client.render_passes_in_draw_order(), NULL); | 1187 renderer.DrawFrame( |
| 1188 renderer_client.render_passes_in_draw_order(), NULL, 1.f, true); |
1181 } | 1189 } |
1182 | 1190 |
1183 TEST_F(GLRendererShaderTest, DrawRenderPassQuadShaderPermutations) { | 1191 TEST_F(GLRendererShaderTest, DrawRenderPassQuadShaderPermutations) { |
1184 gfx::Rect viewport_rect(renderer_client_.DeviceViewport()); | 1192 gfx::Rect viewport_rect(renderer_client_.DeviceViewport()); |
1185 ScopedPtrVector<RenderPass>* render_passes = | 1193 ScopedPtrVector<RenderPass>* render_passes = |
1186 renderer_client_.render_passes_in_draw_order(); | 1194 renderer_client_.render_passes_in_draw_order(); |
1187 | 1195 |
1188 gfx::Rect child_rect(50, 50); | 1196 gfx::Rect child_rect(50, 50); |
1189 RenderPass::Id child_pass_id(2, 0); | 1197 RenderPass::Id child_pass_id(2, 0); |
1190 TestRenderPass* child_pass; | 1198 TestRenderPass* child_pass; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 render_passes, root_pass_id, viewport_rect, gfx::Transform()); | 1241 render_passes, root_pass_id, viewport_rect, gfx::Transform()); |
1234 | 1242 |
1235 AddRenderPassQuad(root_pass, | 1243 AddRenderPassQuad(root_pass, |
1236 child_pass, | 1244 child_pass, |
1237 0, | 1245 0, |
1238 skia::RefPtr<SkImageFilter>(), | 1246 skia::RefPtr<SkImageFilter>(), |
1239 gfx::Transform()); | 1247 gfx::Transform()); |
1240 | 1248 |
1241 renderer_->DecideRenderPassAllocationsForFrame( | 1249 renderer_->DecideRenderPassAllocationsForFrame( |
1242 *renderer_client_.render_passes_in_draw_order()); | 1250 *renderer_client_.render_passes_in_draw_order()); |
1243 renderer_->DrawFrame(renderer_client_.render_passes_in_draw_order(), NULL); | 1251 renderer_->DrawFrame( |
| 1252 renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true); |
1244 TestRenderPassProgram(); | 1253 TestRenderPassProgram(); |
1245 | 1254 |
1246 // RenderPassColorMatrixProgram | 1255 // RenderPassColorMatrixProgram |
1247 render_passes->clear(); | 1256 render_passes->clear(); |
1248 | 1257 |
1249 child_pass = AddRenderPass( | 1258 child_pass = AddRenderPass( |
1250 render_passes, child_pass_id, child_rect, transform_causing_aa); | 1259 render_passes, child_pass_id, child_rect, transform_causing_aa); |
1251 | 1260 |
1252 root_pass = AddRenderPass( | 1261 root_pass = AddRenderPass( |
1253 render_passes, root_pass_id, viewport_rect, gfx::Transform()); | 1262 render_passes, root_pass_id, viewport_rect, gfx::Transform()); |
1254 | 1263 |
1255 AddRenderPassQuad(root_pass, child_pass, 0, filter, gfx::Transform()); | 1264 AddRenderPassQuad(root_pass, child_pass, 0, filter, gfx::Transform()); |
1256 | 1265 |
1257 renderer_->DecideRenderPassAllocationsForFrame( | 1266 renderer_->DecideRenderPassAllocationsForFrame( |
1258 *renderer_client_.render_passes_in_draw_order()); | 1267 *renderer_client_.render_passes_in_draw_order()); |
1259 renderer_->DrawFrame(renderer_client_.render_passes_in_draw_order(), NULL); | 1268 renderer_->DrawFrame( |
| 1269 renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true); |
1260 TestRenderPassColorMatrixProgram(); | 1270 TestRenderPassColorMatrixProgram(); |
1261 | 1271 |
1262 // RenderPassMaskProgram | 1272 // RenderPassMaskProgram |
1263 render_passes->clear(); | 1273 render_passes->clear(); |
1264 | 1274 |
1265 child_pass = AddRenderPass( | 1275 child_pass = AddRenderPass( |
1266 render_passes, child_pass_id, child_rect, gfx::Transform()); | 1276 render_passes, child_pass_id, child_rect, gfx::Transform()); |
1267 | 1277 |
1268 root_pass = AddRenderPass( | 1278 root_pass = AddRenderPass( |
1269 render_passes, root_pass_id, viewport_rect, gfx::Transform()); | 1279 render_passes, root_pass_id, viewport_rect, gfx::Transform()); |
1270 | 1280 |
1271 AddRenderPassQuad(root_pass, | 1281 AddRenderPassQuad(root_pass, |
1272 child_pass, | 1282 child_pass, |
1273 mask, | 1283 mask, |
1274 skia::RefPtr<SkImageFilter>(), | 1284 skia::RefPtr<SkImageFilter>(), |
1275 gfx::Transform()); | 1285 gfx::Transform()); |
1276 | 1286 |
1277 renderer_->DecideRenderPassAllocationsForFrame( | 1287 renderer_->DecideRenderPassAllocationsForFrame( |
1278 *renderer_client_.render_passes_in_draw_order()); | 1288 *renderer_client_.render_passes_in_draw_order()); |
1279 renderer_->DrawFrame(renderer_client_.render_passes_in_draw_order(), NULL); | 1289 renderer_->DrawFrame( |
| 1290 renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true); |
1280 TestRenderPassMaskProgram(); | 1291 TestRenderPassMaskProgram(); |
1281 | 1292 |
1282 // RenderPassMaskColorMatrixProgram | 1293 // RenderPassMaskColorMatrixProgram |
1283 render_passes->clear(); | 1294 render_passes->clear(); |
1284 | 1295 |
1285 child_pass = AddRenderPass( | 1296 child_pass = AddRenderPass( |
1286 render_passes, child_pass_id, child_rect, gfx::Transform()); | 1297 render_passes, child_pass_id, child_rect, gfx::Transform()); |
1287 | 1298 |
1288 root_pass = AddRenderPass( | 1299 root_pass = AddRenderPass( |
1289 render_passes, root_pass_id, viewport_rect, gfx::Transform()); | 1300 render_passes, root_pass_id, viewport_rect, gfx::Transform()); |
1290 | 1301 |
1291 AddRenderPassQuad(root_pass, child_pass, mask, filter, gfx::Transform()); | 1302 AddRenderPassQuad(root_pass, child_pass, mask, filter, gfx::Transform()); |
1292 | 1303 |
1293 renderer_->DecideRenderPassAllocationsForFrame( | 1304 renderer_->DecideRenderPassAllocationsForFrame( |
1294 *renderer_client_.render_passes_in_draw_order()); | 1305 *renderer_client_.render_passes_in_draw_order()); |
1295 renderer_->DrawFrame(renderer_client_.render_passes_in_draw_order(), NULL); | 1306 renderer_->DrawFrame( |
| 1307 renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true); |
1296 TestRenderPassMaskColorMatrixProgram(); | 1308 TestRenderPassMaskColorMatrixProgram(); |
1297 | 1309 |
1298 // RenderPassProgramAA | 1310 // RenderPassProgramAA |
1299 render_passes->clear(); | 1311 render_passes->clear(); |
1300 | 1312 |
1301 child_pass = AddRenderPass( | 1313 child_pass = AddRenderPass( |
1302 render_passes, child_pass_id, child_rect, transform_causing_aa); | 1314 render_passes, child_pass_id, child_rect, transform_causing_aa); |
1303 | 1315 |
1304 root_pass = AddRenderPass( | 1316 root_pass = AddRenderPass( |
1305 render_passes, root_pass_id, viewport_rect, gfx::Transform()); | 1317 render_passes, root_pass_id, viewport_rect, gfx::Transform()); |
1306 | 1318 |
1307 AddRenderPassQuad(root_pass, | 1319 AddRenderPassQuad(root_pass, |
1308 child_pass, | 1320 child_pass, |
1309 0, | 1321 0, |
1310 skia::RefPtr<SkImageFilter>(), | 1322 skia::RefPtr<SkImageFilter>(), |
1311 transform_causing_aa); | 1323 transform_causing_aa); |
1312 | 1324 |
1313 renderer_->DecideRenderPassAllocationsForFrame( | 1325 renderer_->DecideRenderPassAllocationsForFrame( |
1314 *renderer_client_.render_passes_in_draw_order()); | 1326 *renderer_client_.render_passes_in_draw_order()); |
1315 renderer_->DrawFrame(renderer_client_.render_passes_in_draw_order(), NULL); | 1327 renderer_->DrawFrame( |
| 1328 renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true); |
1316 TestRenderPassProgramAA(); | 1329 TestRenderPassProgramAA(); |
1317 | 1330 |
1318 // RenderPassColorMatrixProgramAA | 1331 // RenderPassColorMatrixProgramAA |
1319 render_passes->clear(); | 1332 render_passes->clear(); |
1320 | 1333 |
1321 child_pass = AddRenderPass( | 1334 child_pass = AddRenderPass( |
1322 render_passes, child_pass_id, child_rect, transform_causing_aa); | 1335 render_passes, child_pass_id, child_rect, transform_causing_aa); |
1323 | 1336 |
1324 root_pass = AddRenderPass( | 1337 root_pass = AddRenderPass( |
1325 render_passes, root_pass_id, viewport_rect, gfx::Transform()); | 1338 render_passes, root_pass_id, viewport_rect, gfx::Transform()); |
1326 | 1339 |
1327 AddRenderPassQuad(root_pass, child_pass, 0, filter, transform_causing_aa); | 1340 AddRenderPassQuad(root_pass, child_pass, 0, filter, transform_causing_aa); |
1328 | 1341 |
1329 renderer_->DecideRenderPassAllocationsForFrame( | 1342 renderer_->DecideRenderPassAllocationsForFrame( |
1330 *renderer_client_.render_passes_in_draw_order()); | 1343 *renderer_client_.render_passes_in_draw_order()); |
1331 renderer_->DrawFrame(renderer_client_.render_passes_in_draw_order(), NULL); | 1344 renderer_->DrawFrame( |
| 1345 renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true); |
1332 TestRenderPassColorMatrixProgramAA(); | 1346 TestRenderPassColorMatrixProgramAA(); |
1333 | 1347 |
1334 // RenderPassMaskProgramAA | 1348 // RenderPassMaskProgramAA |
1335 render_passes->clear(); | 1349 render_passes->clear(); |
1336 | 1350 |
1337 child_pass = AddRenderPass(render_passes, child_pass_id, child_rect, | 1351 child_pass = AddRenderPass(render_passes, child_pass_id, child_rect, |
1338 transform_causing_aa); | 1352 transform_causing_aa); |
1339 | 1353 |
1340 root_pass = AddRenderPass(render_passes, root_pass_id, viewport_rect, | 1354 root_pass = AddRenderPass(render_passes, root_pass_id, viewport_rect, |
1341 gfx::Transform()); | 1355 gfx::Transform()); |
1342 | 1356 |
1343 AddRenderPassQuad(root_pass, child_pass, mask, skia::RefPtr<SkImageFilter>(), | 1357 AddRenderPassQuad(root_pass, child_pass, mask, skia::RefPtr<SkImageFilter>(), |
1344 transform_causing_aa); | 1358 transform_causing_aa); |
1345 | 1359 |
1346 renderer_->DecideRenderPassAllocationsForFrame( | 1360 renderer_->DecideRenderPassAllocationsForFrame( |
1347 *renderer_client_.render_passes_in_draw_order()); | 1361 *renderer_client_.render_passes_in_draw_order()); |
1348 renderer_->DrawFrame(renderer_client_.render_passes_in_draw_order(), NULL); | 1362 renderer_->DrawFrame( |
| 1363 renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true); |
1349 TestRenderPassMaskProgramAA(); | 1364 TestRenderPassMaskProgramAA(); |
1350 | 1365 |
1351 // RenderPassMaskColorMatrixProgramAA | 1366 // RenderPassMaskColorMatrixProgramAA |
1352 render_passes->clear(); | 1367 render_passes->clear(); |
1353 | 1368 |
1354 child_pass = AddRenderPass(render_passes, child_pass_id, child_rect, | 1369 child_pass = AddRenderPass(render_passes, child_pass_id, child_rect, |
1355 transform_causing_aa); | 1370 transform_causing_aa); |
1356 | 1371 |
1357 root_pass = AddRenderPass(render_passes, root_pass_id, viewport_rect, | 1372 root_pass = AddRenderPass(render_passes, root_pass_id, viewport_rect, |
1358 transform_causing_aa); | 1373 transform_causing_aa); |
1359 | 1374 |
1360 AddRenderPassQuad(root_pass, child_pass, mask, filter, transform_causing_aa); | 1375 AddRenderPassQuad(root_pass, child_pass, mask, filter, transform_causing_aa); |
1361 | 1376 |
1362 renderer_->DecideRenderPassAllocationsForFrame( | 1377 renderer_->DecideRenderPassAllocationsForFrame( |
1363 *renderer_client_.render_passes_in_draw_order()); | 1378 *renderer_client_.render_passes_in_draw_order()); |
1364 renderer_->DrawFrame(renderer_client_.render_passes_in_draw_order(), NULL); | 1379 renderer_->DrawFrame( |
| 1380 renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true); |
1365 TestRenderPassMaskColorMatrixProgramAA(); | 1381 TestRenderPassMaskColorMatrixProgramAA(); |
1366 } | 1382 } |
1367 | 1383 |
1368 // At this time, the AA code path cannot be taken if the surface's rect would | 1384 // At this time, the AA code path cannot be taken if the surface's rect would |
1369 // project incorrectly by the given transform, because of w<0 clipping. | 1385 // project incorrectly by the given transform, because of w<0 clipping. |
1370 TEST_F(GLRendererShaderTest, DrawRenderPassQuadSkipsAAForClippingTransform) { | 1386 TEST_F(GLRendererShaderTest, DrawRenderPassQuadSkipsAAForClippingTransform) { |
1371 gfx::Rect child_rect(50, 50); | 1387 gfx::Rect child_rect(50, 50); |
1372 RenderPass::Id child_pass_id(2, 0); | 1388 RenderPass::Id child_pass_id(2, 0); |
1373 TestRenderPass* child_pass; | 1389 TestRenderPass* child_pass; |
1374 | 1390 |
(...skipping 27 matching lines...) Expand all Loading... |
1402 render_passes, root_pass_id, viewport_rect, gfx::Transform()); | 1418 render_passes, root_pass_id, viewport_rect, gfx::Transform()); |
1403 | 1419 |
1404 AddRenderPassQuad(root_pass, | 1420 AddRenderPassQuad(root_pass, |
1405 child_pass, | 1421 child_pass, |
1406 0, | 1422 0, |
1407 skia::RefPtr<SkImageFilter>(), | 1423 skia::RefPtr<SkImageFilter>(), |
1408 transform_preventing_aa); | 1424 transform_preventing_aa); |
1409 | 1425 |
1410 renderer_->DecideRenderPassAllocationsForFrame( | 1426 renderer_->DecideRenderPassAllocationsForFrame( |
1411 *renderer_client_.render_passes_in_draw_order()); | 1427 *renderer_client_.render_passes_in_draw_order()); |
1412 renderer_->DrawFrame(renderer_client_.render_passes_in_draw_order(), NULL); | 1428 renderer_->DrawFrame( |
| 1429 renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true); |
1413 | 1430 |
1414 // If use_aa incorrectly ignores clipping, it will use the | 1431 // If use_aa incorrectly ignores clipping, it will use the |
1415 // RenderPassProgramAA shader instead of the RenderPassProgram. | 1432 // RenderPassProgramAA shader instead of the RenderPassProgram. |
1416 TestRenderPassProgram(); | 1433 TestRenderPassProgram(); |
1417 } | 1434 } |
1418 | 1435 |
1419 TEST_F(GLRendererShaderTest, DrawSolidColorShader) { | 1436 TEST_F(GLRendererShaderTest, DrawSolidColorShader) { |
1420 gfx::Rect viewport_rect(renderer_client_.DeviceViewport()); | 1437 gfx::Rect viewport_rect(renderer_client_.DeviceViewport()); |
1421 ScopedPtrVector<RenderPass>* render_passes = | 1438 ScopedPtrVector<RenderPass>* render_passes = |
1422 renderer_client_.render_passes_in_draw_order(); | 1439 renderer_client_.render_passes_in_draw_order(); |
1423 | 1440 |
1424 RenderPass::Id root_pass_id(1, 0); | 1441 RenderPass::Id root_pass_id(1, 0); |
1425 TestRenderPass* root_pass; | 1442 TestRenderPass* root_pass; |
1426 | 1443 |
1427 gfx::Transform pixel_aligned_transform_causing_aa; | 1444 gfx::Transform pixel_aligned_transform_causing_aa; |
1428 pixel_aligned_transform_causing_aa.Translate(25.5f, 25.5f); | 1445 pixel_aligned_transform_causing_aa.Translate(25.5f, 25.5f); |
1429 pixel_aligned_transform_causing_aa.Scale(0.5f, 0.5f); | 1446 pixel_aligned_transform_causing_aa.Scale(0.5f, 0.5f); |
1430 | 1447 |
1431 render_passes->clear(); | 1448 render_passes->clear(); |
1432 | 1449 |
1433 root_pass = AddRenderPass( | 1450 root_pass = AddRenderPass( |
1434 render_passes, root_pass_id, viewport_rect, gfx::Transform()); | 1451 render_passes, root_pass_id, viewport_rect, gfx::Transform()); |
1435 AddTransformedQuad(root_pass, | 1452 AddTransformedQuad(root_pass, |
1436 viewport_rect, | 1453 viewport_rect, |
1437 SK_ColorYELLOW, | 1454 SK_ColorYELLOW, |
1438 pixel_aligned_transform_causing_aa); | 1455 pixel_aligned_transform_causing_aa); |
1439 | 1456 |
1440 renderer_->DecideRenderPassAllocationsForFrame( | 1457 renderer_->DecideRenderPassAllocationsForFrame( |
1441 *renderer_client_.render_passes_in_draw_order()); | 1458 *renderer_client_.render_passes_in_draw_order()); |
1442 renderer_->DrawFrame(renderer_client_.render_passes_in_draw_order(), NULL); | 1459 renderer_->DrawFrame( |
| 1460 renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true); |
1443 | 1461 |
1444 TestSolidColorProgramAA(); | 1462 TestSolidColorProgramAA(); |
1445 } | 1463 } |
1446 | 1464 |
1447 class OutputSurfaceMockContext : public TestWebGraphicsContext3D { | 1465 class OutputSurfaceMockContext : public TestWebGraphicsContext3D { |
1448 public: | 1466 public: |
1449 OutputSurfaceMockContext() { | 1467 OutputSurfaceMockContext() { |
1450 test_capabilities_.discard_backbuffer = true; | 1468 test_capabilities_.discard_backbuffer = true; |
1451 test_capabilities_.post_sub_buffer = true; | 1469 test_capabilities_.post_sub_buffer = true; |
1452 } | 1470 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 }; | 1504 }; |
1487 | 1505 |
1488 class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient { | 1506 class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient { |
1489 protected: | 1507 protected: |
1490 virtual void SetUp() { | 1508 virtual void SetUp() { |
1491 FakeOutputSurfaceClient output_surface_client_; | 1509 FakeOutputSurfaceClient output_surface_client_; |
1492 CHECK(output_surface_.BindToClient(&output_surface_client_)); | 1510 CHECK(output_surface_.BindToClient(&output_surface_client_)); |
1493 | 1511 |
1494 resource_provider_ = ResourceProvider::Create(&output_surface_, 0).Pass(); | 1512 resource_provider_ = ResourceProvider::Create(&output_surface_, 0).Pass(); |
1495 | 1513 |
1496 renderer_.reset(new FakeRendererGL(this, | 1514 renderer_.reset(new FakeRendererGL( |
1497 &output_surface_, | 1515 this, &settings_, &output_surface_, resource_provider_.get())); |
1498 resource_provider_.get())); | |
1499 EXPECT_TRUE(renderer_->Initialize()); | 1516 EXPECT_TRUE(renderer_->Initialize()); |
1500 } | 1517 } |
1501 | 1518 |
1502 void SwapBuffers() { renderer_->SwapBuffers(); } | 1519 void SwapBuffers() { renderer_->SwapBuffers(); } |
1503 | 1520 |
1504 void DrawFrame() { | 1521 void DrawFrame(float device_scale_factor) { |
1505 gfx::Rect viewport_rect(DeviceViewport()); | 1522 gfx::Rect viewport_rect(DeviceViewport()); |
1506 ScopedPtrVector<RenderPass>* render_passes = render_passes_in_draw_order(); | 1523 ScopedPtrVector<RenderPass>* render_passes = render_passes_in_draw_order(); |
1507 render_passes->clear(); | 1524 render_passes->clear(); |
1508 | 1525 |
1509 RenderPass::Id render_pass_id(1, 0); | 1526 RenderPass::Id render_pass_id(1, 0); |
1510 TestRenderPass* render_pass = AddRenderPass( | 1527 TestRenderPass* render_pass = AddRenderPass( |
1511 render_passes, render_pass_id, viewport_rect, gfx::Transform()); | 1528 render_passes, render_pass_id, viewport_rect, gfx::Transform()); |
1512 AddQuad(render_pass, viewport_rect, SK_ColorGREEN); | 1529 AddQuad(render_pass, viewport_rect, SK_ColorGREEN); |
1513 | 1530 |
1514 EXPECT_CALL(output_surface_, EnsureBackbuffer()).WillRepeatedly(Return()); | 1531 EXPECT_CALL(output_surface_, EnsureBackbuffer()).WillRepeatedly(Return()); |
1515 | 1532 |
1516 EXPECT_CALL(output_surface_, | 1533 EXPECT_CALL(output_surface_, |
1517 Reshape(DeviceViewport().size(), DeviceScaleFactor())).Times(1); | 1534 Reshape(DeviceViewport().size(), device_scale_factor)).Times(1); |
1518 | 1535 |
1519 EXPECT_CALL(output_surface_, BindFramebuffer()).Times(1); | 1536 EXPECT_CALL(output_surface_, BindFramebuffer()).Times(1); |
1520 | 1537 |
1521 EXPECT_CALL(*Context(), drawElements(_, _, _, _)).Times(1); | 1538 EXPECT_CALL(*Context(), drawElements(_, _, _, _)).Times(1); |
1522 | 1539 |
1523 renderer_->DecideRenderPassAllocationsForFrame( | 1540 renderer_->DecideRenderPassAllocationsForFrame( |
1524 *render_passes_in_draw_order()); | 1541 *render_passes_in_draw_order()); |
1525 renderer_->DrawFrame(render_passes_in_draw_order(), NULL); | 1542 renderer_->DrawFrame( |
| 1543 render_passes_in_draw_order(), NULL, device_scale_factor, true); |
1526 } | 1544 } |
1527 | 1545 |
1528 OutputSurfaceMockContext* Context() { | 1546 OutputSurfaceMockContext* Context() { |
1529 return static_cast<OutputSurfaceMockContext*>( | 1547 return static_cast<OutputSurfaceMockContext*>( |
1530 output_surface_.context_provider()->Context3d()); | 1548 output_surface_.context_provider()->Context3d()); |
1531 } | 1549 } |
1532 | 1550 |
| 1551 LayerTreeSettings settings_; |
1533 FakeOutputSurfaceClient output_surface_client_; | 1552 FakeOutputSurfaceClient output_surface_client_; |
1534 StrictMock<MockOutputSurface> output_surface_; | 1553 StrictMock<MockOutputSurface> output_surface_; |
1535 scoped_ptr<ResourceProvider> resource_provider_; | 1554 scoped_ptr<ResourceProvider> resource_provider_; |
1536 scoped_ptr<FakeRendererGL> renderer_; | 1555 scoped_ptr<FakeRendererGL> renderer_; |
1537 }; | 1556 }; |
1538 | 1557 |
1539 TEST_F(MockOutputSurfaceTest, DrawFrameAndSwap) { | 1558 TEST_F(MockOutputSurfaceTest, DrawFrameAndSwap) { |
1540 DrawFrame(); | 1559 DrawFrame(1.f); |
1541 | 1560 |
1542 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); | 1561 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); |
1543 renderer_->SwapBuffers(); | 1562 renderer_->SwapBuffers(); |
1544 } | 1563 } |
1545 | 1564 |
1546 TEST_F(MockOutputSurfaceTest, DrawFrameAndResizeAndSwap) { | 1565 TEST_F(MockOutputSurfaceTest, DrawFrameAndResizeAndSwap) { |
1547 DrawFrame(); | 1566 DrawFrame(1.f); |
1548 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); | 1567 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); |
1549 renderer_->SwapBuffers(); | 1568 renderer_->SwapBuffers(); |
1550 | 1569 |
1551 set_viewport_and_scale(gfx::Size(2, 2), 2.f); | 1570 set_viewport(gfx::Size(2, 2)); |
1552 renderer_->ViewportChanged(); | 1571 renderer_->ViewportChanged(); |
1553 | 1572 |
1554 DrawFrame(); | 1573 DrawFrame(2.f); |
1555 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); | 1574 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); |
1556 renderer_->SwapBuffers(); | 1575 renderer_->SwapBuffers(); |
1557 | 1576 |
1558 DrawFrame(); | 1577 DrawFrame(2.f); |
1559 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); | 1578 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); |
1560 renderer_->SwapBuffers(); | 1579 renderer_->SwapBuffers(); |
1561 | 1580 |
1562 set_viewport_and_scale(gfx::Size(1, 1), 1.f); | 1581 set_viewport(gfx::Size(1, 1)); |
1563 renderer_->ViewportChanged(); | 1582 renderer_->ViewportChanged(); |
1564 | 1583 |
1565 DrawFrame(); | 1584 DrawFrame(1.f); |
1566 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); | 1585 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); |
1567 renderer_->SwapBuffers(); | 1586 renderer_->SwapBuffers(); |
1568 } | 1587 } |
1569 | 1588 |
1570 class GLRendererTestSyncPoint : public GLRendererPixelTest { | 1589 class GLRendererTestSyncPoint : public GLRendererPixelTest { |
1571 protected: | 1590 protected: |
1572 static void SyncPointCallback(int* callback_count) { | 1591 static void SyncPointCallback(int* callback_count) { |
1573 ++(*callback_count); | 1592 ++(*callback_count); |
1574 base::MessageLoop::current()->QuitWhenIdle(); | 1593 base::MessageLoop::current()->QuitWhenIdle(); |
1575 } | 1594 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1634 base::MessageLoop::current()->Run(); | 1653 base::MessageLoop::current()->Run(); |
1635 | 1654 |
1636 // The sync point should have happened. | 1655 // The sync point should have happened. |
1637 EXPECT_EQ(1, sync_point_callback_count); | 1656 EXPECT_EQ(1, sync_point_callback_count); |
1638 EXPECT_EQ(1, other_callback_count); | 1657 EXPECT_EQ(1, other_callback_count); |
1639 } | 1658 } |
1640 #endif // OS_ANDROID | 1659 #endif // OS_ANDROID |
1641 | 1660 |
1642 } // namespace | 1661 } // namespace |
1643 } // namespace cc | 1662 } // namespace cc |
OLD | NEW |