diff options
Diffstat (limited to 'cc')
-rw-r--r-- | cc/output/delegating_renderer.cc | 2 | ||||
-rw-r--r-- | cc/output/delegating_renderer.h | 2 | ||||
-rw-r--r-- | cc/output/direct_renderer.cc | 26 | ||||
-rw-r--r-- | cc/output/direct_renderer.h | 6 | ||||
-rw-r--r-- | cc/output/gl_renderer.cc | 22 | ||||
-rw-r--r-- | cc/output/gl_renderer_unittest.cc | 938 | ||||
-rw-r--r-- | cc/output/renderer.h | 14 | ||||
-rw-r--r-- | cc/output/renderer_pixeltest.cc | 3 | ||||
-rw-r--r-- | cc/output/software_renderer_unittest.cc | 84 | ||||
-rw-r--r-- | cc/test/layer_tree_pixel_test.cc | 17 | ||||
-rw-r--r-- | cc/test/layer_tree_pixel_test.h | 1 | ||||
-rw-r--r-- | cc/test/pixel_test.cc | 81 | ||||
-rw-r--r-- | cc/test/pixel_test.h | 22 | ||||
-rw-r--r-- | cc/test/pixel_test_output_surface.cc | 7 | ||||
-rw-r--r-- | cc/test/pixel_test_output_surface.h | 8 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 18 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.h | 13 |
17 files changed, 705 insertions, 559 deletions
diff --git a/cc/output/delegating_renderer.cc b/cc/output/delegating_renderer.cc index 9532cc3..c76f250 100644 --- a/cc/output/delegating_renderer.cc +++ b/cc/output/delegating_renderer.cc @@ -96,6 +96,8 @@ static ResourceProvider::ResourceId AppendToArray( void DelegatingRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order, ContextProvider* offscreen_context_provider, float device_scale_factor, + gfx::Rect device_viewport_rect, + gfx::Rect device_clip_rect, bool allow_partial_swap, bool disable_picture_quad_image_filtering) { TRACE_EVENT0("cc", "DelegatingRenderer::DrawFrame"); diff --git a/cc/output/delegating_renderer.h b/cc/output/delegating_renderer.h index 3c74aa8..c18bfa7 100644 --- a/cc/output/delegating_renderer.h +++ b/cc/output/delegating_renderer.h @@ -31,6 +31,8 @@ class CC_EXPORT DelegatingRenderer : public Renderer { virtual void DrawFrame(RenderPassList* render_passes_in_draw_order, ContextProvider* offscreen_context_provider, float device_scale_factor, + gfx::Rect device_viewport_rect, + gfx::Rect device_clip_rect, bool allow_partial_swap, bool disable_picture_quad_image_filtering) OVERRIDE; diff --git a/cc/output/direct_renderer.cc b/cc/output/direct_renderer.cc index 24c3fc2..37f8247 100644 --- a/cc/output/direct_renderer.cc +++ b/cc/output/direct_renderer.cc @@ -195,6 +195,8 @@ void DirectRenderer::DecideRenderPassAllocationsForFrame( void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order, ContextProvider* offscreen_context_provider, float device_scale_factor, + gfx::Rect device_viewport_rect, + gfx::Rect device_clip_rect, bool allow_partial_swap, bool disable_picture_quad_image_filtering) { TRACE_EVENT0("cc", "DirectRenderer::DrawFrame"); @@ -210,7 +212,9 @@ void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order, Capabilities().using_partial_swap && allow_partial_swap ? root_render_pass->damage_rect : root_render_pass->output_rect; - frame.root_damage_rect.Intersect(gfx::Rect(client_->DeviceViewport().size())); + frame.root_damage_rect.Intersect(gfx::Rect(device_viewport_rect.size())); + frame.device_viewport_rect = device_viewport_rect; + frame.device_clip_rect = device_clip_rect; frame.offscreen_context_provider = offscreen_context_provider; frame.disable_picture_quad_image_filtering = disable_picture_quad_image_filtering; @@ -220,8 +224,7 @@ void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order, // Only reshape when we know we are going to draw. Otherwise, the reshape // can leave the window at the wrong size if we never draw and the proper // viewport size is never set. - output_surface_->Reshape(client_->DeviceViewport().size(), - device_scale_factor); + output_surface_->Reshape(device_viewport_rect.size(), device_scale_factor); BeginDrawingFrame(&frame); for (size_t i = 0; i < render_passes_in_draw_order->size(); ++i) { @@ -269,11 +272,12 @@ bool DirectRenderer::NeedDeviceClip(const DrawingFrame* frame) const { if (frame->current_render_pass != frame->root_render_pass) return false; - return !client_->DeviceClip().Contains(client_->DeviceViewport()); + return !frame->device_clip_rect.Contains(frame->device_viewport_rect); } -gfx::Rect DirectRenderer::DeviceClipRect(const DrawingFrame* frame) const { - gfx::Rect device_clip_rect = client_->DeviceClip(); +gfx::Rect DirectRenderer::DeviceClipRectInWindowSpace(const DrawingFrame* frame) + const { + gfx::Rect device_clip_rect = frame->device_clip_rect; if (FlippedFramebuffer()) device_clip_rect.set_y(current_surface_size_.height() - device_clip_rect.bottom()); @@ -287,7 +291,7 @@ void DirectRenderer::SetScissorStateForQuad(const DrawingFrame* frame, return; } if (NeedDeviceClip(frame)) { - SetScissorTestRect(DeviceClipRect(frame)); + SetScissorTestRect(DeviceClipRectInWindowSpace(frame)); return; } @@ -317,7 +321,7 @@ void DirectRenderer::SetScissorTestRectInDrawSpace(const DrawingFrame* frame, gfx::RectF draw_space_rect) { gfx::Rect window_space_rect = MoveFromDrawToWindowSpace(draw_space_rect); if (NeedDeviceClip(frame)) - window_space_rect.Intersect(DeviceClipRect(frame)); + window_space_rect.Intersect(DeviceClipRectInWindowSpace(frame)); SetScissorTestRect(window_space_rect); } @@ -335,7 +339,7 @@ void DirectRenderer::DrawRenderPass(DrawingFrame* frame, gfx::RectF render_pass_scissor; bool draw_rect_covers_full_surface = true; if (frame->current_render_pass == frame->root_render_pass && - !client_->DeviceViewport().Contains( + !frame->device_viewport_rect.Contains( gfx::Rect(output_surface_->SurfaceSize()))) draw_rect_covers_full_surface = false; @@ -349,7 +353,7 @@ void DirectRenderer::DrawRenderPass(DrawingFrame* frame, if (frame->current_render_pass != frame->root_render_pass || settings_->should_clear_root_render_pass) { if (NeedDeviceClip(frame)) { - SetScissorTestRect(DeviceClipRect(frame)); + SetScissorTestRect(DeviceClipRectInWindowSpace(frame)); draw_rect_covers_full_surface = false; } else if (!using_scissor_as_optimization) { EnsureScissorTestDisabled(); @@ -392,7 +396,7 @@ bool DirectRenderer::UseRenderPass(DrawingFrame* frame, BindFramebufferToOutputSurface(frame); InitializeViewport(frame, render_pass->output_rect, - client_->DeviceViewport(), + frame->device_viewport_rect, output_surface_->SurfaceSize()); return true; } diff --git a/cc/output/direct_renderer.h b/cc/output/direct_renderer.h index 6be6707..5c4dc7e 100644 --- a/cc/output/direct_renderer.h +++ b/cc/output/direct_renderer.h @@ -34,6 +34,8 @@ class CC_EXPORT DirectRenderer : public Renderer { virtual void DrawFrame(RenderPassList* render_passes_in_draw_order, ContextProvider* offscreen_context_provider, float device_scale_factor, + gfx::Rect device_viewport_rect, + gfx::Rect device_clip_rect, bool allow_partial_swap, bool disable_picture_quad_image_filtering) OVERRIDE; @@ -46,6 +48,8 @@ class CC_EXPORT DirectRenderer : public Renderer { const ScopedResource* current_texture; gfx::RectF root_damage_rect; + gfx::Rect device_viewport_rect; + gfx::Rect device_clip_rect; gfx::Transform projection_matrix; gfx::Transform window_matrix; @@ -74,7 +78,7 @@ class CC_EXPORT DirectRenderer : public Renderer { gfx::Rect MoveFromDrawToWindowSpace(const gfx::RectF& draw_rect) const; bool NeedDeviceClip(const DrawingFrame* frame) const; - gfx::Rect DeviceClipRect(const DrawingFrame* frame) const; + gfx::Rect DeviceClipRectInWindowSpace(const DrawingFrame* frame) const; static gfx::RectF ComputeScissorRectForRenderPass(const DrawingFrame* frame); void SetScissorStateForQuad(const DrawingFrame* frame, const DrawQuad& quad); void SetScissorStateForQuadWithRenderPassScissor( diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc index b131df0..b383d9f 100644 --- a/cc/output/gl_renderer.cc +++ b/cc/output/gl_renderer.cc @@ -212,9 +212,6 @@ GLRenderer::GLRenderer(RendererClient* client, context_caps.discard_framebuffer; InitializeSharedObjects(); - - // Make sure the viewport and context gets initialized, even if it is to zero. - ViewportChanged(); } GLRenderer::~GLRenderer() { @@ -310,10 +307,10 @@ void GLRenderer::ClearFramebuffer(DrawingFrame* frame, } void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { - if (client_->DeviceViewport().IsEmpty()) + if (frame->device_viewport_rect.IsEmpty()) return; - TRACE_EVENT0("cc", "GLRenderer::DrawLayers"); + TRACE_EVENT0("cc", "GLRenderer::BeginDrawingFrame"); ReinitializeGLState(); } @@ -2142,23 +2139,24 @@ void GLRenderer::Finish() { } void GLRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) { - DCHECK(visible_); DCHECK(!is_backbuffer_discarded_); TRACE_EVENT0("cc", "GLRenderer::SwapBuffers"); // We're done! Time to swapbuffers! + gfx::Size surface_size = output_surface_->SurfaceSize(); + CompositorFrame compositor_frame; compositor_frame.metadata = metadata; compositor_frame.gl_frame_data = make_scoped_ptr(new GLFrameData); - compositor_frame.gl_frame_data->size = output_surface_->SurfaceSize(); + compositor_frame.gl_frame_data->size = surface_size; if (capabilities_.using_partial_swap) { // If supported, we can save significant bandwidth by only swapping the - // damaged/scissored region (clamped to the viewport) - swap_buffer_rect_.Intersect(client_->DeviceViewport()); - int flipped_y_pos_of_rect_bottom = - client_->DeviceViewport().height() - swap_buffer_rect_.y() - - swap_buffer_rect_.height(); + // damaged/scissored region (clamped to the viewport). + swap_buffer_rect_.Intersect(gfx::Rect(surface_size)); + int flipped_y_pos_of_rect_bottom = surface_size.height() - + swap_buffer_rect_.y() - + swap_buffer_rect_.height(); compositor_frame.gl_frame_data->sub_buffer_rect = gfx::Rect(swap_buffer_rect_.x(), flipped_y_pos_of_rect_bottom, diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc index 838d485..c9b6cca 100644 --- a/cc/output/gl_renderer_unittest.cc +++ b/cc/output/gl_renderer_unittest.cc @@ -55,10 +55,17 @@ using blink::WGC3Duint; namespace cc { -#define EXPECT_PROGRAM_VALID(program_binding) \ - do { \ - EXPECT_TRUE((program_binding)->program()); \ - EXPECT_TRUE((program_binding)->initialized()); \ +class GLRendererTest : public testing::Test { + protected: + RenderPass* root_render_pass() { return render_passes_in_draw_order_.back(); } + + RenderPassList render_passes_in_draw_order_; +}; + +#define EXPECT_PROGRAM_VALID(program_binding) \ + do { \ + EXPECT_TRUE((program_binding)->program()); \ + EXPECT_TRUE((program_binding)->initialized()); \ } while (false) // Explicitly named to be a friend in GLRenderer for shader access. @@ -109,13 +116,12 @@ class GLRendererShaderPixelTest : public GLRendererPixelTest { TestShadersWithSamplerType(precision, SamplerTypeExternalOES); } - void TestShadersWithSamplerType( - TexCoordPrecision precision, SamplerType sampler) { + void TestShadersWithSamplerType(TexCoordPrecision precision, + SamplerType sampler) { EXPECT_PROGRAM_VALID(renderer()->GetTileProgram(precision, sampler)); EXPECT_PROGRAM_VALID(renderer()->GetTileProgramOpaque(precision, sampler)); EXPECT_PROGRAM_VALID(renderer()->GetTileProgramAA(precision, sampler)); - EXPECT_PROGRAM_VALID( - renderer()->GetTileProgramSwizzle(precision, sampler)); + EXPECT_PROGRAM_VALID(renderer()->GetTileProgramSwizzle(precision, sampler)); EXPECT_PROGRAM_VALID( renderer()->GetTileProgramSwizzleOpaque(precision, sampler)); EXPECT_PROGRAM_VALID( @@ -131,24 +137,9 @@ TEST_F(GLRendererShaderPixelTest, AllShadersCompile) { TestShaders(); } class FakeRendererClient : public RendererClient { public: - FakeRendererClient() - : host_impl_(&proxy_), - set_full_root_layer_damage_count_(0), - root_layer_(LayerImpl::Create(host_impl_.active_tree(), 1)), - viewport_(gfx::Rect(0, 0, 1, 1)), - clip_(gfx::Rect(0, 0, 1, 1)) { - root_layer_->CreateRenderSurface(); - RenderPass::Id render_pass_id = - root_layer_->render_surface()->RenderPassId(); - scoped_ptr<RenderPass> root_render_pass = RenderPass::Create(); - root_render_pass->SetNew( - render_pass_id, gfx::Rect(), gfx::Rect(), gfx::Transform()); - render_passes_in_draw_order_.push_back(root_render_pass.Pass()); - } + FakeRendererClient() : set_full_root_layer_damage_count_(0) {} // RendererClient methods. - virtual gfx::Rect DeviceViewport() const OVERRIDE { return viewport_; } - virtual gfx::Rect DeviceClip() const OVERRIDE { return clip_; } virtual void SetFullRootLayerDamage() OVERRIDE { set_full_root_layer_damage_count_++; } @@ -157,22 +148,9 @@ class FakeRendererClient : public RendererClient { int set_full_root_layer_damage_count() const { return set_full_root_layer_damage_count_; } - void set_viewport(gfx::Rect viewport) { viewport_ = viewport; } - void set_clip(gfx::Rect clip) { clip_ = clip; } - - RenderPass* root_render_pass() { return render_passes_in_draw_order_.back(); } - RenderPassList* render_passes_in_draw_order() { - return &render_passes_in_draw_order_; - } private: - FakeImplProxy proxy_; - FakeLayerTreeHostImpl host_impl_; int set_full_root_layer_damage_count_; - scoped_ptr<LayerImpl> root_layer_; - RenderPassList render_passes_in_draw_order_; - gfx::Rect viewport_; - gfx::Rect clip_; }; class FakeRendererGL : public GLRenderer { @@ -198,9 +176,9 @@ class FakeRendererGL : public GLRenderer { using GLRenderer::stencil_enabled; }; -class GLRendererTest : public testing::Test { +class GLRendererWithDefaultHarnessTest : public GLRendererTest { protected: - GLRendererTest() { + GLRendererWithDefaultHarnessTest() { output_surface_ = FakeOutputSurface::Create3d( TestWebGraphicsContext3D::Create()).Pass(); CHECK(output_surface_->BindToClient(&output_surface_client_)); @@ -228,7 +206,7 @@ class GLRendererTest : public testing::Test { // declared above it. } // namespace -class GLRendererShaderTest : public testing::Test { +class GLRendererShaderTest : public GLRendererTest { protected: GLRendererShaderTest() { output_surface_ = FakeOutputSurface::Create3d().Pass(); @@ -251,9 +229,8 @@ class GLRendererShaderTest : public testing::Test { void TestRenderPassColorMatrixProgram(TexCoordPrecision precision) { EXPECT_PROGRAM_VALID( &renderer_->render_pass_color_matrix_program_[precision]); - EXPECT_EQ( - renderer_->render_pass_color_matrix_program_[precision].program(), - renderer_->program_shadow_); + EXPECT_EQ(renderer_->render_pass_color_matrix_program_[precision].program(), + renderer_->program_shadow_); } void TestRenderPassMaskProgram(TexCoordPrecision precision) { @@ -265,9 +242,9 @@ class GLRendererShaderTest : public testing::Test { void TestRenderPassMaskColorMatrixProgram(TexCoordPrecision precision) { EXPECT_PROGRAM_VALID( &renderer_->render_pass_mask_color_matrix_program_[precision]); - EXPECT_EQ(renderer_-> - render_pass_mask_color_matrix_program_[precision].program(), - renderer_->program_shadow_); + EXPECT_EQ( + renderer_->render_pass_mask_color_matrix_program_[precision].program(), + renderer_->program_shadow_); } void TestRenderPassProgramAA(TexCoordPrecision precision) { @@ -279,9 +256,9 @@ class GLRendererShaderTest : public testing::Test { void TestRenderPassColorMatrixProgramAA(TexCoordPrecision precision) { EXPECT_PROGRAM_VALID( &renderer_->render_pass_color_matrix_program_aa_[precision]); - EXPECT_EQ(renderer_-> - render_pass_color_matrix_program_aa_[precision].program(), - renderer_->program_shadow_); + EXPECT_EQ( + renderer_->render_pass_color_matrix_program_aa_[precision].program(), + renderer_->program_shadow_); } void TestRenderPassMaskProgramAA(TexCoordPrecision precision) { @@ -293,8 +270,8 @@ class GLRendererShaderTest : public testing::Test { void TestRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision) { EXPECT_PROGRAM_VALID( &renderer_->render_pass_mask_color_matrix_program_aa_[precision]); - EXPECT_EQ(renderer_-> - render_pass_mask_color_matrix_program_aa_[precision].program(), + EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_aa_[precision] + .program(), renderer_->program_shadow_); } @@ -319,7 +296,7 @@ namespace { // visible. // Expected: it is discarded and damage tracker is reset. TEST_F( - GLRendererTest, + GLRendererWithDefaultHarnessTest, SuggestBackbufferNoShouldDiscardBackbufferAndDamageRootLayerIfNotVisible) { renderer_->SetVisible(false); EXPECT_EQ(1, renderer_client_.set_full_root_layer_damage_count()); @@ -329,7 +306,8 @@ TEST_F( // Test GLRenderer DiscardBackbuffer functionality: // Suggest discarding framebuffer when one exists and the renderer is visible. // Expected: the allocation is ignored. -TEST_F(GLRendererTest, SuggestBackbufferNoDoNothingWhenVisible) { +TEST_F(GLRendererWithDefaultHarnessTest, + SuggestBackbufferNoDoNothingWhenVisible) { renderer_->SetVisible(true); EXPECT_EQ(0, renderer_client_.set_full_root_layer_damage_count()); EXPECT_FALSE(renderer_->IsBackbufferDiscarded()); @@ -338,7 +316,8 @@ TEST_F(GLRendererTest, SuggestBackbufferNoDoNothingWhenVisible) { // Test GLRenderer DiscardBackbuffer functionality: // Suggest discarding framebuffer when one does not exist. // Expected: it does nothing. -TEST_F(GLRendererTest, SuggestBackbufferNoWhenItDoesntExistShouldDoNothing) { +TEST_F(GLRendererWithDefaultHarnessTest, + SuggestBackbufferNoWhenItDoesntExistShouldDoNothing) { renderer_->SetVisible(false); EXPECT_EQ(1, renderer_client_.set_full_root_layer_damage_count()); EXPECT_TRUE(renderer_->IsBackbufferDiscarded()); @@ -350,28 +329,52 @@ TEST_F(GLRendererTest, SuggestBackbufferNoWhenItDoesntExistShouldDoNothing) { // Test GLRenderer DiscardBackbuffer functionality: // Begin drawing a frame while a framebuffer is discarded. // Expected: will recreate framebuffer. -TEST_F(GLRendererTest, DiscardedBackbufferIsRecreatedForScopeDuration) { +TEST_F(GLRendererWithDefaultHarnessTest, + DiscardedBackbufferIsRecreatedForScopeDuration) { + gfx::Rect viewport_rect(1, 1); renderer_->SetVisible(false); EXPECT_TRUE(renderer_->IsBackbufferDiscarded()); EXPECT_EQ(1, renderer_client_.set_full_root_layer_damage_count()); + AddRenderPass(&render_passes_in_draw_order_, + RenderPass::Id(1, 0), + viewport_rect, + gfx::Transform()); + renderer_->SetVisible(true); - renderer_->DrawFrame( - renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer_->DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); EXPECT_FALSE(renderer_->IsBackbufferDiscarded()); SwapBuffers(); EXPECT_EQ(1u, output_surface_->num_sent_frames()); } -TEST_F(GLRendererTest, FramebufferDiscardedAfterReadbackWhenNotVisible) { +TEST_F(GLRendererWithDefaultHarnessTest, + FramebufferDiscardedAfterReadbackWhenNotVisible) { + gfx::Rect viewport_rect(1, 1); renderer_->SetVisible(false); EXPECT_TRUE(renderer_->IsBackbufferDiscarded()); EXPECT_EQ(1, renderer_client_.set_full_root_layer_damage_count()); + AddRenderPass(&render_passes_in_draw_order_, + RenderPass::Id(1, 0), + viewport_rect, + gfx::Transform()); + char pixels[4]; - renderer_->DrawFrame( - renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer_->DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); EXPECT_FALSE(renderer_->IsBackbufferDiscarded()); renderer_->GetFramebufferPixels(pixels, gfx::Rect(0, 0, 1, 1)); @@ -379,14 +382,25 @@ TEST_F(GLRendererTest, FramebufferDiscardedAfterReadbackWhenNotVisible) { EXPECT_EQ(2, renderer_client_.set_full_root_layer_damage_count()); } -TEST_F(GLRendererTest, ExternalStencil) { +TEST_F(GLRendererWithDefaultHarnessTest, ExternalStencil) { + gfx::Rect viewport_rect(1, 1); EXPECT_FALSE(renderer_->stencil_enabled()); output_surface_->set_has_external_stencil_test(true); - renderer_client_.root_render_pass()->has_transparent_background = false; - renderer_->DrawFrame( - renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true, false); + TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, + RenderPass::Id(1, 0), + viewport_rect, + gfx::Transform()); + root_pass->has_transparent_background = false; + + renderer_->DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); EXPECT_TRUE(renderer_->stencil_enabled()); } @@ -536,9 +550,7 @@ class ForbidSynchronousCallContext : public TestWebGraphicsContext3D { } }; -// This test isn't using the same fixture as GLRendererTest, and you can't mix -// TEST() and TEST_F() with the same name, Hence LRC2. -TEST(GLRendererTest2, InitializationDoesNotMakeSynchronousCalls) { +TEST_F(GLRendererTest, InitializationDoesNotMakeSynchronousCalls) { FakeOutputSurfaceClient output_surface_client; scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( scoped_ptr<TestWebGraphicsContext3D>(new ForbidSynchronousCallContext))); @@ -559,20 +571,22 @@ class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D { public: LoseContextOnFirstGetContext() {} - virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value) - OVERRIDE { + virtual void getProgramiv(WebGLId program, + WGC3Denum pname, + WGC3Dint* value) OVERRIDE { context_lost_ = true; *value = 0; } - virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value) - OVERRIDE { + virtual void getShaderiv(WebGLId shader, + WGC3Denum pname, + WGC3Dint* value) OVERRIDE { context_lost_ = true; *value = 0; } }; -TEST(GLRendererTest2, InitializationWithQuicklyLostContextDoesNotAssert) { +TEST_F(GLRendererTest, InitializationWithQuicklyLostContextDoesNotAssert) { FakeOutputSurfaceClient output_surface_client; scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( scoped_ptr<TestWebGraphicsContext3D>(new LoseContextOnFirstGetContext))); @@ -591,9 +605,7 @@ TEST(GLRendererTest2, InitializationWithQuicklyLostContextDoesNotAssert) { class ClearCountingContext : public TestWebGraphicsContext3D { public: - ClearCountingContext() { - test_capabilities_.discard_framebuffer = true; - } + ClearCountingContext() { test_capabilities_.discard_framebuffer = true; } MOCK_METHOD3(discardFramebufferEXT, void(WGC3Denum target, @@ -602,7 +614,7 @@ class ClearCountingContext : public TestWebGraphicsContext3D { MOCK_METHOD1(clear, void(WGC3Dbitfield mask)); }; -TEST(GLRendererTest2, OpaqueBackground) { +TEST_F(GLRendererTest, OpaqueBackground) { scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); ClearCountingContext* context = context_owned.get(); @@ -621,7 +633,12 @@ TEST(GLRendererTest2, OpaqueBackground) { output_surface.get(), resource_provider.get()); - renderer_client.root_render_pass()->has_transparent_background = false; + gfx::Rect viewport_rect(1, 1); + TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, + RenderPass::Id(1, 0), + viewport_rect, + gfx::Transform()); + root_pass->has_transparent_background = false; // On DEBUG builds, render passes with opaque background clear to blue to // easily see regions that were not drawn on the screen. @@ -633,12 +650,17 @@ TEST(GLRendererTest2, OpaqueBackground) { #else EXPECT_CALL(*context, clear(_)).Times(1); #endif - renderer.DrawFrame( - renderer_client.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer.DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); Mock::VerifyAndClearExpectations(context); } -TEST(GLRendererTest2, TransparentBackground) { +TEST_F(GLRendererTest, TransparentBackground) { scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); ClearCountingContext* context = context_owned.get(); @@ -657,18 +679,27 @@ TEST(GLRendererTest2, TransparentBackground) { output_surface.get(), resource_provider.get()); - renderer_client.root_render_pass()->has_transparent_background = true; + gfx::Rect viewport_rect(1, 1); + TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, + RenderPass::Id(1, 0), + viewport_rect, + gfx::Transform()); + root_pass->has_transparent_background = true; - EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, 1, _)) - .Times(1); + EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, 1, _)).Times(1); EXPECT_CALL(*context, clear(_)).Times(1); - renderer.DrawFrame( - renderer_client.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer.DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); Mock::VerifyAndClearExpectations(context); } -TEST(GLRendererTest2, OffscreenOutputSurface) { +TEST_F(GLRendererTest, OffscreenOutputSurface) { scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); ClearCountingContext* context = context_owned.get(); @@ -687,12 +718,23 @@ TEST(GLRendererTest2, OffscreenOutputSurface) { output_surface.get(), resource_provider.get()); + gfx::Rect viewport_rect(1, 1); + AddRenderPass(&render_passes_in_draw_order_, + RenderPass::Id(1, 0), + viewport_rect, + gfx::Transform()); + EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, _, _)) .With(Args<2, 1>(ElementsAre(GL_COLOR_ATTACHMENT0))) .Times(1); EXPECT_CALL(*context, clear(_)).Times(AnyNumber()); - renderer.DrawFrame( - renderer_client.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer.DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); Mock::VerifyAndClearExpectations(context); } @@ -738,7 +780,7 @@ class VisibilityChangeIsLastCallTrackingContext bool last_call_was_set_visibility_; }; -TEST(GLRendererTest2, VisibilityChangeIsLastCall) { +TEST_F(GLRendererTest, VisibilityChangeIsLastCall) { scoped_ptr<VisibilityChangeIsLastCallTrackingContext> context_owned( new VisibilityChangeIsLastCallTrackingContext); VisibilityChangeIsLastCallTrackingContext* context = context_owned.get(); @@ -765,22 +807,32 @@ TEST(GLRendererTest2, VisibilityChangeIsLastCall) { output_surface.get(), resource_provider.get()); + gfx::Rect viewport_rect(1, 1); + AddRenderPass(&render_passes_in_draw_order_, + RenderPass::Id(1, 0), + viewport_rect, + gfx::Transform()); + // Ensure that the call to SetSurfaceVisible is the last call issue to the // GPU process, after glFlush is called, and after the RendererClient's // SetManagedMemoryPolicy is called. Plumb this tracking between both the // RenderClient and the Context by giving them both a pointer to a variable on // the stack. renderer.SetVisible(true); - renderer.DrawFrame( - renderer_client.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer.DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); renderer.SetVisible(false); EXPECT_TRUE(context->last_call_was_set_visibility()); } class TextureStateTrackingContext : public TestWebGraphicsContext3D { public: - TextureStateTrackingContext() - : active_texture_(GL_INVALID_ENUM) { + TextureStateTrackingContext() : active_texture_(GL_INVALID_ENUM) { test_capabilities_.egl_image_external = true; } @@ -803,7 +855,7 @@ class TextureStateTrackingContext : public TestWebGraphicsContext3D { WGC3Denum active_texture_; }; -TEST(GLRendererTest2, ActiveTextureState) { +TEST_F(GLRendererTest, ActiveTextureState) { scoped_ptr<TextureStateTrackingContext> context_owned( new TextureStateTrackingContext); TextureStateTrackingContext* context = context_owned.get(); @@ -827,12 +879,12 @@ TEST(GLRendererTest2, ActiveTextureState) { EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber()); cc::RenderPass::Id id(1, 1); - scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); - pass->SetNew(id, - gfx::Rect(0, 0, 100, 100), - gfx::Rect(0, 0, 100, 100), - gfx::Transform()); - pass->AppendOneOfEveryQuadType(resource_provider.get(), RenderPass::Id(2, 1)); + TestRenderPass* root_pass = AddRenderPass( + &render_passes_in_draw_order_, id, gfx::Rect(100, 100), gfx::Transform()); + root_pass->AppendOneOfEveryQuadType(resource_provider.get(), + RenderPass::Id(2, 1)); + + renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); // Set up expected texture filter state transitions that match the quads // created in AppendOneOfEveryQuadType(). @@ -864,18 +916,14 @@ TEST(GLRendererTest2, ActiveTextureState) { EXPECT_CALL(*context, drawElements(_, _, _, _)).Times(6); } - cc::DirectRenderer::DrawingFrame drawing_frame; - renderer.BeginDrawingFrame(&drawing_frame); - EXPECT_EQ(static_cast<unsigned>(GL_TEXTURE0), context->active_texture()); - - for (cc::QuadList::BackToFrontIterator - it = pass->quad_list.BackToFrontBegin(); - it != pass->quad_list.BackToFrontEnd(); - ++it) { - renderer.DoDrawQuad(&drawing_frame, *it); - } - renderer.FinishDrawingQuadList(); - EXPECT_EQ(static_cast<unsigned>(GL_TEXTURE0), context->active_texture()); + gfx::Rect viewport_rect(100, 100); + renderer.DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); Mock::VerifyAndClearExpectations(context); } @@ -889,14 +937,14 @@ class NoClearRootRenderPassMockContext : public TestWebGraphicsContext3D { WGC3Dintptr offset)); }; -TEST(GLRendererTest2, ShouldClearRootRenderPass) { +TEST_F(GLRendererTest, ShouldClearRootRenderPass) { scoped_ptr<NoClearRootRenderPassMockContext> mock_context_owned( new NoClearRootRenderPassMockContext); NoClearRootRenderPassMockContext* mock_context = mock_context_owned.get(); FakeOutputSurfaceClient output_surface_client; scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( - mock_context_owned.PassAs<TestWebGraphicsContext3D>())); + mock_context_owned.PassAs<TestWebGraphicsContext3D>())); CHECK(output_surface->BindToClient(&output_surface_client)); scoped_ptr<ResourceProvider> resource_provider( @@ -911,19 +959,20 @@ TEST(GLRendererTest2, ShouldClearRootRenderPass) { output_surface.get(), resource_provider.get()); - gfx::Rect viewport_rect(renderer_client.DeviceViewport()); - ScopedPtrVector<RenderPass>& render_passes = - *renderer_client.render_passes_in_draw_order(); - render_passes.clear(); + gfx::Rect viewport_rect(10, 10); RenderPass::Id root_pass_id(1, 0); - TestRenderPass* root_pass = AddRenderPass( - &render_passes, root_pass_id, viewport_rect, gfx::Transform()); + TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); AddQuad(root_pass, viewport_rect, SK_ColorGREEN); RenderPass::Id child_pass_id(2, 0); - TestRenderPass* child_pass = AddRenderPass( - &render_passes, child_pass_id, viewport_rect, gfx::Transform()); + TestRenderPass* child_pass = AddRenderPass(&render_passes_in_draw_order_, + child_pass_id, + viewport_rect, + gfx::Transform()); AddQuad(child_pass, viewport_rect, SK_ColorBLUE); AddRenderPassQuad(root_pass, child_pass); @@ -941,16 +990,20 @@ TEST(GLRendererTest2, ShouldClearRootRenderPass) { EXPECT_CALL(*mock_context, drawElements(_, _, _, _)).Times(1); // The second render pass is the root one, clearing should be prevented. - EXPECT_CALL(*mock_context, clear(clear_bits)).Times(0) - .After(first_render_pass); + EXPECT_CALL(*mock_context, clear(clear_bits)).Times(0).After( + first_render_pass); - EXPECT_CALL(*mock_context, drawElements(_, _, _, _)).Times(AnyNumber()) - .After(first_render_pass); + EXPECT_CALL(*mock_context, drawElements(_, _, _, _)).Times(AnyNumber()).After( + first_render_pass); - renderer.DecideRenderPassAllocationsForFrame( - *renderer_client.render_passes_in_draw_order()); - renderer.DrawFrame( - renderer_client.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer.DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); // In multiple render passes all but the root pass should clear the // framebuffer. @@ -977,7 +1030,7 @@ class ScissorTestOnClearCheckingContext : public TestWebGraphicsContext3D { bool scissor_enabled_; }; -TEST(GLRendererTest2, ScissorTestWhenClearing) { +TEST_F(GLRendererTest, ScissorTestWhenClearing) { scoped_ptr<ScissorTestOnClearCheckingContext> context_owned( new ScissorTestOnClearCheckingContext); @@ -997,35 +1050,43 @@ TEST(GLRendererTest2, ScissorTestWhenClearing) { resource_provider.get()); EXPECT_FALSE(renderer.Capabilities().using_partial_swap); - gfx::Rect viewport_rect(renderer_client.DeviceViewport()); - ScopedPtrVector<RenderPass>& render_passes = - *renderer_client.render_passes_in_draw_order(); - render_passes.clear(); + gfx::Rect viewport_rect(1, 1); gfx::Rect grand_child_rect(25, 25); RenderPass::Id grand_child_pass_id(3, 0); - TestRenderPass* grand_child_pass = AddRenderPass( - &render_passes, grand_child_pass_id, grand_child_rect, gfx::Transform()); + TestRenderPass* grand_child_pass = + AddRenderPass(&render_passes_in_draw_order_, + grand_child_pass_id, + grand_child_rect, + gfx::Transform()); AddClippedQuad(grand_child_pass, grand_child_rect, SK_ColorYELLOW); gfx::Rect child_rect(50, 50); RenderPass::Id child_pass_id(2, 0); - TestRenderPass* child_pass = AddRenderPass( - &render_passes, child_pass_id, child_rect, gfx::Transform()); + TestRenderPass* child_pass = AddRenderPass(&render_passes_in_draw_order_, + child_pass_id, + child_rect, + gfx::Transform()); AddQuad(child_pass, child_rect, SK_ColorBLUE); RenderPass::Id root_pass_id(1, 0); - TestRenderPass* root_pass = AddRenderPass( - &render_passes, root_pass_id, viewport_rect, gfx::Transform()); + TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); AddQuad(root_pass, viewport_rect, SK_ColorGREEN); AddRenderPassQuad(root_pass, child_pass); AddRenderPassQuad(child_pass, grand_child_pass); - renderer.DecideRenderPassAllocationsForFrame( - *renderer_client.render_passes_in_draw_order()); - renderer.DrawFrame( - renderer_client.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer.DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); } class DiscardCheckingContext : public TestWebGraphicsContext3D { @@ -1060,7 +1121,7 @@ class NonReshapableOutputSurface : public FakeOutputSurface { void set_fixed_size(gfx::Size size) { surface_size_ = size; } }; -TEST(GLRendererTest2, NoDiscardOnPartialUpdates) { +TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) { scoped_ptr<DiscardCheckingContext> context_owned(new DiscardCheckingContext); DiscardCheckingContext* context = context_owned.get(); @@ -1077,61 +1138,75 @@ TEST(GLRendererTest2, NoDiscardOnPartialUpdates) { LayerTreeSettings settings; settings.partial_swap_enabled = true; FakeRendererClient renderer_client; - renderer_client.set_viewport(gfx::Rect(0, 0, 100, 100)); - renderer_client.set_clip(gfx::Rect(0, 0, 100, 100)); FakeRendererGL renderer(&renderer_client, &settings, output_surface.get(), resource_provider.get()); EXPECT_TRUE(renderer.Capabilities().using_partial_swap); - gfx::Rect viewport_rect(renderer_client.DeviceViewport()); - ScopedPtrVector<RenderPass>& render_passes = - *renderer_client.render_passes_in_draw_order(); - render_passes.clear(); + gfx::Rect viewport_rect(100, 100); + gfx::Rect clip_rect(100, 100); { // Partial frame, should not discard. RenderPass::Id root_pass_id(1, 0); - TestRenderPass* root_pass = AddRenderPass( - &render_passes, root_pass_id, viewport_rect, gfx::Transform()); + TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); AddQuad(root_pass, viewport_rect, SK_ColorGREEN); root_pass->damage_rect = gfx::RectF(2.f, 2.f, 3.f, 3.f); - renderer.DecideRenderPassAllocationsForFrame( - *renderer_client.render_passes_in_draw_order()); - renderer.DrawFrame( - renderer_client.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer.DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + clip_rect, + true, + false); EXPECT_EQ(0, context->discarded()); context->reset(); } { // Full frame, should discard. RenderPass::Id root_pass_id(1, 0); - TestRenderPass* root_pass = AddRenderPass( - &render_passes, root_pass_id, viewport_rect, gfx::Transform()); + TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); AddQuad(root_pass, viewport_rect, SK_ColorGREEN); root_pass->damage_rect = gfx::RectF(root_pass->output_rect); - renderer.DecideRenderPassAllocationsForFrame( - *renderer_client.render_passes_in_draw_order()); - renderer.DrawFrame( - renderer_client.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer.DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + clip_rect, + true, + false); EXPECT_EQ(1, context->discarded()); context->reset(); } { // Partial frame, disallow partial swap, should discard. RenderPass::Id root_pass_id(1, 0); - TestRenderPass* root_pass = AddRenderPass( - &render_passes, root_pass_id, viewport_rect, gfx::Transform()); + TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); AddQuad(root_pass, viewport_rect, SK_ColorGREEN); root_pass->damage_rect = gfx::RectF(2.f, 2.f, 3.f, 3.f); - renderer.DecideRenderPassAllocationsForFrame( - *renderer_client.render_passes_in_draw_order()); - renderer.DrawFrame( - renderer_client.render_passes_in_draw_order(), NULL, 1.f, false, false); + renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer.DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + clip_rect, + false, + false); EXPECT_EQ(1, context->discarded()); context->reset(); } @@ -1139,68 +1214,90 @@ TEST(GLRendererTest2, NoDiscardOnPartialUpdates) { // Full frame, external scissor is set, should not discard. output_surface->set_has_external_stencil_test(true); RenderPass::Id root_pass_id(1, 0); - TestRenderPass* root_pass = AddRenderPass( - &render_passes, root_pass_id, viewport_rect, gfx::Transform()); + TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); AddQuad(root_pass, viewport_rect, SK_ColorGREEN); root_pass->damage_rect = gfx::RectF(root_pass->output_rect); root_pass->has_transparent_background = false; - renderer.DecideRenderPassAllocationsForFrame( - *renderer_client.render_passes_in_draw_order()); - renderer.DrawFrame( - renderer_client.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer.DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + clip_rect, + true, + false); EXPECT_EQ(0, context->discarded()); context->reset(); output_surface->set_has_external_stencil_test(false); } { // Full frame, clipped, should not discard. - renderer_client.set_clip(gfx::Rect(10, 10, 10, 10)); + clip_rect = gfx::Rect(10, 10, 10, 10); RenderPass::Id root_pass_id(1, 0); - TestRenderPass* root_pass = AddRenderPass( - &render_passes, root_pass_id, viewport_rect, gfx::Transform()); + TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); AddQuad(root_pass, viewport_rect, SK_ColorGREEN); root_pass->damage_rect = gfx::RectF(root_pass->output_rect); - renderer.DecideRenderPassAllocationsForFrame( - *renderer_client.render_passes_in_draw_order()); - renderer.DrawFrame( - renderer_client.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer.DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + clip_rect, + true, + false); EXPECT_EQ(0, context->discarded()); context->reset(); } { // Full frame, doesn't cover the surface, should not discard. - renderer_client.set_viewport(gfx::Rect(10, 10, 10, 10)); - viewport_rect = renderer_client.DeviceViewport(); + viewport_rect = gfx::Rect(10, 10, 10, 10); RenderPass::Id root_pass_id(1, 0); - TestRenderPass* root_pass = AddRenderPass( - &render_passes, root_pass_id, viewport_rect, gfx::Transform()); + TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); AddQuad(root_pass, viewport_rect, SK_ColorGREEN); root_pass->damage_rect = gfx::RectF(root_pass->output_rect); - renderer.DecideRenderPassAllocationsForFrame( - *renderer_client.render_passes_in_draw_order()); - renderer.DrawFrame( - renderer_client.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer.DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + clip_rect, + true, + false); EXPECT_EQ(0, context->discarded()); context->reset(); } { // Full frame, doesn't cover the surface (no offset), should not discard. - renderer_client.set_viewport(gfx::Rect(0, 0, 50, 50)); - renderer_client.set_clip(gfx::Rect(0, 0, 100, 100)); - viewport_rect = renderer_client.DeviceViewport(); + clip_rect = gfx::Rect(100, 100); + viewport_rect = gfx::Rect(50, 50); RenderPass::Id root_pass_id(1, 0); - TestRenderPass* root_pass = AddRenderPass( - &render_passes, root_pass_id, viewport_rect, gfx::Transform()); + TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); AddQuad(root_pass, viewport_rect, SK_ColorGREEN); root_pass->damage_rect = gfx::RectF(root_pass->output_rect); - renderer.DecideRenderPassAllocationsForFrame( - *renderer_client.render_passes_in_draw_order()); - renderer.DrawFrame( - renderer_client.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer.DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + clip_rect, + true, + false); EXPECT_EQ(0, context->discarded()); context->reset(); } @@ -1236,7 +1333,7 @@ class FlippedScissorAndViewportContext : public TestWebGraphicsContext3D { bool did_call_scissor_; }; -TEST(GLRendererTest2, ScissorAndViewportWithinNonreshapableSurface) { +TEST_F(GLRendererTest, ScissorAndViewportWithinNonreshapableSurface) { // In Android WebView, the OutputSurface is unable to respect reshape() calls // and maintains a fixed size. This test verifies that glViewport and // glScissor's Y coordinate is flipped correctly in this environment, and that @@ -1254,35 +1351,35 @@ TEST(GLRendererTest2, ScissorAndViewportWithinNonreshapableSurface) { LayerTreeSettings settings; FakeRendererClient renderer_client; - renderer_client.set_viewport(gfx::Rect(10, 10, 100, 100)); - renderer_client.set_clip(gfx::Rect(10, 10, 100, 100)); FakeRendererGL renderer(&renderer_client, &settings, output_surface.get(), resource_provider.get()); EXPECT_FALSE(renderer.Capabilities().using_partial_swap); - gfx::Rect viewport_rect(renderer_client.DeviceViewport().size()); + gfx::Rect device_viewport_rect(10, 10, 100, 100); + gfx::Rect viewport_rect(device_viewport_rect.size()); gfx::Rect quad_rect = gfx::Rect(20, 20, 20, 20); - ScopedPtrVector<RenderPass>& render_passes = - *renderer_client.render_passes_in_draw_order(); - render_passes.clear(); RenderPass::Id root_pass_id(1, 0); - TestRenderPass* root_pass = AddRenderPass( - &render_passes, root_pass_id, viewport_rect, gfx::Transform()); + TestRenderPass* root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); AddClippedQuad(root_pass, quad_rect, SK_ColorGREEN); - renderer.DecideRenderPassAllocationsForFrame( - *renderer_client.render_passes_in_draw_order()); - renderer.DrawFrame( - renderer_client.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer.DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer.DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + device_viewport_rect, + device_viewport_rect, + true, + false); } TEST_F(GLRendererShaderTest, DrawRenderPassQuadShaderPermutations) { - gfx::Rect viewport_rect(renderer_client_.DeviceViewport()); - ScopedPtrVector<RenderPass>* render_passes = - renderer_client_.render_passes_in_draw_order(); + gfx::Rect viewport_rect(1, 1); gfx::Rect child_rect(50, 50); RenderPass::Id child_pass_id(2, 0); @@ -1291,11 +1388,11 @@ TEST_F(GLRendererShaderTest, DrawRenderPassQuadShaderPermutations) { RenderPass::Id root_pass_id(1, 0); TestRenderPass* root_pass; - cc::ResourceProvider::ResourceId mask = - resource_provider_->CreateResource(gfx::Size(20, 12), - GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, - resource_provider_->best_texture_format()); + cc::ResourceProvider::ResourceId mask = resource_provider_->CreateResource( + gfx::Size(20, 12), + GL_CLAMP_TO_EDGE, + ResourceProvider::TextureUsageAny, + resource_provider_->best_texture_format()); resource_provider_->AllocateForTesting(mask); SkScalar matrix[20]; @@ -1325,152 +1422,205 @@ TEST_F(GLRendererShaderTest, DrawRenderPassQuadShaderPermutations) { transform_causing_aa.Rotate(20.0); // RenderPassProgram - render_passes->clear(); - - child_pass = AddRenderPass( - render_passes, child_pass_id, child_rect, gfx::Transform()); - - root_pass = AddRenderPass( - render_passes, root_pass_id, viewport_rect, gfx::Transform()); - - AddRenderPassQuad(root_pass, - child_pass, - 0, - FilterOperations(), - gfx::Transform()); - - renderer_->DecideRenderPassAllocationsForFrame( - *renderer_client_.render_passes_in_draw_order()); - renderer_->DrawFrame( - renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true, false); + child_pass = AddRenderPass(&render_passes_in_draw_order_, + child_pass_id, + child_rect, + gfx::Transform()); + + root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); + + AddRenderPassQuad( + root_pass, child_pass, 0, FilterOperations(), gfx::Transform()); + + renderer_->DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer_->DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); TestRenderPassProgram(TexCoordPrecisionMedium); // RenderPassColorMatrixProgram - render_passes->clear(); + render_passes_in_draw_order_.clear(); - child_pass = AddRenderPass( - render_passes, child_pass_id, child_rect, transform_causing_aa); + child_pass = AddRenderPass(&render_passes_in_draw_order_, + child_pass_id, + child_rect, + transform_causing_aa); - root_pass = AddRenderPass( - render_passes, root_pass_id, viewport_rect, gfx::Transform()); + root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); AddRenderPassQuad(root_pass, child_pass, 0, filters, gfx::Transform()); - renderer_->DecideRenderPassAllocationsForFrame( - *renderer_client_.render_passes_in_draw_order()); - renderer_->DrawFrame( - renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer_->DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer_->DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); TestRenderPassColorMatrixProgram(TexCoordPrecisionMedium); // RenderPassMaskProgram - render_passes->clear(); - - child_pass = AddRenderPass( - render_passes, child_pass_id, child_rect, gfx::Transform()); - - root_pass = AddRenderPass( - render_passes, root_pass_id, viewport_rect, gfx::Transform()); - - AddRenderPassQuad(root_pass, - child_pass, - mask, - FilterOperations(), - gfx::Transform()); - - renderer_->DecideRenderPassAllocationsForFrame( - *renderer_client_.render_passes_in_draw_order()); - renderer_->DrawFrame( - renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true, false); + render_passes_in_draw_order_.clear(); + + child_pass = AddRenderPass(&render_passes_in_draw_order_, + child_pass_id, + child_rect, + gfx::Transform()); + + root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); + + AddRenderPassQuad( + root_pass, child_pass, mask, FilterOperations(), gfx::Transform()); + + renderer_->DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer_->DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); TestRenderPassMaskProgram(TexCoordPrecisionMedium); // RenderPassMaskColorMatrixProgram - render_passes->clear(); + render_passes_in_draw_order_.clear(); - child_pass = AddRenderPass( - render_passes, child_pass_id, child_rect, gfx::Transform()); + child_pass = AddRenderPass(&render_passes_in_draw_order_, + child_pass_id, + child_rect, + gfx::Transform()); - root_pass = AddRenderPass( - render_passes, root_pass_id, viewport_rect, gfx::Transform()); + root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); AddRenderPassQuad(root_pass, child_pass, mask, filters, gfx::Transform()); - renderer_->DecideRenderPassAllocationsForFrame( - *renderer_client_.render_passes_in_draw_order()); - renderer_->DrawFrame( - renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer_->DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer_->DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); TestRenderPassMaskColorMatrixProgram(TexCoordPrecisionMedium); // RenderPassProgramAA - render_passes->clear(); - - child_pass = AddRenderPass( - render_passes, child_pass_id, child_rect, transform_causing_aa); - - root_pass = AddRenderPass( - render_passes, root_pass_id, viewport_rect, gfx::Transform()); - - AddRenderPassQuad(root_pass, - child_pass, - 0, - FilterOperations(), - transform_causing_aa); - - renderer_->DecideRenderPassAllocationsForFrame( - *renderer_client_.render_passes_in_draw_order()); - renderer_->DrawFrame( - renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true, false); + render_passes_in_draw_order_.clear(); + + child_pass = AddRenderPass(&render_passes_in_draw_order_, + child_pass_id, + child_rect, + transform_causing_aa); + + root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); + + AddRenderPassQuad( + root_pass, child_pass, 0, FilterOperations(), transform_causing_aa); + + renderer_->DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer_->DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); TestRenderPassProgramAA(TexCoordPrecisionMedium); // RenderPassColorMatrixProgramAA - render_passes->clear(); + render_passes_in_draw_order_.clear(); - child_pass = AddRenderPass( - render_passes, child_pass_id, child_rect, transform_causing_aa); + child_pass = AddRenderPass(&render_passes_in_draw_order_, + child_pass_id, + child_rect, + transform_causing_aa); - root_pass = AddRenderPass( - render_passes, root_pass_id, viewport_rect, gfx::Transform()); + root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); AddRenderPassQuad(root_pass, child_pass, 0, filters, transform_causing_aa); - renderer_->DecideRenderPassAllocationsForFrame( - *renderer_client_.render_passes_in_draw_order()); - renderer_->DrawFrame( - renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer_->DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer_->DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); TestRenderPassColorMatrixProgramAA(TexCoordPrecisionMedium); // RenderPassMaskProgramAA - render_passes->clear(); - - child_pass = AddRenderPass(render_passes, child_pass_id, child_rect, - transform_causing_aa); - - root_pass = AddRenderPass(render_passes, root_pass_id, viewport_rect, - gfx::Transform()); - - AddRenderPassQuad(root_pass, child_pass, mask, FilterOperations(), - transform_causing_aa); - - renderer_->DecideRenderPassAllocationsForFrame( - *renderer_client_.render_passes_in_draw_order()); - renderer_->DrawFrame( - renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true, false); + render_passes_in_draw_order_.clear(); + + child_pass = AddRenderPass(&render_passes_in_draw_order_, + child_pass_id, + child_rect, + transform_causing_aa); + + root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); + + AddRenderPassQuad( + root_pass, child_pass, mask, FilterOperations(), transform_causing_aa); + + renderer_->DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer_->DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); TestRenderPassMaskProgramAA(TexCoordPrecisionMedium); // RenderPassMaskColorMatrixProgramAA - render_passes->clear(); + render_passes_in_draw_order_.clear(); - child_pass = AddRenderPass(render_passes, child_pass_id, child_rect, - transform_causing_aa); + child_pass = AddRenderPass(&render_passes_in_draw_order_, + child_pass_id, + child_rect, + transform_causing_aa); - root_pass = AddRenderPass(render_passes, root_pass_id, viewport_rect, - transform_causing_aa); + root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + transform_causing_aa); AddRenderPassQuad(root_pass, child_pass, mask, filters, transform_causing_aa); - renderer_->DecideRenderPassAllocationsForFrame( - *renderer_client_.render_passes_in_draw_order()); - renderer_->DrawFrame( - renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer_->DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer_->DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); TestRenderPassMaskColorMatrixProgramAA(TexCoordPrecisionMedium); } @@ -1481,7 +1631,7 @@ TEST_F(GLRendererShaderTest, DrawRenderPassQuadSkipsAAForClippingTransform) { RenderPass::Id child_pass_id(2, 0); TestRenderPass* child_pass; - gfx::Rect viewport_rect(renderer_client_.DeviceViewport()); + gfx::Rect viewport_rect(1, 1); RenderPass::Id root_pass_id(1, 0); TestRenderPass* root_pass; @@ -1493,33 +1643,30 @@ TEST_F(GLRendererShaderTest, DrawRenderPassQuadSkipsAAForClippingTransform) { // Verify that the test transform and test rect actually do cause the clipped // flag to trigger. Otherwise we are not testing the intended scenario. bool clipped = false; - MathUtil::MapQuad(transform_preventing_aa, - gfx::QuadF(child_rect), - &clipped); + MathUtil::MapQuad(transform_preventing_aa, gfx::QuadF(child_rect), &clipped); ASSERT_TRUE(clipped); - // Set up the render pass quad to be drawn - ScopedPtrVector<RenderPass>* render_passes = - renderer_client_.render_passes_in_draw_order(); - - render_passes->clear(); + child_pass = AddRenderPass(&render_passes_in_draw_order_, + child_pass_id, + child_rect, + transform_preventing_aa); - child_pass = AddRenderPass( - render_passes, child_pass_id, child_rect, transform_preventing_aa); + root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); - root_pass = AddRenderPass( - render_passes, root_pass_id, viewport_rect, gfx::Transform()); + AddRenderPassQuad( + root_pass, child_pass, 0, FilterOperations(), transform_preventing_aa); - AddRenderPassQuad(root_pass, - child_pass, - 0, - FilterOperations(), - transform_preventing_aa); - - renderer_->DecideRenderPassAllocationsForFrame( - *renderer_client_.render_passes_in_draw_order()); - renderer_->DrawFrame( - renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer_->DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer_->DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); // If use_aa incorrectly ignores clipping, it will use the // RenderPassProgramAA shader instead of the RenderPassProgram. @@ -1527,10 +1674,7 @@ TEST_F(GLRendererShaderTest, DrawRenderPassQuadSkipsAAForClippingTransform) { } TEST_F(GLRendererShaderTest, DrawSolidColorShader) { - gfx::Rect viewport_rect(renderer_client_.DeviceViewport()); - ScopedPtrVector<RenderPass>* render_passes = - renderer_client_.render_passes_in_draw_order(); - + gfx::Rect viewport_rect(1, 1); RenderPass::Id root_pass_id(1, 0); TestRenderPass* root_pass; @@ -1538,19 +1682,23 @@ TEST_F(GLRendererShaderTest, DrawSolidColorShader) { pixel_aligned_transform_causing_aa.Translate(25.5f, 25.5f); pixel_aligned_transform_causing_aa.Scale(0.5f, 0.5f); - render_passes->clear(); - - root_pass = AddRenderPass( - render_passes, root_pass_id, viewport_rect, gfx::Transform()); + root_pass = AddRenderPass(&render_passes_in_draw_order_, + root_pass_id, + viewport_rect, + gfx::Transform()); AddTransformedQuad(root_pass, viewport_rect, SK_ColorYELLOW, pixel_aligned_transform_causing_aa); - renderer_->DecideRenderPassAllocationsForFrame( - *renderer_client_.render_passes_in_draw_order()); - renderer_->DrawFrame( - renderer_client_.render_passes_in_draw_order(), NULL, 1.f, true, false); + renderer_->DecideRenderPassAllocationsForFrame(render_passes_in_draw_order_); + renderer_->DrawFrame(&render_passes_in_draw_order_, + NULL, + 1.f, + viewport_rect, + viewport_rect, + true, + false); TestSolidColorProgramAA(); } @@ -1580,9 +1728,9 @@ class OutputSurfaceMockContext : public TestWebGraphicsContext3D { class MockOutputSurface : public OutputSurface { public: MockOutputSurface() - : OutputSurface(TestContextProvider::Create( - scoped_ptr<TestWebGraphicsContext3D>( - new StrictMock<OutputSurfaceMockContext>))) { + : OutputSurface( + TestContextProvider::Create(scoped_ptr<TestWebGraphicsContext3D>( + new StrictMock<OutputSurfaceMockContext>))) { surface_size_ = gfx::Size(100, 100); } virtual ~MockOutputSurface() {} @@ -1594,7 +1742,7 @@ class MockOutputSurface : public OutputSurface { MOCK_METHOD1(SwapBuffers, void(CompositorFrame* frame)); }; -class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient { +class MockOutputSurfaceTest : public GLRendererTest { protected: virtual void SetUp() { FakeOutputSurfaceClient output_surface_client_; @@ -1603,35 +1751,41 @@ class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient { resource_provider_ = ResourceProvider::Create(&output_surface_, NULL, 0, false, 1).Pass(); - renderer_.reset(new FakeRendererGL( - this, &settings_, &output_surface_, resource_provider_.get())); + renderer_.reset(new FakeRendererGL(&renderer_client_, + &settings_, + &output_surface_, + resource_provider_.get())); } void SwapBuffers() { renderer_->SwapBuffers(CompositorFrameMetadata()); } - void DrawFrame(float device_scale_factor) { - gfx::Rect viewport_rect(DeviceViewport()); - ScopedPtrVector<RenderPass>* render_passes = render_passes_in_draw_order(); - render_passes->clear(); - + void DrawFrame(float device_scale_factor, gfx::Rect device_viewport_rect) { RenderPass::Id render_pass_id(1, 0); - TestRenderPass* render_pass = AddRenderPass( - render_passes, render_pass_id, viewport_rect, gfx::Transform()); - AddQuad(render_pass, viewport_rect, SK_ColorGREEN); + TestRenderPass* render_pass = AddRenderPass(&render_passes_in_draw_order_, + render_pass_id, + device_viewport_rect, + gfx::Transform()); + AddQuad(render_pass, device_viewport_rect, SK_ColorGREEN); EXPECT_CALL(output_surface_, EnsureBackbuffer()).WillRepeatedly(Return()); EXPECT_CALL(output_surface_, - Reshape(DeviceViewport().size(), device_scale_factor)).Times(1); + Reshape(device_viewport_rect.size(), device_scale_factor)) + .Times(1); EXPECT_CALL(output_surface_, BindFramebuffer()).Times(1); EXPECT_CALL(*Context(), drawElements(_, _, _, _)).Times(1); renderer_->DecideRenderPassAllocationsForFrame( - *render_passes_in_draw_order()); - renderer_->DrawFrame( - render_passes_in_draw_order(), NULL, device_scale_factor, true, false); + render_passes_in_draw_order_); + renderer_->DrawFrame(&render_passes_in_draw_order_, + NULL, + device_scale_factor, + device_viewport_rect, + device_viewport_rect, + true, + false); } OutputSurfaceMockContext* Context() { @@ -1643,36 +1797,38 @@ class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient { FakeOutputSurfaceClient output_surface_client_; StrictMock<MockOutputSurface> output_surface_; scoped_ptr<ResourceProvider> resource_provider_; + FakeRendererClient renderer_client_; scoped_ptr<FakeRendererGL> renderer_; }; TEST_F(MockOutputSurfaceTest, DrawFrameAndSwap) { - DrawFrame(1.f); + gfx::Rect device_viewport_rect(1, 1); + DrawFrame(1.f, device_viewport_rect); EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); renderer_->SwapBuffers(CompositorFrameMetadata()); } TEST_F(MockOutputSurfaceTest, DrawFrameAndResizeAndSwap) { - DrawFrame(1.f); + gfx::Rect device_viewport_rect(1, 1); + + DrawFrame(1.f, device_viewport_rect); EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); renderer_->SwapBuffers(CompositorFrameMetadata()); - set_viewport(gfx::Rect(0, 0, 2, 2)); - renderer_->ViewportChanged(); + device_viewport_rect = gfx::Rect(2, 2); - DrawFrame(2.f); + DrawFrame(2.f, device_viewport_rect); EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); renderer_->SwapBuffers(CompositorFrameMetadata()); - DrawFrame(2.f); + DrawFrame(2.f, device_viewport_rect); EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); renderer_->SwapBuffers(CompositorFrameMetadata()); - set_viewport(gfx::Rect(0, 0, 1, 1)); - renderer_->ViewportChanged(); + device_viewport_rect = gfx::Rect(1, 1); - DrawFrame(1.f); + DrawFrame(1.f, device_viewport_rect); EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); renderer_->SwapBuffers(CompositorFrameMetadata()); } @@ -1713,8 +1869,7 @@ TEST_F(GLRendererTestSyncPoint, SignalSyncPointOnLostContext) { context3d->finish(); // Post a task after the sync point. base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&OtherCallback, &other_callback_count)); + FROM_HERE, base::Bind(&OtherCallback, &other_callback_count)); base::MessageLoop::current()->Run(); @@ -1743,8 +1898,7 @@ TEST_F(GLRendererTestSyncPoint, SignalSyncPoint) { context3d->finish(); // Post a task after the sync point. base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&OtherCallback, &other_callback_count)); + FROM_HERE, base::Bind(&OtherCallback, &other_callback_count)); base::MessageLoop::current()->Run(); diff --git a/cc/output/renderer.h b/cc/output/renderer.h index 65c2cb5..147b535f 100644 --- a/cc/output/renderer.h +++ b/cc/output/renderer.h @@ -18,15 +18,7 @@ class ScopedResource; class CC_EXPORT RendererClient { public: - // These return the draw viewport and clip in non-y-flipped window space. - // Note that while a draw is in progress, these are guaranteed to be - // contained within the output surface size. - virtual gfx::Rect DeviceViewport() const = 0; - virtual gfx::Rect DeviceClip() const = 0; virtual void SetFullRootLayerDamage() = 0; - - protected: - virtual ~RendererClient() {} }; class CC_EXPORT Renderer { @@ -35,8 +27,6 @@ class CC_EXPORT Renderer { virtual const RendererCapabilities& Capabilities() const = 0; - virtual void ViewportChanged() {} - virtual bool CanReadPixels() const = 0; virtual void DecideRenderPassAllocationsForFrame( @@ -46,9 +36,13 @@ class CC_EXPORT Renderer { // This passes ownership of the render passes to the renderer. It should // consume them, and empty the list. The parameters here may change from frame // to frame and should not be cached. + // The |device_viewport_rect| and |device_clip_rect| are in non-y-flipped + // window space. virtual void DrawFrame(RenderPassList* render_passes_in_draw_order, ContextProvider* offscreen_context_provider, float device_scale_factor, + gfx::Rect device_viewport_rect, + gfx::Rect device_clip_rect, bool allow_partial_swap, bool disable_picture_quad_image_filtering) = 0; diff --git a/cc/output/renderer_pixeltest.cc b/cc/output/renderer_pixeltest.cc index 23190c3..4aa0901 100644 --- a/cc/output/renderer_pixeltest.cc +++ b/cc/output/renderer_pixeltest.cc @@ -1845,8 +1845,7 @@ TYPED_TEST(RendererPixelTest, PictureDrawQuadDisableImageFiltering) { ExactPixelComparator(true))); } -TYPED_TEST(RendererPixelTest, - PictureDrawQuadNonIdentityScale) { +TYPED_TEST(RendererPixelTest, PictureDrawQuadNonIdentityScale) { gfx::Size pile_tile_size(1000, 1000); gfx::Rect viewport(this->device_viewport_size_); // TODO(enne): the renderer should figure this out on its own. diff --git a/cc/output/software_renderer_unittest.cc b/cc/output/software_renderer_unittest.cc index 4829f20b..fc1c707 100644 --- a/cc/output/software_renderer_unittest.cc +++ b/cc/output/software_renderer_unittest.cc @@ -45,15 +45,7 @@ class SoftwareRendererTest : public testing::Test, public RendererClient { SoftwareRenderer* renderer() const { return renderer_.get(); } - void set_viewport(gfx::Rect viewport) { - viewport_ = viewport; - } - // RendererClient implementation. - virtual gfx::Rect DeviceViewport() const OVERRIDE { - return viewport_; - } - virtual gfx::Rect DeviceClip() const OVERRIDE { return DeviceViewport(); } virtual void SetFullRootLayerDamage() OVERRIDE {} protected: @@ -62,7 +54,6 @@ class SoftwareRendererTest : public testing::Test, public RendererClient { scoped_ptr<FakeOutputSurface> output_surface_; scoped_ptr<ResourceProvider> resource_provider_; scoped_ptr<SoftwareRenderer> renderer_; - gfx::Rect viewport_; }; TEST_F(SoftwareRendererTest, SolidColorQuad) { @@ -71,7 +62,6 @@ TEST_F(SoftwareRendererTest, SolidColorQuad) { gfx::Rect outer_rect(outer_size); gfx::Rect inner_rect(gfx::Point(1, 1), inner_size); gfx::Rect visible_rect(gfx::Point(1, 2), gfx::Size(98, 97)); - set_viewport(gfx::Rect(outer_size)); InitializeRenderer(make_scoped_ptr(new SoftwareOutputDevice)); @@ -100,12 +90,18 @@ TEST_F(SoftwareRendererTest, SolidColorQuad) { list.push_back(root_render_pass.PassAs<RenderPass>()); float device_scale_factor = 1.f; - renderer()->DrawFrame(&list, NULL, device_scale_factor, true, false); + gfx::Rect device_viewport_rect(outer_size); + renderer()->DrawFrame(&list, + NULL, + device_scale_factor, + device_viewport_rect, + device_viewport_rect, + true, + false); SkBitmap output; - output.setConfig(SkBitmap::kARGB_8888_Config, - DeviceViewport().width(), - DeviceViewport().height()); + output.setConfig( + SkBitmap::kARGB_8888_Config, outer_rect.width(), outer_rect.height()); output.allocPixels(); renderer()->GetFramebufferPixels(output.getPixels(), outer_rect); @@ -123,7 +119,6 @@ TEST_F(SoftwareRendererTest, TileQuad) { gfx::Size inner_size(98, 98); gfx::Rect outer_rect(outer_size); gfx::Rect inner_rect(gfx::Point(1, 1), inner_size); - set_viewport(gfx::Rect(outer_size)); InitializeRenderer(make_scoped_ptr(new SoftwareOutputDevice)); ResourceProvider::ResourceId resource_yellow = @@ -161,7 +156,7 @@ TEST_F(SoftwareRendererTest, TileQuad) { gfx::Rect(inner_size), gfx::Vector2d()); - gfx::Rect root_rect = DeviceViewport(); + gfx::Rect root_rect = outer_rect; scoped_ptr<SharedQuadState> shared_quad_state = SharedQuadState::Create(); shared_quad_state->SetAll(gfx::Transform(), @@ -198,12 +193,18 @@ TEST_F(SoftwareRendererTest, TileQuad) { list.push_back(root_render_pass.PassAs<RenderPass>()); float device_scale_factor = 1.f; - renderer()->DrawFrame(&list, NULL, device_scale_factor, true, false); + gfx::Rect device_viewport_rect(outer_size); + renderer()->DrawFrame(&list, + NULL, + device_scale_factor, + device_viewport_rect, + device_viewport_rect, + true, + false); SkBitmap output; - output.setConfig(SkBitmap::kARGB_8888_Config, - DeviceViewport().width(), - DeviceViewport().height()); + output.setConfig( + SkBitmap::kARGB_8888_Config, outer_size.width(), outer_size.height()); output.allocPixels(); renderer()->GetFramebufferPixels(output.getPixels(), outer_rect); @@ -220,7 +221,6 @@ TEST_F(SoftwareRendererTest, TileQuadVisibleRect) { gfx::Rect tile_rect(tile_size); gfx::Rect visible_rect = tile_rect; visible_rect.Inset(1, 2, 3, 4); - set_viewport(gfx::Rect(tile_size)); InitializeRenderer(make_scoped_ptr(new SoftwareOutputDevice)); ResourceProvider::ResourceId resource_cyan = @@ -245,7 +245,7 @@ TEST_F(SoftwareRendererTest, TileQuadVisibleRect) { gfx::Rect(tile_size), gfx::Vector2d()); - gfx::Rect root_rect = DeviceViewport(); + gfx::Rect root_rect(tile_size); scoped_ptr<SharedQuadState> shared_quad_state = SharedQuadState::Create(); shared_quad_state->SetAll(gfx::Transform(), @@ -274,12 +274,18 @@ TEST_F(SoftwareRendererTest, TileQuadVisibleRect) { list.push_back(root_render_pass.PassAs<RenderPass>()); float device_scale_factor = 1.f; - renderer()->DrawFrame(&list, NULL, device_scale_factor, true, false); + gfx::Rect device_viewport_rect(tile_size); + renderer()->DrawFrame(&list, + NULL, + device_scale_factor, + device_viewport_rect, + device_viewport_rect, + true, + false); SkBitmap output; - output.setConfig(SkBitmap::kARGB_8888_Config, - DeviceViewport().width(), - DeviceViewport().height()); + output.setConfig( + SkBitmap::kARGB_8888_Config, tile_size.width(), tile_size.height()); output.allocPixels(); renderer()->GetFramebufferPixels(output.getPixels(), tile_rect); @@ -306,7 +312,6 @@ TEST_F(SoftwareRendererTest, TileQuadVisibleRect) { TEST_F(SoftwareRendererTest, ShouldClearRootRenderPass) { float device_scale_factor = 1.f; gfx::Rect viewport_rect(0, 0, 100, 100); - set_viewport(viewport_rect); settings_.should_clear_root_render_pass = false; InitializeRenderer(make_scoped_ptr(new SoftwareOutputDevice)); @@ -326,7 +331,13 @@ TEST_F(SoftwareRendererTest, ShouldClearRootRenderPass) { AddQuad(root_clear_pass, viewport_rect, SK_ColorGREEN); renderer()->DecideRenderPassAllocationsForFrame(list); - renderer()->DrawFrame(&list, NULL, device_scale_factor, true, false); + renderer()->DrawFrame(&list, + NULL, + device_scale_factor, + viewport_rect, + viewport_rect, + true, + false); renderer()->GetFramebufferPixels(output.getPixels(), viewport_rect); EXPECT_EQ(SK_ColorGREEN, output.getColor(0, 0)); @@ -345,7 +356,13 @@ TEST_F(SoftwareRendererTest, ShouldClearRootRenderPass) { AddQuad(root_smaller_pass, smaller_rect, SK_ColorMAGENTA); renderer()->DecideRenderPassAllocationsForFrame(list); - renderer()->DrawFrame(&list, NULL, device_scale_factor, true, false); + renderer()->DrawFrame(&list, + NULL, + device_scale_factor, + viewport_rect, + viewport_rect, + true, + false); renderer()->GetFramebufferPixels(output.getPixels(), viewport_rect); // If we didn't clear, the borders should still be green. @@ -362,7 +379,6 @@ TEST_F(SoftwareRendererTest, ShouldClearRootRenderPass) { TEST_F(SoftwareRendererTest, RenderPassVisibleRect) { float device_scale_factor = 1.f; gfx::Rect viewport_rect(0, 0, 100, 100); - set_viewport(viewport_rect); InitializeRenderer(make_scoped_ptr(new SoftwareOutputDevice)); RenderPassList list; @@ -392,7 +408,13 @@ TEST_F(SoftwareRendererTest, RenderPassVisibleRect) { root_clear_pass->quad_list[0]->visible_rect = interior_visible_rect; renderer()->DecideRenderPassAllocationsForFrame(list); - renderer()->DrawFrame(&list, NULL, device_scale_factor, true, false); + renderer()->DrawFrame(&list, + NULL, + device_scale_factor, + viewport_rect, + viewport_rect, + true, + false); renderer()->GetFramebufferPixels(output.getPixels(), viewport_rect); EXPECT_EQ(SK_ColorGREEN, output.getColor(0, 0)); diff --git a/cc/test/layer_tree_pixel_test.cc b/cc/test/layer_tree_pixel_test.cc index 3ad33dc..5388cba 100644 --- a/cc/test/layer_tree_pixel_test.cc +++ b/cc/test/layer_tree_pixel_test.cc @@ -34,7 +34,6 @@ LayerTreePixelTest::~LayerTreePixelTest() {} scoped_ptr<OutputSurface> LayerTreePixelTest::CreateOutputSurface( bool fallback) { - gfx::Vector2d viewport_offset(20, 10); gfx::Size surface_expansion_size(40, 60); scoped_ptr<PixelTestOutputSurface> output_surface; @@ -62,7 +61,6 @@ scoped_ptr<OutputSurface> LayerTreePixelTest::CreateOutputSurface( } } - output_surface->set_viewport_offset(viewport_offset); output_surface->set_surface_expansion_size(surface_expansion_size); return output_surface.PassAs<OutputSurface>(); } @@ -75,6 +73,21 @@ LayerTreePixelTest::OffscreenContextProvider() { return provider; } +void LayerTreePixelTest::CommitCompleteOnThread(LayerTreeHostImpl* impl) { + LayerTreeImpl* commit_tree = + impl->pending_tree() ? impl->pending_tree() : impl->active_tree(); + if (commit_tree->source_frame_number() != 0) + return; + + gfx::Rect viewport = impl->DeviceViewport(); + // The viewport has a 0,0 origin without external influence. + EXPECT_EQ(gfx::Point().ToString(), viewport.origin().ToString()); + // Be that influence! + viewport += gfx::Vector2d(20, 10); + impl->SetExternalDrawConstraints(gfx::Transform(), viewport, viewport, true); + EXPECT_EQ(viewport.ToString(), impl->DeviceViewport().ToString()); +} + scoped_ptr<CopyOutputRequest> LayerTreePixelTest::CreateCopyOutputRequest() { return CopyOutputRequest::CreateBitmapRequest( base::Bind(&LayerTreePixelTest::ReadbackResult, base::Unretained(this))); diff --git a/cc/test/layer_tree_pixel_test.h b/cc/test/layer_tree_pixel_test.h index d6e14c2..92d955f 100644 --- a/cc/test/layer_tree_pixel_test.h +++ b/cc/test/layer_tree_pixel_test.h @@ -31,6 +31,7 @@ class LayerTreePixelTest : public LayerTreeTest { virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) OVERRIDE; virtual scoped_refptr<ContextProvider> OffscreenContextProvider() OVERRIDE; + virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE; virtual scoped_ptr<CopyOutputRequest> CreateCopyOutputRequest(); diff --git a/cc/test/pixel_test.cc b/cc/test/pixel_test.cc index 0e6b60d..414a325 100644 --- a/cc/test/pixel_test.cc +++ b/cc/test/pixel_test.cc @@ -16,6 +16,7 @@ #include "cc/output/software_renderer.h" #include "cc/resources/resource_provider.h" #include "cc/resources/texture_mailbox_deleter.h" +#include "cc/test/fake_output_surface_client.h" #include "cc/test/paths.h" #include "cc/test/pixel_test_output_surface.h" #include "cc/test/pixel_test_software_output_device.h" @@ -27,52 +28,10 @@ namespace cc { -class PixelTest::PixelTestRendererClient - : public RendererClient, public OutputSurfaceClient { - public: - explicit PixelTestRendererClient(gfx::Rect device_viewport) - : device_viewport_(device_viewport), device_clip_(device_viewport) {} - - // RendererClient implementation. - virtual gfx::Rect DeviceViewport() const OVERRIDE { - return device_viewport_; - } - virtual gfx::Rect DeviceClip() const OVERRIDE { return device_clip_; } - virtual void SetFullRootLayerDamage() OVERRIDE {} - - // OutputSurfaceClient implementation. - virtual bool DeferredInitialize( - scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE { - return false; - } - virtual void ReleaseGL() OVERRIDE {} - virtual void SetNeedsRedrawRect(gfx::Rect damage_rect) OVERRIDE {} - virtual void BeginImplFrame(const BeginFrameArgs& args) OVERRIDE {} - virtual void DidSwapBuffers() OVERRIDE {} - virtual void OnSwapBuffersComplete() OVERRIDE {} - virtual void ReclaimResources(const CompositorFrameAck* ack) OVERRIDE {} - virtual void DidLoseOutputSurface() OVERRIDE {} - virtual void SetExternalDrawConstraints( - const gfx::Transform& transform, - gfx::Rect viewport, - gfx::Rect clip, - bool valid_for_tile_management) OVERRIDE { - device_viewport_ = viewport; - device_clip_ = clip; - } - virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE {} - virtual void SetTreeActivationCallback(const base::Closure&) OVERRIDE {} - - private: - gfx::Rect device_viewport_; - gfx::Rect device_clip_; -}; - PixelTest::PixelTest() : device_viewport_size_(gfx::Size(200, 200)), disable_picture_quad_image_filtering_(false), - fake_client_( - new PixelTestRendererClient(gfx::Rect(device_viewport_size_))) {} + output_surface_client_(new FakeOutputSurfaceClient) {} PixelTest::~PixelTest() {} @@ -112,12 +71,19 @@ bool PixelTest::RunPixelTestWithReadbackTarget( } float device_scale_factor = 1.f; + gfx::Rect device_viewport_rect = + gfx::Rect(device_viewport_size_) + external_device_viewport_offset_; + gfx::Rect device_clip_rect = external_device_clip_rect_.IsEmpty() + ? device_viewport_rect + : external_device_clip_rect_; bool allow_partial_swap = true; renderer_->DecideRenderPassAllocationsForFrame(*pass_list); renderer_->DrawFrame(pass_list, offscreen_contexts.get(), device_scale_factor, + device_viewport_rect, + device_clip_rect, allow_partial_swap, disable_picture_quad_image_filtering_); @@ -155,20 +121,19 @@ bool PixelTest::PixelsMatchReference(const base::FilePath& ref_file, } void PixelTest::SetUpGLRenderer(bool use_skia_gpu_backend) { - CHECK(fake_client_); CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL)); using webkit::gpu::ContextProviderInProcess; output_surface_.reset(new PixelTestOutputSurface( ContextProviderInProcess::CreateOffscreen())); - output_surface_->BindToClient(fake_client_.get()); + output_surface_->BindToClient(output_surface_client_.get()); resource_provider_ = ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1); texture_mailbox_deleter_ = make_scoped_ptr(new TextureMailboxDeleter); - renderer_ = GLRenderer::Create(fake_client_.get(), + renderer_ = GLRenderer::Create(this, &settings_, output_surface_.get(), resource_provider_.get(), @@ -176,12 +141,9 @@ void PixelTest::SetUpGLRenderer(bool use_skia_gpu_backend) { 0).PassAs<DirectRenderer>(); } -void PixelTest::ForceExpandedViewport(gfx::Size surface_expansion, - gfx::Vector2d viewport_offset) { +void PixelTest::ForceExpandedViewport(gfx::Size surface_expansion) { static_cast<PixelTestOutputSurface*>(output_surface_.get()) ->set_surface_expansion_size(surface_expansion); - static_cast<PixelTestOutputSurface*>(output_surface_.get()) - ->set_viewport_offset(viewport_offset); SoftwareOutputDevice* device = output_surface_->software_device(); if (device) { static_cast<PixelTestSoftwareOutputDevice*>(device) @@ -189,9 +151,12 @@ void PixelTest::ForceExpandedViewport(gfx::Size surface_expansion, } } +void PixelTest::ForceViewportOffset(gfx::Vector2d viewport_offset) { + external_device_viewport_offset_ = viewport_offset; +} + void PixelTest::ForceDeviceClip(gfx::Rect clip) { - static_cast<PixelTestOutputSurface*>(output_surface_.get()) - ->set_device_clip(clip); + external_device_clip_rect_ = clip; } void PixelTest::EnableExternalStencilTest() { @@ -200,18 +165,14 @@ void PixelTest::EnableExternalStencilTest() { } void PixelTest::SetUpSoftwareRenderer() { - CHECK(fake_client_); - scoped_ptr<SoftwareOutputDevice> device(new PixelTestSoftwareOutputDevice()); output_surface_.reset(new PixelTestOutputSurface(device.Pass())); - output_surface_->BindToClient(fake_client_.get()); + output_surface_->BindToClient(output_surface_client_.get()); resource_provider_ = ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1); - renderer_ = SoftwareRenderer::Create(fake_client_.get(), - &settings_, - output_surface_.get(), - resource_provider_.get()) - .PassAs<DirectRenderer>(); + renderer_ = SoftwareRenderer::Create( + this, &settings_, output_surface_.get(), resource_provider_.get()) + .PassAs<DirectRenderer>(); } } // namespace cc diff --git a/cc/test/pixel_test.h b/cc/test/pixel_test.h index 6885096..0835cdc 100644 --- a/cc/test/pixel_test.h +++ b/cc/test/pixel_test.h @@ -16,11 +16,12 @@ namespace cc { class CopyOutputResult; class DirectRenderer; -class SoftwareRenderer; +class FakeOutputSurfaceClient; class OutputSurface; class ResourceProvider; +class SoftwareRenderer; -class PixelTest : public testing::Test { +class PixelTest : public testing::Test, RendererClient { protected: PixelTest(); virtual ~PixelTest(); @@ -46,21 +47,26 @@ class PixelTest : public testing::Test { gfx::Size device_viewport_size_; bool disable_picture_quad_image_filtering_; class PixelTestRendererClient; + scoped_ptr<FakeOutputSurfaceClient> output_surface_client_; scoped_ptr<OutputSurface> output_surface_; scoped_ptr<ResourceProvider> resource_provider_; scoped_ptr<TextureMailboxDeleter> texture_mailbox_deleter_; - scoped_ptr<PixelTestRendererClient> fake_client_; scoped_ptr<DirectRenderer> renderer_; scoped_ptr<SkBitmap> result_bitmap_; + gfx::Vector2d external_device_viewport_offset_; + gfx::Rect external_device_clip_rect_; void SetUpGLRenderer(bool use_skia_gpu_backend); void SetUpSoftwareRenderer(); - void ForceExpandedViewport(gfx::Size surface_expansion, - gfx::Vector2d viewport_offset); + void ForceExpandedViewport(gfx::Size surface_expansion); + void ForceViewportOffset(gfx::Vector2d viewport_offset); void ForceDeviceClip(gfx::Rect clip); void EnableExternalStencilTest(); + // RendererClient implementation. + virtual void SetFullRootLayerDamage() OVERRIDE {} + private: void ReadbackResult(base::Closure quit_run_loop, scoped_ptr<CopyOutputResult> result); @@ -128,7 +134,8 @@ inline bool RendererPixelTest<GLRenderer>::ExpandedViewport() const { template<> inline void RendererPixelTest<GLRendererWithExpandedViewport>::SetUp() { SetUpGLRenderer(false); - ForceExpandedViewport(gfx::Size(50, 50), gfx::Vector2d(10, 20)); + ForceExpandedViewport(gfx::Size(50, 50)); + ForceViewportOffset(gfx::Vector2d(10, 20)); } template <> @@ -161,7 +168,8 @@ inline bool RendererPixelTest<SoftwareRenderer>::ExpandedViewport() const { template<> inline void RendererPixelTest<SoftwareRendererWithExpandedViewport>::SetUp() { SetUpSoftwareRenderer(); - ForceExpandedViewport(gfx::Size(50, 50), gfx::Vector2d(10, 20)); + ForceExpandedViewport(gfx::Size(50, 50)); + ForceViewportOffset(gfx::Vector2d(10, 20)); } template <> diff --git a/cc/test/pixel_test_output_surface.cc b/cc/test/pixel_test_output_surface.cc index 8306cc8..1ea89e2 100644 --- a/cc/test/pixel_test_output_surface.cc +++ b/cc/test/pixel_test_output_surface.cc @@ -21,13 +21,6 @@ void PixelTestOutputSurface::Reshape(gfx::Size size, float scale_factor) { gfx::Size expanded_size(size.width() + surface_expansion_size_.width(), size.height() + surface_expansion_size_.height()); OutputSurface::Reshape(expanded_size, scale_factor); - - gfx::Rect offset_viewport = gfx::Rect(size) + viewport_offset_; - gfx::Rect offset_clip = device_clip_.IsEmpty() - ? offset_viewport - : device_clip_ + viewport_offset_; - SetExternalDrawConstraints( - gfx::Transform(), offset_viewport, offset_clip, true); } bool PixelTestOutputSurface::HasExternalStencilTest() const { diff --git a/cc/test/pixel_test_output_surface.h b/cc/test/pixel_test_output_surface.h index 0b58ac26..2aca4f2 100644 --- a/cc/test/pixel_test_output_surface.h +++ b/cc/test/pixel_test_output_surface.h @@ -22,20 +22,12 @@ class PixelTestOutputSurface : public OutputSurface { void set_surface_expansion_size(gfx::Size surface_expansion_size) { surface_expansion_size_ = surface_expansion_size; } - void set_viewport_offset(gfx::Vector2d viewport_offset) { - viewport_offset_ = viewport_offset; - } - void set_device_clip(gfx::Rect device_clip) { - device_clip_ = device_clip; - } void set_has_external_stencil_test(bool has_test) { external_stencil_test_ = has_test; } private: gfx::Size surface_expansion_size_; - gfx::Vector2d viewport_offset_; - gfx::Rect device_clip_; bool external_stencil_test_; }; diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index bb493c8..4bda19a 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -1387,9 +1387,13 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame, scoped_ptr<SoftwareRenderer> temp_software_renderer = SoftwareRenderer::Create(this, &settings_, output_surface_.get(), NULL); - temp_software_renderer->DrawFrame( - &frame->render_passes, NULL, device_scale_factor_, allow_partial_swap, - disable_picture_quad_image_filtering); + temp_software_renderer->DrawFrame(&frame->render_passes, + NULL, + device_scale_factor_, + DeviceViewport(), + DeviceClip(), + allow_partial_swap, + disable_picture_quad_image_filtering); } else { // We don't track damage on the HUD layer (it interacts with damage tracking // visualizations), so disable partial swaps to make the HUD layer display @@ -1399,6 +1403,8 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame, renderer_->DrawFrame(&frame->render_passes, offscreen_context_provider_.get(), device_scale_factor_, + DeviceViewport(), + DeviceClip(), allow_partial_swap, false); } @@ -1894,9 +1900,6 @@ void LayerTreeHostImpl::SetViewportSize(gfx::Size device_viewport_size) { UpdateMaxScrollOffset(); - if (renderer_) - renderer_->ViewportChanged(); - client_->OnCanDrawStateChanged(CanDraw()); SetFullRootLayerDamage(); } @@ -1922,9 +1925,6 @@ void LayerTreeHostImpl::SetDeviceScaleFactor(float device_scale_factor) { return; device_scale_factor_ = device_scale_factor; - if (renderer_) - renderer_->ViewportChanged(); - UpdateMaxScrollOffset(); SetFullRootLayerDamage(); } diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 5c0aba9..8d1230b 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -209,13 +209,7 @@ class CC_EXPORT LayerTreeHostImpl // invariant relative to page scale). gfx::SizeF UnscaledScrollableViewportSize() const; - // RendererClient implementation - - // Viewport rectangle and clip in nonflipped window space. These rects - // should only be used by Renderer subclasses to populate glViewport/glClip - // and their software-mode equivalents. - virtual gfx::Rect DeviceViewport() const OVERRIDE; - virtual gfx::Rect DeviceClip() const OVERRIDE; + // RendererClient implementation. virtual void SetFullRootLayerDamage() OVERRIDE; // TileManagerClient implementation. @@ -418,6 +412,11 @@ class CC_EXPORT LayerTreeHostImpl void ScheduleMicroBenchmark(scoped_ptr<MicroBenchmarkImpl> benchmark); CompositorFrameMetadata MakeCompositorFrameMetadata() const; + // Viewport rectangle and clip in nonflipped window space. These rects + // should only be used by Renderer subclasses to populate glViewport/glClip + // and their software-mode equivalents. + gfx::Rect DeviceViewport() const; + gfx::Rect DeviceClip() const; // When a SwapPromiseMonitor is created on the impl thread, it calls // InsertSwapPromiseMonitor() to register itself with LayerTreeHostImpl. |