diff options
author | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-10 22:49:04 +0000 |
---|---|---|
committer | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-10 22:49:04 +0000 |
commit | c05dfbbb633b1955c57e0b5e12e8cd26801231c4 (patch) | |
tree | 87e5490353b1a69b901336081ceab73bffd9842d | |
parent | 6a8ab1dceba32f021f112ce62c8ac80d70e658c3 (diff) | |
download | chromium_src-c05dfbbb633b1955c57e0b5e12e8cd26801231c4.zip chromium_src-c05dfbbb633b1955c57e0b5e12e8cd26801231c4.tar.gz chromium_src-c05dfbbb633b1955c57e0b5e12e8cd26801231c4.tar.bz2 |
Pass resourceless software mode in SetExternalConstraints
This fixes the bug that resourceless software mode not
dirtying the draw properties.
This allows OutputSurface::ForcedDrawToSoftwareDevice to be
removed. And merged the valid_for_tile_management parameter
into resourceless_software_draw. This effectively reverses
the last bool parameter on SetExternalDrawConstraints.
BUG=391829
Review URL: https://codereview.chromium.org/376683004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282445 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | android_webview/browser/parent_output_surface.cc | 7 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl.cc | 4 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl_unittest.cc | 36 | ||||
-rw-r--r-- | cc/output/output_surface.cc | 13 | ||||
-rw-r--r-- | cc/output/output_surface.h | 7 | ||||
-rw-r--r-- | cc/output/output_surface_client.h | 2 | ||||
-rw-r--r-- | cc/output/software_renderer.cc | 4 | ||||
-rw-r--r-- | cc/surfaces/display.h | 2 | ||||
-rw-r--r-- | cc/test/fake_output_surface.cc | 7 | ||||
-rw-r--r-- | cc/test/fake_output_surface.h | 6 | ||||
-rw-r--r-- | cc/test/fake_output_surface_client.h | 2 | ||||
-rw-r--r-- | cc/test/layer_tree_pixel_test.cc | 4 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 40 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.h | 8 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl_unittest.cc | 26 | ||||
-rw-r--r-- | cc/trees/layer_tree_impl.cc | 8 | ||||
-rw-r--r-- | cc/trees/layer_tree_impl.h | 2 | ||||
-rw-r--r-- | content/browser/android/in_process/synchronous_compositor_output_surface.cc | 21 | ||||
-rw-r--r-- | content/browser/android/in_process/synchronous_compositor_output_surface.h | 3 |
19 files changed, 101 insertions, 101 deletions
diff --git a/android_webview/browser/parent_output_surface.cc b/android_webview/browser/parent_output_surface.cc index 0150eaa..54b7f97 100644 --- a/android_webview/browser/parent_output_surface.cc +++ b/android_webview/browser/parent_output_surface.cc @@ -27,9 +27,10 @@ void ParentOutputSurface::SetDrawConstraints(const gfx::Size& surface_size, const gfx::Rect& clip) { DCHECK(client_); surface_size_ = surface_size; - gfx::Transform identity; - gfx::Rect empty; - SetExternalDrawConstraints(identity, empty, clip, true); + const gfx::Transform identity; + const gfx::Rect empty; + const bool resourceless_software_draw = false; + SetExternalDrawConstraints(identity, empty, clip, resourceless_software_draw); } } // namespace android_webview diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index 885ac67..094cd4f 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc @@ -401,7 +401,9 @@ void PictureLayerImpl::UpdateTiles( DCHECK(!occlusion_tracker || layer_tree_impl()->settings().use_occlusion_for_tile_prioritization); - if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { + // Transforms and viewport are invalid for tile management inside a + // resourceless software draw, so don't update them. + if (!layer_tree_impl()->resourceless_software_draw()) { visible_rect_for_tile_priority_ = visible_content_rect(); viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); screen_space_transform_for_tile_priority_ = screen_space_transform(); diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index 2258655..1ff6cd8 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -319,11 +319,13 @@ TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); // UpdateTiles with valid viewport. Should update tile viewport. - bool valid_for_tile_management = true; + // Note viewport is considered invalid if and only if in resourceless + // software draw. + bool resourceless_software_draw = false; gfx::Rect viewport = gfx::Rect(layer_bounds); gfx::Transform transform; host_impl_.SetExternalDrawConstraints( - transform, viewport, viewport, valid_for_tile_management); + transform, viewport, viewport, resourceless_software_draw); active_layer_->draw_properties().visible_content_rect = viewport; active_layer_->draw_properties().screen_space_transform = transform; active_layer_->UpdateTiles(NULL); @@ -341,13 +343,13 @@ TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { // Should not update tile viewport. time_ticks += base::TimeDelta::FromMilliseconds(200); host_impl_.SetCurrentFrameTimeTicks(time_ticks); - valid_for_tile_management = false; + resourceless_software_draw = true; viewport = gfx::ScaleToEnclosingRect(viewport, 2); transform.Translate(1.f, 1.f); active_layer_->draw_properties().visible_content_rect = viewport; active_layer_->draw_properties().screen_space_transform = transform; host_impl_.SetExternalDrawConstraints( - transform, viewport, viewport, valid_for_tile_management); + transform, viewport, viewport, resourceless_software_draw); active_layer_->UpdateTiles(NULL); EXPECT_RECT_EQ(visible_rect_for_tile_priority, @@ -361,9 +363,9 @@ TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { // Keep expanded viewport but mark it valid. Should update tile viewport. time_ticks += base::TimeDelta::FromMilliseconds(200); host_impl_.SetCurrentFrameTimeTicks(time_ticks); - valid_for_tile_management = true; + resourceless_software_draw = false; host_impl_.SetExternalDrawConstraints( - transform, viewport, viewport, valid_for_tile_management); + transform, viewport, viewport, resourceless_software_draw); active_layer_->UpdateTiles(NULL); EXPECT_FALSE(visible_rect_for_tile_priority == @@ -391,10 +393,10 @@ TEST_F(PictureLayerImplTest, InvalidViewportAfterReleaseResources) { Region invalidation; AddDefaultTilingsWithInvalidation(invalidation); - bool valid_for_tile_management = false; + bool resourceless_software_draw = true; gfx::Rect viewport = gfx::Rect(layer_bounds); host_impl_.SetExternalDrawConstraints( - gfx::Transform(), viewport, viewport, valid_for_tile_management); + gfx::Transform(), viewport, viewport, resourceless_software_draw); ResetTilingsAndRasterScales(); host_impl_.pending_tree()->UpdateDrawProperties(); host_impl_.active_tree()->UpdateDrawProperties(); @@ -2418,11 +2420,13 @@ TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); // UpdateTiles with valid viewport. Should update tile viewport. - bool valid_for_tile_management = true; + // Note viewport is considered invalid if and only if in resourceless + // software draw. + bool resourceless_software_draw = false; gfx::Rect viewport = gfx::Rect(layer_bounds); gfx::Transform transform; host_impl_.SetExternalDrawConstraints( - transform, viewport, viewport, valid_for_tile_management); + transform, viewport, viewport, resourceless_software_draw); active_layer_->draw_properties().visible_content_rect = viewport; active_layer_->draw_properties().screen_space_transform = transform; active_layer_->UpdateTiles(NULL); @@ -2440,13 +2444,13 @@ TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { // Should not update tile viewport. time_ticks += base::TimeDelta::FromMilliseconds(200); host_impl_.SetCurrentFrameTimeTicks(time_ticks); - valid_for_tile_management = false; + resourceless_software_draw = true; viewport = gfx::ScaleToEnclosingRect(viewport, 2); transform.Translate(1.f, 1.f); active_layer_->draw_properties().visible_content_rect = viewport; active_layer_->draw_properties().screen_space_transform = transform; host_impl_.SetExternalDrawConstraints( - transform, viewport, viewport, valid_for_tile_management); + transform, viewport, viewport, resourceless_software_draw); active_layer_->UpdateTiles(NULL); EXPECT_RECT_EQ(visible_rect_for_tile_priority, @@ -2460,9 +2464,9 @@ TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { // Keep expanded viewport but mark it valid. Should update tile viewport. time_ticks += base::TimeDelta::FromMilliseconds(200); host_impl_.SetCurrentFrameTimeTicks(time_ticks); - valid_for_tile_management = true; + resourceless_software_draw = false; host_impl_.SetExternalDrawConstraints( - transform, viewport, viewport, valid_for_tile_management); + transform, viewport, viewport, resourceless_software_draw); active_layer_->UpdateTiles(NULL); EXPECT_FALSE(visible_rect_for_tile_priority == @@ -2490,10 +2494,10 @@ TEST_F(NoLowResPictureLayerImplTest, InvalidViewportAfterReleaseResources) { Region invalidation; AddDefaultTilingsWithInvalidation(invalidation); - bool valid_for_tile_management = false; + bool resourceless_software_draw = true; gfx::Rect viewport = gfx::Rect(layer_bounds); host_impl_.SetExternalDrawConstraints( - gfx::Transform(), viewport, viewport, valid_for_tile_management); + gfx::Transform(), viewport, viewport, resourceless_software_draw); ResetTilingsAndRasterScales(); host_impl_.pending_tree()->UpdateDrawProperties(); host_impl_.active_tree()->UpdateDrawProperties(); diff --git a/cc/output/output_surface.cc b/cc/output/output_surface.cc index 369a152..518ec78 100644 --- a/cc/output/output_surface.cc +++ b/cc/output/output_surface.cc @@ -91,12 +91,13 @@ void OutputSurface::SetExternalStencilTest(bool enabled) { external_stencil_test_enabled_ = enabled; } -void OutputSurface::SetExternalDrawConstraints(const gfx::Transform& transform, - const gfx::Rect& viewport, - const gfx::Rect& clip, - bool valid_for_tile_management) { +void OutputSurface::SetExternalDrawConstraints( + const gfx::Transform& transform, + const gfx::Rect& viewport, + const gfx::Rect& clip, + bool resourceless_software_draw) { client_->SetExternalDrawConstraints( - transform, viewport, clip, valid_for_tile_management); + transform, viewport, clip, resourceless_software_draw); } OutputSurface::~OutputSurface() { @@ -107,8 +108,6 @@ bool OutputSurface::HasExternalStencilTest() const { return external_stencil_test_enabled_; } -bool OutputSurface::ForcedDrawToSoftwareDevice() const { return false; } - bool OutputSurface::BindToClient(OutputSurfaceClient* client) { DCHECK(client); client_ = client; diff --git a/cc/output/output_surface.h b/cc/output/output_surface.h index 4ba3e5f..07c0f26 100644 --- a/cc/output/output_surface.h +++ b/cc/output/output_surface.h @@ -94,11 +94,6 @@ class CC_EXPORT OutputSurface { return software_device_.get(); } - // In the case where both the context3d and software_device are present - // (namely Android WebView), this is called to determine whether the software - // device should be used on the current frame. - virtual bool ForcedDrawToSoftwareDevice() const; - // Called by the compositor on the compositor thread. This is a place where // thread-specific data for the output surface can be initialized, since from // this point on the output surface will only be used on the compositor @@ -171,7 +166,7 @@ class CC_EXPORT OutputSurface { void SetExternalDrawConstraints(const gfx::Transform& transform, const gfx::Rect& viewport, const gfx::Rect& clip, - bool valid_for_tile_management); + bool resourceless_software_draw); private: void SetUpContext3d(); diff --git a/cc/output/output_surface_client.h b/cc/output/output_surface_client.h index 9742a6f..2c6c128 100644 --- a/cc/output/output_surface_client.h +++ b/cc/output/output_surface_client.h @@ -41,7 +41,7 @@ class CC_EXPORT OutputSurfaceClient { virtual void SetExternalDrawConstraints(const gfx::Transform& transform, const gfx::Rect& viewport, const gfx::Rect& clip, - bool valid_for_tile_management) = 0; + bool resourceless_software_draw) = 0; virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) = 0; // If set, |callback| will be called subsequent to each new tree activation, // regardless of the compositor visibility or damage. |callback| must remain diff --git a/cc/output/software_renderer.cc b/cc/output/software_renderer.cc index 0f6babc..0a04f09 100644 --- a/cc/output/software_renderer.cc +++ b/cc/output/software_renderer.cc @@ -472,7 +472,9 @@ void SoftwareRenderer::DrawTextureQuad(const DrawingFrame* frame, void SoftwareRenderer::DrawTileQuad(const DrawingFrame* frame, const TileDrawQuad* quad) { - DCHECK(!output_surface_->ForcedDrawToSoftwareDevice()); + // |resource_provider_| can be NULL in resourceless software draws, which + // should never produce tile quads in the first place. + DCHECK(resource_provider_); DCHECK(IsSoftwareResource(quad->resource_id)); ResourceProvider::ScopedReadLockSoftware lock(resource_provider_, diff --git a/cc/surfaces/display.h b/cc/surfaces/display.h index b032afb..9718597 100644 --- a/cc/surfaces/display.h +++ b/cc/surfaces/display.h @@ -61,7 +61,7 @@ class CC_SURFACES_EXPORT Display : public OutputSurfaceClient, const gfx::Transform& transform, const gfx::Rect& viewport, const gfx::Rect& clip, - bool valid_for_tile_management) OVERRIDE {} + bool resourceless_software_draw) OVERRIDE {} virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE {} virtual void SetTreeActivationCallback( const base::Closure& callback) OVERRIDE {} diff --git a/cc/test/fake_output_surface.cc b/cc/test/fake_output_surface.cc index 3346b56..9c027ea 100644 --- a/cc/test/fake_output_surface.cc +++ b/cc/test/fake_output_surface.cc @@ -21,7 +21,6 @@ FakeOutputSurface::FakeOutputSurface( client_(NULL), num_sent_frames_(0), needs_begin_frame_(false), - forced_draw_to_software_device_(false), has_external_stencil_test_(false), fake_weak_ptr_factory_(this) { if (delegated_rendering) { @@ -36,7 +35,6 @@ FakeOutputSurface::FakeOutputSurface( : OutputSurface(software_device.Pass()), client_(NULL), num_sent_frames_(0), - forced_draw_to_software_device_(false), has_external_stencil_test_(false), fake_weak_ptr_factory_(this) { if (delegated_rendering) { @@ -52,7 +50,6 @@ FakeOutputSurface::FakeOutputSurface( : OutputSurface(context_provider, software_device.Pass()), client_(NULL), num_sent_frames_(0), - forced_draw_to_software_device_(false), has_external_stencil_test_(false), fake_weak_ptr_factory_(this) { if (delegated_rendering) { @@ -103,10 +100,6 @@ void FakeOutputSurface::OnBeginFrame() { } -bool FakeOutputSurface::ForcedDrawToSoftwareDevice() const { - return forced_draw_to_software_device_; -} - bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { if (OutputSurface::BindToClient(client)) { client_ = client; diff --git a/cc/test/fake_output_surface.h b/cc/test/fake_output_surface.h index f8acc1d..4fd0d72 100644 --- a/cc/test/fake_output_surface.h +++ b/cc/test/fake_output_surface.h @@ -97,11 +97,6 @@ class FakeOutputSurface : public OutputSurface { virtual void SetNeedsBeginFrame(bool enable) OVERRIDE; bool needs_begin_frame() const { return needs_begin_frame_; } - void set_forced_draw_to_software_device(bool forced) { - forced_draw_to_software_device_ = forced; - } - virtual bool ForcedDrawToSoftwareDevice() const OVERRIDE; - virtual bool BindToClient(OutputSurfaceClient* client) OVERRIDE; using OutputSurface::ReleaseGL; @@ -144,7 +139,6 @@ class FakeOutputSurface : public OutputSurface { CompositorFrame last_sent_frame_; size_t num_sent_frames_; bool needs_begin_frame_; - bool forced_draw_to_software_device_; bool has_external_stencil_test_; TransferableResourceArray resources_held_by_parent_; base::WeakPtrFactory<FakeOutputSurface> fake_weak_ptr_factory_; diff --git a/cc/test/fake_output_surface_client.h b/cc/test/fake_output_surface_client.h index 7058e52..5e887b8 100644 --- a/cc/test/fake_output_surface_client.h +++ b/cc/test/fake_output_surface_client.h @@ -42,7 +42,7 @@ class FakeOutputSurfaceClient : public OutputSurfaceClient { const gfx::Transform& transform, const gfx::Rect& viewport, const gfx::Rect& clip, - bool valid_for_tile_management) OVERRIDE {} + bool resourceless_software_draw) OVERRIDE {} virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE; virtual void SetTreeActivationCallback(const base::Closure&) OVERRIDE {} diff --git a/cc/test/layer_tree_pixel_test.cc b/cc/test/layer_tree_pixel_test.cc index 063f4d9..cbb936b 100644 --- a/cc/test/layer_tree_pixel_test.cc +++ b/cc/test/layer_tree_pixel_test.cc @@ -75,7 +75,9 @@ void LayerTreePixelTest::CommitCompleteOnThread(LayerTreeHostImpl* impl) { EXPECT_EQ(gfx::Point().ToString(), viewport.origin().ToString()); // Be that influence! viewport += gfx::Vector2d(20, 10); - impl->SetExternalDrawConstraints(gfx::Transform(), viewport, viewport, true); + bool resourceless_software_draw = false; + impl->SetExternalDrawConstraints( + gfx::Transform(), viewport, viewport, resourceless_software_draw); EXPECT_EQ(viewport.ToString(), impl->DeviceViewport().ToString()); } diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index c3738e5..b874400 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -246,7 +246,7 @@ LayerTreeHostImpl::LayerTreeHostImpl( device_scale_factor_(1.f), overhang_ui_resource_id_(0), overdraw_bottom_height_(0.f), - device_viewport_valid_for_tile_management_(true), + resourceless_software_draw_(false), begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), animation_registrar_(AnimationRegistrar::Create()), rendering_stats_instrumentation_(rendering_stats_instrumentation), @@ -569,17 +569,17 @@ void LayerTreeHostImpl::FrameData::AppendRenderPass( render_passes.push_back(render_pass.Pass()); } -static DrawMode GetDrawMode(OutputSurface* output_surface) { - if (output_surface->ForcedDrawToSoftwareDevice()) { +DrawMode LayerTreeHostImpl::GetDrawMode() const { + if (resourceless_software_draw_) { return DRAW_MODE_RESOURCELESS_SOFTWARE; - } else if (output_surface->context_provider()) { + } else if (output_surface_->context_provider()) { return DRAW_MODE_HARDWARE; } else { - DCHECK_EQ(!output_surface->software_device(), - output_surface->capabilities().delegated_rendering && - !output_surface->capabilities().deferred_gl_initialization) - << output_surface->capabilities().delegated_rendering << " " - << output_surface->capabilities().deferred_gl_initialization; + DCHECK_EQ(!output_surface_->software_device(), + output_surface_->capabilities().delegated_rendering && + !output_surface_->capabilities().deferred_gl_initialization) + << output_surface_->capabilities().delegated_rendering << " " + << output_surface_->capabilities().deferred_gl_initialization; return DRAW_MODE_SOFTWARE; } } @@ -798,7 +798,7 @@ DrawResult LayerTreeHostImpl::CalculateRenderPasses( int layers_drawn = 0; - const DrawMode draw_mode = GetDrawMode(output_surface_.get()); + const DrawMode draw_mode = GetDrawMode(); LayerIteratorType end = LayerIteratorType::End(frame->render_surface_layer_list); @@ -935,8 +935,9 @@ DrawResult LayerTreeHostImpl::CalculateRenderPasses( DCHECK(!frame->render_passes.empty()); // Should only have one render pass in resourceless software mode. - if (output_surface_->ForcedDrawToSoftwareDevice()) - DCHECK_EQ(1u, frame->render_passes.size()); + DCHECK(draw_mode != DRAW_MODE_RESOURCELESS_SOFTWARE || + frame->render_passes.size() == 1u) + << frame->render_passes.size(); return draw_result; } @@ -1325,15 +1326,16 @@ void LayerTreeHostImpl::SetExternalDrawConstraints( const gfx::Transform& transform, const gfx::Rect& viewport, const gfx::Rect& clip, - bool valid_for_tile_management) { - if (external_transform_ != transform || external_viewport_ != viewport) { + bool resourceless_software_draw) { + if (external_transform_ != transform || external_viewport_ != viewport || + resourceless_software_draw_ != resourceless_software_draw) { active_tree_->set_needs_update_draw_properties(); } external_transform_ = transform; external_viewport_ = viewport; external_clip_ = clip; - device_viewport_valid_for_tile_management_ = valid_for_tile_management; + resourceless_software_draw_ = resourceless_software_draw; } void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { @@ -1476,16 +1478,18 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame, TracedValue::FromValue(AsValueWithFrame(frame).release())); } + const DrawMode draw_mode = GetDrawMode(); + // Because the contents of the HUD depend on everything else in the frame, the // contents of its texture are updated as the last thing before the frame is // drawn. if (active_tree_->hud_layer()) { TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); - active_tree_->hud_layer()->UpdateHudTexture( - GetDrawMode(output_surface_.get()), resource_provider_.get()); + active_tree_->hud_layer()->UpdateHudTexture(draw_mode, + resource_provider_.get()); } - if (output_surface_->ForcedDrawToSoftwareDevice()) { + if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) { bool disable_picture_quad_image_filtering = IsCurrentlyScrolling() || needs_animate_layers(); diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 4528dc7..f6982a7b 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -216,9 +216,7 @@ class CC_EXPORT LayerTreeHostImpl // Resets all of the trees to an empty state. void ResetTreesForTesting(); - bool device_viewport_valid_for_tile_management() const { - return device_viewport_valid_for_tile_management_; - } + DrawMode GetDrawMode() const; // Viewport size in draw space: this size is in physical pixels and is used // for draw properties, tilings, quads and render passes. @@ -255,7 +253,7 @@ class CC_EXPORT LayerTreeHostImpl const gfx::Transform& transform, const gfx::Rect& viewport, const gfx::Rect& clip, - bool valid_for_tile_management) OVERRIDE; + bool resourceless_software_draw) OVERRIDE; virtual void DidLoseOutputSurface() OVERRIDE; virtual void DidSwapBuffers() OVERRIDE; virtual void DidSwapBuffersComplete() OVERRIDE; @@ -668,7 +666,7 @@ class CC_EXPORT LayerTreeHostImpl gfx::Transform external_transform_; gfx::Rect external_viewport_; gfx::Rect external_clip_; - bool device_viewport_valid_for_tile_management_; + bool resourceless_software_draw_; gfx::Rect viewport_damage_rect_; diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index f76abbb..ae2253b 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -5586,8 +5586,14 @@ TEST_F(LayerTreeHostImplTest, ForcedDrawToSoftwareDeviceBasicRender) { SetupScrollAndContentsLayers(gfx::Size(100, 100)); - output_surface->set_forced_draw_to_software_device(true); - EXPECT_TRUE(output_surface->ForcedDrawToSoftwareDevice()); + const gfx::Transform external_transform; + const gfx::Rect external_viewport; + const gfx::Rect external_clip; + const bool resourceless_software_draw = true; + host_impl_->SetExternalDrawConstraints(external_transform, + external_viewport, + external_clip, + resourceless_software_draw); EXPECT_EQ(0, software_device->frames_began_); EXPECT_EQ(0, software_device->frames_ended_); @@ -5613,8 +5619,14 @@ TEST_F(LayerTreeHostImplTest, EXPECT_TRUE(CreateHostImpl(DefaultSettings(), scoped_ptr<OutputSurface>(output_surface))); - output_surface->set_forced_draw_to_software_device(true); - EXPECT_TRUE(output_surface->ForcedDrawToSoftwareDevice()); + const gfx::Transform external_transform; + const gfx::Rect external_viewport; + const gfx::Rect external_clip; + const bool resourceless_software_draw = true; + host_impl_->SetExternalDrawConstraints(external_transform, + external_viewport, + external_clip, + resourceless_software_draw); // SolidColorLayerImpl will be drawn. scoped_ptr<SolidColorLayerImpl> root_layer = @@ -6702,13 +6714,13 @@ TEST_F(LayerTreeHostImplTest, ExternalTransformReflectedInNextDraw) { gfx::Transform external_transform; const gfx::Rect external_viewport(layer_size); const gfx::Rect external_clip(layer_size); - const bool valid_for_tile_management = true; + const bool resourceless_software_draw = false; LayerImpl* layer = SetupScrollAndContentsLayers(layer_size); host_impl_->SetExternalDrawConstraints(external_transform, external_viewport, external_clip, - valid_for_tile_management); + resourceless_software_draw); DrawFrame(); EXPECT_TRANSFORMATION_MATRIX_EQ( external_transform, layer->draw_properties().target_space_transform); @@ -6717,7 +6729,7 @@ TEST_F(LayerTreeHostImplTest, ExternalTransformReflectedInNextDraw) { host_impl_->SetExternalDrawConstraints(external_transform, external_viewport, external_clip, - valid_for_tile_management); + resourceless_software_draw); DrawFrame(); EXPECT_TRANSFORMATION_MATRIX_EQ( external_transform, layer->draw_properties().target_space_transform); diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc index ae5f956..908e993 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc @@ -459,8 +459,7 @@ bool LayerTreeImpl::UpdateDrawProperties() { source_frame_number_); LayerImpl* page_scale_layer = page_scale_layer_ ? page_scale_layer_ : InnerViewportContainerLayer(); - bool can_render_to_separate_surface = - !output_surface()->ForcedDrawToSoftwareDevice(); + bool can_render_to_separate_surface = !resourceless_software_draw(); ++render_surface_layer_list_id_; LayerTreeHostCommon::CalcDrawPropsImplInputs inputs( @@ -680,8 +679,9 @@ MemoryHistory* LayerTreeImpl::memory_history() const { return layer_tree_host_impl_->memory_history(); } -bool LayerTreeImpl::device_viewport_valid_for_tile_management() const { - return layer_tree_host_impl_->device_viewport_valid_for_tile_management(); +bool LayerTreeImpl::resourceless_software_draw() const { + return layer_tree_host_impl_->GetDrawMode() == + DRAW_MODE_RESOURCELESS_SOFTWARE; } gfx::Size LayerTreeImpl::device_viewport_size() const { diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h index d48058a..ea636ca 100644 --- a/cc/trees/layer_tree_impl.h +++ b/cc/trees/layer_tree_impl.h @@ -74,7 +74,7 @@ class CC_EXPORT LayerTreeImpl { FrameRateCounter* frame_rate_counter() const; PaintTimeCounter* paint_time_counter() const; MemoryHistory* memory_history() const; - bool device_viewport_valid_for_tile_management() const; + bool resourceless_software_draw() const; gfx::Size device_viewport_size() const; bool IsActiveTree() const; bool IsPendingTree() const; diff --git a/content/browser/android/in_process/synchronous_compositor_output_surface.cc b/content/browser/android/in_process/synchronous_compositor_output_surface.cc index 041de4d..4e8ff8d 100644 --- a/content/browser/android/in_process/synchronous_compositor_output_surface.cc +++ b/content/browser/android/in_process/synchronous_compositor_output_surface.cc @@ -95,14 +95,6 @@ SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { delegate->DidDestroySynchronousOutputSurface(this); } -bool SynchronousCompositorOutputSurface::ForcedDrawToSoftwareDevice() const { - // |current_sw_canvas_| indicates we're in a DemandDrawSw call. In addition - // |invoking_composite_| == false indicates an attempt to draw outside of - // the synchronous compositor's control: force it into SW path and hence to - // the null canvas (and will log a warning there). - return current_sw_canvas_ != NULL || !invoking_composite_; -} - bool SynchronousCompositorOutputSurface::BindToClient( cc::OutputSurfaceClient* surface_client) { DCHECK(CalledOnValidThread()); @@ -207,7 +199,7 @@ void SynchronousCompositorOutputSurface::InvokeComposite( const gfx::Transform& transform, gfx::Rect viewport, gfx::Rect clip, - bool valid_for_tile_management) { + bool hardware_draw) { DCHECK(!invoking_composite_); DCHECK(!frame_holder_.get()); base::AutoReset<bool> invoking_composite_resetter(&invoking_composite_, true); @@ -215,20 +207,23 @@ void SynchronousCompositorOutputSurface::InvokeComposite( gfx::Transform adjusted_transform = transform; AdjustTransform(&adjusted_transform, viewport); SetExternalDrawConstraints( - adjusted_transform, viewport, clip, valid_for_tile_management); + adjusted_transform, viewport, clip, !hardware_draw); SetNeedsRedrawRect(gfx::Rect(viewport.size())); client_->BeginFrame(cc::BeginFrameArgs::CreateForSynchronousCompositor()); // After software draws (which might move the viewport arbitrarily), restore // the previous hardware viewport to allow CC's tile manager to prioritize // properly. - if (valid_for_tile_management) { + if (hardware_draw) { cached_hw_transform_ = adjusted_transform; cached_hw_viewport_ = viewport; cached_hw_clip_ = clip; } else { - SetExternalDrawConstraints( - cached_hw_transform_, cached_hw_viewport_, cached_hw_clip_, true); + bool resourceless_software_draw = false; + SetExternalDrawConstraints(cached_hw_transform_, + cached_hw_viewport_, + cached_hw_clip_, + resourceless_software_draw); } if (frame_holder_.get()) diff --git a/content/browser/android/in_process/synchronous_compositor_output_surface.h b/content/browser/android/in_process/synchronous_compositor_output_surface.h index 3a456a4..2c04ed2 100644 --- a/content/browser/android/in_process/synchronous_compositor_output_surface.h +++ b/content/browser/android/in_process/synchronous_compositor_output_surface.h @@ -55,7 +55,6 @@ class SynchronousCompositorOutputSurface virtual ~SynchronousCompositorOutputSurface(); // OutputSurface. - virtual bool ForcedDrawToSoftwareDevice() const OVERRIDE; virtual bool BindToClient(cc::OutputSurfaceClient* surface_client) OVERRIDE; virtual void Reshape(const gfx::Size& size, float scale_factor) OVERRIDE; virtual void SetNeedsBeginFrame(bool enable) OVERRIDE; @@ -80,7 +79,7 @@ class SynchronousCompositorOutputSurface void InvokeComposite(const gfx::Transform& transform, gfx::Rect viewport, gfx::Rect clip, - bool valid_for_tile_management); + bool hardware_draw); bool CalledOnValidThread() const; SynchronousCompositorOutputSurfaceDelegate* GetDelegate(); |