Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: cc/output/gl_renderer_unittest.cc

Issue 12912010: cc: Convert non-const reference arguments to pointers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ui/compositor Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/output/gl_renderer_pixeltest.cc ('k') | cc/output/renderer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "cc/output/compositor_frame_metadata.h" 7 #include "cc/output/compositor_frame_metadata.h"
8 #include "cc/quads/draw_quad.h" 8 #include "cc/quads/draw_quad.h"
9 #include "cc/resources/prioritized_resource_manager.h" 9 #include "cc/resources/prioritized_resource_manager.h"
10 #include "cc/resources/resource_provider.h" 10 #include "cc/resources/resource_provider.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 virtual bool HasImplThread() const OVERRIDE { return false; } 154 virtual bool HasImplThread() const OVERRIDE { return false; }
155 virtual bool ShouldClearRootRenderPass() const OVERRIDE { return true; } 155 virtual bool ShouldClearRootRenderPass() const OVERRIDE { return true; }
156 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const OVERRIDE { 156 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const OVERRIDE {
157 return CompositorFrameMetadata(); 157 return CompositorFrameMetadata();
158 } 158 }
159 159
160 // Methods added for test. 160 // Methods added for test.
161 int set_full_root_layer_damage_count() const { 161 int set_full_root_layer_damage_count() const {
162 return set_full_root_layer_damage_count_; 162 return set_full_root_layer_damage_count_;
163 } 163 }
164 void set_last_call_was_set_visibility_pointer(bool* last_call_was_set_visibili ty) { 164 void set_last_call_was_set_visibility_pointer(
165 bool* last_call_was_set_visibility) {
165 last_call_was_set_visibility_ = last_call_was_set_visibility; 166 last_call_was_set_visibility_ = last_call_was_set_visibility;
166 } 167 }
167 168
168 RenderPass* root_render_pass() { return render_passes_in_draw_order_.back(); } 169 RenderPass* root_render_pass() { return render_passes_in_draw_order_.back(); }
169 RenderPassList* render_passes_in_draw_order() { 170 RenderPassList* render_passes_in_draw_order() {
170 return &render_passes_in_draw_order_; 171 return &render_passes_in_draw_order_;
171 } 172 }
172 173
173 size_t memory_allocation_limit_bytes() const { 174 size_t memory_allocation_limit_bytes() const {
174 return memory_allocation_limit_bytes_; 175 return memory_allocation_limit_bytes_;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 // Test GLRenderer DiscardBackbuffer functionality: 284 // Test GLRenderer DiscardBackbuffer functionality:
284 // Begin drawing a frame while a framebuffer is discarded. 285 // Begin drawing a frame while a framebuffer is discarded.
285 // Expected: will recreate framebuffer. 286 // Expected: will recreate framebuffer.
286 TEST_F(GLRendererTest, DiscardedBackbufferIsRecreatedForScopeDuration) { 287 TEST_F(GLRendererTest, DiscardedBackbufferIsRecreatedForScopeDuration) {
287 renderer_.SetVisible(false); 288 renderer_.SetVisible(false);
288 context()->SetMemoryAllocation(suggest_have_backbuffer_no_); 289 context()->SetMemoryAllocation(suggest_have_backbuffer_no_);
289 EXPECT_TRUE(renderer_.IsBackbufferDiscarded()); 290 EXPECT_TRUE(renderer_.IsBackbufferDiscarded());
290 EXPECT_EQ(1, mock_client_.set_full_root_layer_damage_count()); 291 EXPECT_EQ(1, mock_client_.set_full_root_layer_damage_count());
291 292
292 renderer_.SetVisible(true); 293 renderer_.SetVisible(true);
293 renderer_.DrawFrame(*mock_client_.render_passes_in_draw_order()); 294 renderer_.DrawFrame(mock_client_.render_passes_in_draw_order());
294 EXPECT_FALSE(renderer_.IsBackbufferDiscarded()); 295 EXPECT_FALSE(renderer_.IsBackbufferDiscarded());
295 296
296 SwapBuffers(); 297 SwapBuffers();
297 EXPECT_EQ(1, context()->frame_count()); 298 EXPECT_EQ(1, context()->frame_count());
298 } 299 }
299 300
300 TEST_F(GLRendererTest, FramebufferDiscardedAfterReadbackWhenNotVisible) { 301 TEST_F(GLRendererTest, FramebufferDiscardedAfterReadbackWhenNotVisible) {
301 renderer_.SetVisible(false); 302 renderer_.SetVisible(false);
302 context()->SetMemoryAllocation(suggest_have_backbuffer_no_); 303 context()->SetMemoryAllocation(suggest_have_backbuffer_no_);
303 EXPECT_TRUE(renderer_.IsBackbufferDiscarded()); 304 EXPECT_TRUE(renderer_.IsBackbufferDiscarded());
304 EXPECT_EQ(1, mock_client_.set_full_root_layer_damage_count()); 305 EXPECT_EQ(1, mock_client_.set_full_root_layer_damage_count());
305 306
306 char pixels[4]; 307 char pixels[4];
307 renderer_.DrawFrame(*mock_client_.render_passes_in_draw_order()); 308 renderer_.DrawFrame(mock_client_.render_passes_in_draw_order());
308 EXPECT_FALSE(renderer_.IsBackbufferDiscarded()); 309 EXPECT_FALSE(renderer_.IsBackbufferDiscarded());
309 310
310 renderer_.GetFramebufferPixels(pixels, gfx::Rect(0, 0, 1, 1)); 311 renderer_.GetFramebufferPixels(pixels, gfx::Rect(0, 0, 1, 1));
311 EXPECT_TRUE(renderer_.IsBackbufferDiscarded()); 312 EXPECT_TRUE(renderer_.IsBackbufferDiscarded());
312 EXPECT_EQ(2, mock_client_.set_full_root_layer_damage_count()); 313 EXPECT_EQ(2, mock_client_.set_full_root_layer_damage_count());
313 } 314 }
314 315
315 class ForbidSynchronousCallContext : public TestWebGraphicsContext3D { 316 class ForbidSynchronousCallContext : public TestWebGraphicsContext3D {
316 public: 317 public:
317 ForbidSynchronousCallContext() {} 318 ForbidSynchronousCallContext() {}
318 319
319 virtual bool getActiveAttrib(WebGLId program, WGC3Duint index, ActiveInfo& inf o) { 320 virtual bool getActiveAttrib(WebGLId program,
321 WGC3Duint index,
322 ActiveInfo& info) {
320 ADD_FAILURE(); 323 ADD_FAILURE();
321 return false; 324 return false;
322 } 325 }
323 virtual bool getActiveUniform(WebGLId program, WGC3Duint index, ActiveInfo& in fo) { 326 virtual bool getActiveUniform(WebGLId program,
327 WGC3Duint index,
328 ActiveInfo& info) {
324 ADD_FAILURE(); 329 ADD_FAILURE();
325 return false; 330 return false;
326 } 331 }
327 virtual void getAttachedShaders(WebGLId program, 332 virtual void getAttachedShaders(WebGLId program,
328 WGC3Dsizei max_count, 333 WGC3Dsizei max_count,
329 WGC3Dsizei* count, 334 WGC3Dsizei* count,
330 WebGLId* shaders) { 335 WebGLId* shaders) {
331 ADD_FAILURE(); 336 ADD_FAILURE();
332 } 337 }
333 virtual WGC3Dint getAttribLocation(WebGLId program, const WGC3Dchar* name) { 338 virtual WGC3Dint getAttribLocation(WebGLId program, const WGC3Dchar* name) {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 525
521 // WebGraphicsContext3D methods. 526 // WebGraphicsContext3D methods.
522 527
523 // This method would normally do a glSwapBuffers under the hood. 528 // This method would normally do a glSwapBuffers under the hood.
524 virtual void prepareTexture() {} 529 virtual void prepareTexture() {}
525 virtual void setMemoryAllocationChangedCallbackCHROMIUM( 530 virtual void setMemoryAllocationChangedCallbackCHROMIUM(
526 WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) {} 531 WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) {}
527 virtual WebString getString(WebKit::WGC3Denum name) { return WebString(); } 532 virtual WebString getString(WebKit::WGC3Denum name) { return WebString(); }
528 }; 533 };
529 534
530 TEST( 535 TEST(GLRendererTest2,
531 GLRendererTest2, 536 InitializationWithoutGpuMemoryManagerExtensionSupportShouldDefaultToNonZero Allocation) {
532 InitializationWithoutGpuMemoryManagerExtensionSupportShouldDefaultToNonZeroA llocation) {
533 FakeRendererClient mock_client; 537 FakeRendererClient mock_client;
534 scoped_ptr<OutputSurface> output_surface( 538 scoped_ptr<OutputSurface> output_surface(
535 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( 539 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(
536 new ContextThatDoesNotSupportMemoryManagmentExtensions))); 540 new ContextThatDoesNotSupportMemoryManagmentExtensions)));
537 scoped_ptr<ResourceProvider> resource_provider( 541 scoped_ptr<ResourceProvider> resource_provider(
538 ResourceProvider::Create(output_surface.get())); 542 ResourceProvider::Create(output_surface.get()));
539 FakeRendererGL renderer( 543 FakeRendererGL renderer(
540 &mock_client, output_surface.get(), resource_provider.get()); 544 &mock_client, output_surface.get(), resource_provider.get());
541 545
542 renderer.Initialize(); 546 renderer.Initialize();
(...skipping 21 matching lines...) Expand all
564 static_cast<ClearCountingContext*>(output_surface->context3d()); 568 static_cast<ClearCountingContext*>(output_surface->context3d());
565 scoped_ptr<ResourceProvider> resource_provider( 569 scoped_ptr<ResourceProvider> resource_provider(
566 ResourceProvider::Create(output_surface.get())); 570 ResourceProvider::Create(output_surface.get()));
567 FakeRendererGL renderer( 571 FakeRendererGL renderer(
568 &mock_client, output_surface.get(), resource_provider.get()); 572 &mock_client, output_surface.get(), resource_provider.get());
569 573
570 mock_client.root_render_pass()->has_transparent_background = false; 574 mock_client.root_render_pass()->has_transparent_background = false;
571 575
572 EXPECT_TRUE(renderer.Initialize()); 576 EXPECT_TRUE(renderer.Initialize());
573 577
574 renderer.DrawFrame(*mock_client.render_passes_in_draw_order()); 578 renderer.DrawFrame(mock_client.render_passes_in_draw_order());
575 579
576 // On DEBUG builds, render passes with opaque background clear to blue to 580 // On DEBUG builds, render passes with opaque background clear to blue to
577 // easily see regions that were not drawn on the screen. 581 // easily see regions that were not drawn on the screen.
578 #ifdef NDEBUG 582 #ifdef NDEBUG
579 EXPECT_EQ(0, context->clear_count()); 583 EXPECT_EQ(0, context->clear_count());
580 #else 584 #else
581 EXPECT_EQ(1, context->clear_count()); 585 EXPECT_EQ(1, context->clear_count());
582 #endif 586 #endif
583 } 587 }
584 588
585 TEST(GLRendererTest2, TransparentBackground) { 589 TEST(GLRendererTest2, TransparentBackground) {
586 FakeRendererClient mock_client; 590 FakeRendererClient mock_client;
587 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 591 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
588 scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); 592 scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext)));
589 ClearCountingContext* context = 593 ClearCountingContext* context =
590 static_cast<ClearCountingContext*>(output_surface->context3d()); 594 static_cast<ClearCountingContext*>(output_surface->context3d());
591 scoped_ptr<ResourceProvider> resource_provider( 595 scoped_ptr<ResourceProvider> resource_provider(
592 ResourceProvider::Create(output_surface.get())); 596 ResourceProvider::Create(output_surface.get()));
593 FakeRendererGL renderer( 597 FakeRendererGL renderer(
594 &mock_client, output_surface.get(), resource_provider.get()); 598 &mock_client, output_surface.get(), resource_provider.get());
595 599
596 mock_client.root_render_pass()->has_transparent_background = true; 600 mock_client.root_render_pass()->has_transparent_background = true;
597 601
598 EXPECT_TRUE(renderer.Initialize()); 602 EXPECT_TRUE(renderer.Initialize());
599 603
600 renderer.DrawFrame(*mock_client.render_passes_in_draw_order()); 604 renderer.DrawFrame(mock_client.render_passes_in_draw_order());
601 605
602 EXPECT_EQ(1, context->clear_count()); 606 EXPECT_EQ(1, context->clear_count());
603 } 607 }
604 608
605 class VisibilityChangeIsLastCallTrackingContext : 609 class VisibilityChangeIsLastCallTrackingContext :
606 public TestWebGraphicsContext3D { 610 public TestWebGraphicsContext3D {
607 public: 611 public:
608 VisibilityChangeIsLastCallTrackingContext() 612 VisibilityChangeIsLastCallTrackingContext()
609 : last_call_was_set_visibility_(0) {} 613 : last_call_was_set_visibility_(0) {}
610 614
(...skipping 24 matching lines...) Expand all
635 // This method would normally do a glSwapBuffers under the hood. 639 // This method would normally do a glSwapBuffers under the hood.
636 virtual WebString getString(WebKit::WGC3Denum name) { 640 virtual WebString getString(WebKit::WGC3Denum name) {
637 if (name == GL_EXTENSIONS) 641 if (name == GL_EXTENSIONS)
638 return WebString( 642 return WebString(
639 "GL_CHROMIUM_set_visibility GL_CHROMIUM_gpu_memory_manager " 643 "GL_CHROMIUM_set_visibility GL_CHROMIUM_gpu_memory_manager "
640 "GL_CHROMIUM_discard_backbuffer"); 644 "GL_CHROMIUM_discard_backbuffer");
641 return WebString(); 645 return WebString();
642 } 646 }
643 647
644 // Methods added for test. 648 // Methods added for test.
645 void set_last_call_was_set_visibility_pointer(bool* last_call_was_set_visibili ty) { 649 void set_last_call_was_set_visibility_pointer(
650 bool* last_call_was_set_visibility) {
646 last_call_was_set_visibility_ = last_call_was_set_visibility; 651 last_call_was_set_visibility_ = last_call_was_set_visibility;
647 } 652 }
648 653
649 private: 654 private:
650 bool* last_call_was_set_visibility_; 655 bool* last_call_was_set_visibility_;
651 }; 656 };
652 657
653 TEST(GLRendererTest2, VisibilityChangeIsLastCall) { 658 TEST(GLRendererTest2, VisibilityChangeIsLastCall) {
654 FakeRendererClient mock_client; 659 FakeRendererClient mock_client;
655 scoped_ptr<OutputSurface> output_surface( 660 scoped_ptr<OutputSurface> output_surface(
656 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( 661 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(
657 new VisibilityChangeIsLastCallTrackingContext))); 662 new VisibilityChangeIsLastCallTrackingContext)));
658 VisibilityChangeIsLastCallTrackingContext* context = 663 VisibilityChangeIsLastCallTrackingContext* context =
659 static_cast<VisibilityChangeIsLastCallTrackingContext*>( 664 static_cast<VisibilityChangeIsLastCallTrackingContext*>(
660 output_surface->context3d()); 665 output_surface->context3d());
661 scoped_ptr<ResourceProvider> resource_provider( 666 scoped_ptr<ResourceProvider> resource_provider(
662 ResourceProvider::Create(output_surface.get())); 667 ResourceProvider::Create(output_surface.get()));
663 FakeRendererGL renderer( 668 FakeRendererGL renderer(
664 &mock_client, output_surface.get(), resource_provider.get()); 669 &mock_client, output_surface.get(), resource_provider.get());
665 670
666 EXPECT_TRUE(renderer.Initialize()); 671 EXPECT_TRUE(renderer.Initialize());
667 672
668 bool last_call_was_set_visiblity = false; 673 bool last_call_was_set_visiblity = false;
669 // Ensure that the call to setVisibilityCHROMIUM is the last call issue to the 674 // Ensure that the call to setVisibilityCHROMIUM is the last call issue to the
670 // GPU process, after glFlush is called, and after the RendererClient's 675 // GPU process, after glFlush is called, and after the RendererClient's
671 // EnforceManagedMemoryPolicy is called. Plumb this tracking between both the 676 // EnforceManagedMemoryPolicy is called. Plumb this tracking between both the
672 // RenderClient and the Context by giving them both a pointer to a variable on 677 // RenderClient and the Context by giving them both a pointer to a variable on
673 // the stack. 678 // the stack.
674 context->set_last_call_was_set_visibility_pointer(&last_call_was_set_visiblity ); 679 context->set_last_call_was_set_visibility_pointer(
675 mock_client.set_last_call_was_set_visibility_pointer(&last_call_was_set_visibl ity); 680 &last_call_was_set_visiblity);
681 mock_client.set_last_call_was_set_visibility_pointer(
682 &last_call_was_set_visiblity);
676 renderer.SetVisible(true); 683 renderer.SetVisible(true);
677 renderer.DrawFrame(*mock_client.render_passes_in_draw_order()); 684 renderer.DrawFrame(mock_client.render_passes_in_draw_order());
678 renderer.SetVisible(false); 685 renderer.SetVisible(false);
679 EXPECT_TRUE(last_call_was_set_visiblity); 686 EXPECT_TRUE(last_call_was_set_visiblity);
680 } 687 }
681 688
682 class TextureStateTrackingContext : public TestWebGraphicsContext3D { 689 class TextureStateTrackingContext : public TestWebGraphicsContext3D {
683 public: 690 public:
684 TextureStateTrackingContext() : active_texture_(GL_INVALID_ENUM) {} 691 TextureStateTrackingContext() : active_texture_(GL_INVALID_ENUM) {}
685 692
686 virtual WebString getString(WGC3Denum name) { 693 virtual WebString getString(WGC3Denum name) {
687 if (name == GL_EXTENSIONS) 694 if (name == GL_EXTENSIONS)
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 763
757 // scaled_tile_quad also uses GL_LINEAR. 764 // scaled_tile_quad also uses GL_LINEAR.
758 EXPECT_CALL(*context, drawElements(_, _, _, _)); 765 EXPECT_CALL(*context, drawElements(_, _, _, _));
759 766
760 // The remaining quads also use GL_LINEAR because nearest neighbor 767 // The remaining quads also use GL_LINEAR because nearest neighbor
761 // filtering is currently only used with tile quads. 768 // filtering is currently only used with tile quads.
762 EXPECT_CALL(*context, drawElements(_, _, _, _)).Times(6); 769 EXPECT_CALL(*context, drawElements(_, _, _, _)).Times(6);
763 } 770 }
764 771
765 cc::DirectRenderer::DrawingFrame drawing_frame; 772 cc::DirectRenderer::DrawingFrame drawing_frame;
766 renderer.BeginDrawingFrame(drawing_frame); 773 renderer.BeginDrawingFrame(&drawing_frame);
767 EXPECT_EQ(context->active_texture(), GL_TEXTURE0); 774 EXPECT_EQ(context->active_texture(), GL_TEXTURE0);
768 775
769 for (cc::QuadList::BackToFrontIterator 776 for (cc::QuadList::BackToFrontIterator
770 it = pass->quad_list.BackToFrontBegin(); 777 it = pass->quad_list.BackToFrontBegin();
771 it != pass->quad_list.BackToFrontEnd(); 778 it != pass->quad_list.BackToFrontEnd();
772 ++it) { 779 ++it) {
773 renderer.DoDrawQuad(drawing_frame, *it); 780 renderer.DoDrawQuad(&drawing_frame, *it);
774 } 781 }
775 renderer.FinishDrawingQuadList(); 782 renderer.FinishDrawingQuadList();
776 EXPECT_EQ(context->active_texture(), GL_TEXTURE0); 783 EXPECT_EQ(context->active_texture(), GL_TEXTURE0);
777 Mock::VerifyAndClearExpectations(context); 784 Mock::VerifyAndClearExpectations(context);
778 } 785 }
779 786
780 class NoClearRootRenderPassFakeClient : public FakeRendererClient { 787 class NoClearRootRenderPassFakeClient : public FakeRendererClient {
781 public: 788 public:
782 virtual bool ShouldClearRootRenderPass() const OVERRIDE { return false; } 789 virtual bool ShouldClearRootRenderPass() const OVERRIDE { return false; }
783 }; 790 };
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 838
832 // The second render pass is the root one, clearing should be prevented. 839 // The second render pass is the root one, clearing should be prevented.
833 EXPECT_CALL(*mock_context, clear(GL_COLOR_BUFFER_BIT)).Times(0) 840 EXPECT_CALL(*mock_context, clear(GL_COLOR_BUFFER_BIT)).Times(0)
834 .After(first_render_pass); 841 .After(first_render_pass);
835 842
836 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)).Times(AnyNumber()) 843 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)).Times(AnyNumber())
837 .After(first_render_pass); 844 .After(first_render_pass);
838 845
839 renderer.DecideRenderPassAllocationsForFrame( 846 renderer.DecideRenderPassAllocationsForFrame(
840 *mock_client.render_passes_in_draw_order()); 847 *mock_client.render_passes_in_draw_order());
841 renderer.DrawFrame(*mock_client.render_passes_in_draw_order()); 848 renderer.DrawFrame(mock_client.render_passes_in_draw_order());
842 849
843 // In multiple render passes all but the root pass should clear the 850 // In multiple render passes all but the root pass should clear the
844 // framebuffer. 851 // framebuffer.
845 Mock::VerifyAndClearExpectations(&mock_context); 852 Mock::VerifyAndClearExpectations(&mock_context);
846 } 853 }
847 854
848 class ScissorTestOnClearCheckingContext : public TestWebGraphicsContext3D { 855 class ScissorTestOnClearCheckingContext : public TestWebGraphicsContext3D {
849 public: 856 public:
850 ScissorTestOnClearCheckingContext() : scissor_enabled_(false) {} 857 ScissorTestOnClearCheckingContext() : scissor_enabled_(false) {}
851 858
(...skipping 26 matching lines...) Expand all
878 EXPECT_FALSE(renderer.Capabilities().using_partial_swap); 885 EXPECT_FALSE(renderer.Capabilities().using_partial_swap);
879 886
880 gfx::Rect viewport_rect(mock_client.DeviceViewportSize()); 887 gfx::Rect viewport_rect(mock_client.DeviceViewportSize());
881 ScopedPtrVector<RenderPass>& render_passes = 888 ScopedPtrVector<RenderPass>& render_passes =
882 *mock_client.render_passes_in_draw_order(); 889 *mock_client.render_passes_in_draw_order();
883 render_passes.clear(); 890 render_passes.clear();
884 891
885 gfx::Rect grand_child_rect(25, 25); 892 gfx::Rect grand_child_rect(25, 25);
886 RenderPass::Id grand_child_pass_id(3, 0); 893 RenderPass::Id grand_child_pass_id(3, 0);
887 TestRenderPass* grand_child_pass = AddRenderPass( 894 TestRenderPass* grand_child_pass = AddRenderPass(
888 & render_passes, grand_child_pass_id, grand_child_rect, gfx::Transform()); 895 &render_passes, grand_child_pass_id, grand_child_rect, gfx::Transform());
889 AddClippedQuad(grand_child_pass, grand_child_rect, SK_ColorYELLOW); 896 AddClippedQuad(grand_child_pass, grand_child_rect, SK_ColorYELLOW);
890 897
891 gfx::Rect child_rect(50, 50); 898 gfx::Rect child_rect(50, 50);
892 RenderPass::Id child_pass_id(2, 0); 899 RenderPass::Id child_pass_id(2, 0);
893 TestRenderPass* child_pass = 900 TestRenderPass* child_pass = AddRenderPass(
894 AddRenderPass(&render_passes, child_pass_id, child_rect, gfx::Transform()) ; 901 &render_passes, child_pass_id, child_rect, gfx::Transform());
895 AddQuad(child_pass, child_rect, SK_ColorBLUE); 902 AddQuad(child_pass, child_rect, SK_ColorBLUE);
896 903
897 RenderPass::Id root_pass_id(1, 0); 904 RenderPass::Id root_pass_id(1, 0);
898 TestRenderPass* root_pass = AddRenderPass( 905 TestRenderPass* root_pass = AddRenderPass(
899 & render_passes, root_pass_id, viewport_rect, gfx::Transform()); 906 &render_passes, root_pass_id, viewport_rect, gfx::Transform());
900 AddQuad(root_pass, viewport_rect, SK_ColorGREEN); 907 AddQuad(root_pass, viewport_rect, SK_ColorGREEN);
901 908
902 AddRenderPassQuad(root_pass, child_pass); 909 AddRenderPassQuad(root_pass, child_pass);
903 AddRenderPassQuad(child_pass, grand_child_pass); 910 AddRenderPassQuad(child_pass, grand_child_pass);
904 911
905 renderer.DecideRenderPassAllocationsForFrame( 912 renderer.DecideRenderPassAllocationsForFrame(
906 *mock_client.render_passes_in_draw_order()); 913 *mock_client.render_passes_in_draw_order());
907 renderer.DrawFrame(*mock_client.render_passes_in_draw_order()); 914 renderer.DrawFrame(mock_client.render_passes_in_draw_order());
908 } 915 }
909 916
910 class OutputSurfaceMockContext : public TestWebGraphicsContext3D { 917 class OutputSurfaceMockContext : public TestWebGraphicsContext3D {
911 public: 918 public:
912 // Specifically override methods even if they are unused (used in conjunction 919 // Specifically override methods even if they are unused (used in conjunction
913 // with StrictMock). We need to make sure that GLRenderer does not issue 920 // with StrictMock). We need to make sure that GLRenderer does not issue
914 // framebuffer-related GL calls directly. Instead these are supposed to go 921 // framebuffer-related GL calls directly. Instead these are supposed to go
915 // through the OutputSurface abstraction. 922 // through the OutputSurface abstraction.
916 MOCK_METHOD0(ensureBackbufferCHROMIUM, void()); 923 MOCK_METHOD0(ensureBackbufferCHROMIUM, void());
917 MOCK_METHOD0(discardBackbufferCHROMIUM, void()); 924 MOCK_METHOD0(discardBackbufferCHROMIUM, void());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 AddQuad(render_pass, viewport_rect, SK_ColorGREEN); 976 AddQuad(render_pass, viewport_rect, SK_ColorGREEN);
970 977
971 EXPECT_CALL(output_surface_, EnsureBackbuffer()).WillRepeatedly(Return()); 978 EXPECT_CALL(output_surface_, EnsureBackbuffer()).WillRepeatedly(Return());
972 979
973 EXPECT_CALL(output_surface_, Reshape(_)).Times(1); 980 EXPECT_CALL(output_surface_, Reshape(_)).Times(1);
974 981
975 EXPECT_CALL(output_surface_, BindFramebuffer()).Times(1); 982 EXPECT_CALL(output_surface_, BindFramebuffer()).Times(1);
976 983
977 EXPECT_CALL(*context(), drawElements(_, _, _, _)).Times(1); 984 EXPECT_CALL(*context(), drawElements(_, _, _, _)).Times(1);
978 985
979 renderer_.DecideRenderPassAllocationsForFrame(*render_passes_in_draw_order() ); 986 renderer_.DecideRenderPassAllocationsForFrame(
980 renderer_.DrawFrame(*render_passes_in_draw_order()); 987 *render_passes_in_draw_order());
988 renderer_.DrawFrame(render_passes_in_draw_order());
981 } 989 }
982 990
983 OutputSurfaceMockContext* context() { 991 OutputSurfaceMockContext* context() {
984 return static_cast<OutputSurfaceMockContext*>(output_surface_.context3d()); 992 return static_cast<OutputSurfaceMockContext*>(output_surface_.context3d());
985 } 993 }
986 994
987 StrictMock<MockOutputSurface> output_surface_; 995 StrictMock<MockOutputSurface> output_surface_;
988 scoped_ptr<ResourceProvider> resource_provider_; 996 scoped_ptr<ResourceProvider> resource_provider_;
989 FakeRendererGL renderer_; 997 FakeRendererGL renderer_;
990 }; 998 };
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 } 1030 }
1023 }; 1031 };
1024 1032
1025 TEST_F(MockOutputSurfaceTestWithSendCompositorFrame, DrawFrame) { 1033 TEST_F(MockOutputSurfaceTestWithSendCompositorFrame, DrawFrame) {
1026 EXPECT_CALL(output_surface_, SendFrameToParentCompositor(_)).Times(1); 1034 EXPECT_CALL(output_surface_, SendFrameToParentCompositor(_)).Times(1);
1027 DrawFrame(); 1035 DrawFrame();
1028 } 1036 }
1029 1037
1030 } // namespace 1038 } // namespace
1031 } // namespace cc 1039 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer_pixeltest.cc ('k') | cc/output/renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698