Commit e4c3c87a authored by jbauman@chromium.org's avatar jbauman@chromium.org

Add compositor support for the LatencyInfo.

This just passes it through from the main thread to the impl thread upon commit (and then to the renderer).

BUG=155367

Review URL: https://chromiumcodereview.appspot.com/14092003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195433 0039d316-1c4b-4281-b951-d872f2087c98
parent c3d638b3
...@@ -157,7 +157,7 @@ void DelegatingRenderer::DrawFrame( ...@@ -157,7 +157,7 @@ void DelegatingRenderer::DrawFrame(
output_surface_->SendFrameToParentCompositor(&out_frame); output_surface_->SendFrameToParentCompositor(&out_frame);
} }
bool DelegatingRenderer::SwapBuffers() { bool DelegatingRenderer::SwapBuffers(const LatencyInfo& latency_info) {
return true; return true;
} }
......
...@@ -30,7 +30,7 @@ class CC_EXPORT DelegatingRenderer : ...@@ -30,7 +30,7 @@ class CC_EXPORT DelegatingRenderer :
virtual void Finish() OVERRIDE {} virtual void Finish() OVERRIDE {}
virtual bool SwapBuffers() OVERRIDE; virtual bool SwapBuffers(const LatencyInfo& latency_info) OVERRIDE;
virtual void GetFramebufferPixels(void* pixels, gfx::Rect rect) OVERRIDE; virtual void GetFramebufferPixels(void* pixels, gfx::Rect rect) OVERRIDE;
......
...@@ -1849,7 +1849,7 @@ void GLRenderer::Finish() { ...@@ -1849,7 +1849,7 @@ void GLRenderer::Finish() {
context_->finish(); context_->finish();
} }
bool GLRenderer::SwapBuffers() { bool GLRenderer::SwapBuffers(const LatencyInfo& latency_info) {
DCHECK(visible_); DCHECK(visible_);
DCHECK(!is_backbuffer_discarded_); DCHECK(!is_backbuffer_discarded_);
...@@ -1866,9 +1866,9 @@ bool GLRenderer::SwapBuffers() { ...@@ -1866,9 +1866,9 @@ bool GLRenderer::SwapBuffers() {
flipped_y_pos_of_rect_bottom, flipped_y_pos_of_rect_bottom,
swap_buffer_rect_.width(), swap_buffer_rect_.width(),
swap_buffer_rect_.height()), swap_buffer_rect_.height()),
LatencyInfo()); latency_info);
} else { } else {
output_surface_->SwapBuffers(LatencyInfo()); output_surface_->SwapBuffers(latency_info);
} }
swap_buffer_rect_ = gfx::Rect(); swap_buffer_rect_ = gfx::Rect();
......
...@@ -56,7 +56,7 @@ class CC_EXPORT GLRenderer : ...@@ -56,7 +56,7 @@ class CC_EXPORT GLRenderer :
virtual void DoNoOp() OVERRIDE; virtual void DoNoOp() OVERRIDE;
// Puts backbuffer onscreen. // Puts backbuffer onscreen.
virtual bool SwapBuffers() OVERRIDE; virtual bool SwapBuffers(const LatencyInfo& latency_info) OVERRIDE;
virtual void GetFramebufferPixels(void* pixels, gfx::Rect rect) OVERRIDE; virtual void GetFramebufferPixels(void* pixels, gfx::Rect rect) OVERRIDE;
......
...@@ -246,7 +246,7 @@ class GLRendererTest : public testing::Test { ...@@ -246,7 +246,7 @@ class GLRendererTest : public testing::Test {
virtual void SetUp() { renderer_.Initialize(); } virtual void SetUp() { renderer_.Initialize(); }
void SwapBuffers() { renderer_.SwapBuffers(); } void SwapBuffers() { renderer_.SwapBuffers(LatencyInfo()); }
FrameCountingMemoryAllocationSettingContext* Context() { FrameCountingMemoryAllocationSettingContext* Context() {
return static_cast<FrameCountingMemoryAllocationSettingContext*>( return static_cast<FrameCountingMemoryAllocationSettingContext*>(
...@@ -1320,7 +1320,7 @@ class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient { ...@@ -1320,7 +1320,7 @@ class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient {
virtual void SetUp() { EXPECT_TRUE(renderer_.Initialize()); } virtual void SetUp() { EXPECT_TRUE(renderer_.Initialize()); }
void SwapBuffers() { renderer_.SwapBuffers(); } void SwapBuffers() { renderer_.SwapBuffers(LatencyInfo()); }
void DrawFrame() { void DrawFrame() {
gfx::Rect viewport_rect(DeviceViewportSize()); gfx::Rect viewport_rect(DeviceViewportSize());
...@@ -1358,7 +1358,7 @@ TEST_F(MockOutputSurfaceTest, DrawFrameAndSwap) { ...@@ -1358,7 +1358,7 @@ TEST_F(MockOutputSurfaceTest, DrawFrameAndSwap) {
DrawFrame(); DrawFrame();
EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1);
renderer_.SwapBuffers(); renderer_.SwapBuffers(LatencyInfo());
} }
class MockOutputSurfaceTestWithPartialSwap : public MockOutputSurfaceTest { class MockOutputSurfaceTestWithPartialSwap : public MockOutputSurfaceTest {
...@@ -1374,7 +1374,7 @@ TEST_F(MockOutputSurfaceTestWithPartialSwap, DrawFrameAndSwap) { ...@@ -1374,7 +1374,7 @@ TEST_F(MockOutputSurfaceTestWithPartialSwap, DrawFrameAndSwap) {
DrawFrame(); DrawFrame();
EXPECT_CALL(output_surface_, PostSubBuffer(_, _)).Times(1); EXPECT_CALL(output_surface_, PostSubBuffer(_, _)).Times(1);
renderer_.SwapBuffers(); renderer_.SwapBuffers(LatencyInfo());
} }
class MockOutputSurfaceTestWithSendCompositorFrame class MockOutputSurfaceTestWithSendCompositorFrame
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "cc/base/cc_export.h" #include "cc/base/cc_export.h"
#include "cc/debug/latency_info.h"
#include "cc/quads/render_pass.h" #include "cc/quads/render_pass.h"
#include "cc/resources/managed_memory_policy.h" #include "cc/resources/managed_memory_policy.h"
#include "cc/trees/layer_tree_host.h" #include "cc/trees/layer_tree_host.h"
...@@ -63,7 +64,7 @@ class CC_EXPORT Renderer { ...@@ -63,7 +64,7 @@ class CC_EXPORT Renderer {
virtual void DoNoOp() {} virtual void DoNoOp() {}
// Puts backbuffer onscreen. // Puts backbuffer onscreen.
virtual bool SwapBuffers() = 0; virtual bool SwapBuffers(const LatencyInfo& latency_info) = 0;
virtual void GetFramebufferPixels(void* pixels, gfx::Rect rect) = 0; virtual void GetFramebufferPixels(void* pixels, gfx::Rect rect) = 0;
......
...@@ -117,7 +117,7 @@ void SoftwareRenderer::FinishDrawingFrame(DrawingFrame* frame) { ...@@ -117,7 +117,7 @@ void SoftwareRenderer::FinishDrawingFrame(DrawingFrame* frame) {
} }
} }
bool SoftwareRenderer::SwapBuffers() { bool SoftwareRenderer::SwapBuffers(const LatencyInfo& latency_info) {
if (Settings().compositor_frame_message) if (Settings().compositor_frame_message)
output_surface_->SendFrameToParentCompositor(&compositor_frame_); output_surface_->SendFrameToParentCompositor(&compositor_frame_);
return true; return true;
......
...@@ -33,7 +33,7 @@ class CC_EXPORT SoftwareRenderer : public DirectRenderer { ...@@ -33,7 +33,7 @@ class CC_EXPORT SoftwareRenderer : public DirectRenderer {
virtual const RendererCapabilities& Capabilities() const OVERRIDE; virtual const RendererCapabilities& Capabilities() const OVERRIDE;
virtual void ViewportChanged() OVERRIDE; virtual void ViewportChanged() OVERRIDE;
virtual void Finish() OVERRIDE; virtual void Finish() OVERRIDE;
virtual bool SwapBuffers() OVERRIDE; virtual bool SwapBuffers(const LatencyInfo& latency_info) OVERRIDE;
virtual void GetFramebufferPixels(void* pixels, gfx::Rect rect) OVERRIDE; virtual void GetFramebufferPixels(void* pixels, gfx::Rect rect) OVERRIDE;
virtual void SetVisible(bool visible) OVERRIDE; virtual void SetVisible(bool visible) OVERRIDE;
virtual void SendManagedMemoryStats( virtual void SendManagedMemoryStats(
......
...@@ -343,6 +343,8 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { ...@@ -343,6 +343,8 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) {
min_page_scale_factor_, min_page_scale_factor_,
max_page_scale_factor_); max_page_scale_factor_);
sync_tree->SetPageScaleDelta(page_scale_delta / sent_page_scale_delta); sync_tree->SetPageScaleDelta(page_scale_delta / sent_page_scale_delta);
sync_tree->SetLatencyInfo(latency_info_);
latency_info_.Clear();
host_impl->SetViewportSize(device_viewport_size_); host_impl->SetViewportSize(device_viewport_size_);
host_impl->SetOverdrawBottomHeight(overdraw_bottom_height_); host_impl->SetOverdrawBottomHeight(overdraw_bottom_height_);
...@@ -680,6 +682,10 @@ void LayerTreeHost::SetVisible(bool visible) { ...@@ -680,6 +682,10 @@ void LayerTreeHost::SetVisible(bool visible) {
proxy_->SetVisible(visible); proxy_->SetVisible(visible);
} }
void LayerTreeHost::SetLatencyInfo(const LatencyInfo& latency_info) {
latency_info_.MergeWith(latency_info);
}
void LayerTreeHost::StartPageScaleAnimation(gfx::Vector2d target_offset, void LayerTreeHost::StartPageScaleAnimation(gfx::Vector2d target_offset,
bool use_anchor, bool use_anchor,
float scale, float scale,
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "cc/animation/animation_events.h" #include "cc/animation/animation_events.h"
#include "cc/base/cc_export.h" #include "cc/base/cc_export.h"
#include "cc/base/scoped_ptr_vector.h" #include "cc/base/scoped_ptr_vector.h"
#include "cc/debug/latency_info.h"
#include "cc/layers/layer_lists.h" #include "cc/layers/layer_lists.h"
#include "cc/output/output_surface.h" #include "cc/output/output_surface.h"
#include "cc/scheduler/rate_limiter.h" #include "cc/scheduler/rate_limiter.h"
...@@ -211,6 +212,7 @@ class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) { ...@@ -211,6 +212,7 @@ class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) {
void ApplyScrollAndScale(const ScrollAndScaleSet& info); void ApplyScrollAndScale(const ScrollAndScaleSet& info);
void SetImplTransform(const gfx::Transform& transform); void SetImplTransform(const gfx::Transform& transform);
void SetLatencyInfo(const LatencyInfo& latency_info);
void StartRateLimiter(WebKit::WebGraphicsContext3D* context3d); void StartRateLimiter(WebKit::WebGraphicsContext3D* context3d);
void StopRateLimiter(WebKit::WebGraphicsContext3D* context3d); void StopRateLimiter(WebKit::WebGraphicsContext3D* context3d);
...@@ -339,6 +341,8 @@ class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) { ...@@ -339,6 +341,8 @@ class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) {
bool in_paint_layer_contents_; bool in_paint_layer_contents_;
LatencyInfo latency_info_;
DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); DISALLOW_COPY_AND_ASSIGN(LayerTreeHost);
}; };
......
...@@ -875,6 +875,8 @@ bool LayerTreeHostImpl::PrepareToDraw(FrameData* frame, ...@@ -875,6 +875,8 @@ bool LayerTreeHostImpl::PrepareToDraw(FrameData* frame,
if (!CalculateRenderPasses(frame)) if (!CalculateRenderPasses(frame))
return false; return false;
frame->latency_info = active_tree_->GetLatencyInfo();
// If we return true, then we expect DrawLayers() to be called before this // If we return true, then we expect DrawLayers() to be called before this
// function is called again. // function is called again.
return true; return true;
...@@ -1019,6 +1021,7 @@ CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const { ...@@ -1019,6 +1021,7 @@ CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const {
return metadata; return metadata;
metadata.root_scroll_offset = RootScrollLayer()->TotalScrollOffset(); metadata.root_scroll_offset = RootScrollLayer()->TotalScrollOffset();
metadata.latency_info = active_tree_->GetLatencyInfo();
return metadata; return metadata;
} }
...@@ -1118,7 +1121,10 @@ const RendererCapabilities& LayerTreeHostImpl::GetRendererCapabilities() const { ...@@ -1118,7 +1121,10 @@ const RendererCapabilities& LayerTreeHostImpl::GetRendererCapabilities() const {
bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) {
if (frame.has_no_damage) if (frame.has_no_damage)
return false; return false;
return renderer_->SwapBuffers(); bool result = renderer_->SwapBuffers(frame.latency_info);
if (result)
active_tree_->ClearLatencyInfo();
return result;
} }
void LayerTreeHostImpl::EnableVSyncNotification(bool enable) { void LayerTreeHostImpl::EnableVSyncNotification(bool enable) {
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "cc/animation/animation_events.h" #include "cc/animation/animation_events.h"
#include "cc/animation/animation_registrar.h" #include "cc/animation/animation_registrar.h"
#include "cc/base/cc_export.h" #include "cc/base/cc_export.h"
#include "cc/debug/latency_info.h"
#include "cc/input/input_handler.h" #include "cc/input/input_handler.h"
#include "cc/input/top_controls_manager_client.h" #include "cc/input/top_controls_manager_client.h"
#include "cc/layers/layer_lists.h" #include "cc/layers/layer_lists.h"
...@@ -131,6 +132,7 @@ class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, ...@@ -131,6 +132,7 @@ class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient,
LayerImplList will_draw_layers; LayerImplList will_draw_layers;
bool contains_incomplete_tile; bool contains_incomplete_tile;
bool has_no_damage; bool has_no_damage;
LatencyInfo latency_info;
// RenderPassSink implementation. // RenderPassSink implementation.
virtual void AppendRenderPass(scoped_ptr<RenderPass> render_pass) OVERRIDE; virtual void AppendRenderPass(scoped_ptr<RenderPass> render_pass) OVERRIDE;
......
...@@ -98,6 +98,8 @@ scoped_ptr<LayerImpl> LayerTreeImpl::DetachLayerTree() { ...@@ -98,6 +98,8 @@ scoped_ptr<LayerImpl> LayerTreeImpl::DetachLayerTree() {
} }
void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) { void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) {
target_tree->SetLatencyInfo(latency_info_);
latency_info_.Clear();
target_tree->SetPageScaleFactorAndLimits( target_tree->SetPageScaleFactorAndLimits(
page_scale_factor(), min_page_scale_factor(), max_page_scale_factor()); page_scale_factor(), min_page_scale_factor(), max_page_scale_factor());
target_tree->SetPageScaleDelta( target_tree->SetPageScaleDelta(
...@@ -686,4 +688,16 @@ void LayerTreeImpl::UpdateRootScrollLayerSizeDelta() { ...@@ -686,4 +688,16 @@ void LayerTreeImpl::UpdateRootScrollLayerSizeDelta() {
scrollable_viewport_size - original_viewport_size); scrollable_viewport_size - original_viewport_size);
} }
void LayerTreeImpl::SetLatencyInfo(const LatencyInfo& latency_info) {
latency_info_.MergeWith(latency_info);
}
const LatencyInfo& LayerTreeImpl::GetLatencyInfo() {
return latency_info_;
}
void LayerTreeImpl::ClearLatencyInfo() {
latency_info_.Clear();
}
} // namespace cc } // namespace cc
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/hash_tables.h" #include "base/hash_tables.h"
#include "base/values.h" #include "base/values.h"
#include "cc/debug/latency_info.h"
#include "cc/layers/layer_impl.h" #include "cc/layers/layer_impl.h"
#if defined(COMPILER_GCC) #if defined(COMPILER_GCC)
...@@ -197,6 +198,10 @@ class CC_EXPORT LayerTreeImpl { ...@@ -197,6 +198,10 @@ class CC_EXPORT LayerTreeImpl {
void DidUpdateScroll(); void DidUpdateScroll();
void DidEndScroll(); void DidEndScroll();
void SetLatencyInfo(const LatencyInfo& latency_info);
const LatencyInfo& GetLatencyInfo();
void ClearLatencyInfo();
protected: protected:
explicit LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl); explicit LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl);
...@@ -248,6 +253,8 @@ class CC_EXPORT LayerTreeImpl { ...@@ -248,6 +253,8 @@ class CC_EXPORT LayerTreeImpl {
// structural differences relative to the active tree. // structural differences relative to the active tree.
bool needs_full_tree_sync_; bool needs_full_tree_sync_;
LatencyInfo latency_info_;
DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl); DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment