diff options
author | aelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-05 00:43:28 +0000 |
---|---|---|
committer | aelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-05 00:43:28 +0000 |
commit | 54af0352fb8c3b48b0f379ea1c48006aa1c34615 (patch) | |
tree | 8c00bd00f8cde9adbfd90db018205cf2e669d666 /cc/test | |
parent | 576748e8df1fdb8a21958671fe860946f12c82f5 (diff) | |
download | chromium_src-54af0352fb8c3b48b0f379ea1c48006aa1c34615.zip chromium_src-54af0352fb8c3b48b0f379ea1c48006aa1c34615.tar.gz chromium_src-54af0352fb8c3b48b0f379ea1c48006aa1c34615.tar.bz2 |
Fix UpdateTilePriorities viewport in Android WebView.
This patch fixes the tile management viewport to be the on-screen-visible
rect for the last hardware draw. There are two problems I needed to solve:
1) Suppress UpdateTilePriorities from happening when the last draw was a
software draw, which is specified by the new
"viewport_valid_for_tile_management" bool.
2) In some cases, the clip rect is smaller than the WebView's visible
viewport -- for example when the Android Browser progress bar is forcing
redraws, the clip is only a small area at the top of the screen. I
switched to using the visible viewport for UpdateDrawProperties +
glViewport, and introduce a separate "DeviceClip" to override glScissor.
(It's necessary to make the change at this level, rather than directly
plumbing the visible viewport to UpdateTilePriorities, because
UpdateTilePriorities also makes use of outputs from the draw properties
calculation.)
I also cleaned up all uses of device_viewport_size() to call DrawViewportSize()
instead, with the sole exception of UnscaledScrollableViewportSize() which
should continue to use the main-thread device_viewport_size_ in all cases
(because that's the viewport for scrolling, not drawing).
New tests: PictureLayerImplTest.SuppressUpdateTilePriorities,
ExternalStencilPixelTest.DeviceClip
NOTRY=true
BUG=232844
Review URL: https://chromiumcodereview.appspot.com/23171014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221321 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test')
-rw-r--r-- | cc/test/fake_layer_tree_host_impl.cc | 11 | ||||
-rw-r--r-- | cc/test/fake_layer_tree_host_impl.h | 5 | ||||
-rw-r--r-- | cc/test/fake_output_surface_client.h | 7 | ||||
-rw-r--r-- | cc/test/pixel_test.cc | 21 | ||||
-rw-r--r-- | cc/test/pixel_test.h | 1 | ||||
-rw-r--r-- | cc/test/pixel_test_output_surface.cc | 6 | ||||
-rw-r--r-- | cc/test/pixel_test_output_surface.h | 4 |
7 files changed, 49 insertions, 6 deletions
diff --git a/cc/test/fake_layer_tree_host_impl.cc b/cc/test/fake_layer_tree_host_impl.cc index cc07041..c1a7326 100644 --- a/cc/test/fake_layer_tree_host_impl.cc +++ b/cc/test/fake_layer_tree_host_impl.cc @@ -36,4 +36,15 @@ void FakeLayerTreeHostImpl::CreatePendingTree() { 1.f, 1.f / arbitrary_large_page_scale, arbitrary_large_page_scale); } +base::TimeTicks FakeLayerTreeHostImpl::CurrentFrameTimeTicks() { + if (current_frame_time_ticks_.is_null()) + return LayerTreeHostImpl::CurrentFrameTimeTicks(); + return current_frame_time_ticks_; +} + +void FakeLayerTreeHostImpl::SetCurrentFrameTimeTicks( + base::TimeTicks current_frame_time_ticks) { + current_frame_time_ticks_ = current_frame_time_ticks; +} + } // namespace cc diff --git a/cc/test/fake_layer_tree_host_impl.h b/cc/test/fake_layer_tree_host_impl.h index da6ec41..b652a91 100644 --- a/cc/test/fake_layer_tree_host_impl.h +++ b/cc/test/fake_layer_tree_host_impl.h @@ -26,9 +26,14 @@ class FakeLayerTreeHostImpl : public LayerTreeHostImpl { virtual void CreatePendingTree() OVERRIDE; + virtual base::TimeTicks CurrentFrameTimeTicks() OVERRIDE; + void SetCurrentFrameTimeTicks(base::TimeTicks current_frame_time_ticks); + using LayerTreeHostImpl::ActivatePendingTree; + using LayerTreeHostImpl::manage_tiles_needed; private: + base::TimeTicks current_frame_time_ticks_; FakeLayerTreeHostImplClient client_; FakeRenderingStatsInstrumentation stats_instrumentation_; }; diff --git a/cc/test/fake_output_surface_client.h b/cc/test/fake_output_surface_client.h index 5a824e7..24c8c74 100644 --- a/cc/test/fake_output_surface_client.h +++ b/cc/test/fake_output_surface_client.h @@ -27,8 +27,11 @@ class FakeOutputSurfaceClient : public OutputSurfaceClient { virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE; virtual void OnSwapBuffersComplete(const CompositorFrameAck* ack) OVERRIDE {} virtual void DidLoseOutputSurface() OVERRIDE; - virtual void SetExternalDrawConstraints(const gfx::Transform& transform, - gfx::Rect viewport) OVERRIDE {} + virtual void SetExternalDrawConstraints( + const gfx::Transform& transform, + gfx::Rect viewport, + gfx::Rect clip, + bool valid_for_tile_management) OVERRIDE {} virtual void SetExternalStencilTest(bool enable) OVERRIDE {} virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE; virtual void SetDiscardBackBufferWhenNotVisible(bool discard) OVERRIDE; diff --git a/cc/test/pixel_test.cc b/cc/test/pixel_test.cc index 73c4437..8801596 100644 --- a/cc/test/pixel_test.cc +++ b/cc/test/pixel_test.cc @@ -28,12 +28,17 @@ class PixelTest::PixelTestRendererClient : public RendererClient, public OutputSurfaceClient { public: explicit PixelTestRendererClient(gfx::Rect device_viewport) - : device_viewport_(device_viewport), stencil_enabled_(false) {} + : device_viewport_(device_viewport), + device_clip_(device_viewport), + stencil_enabled_(false) {} // RendererClient implementation. virtual gfx::Rect DeviceViewport() const OVERRIDE { return device_viewport_; } + virtual gfx::Rect DeviceClip() const OVERRIDE { + return device_clip_; + } virtual float DeviceScaleFactor() const OVERRIDE { return 1.f; } @@ -64,9 +69,13 @@ class PixelTest::PixelTestRendererClient virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE {} virtual void OnSwapBuffersComplete(const CompositorFrameAck* ack) OVERRIDE {} virtual void DidLoseOutputSurface() OVERRIDE {} - virtual void SetExternalDrawConstraints(const gfx::Transform& transform, - gfx::Rect viewport) 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 SetExternalStencilTest(bool enable) OVERRIDE { stencil_enabled_ = enable; @@ -77,6 +86,7 @@ class PixelTest::PixelTestRendererClient private: gfx::Rect device_viewport_; + gfx::Rect device_clip_; bool stencil_enabled_; LayerTreeSettings settings_; }; @@ -188,6 +198,11 @@ void PixelTest::ForceExpandedViewport(gfx::Size surface_expansion, } } +void PixelTest::ForceDeviceClip(gfx::Rect clip) { + static_cast<PixelTestOutputSurface*>(output_surface_.get()) + ->set_device_clip(clip); +} + void PixelTest::EnableExternalStencilTest() { fake_client_->SetExternalStencilTest(true); } diff --git a/cc/test/pixel_test.h b/cc/test/pixel_test.h index e3476bf..86a8112 100644 --- a/cc/test/pixel_test.h +++ b/cc/test/pixel_test.h @@ -55,6 +55,7 @@ class PixelTest : public testing::Test { void ForceExpandedViewport(gfx::Size surface_expansion, gfx::Vector2d viewport_offset); + void ForceDeviceClip(gfx::Rect clip); void EnableExternalStencilTest(); private: diff --git a/cc/test/pixel_test_output_surface.cc b/cc/test/pixel_test_output_surface.cc index 9a4d66a..ffc3d26c 100644 --- a/cc/test/pixel_test_output_surface.cc +++ b/cc/test/pixel_test_output_surface.cc @@ -15,7 +15,11 @@ void PixelTestOutputSurface::Reshape(gfx::Size size, float scale_factor) { OutputSurface::Reshape(expanded_size, scale_factor); gfx::Rect offset_viewport = gfx::Rect(size) + viewport_offset_; - SetExternalDrawConstraints(gfx::Transform(), offset_viewport); + gfx::Rect offset_clip = device_clip_.IsEmpty() + ? offset_viewport + : device_clip_ + viewport_offset_; + SetExternalDrawConstraints( + gfx::Transform(), offset_viewport, offset_clip, true); } } // namespace cc diff --git a/cc/test/pixel_test_output_surface.h b/cc/test/pixel_test_output_surface.h index e9052fe..bb6fdfc 100644 --- a/cc/test/pixel_test_output_surface.h +++ b/cc/test/pixel_test_output_surface.h @@ -26,10 +26,14 @@ class PixelTestOutputSurface : public OutputSurface { void set_viewport_offset(gfx::Vector2d viewport_offset) { viewport_offset_ = viewport_offset; } + void set_device_clip(gfx::Rect device_clip) { + device_clip_ = device_clip; + } private: gfx::Size surface_expansion_size_; gfx::Vector2d viewport_offset_; + gfx::Rect device_clip_; }; } // namespace cc |