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

Unified Diff: cc/trees/layer_tree_host_impl.cc

Issue 267783004: Refactoring the way begin frame sources inside scheduler work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Scheduler tests now pass and the code is cleaner. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl.cc
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 219ea891051ebbc651e95f2f6438fbb9f9621096..9a00aec884da963e9eb5fbca4b7701a8e8ef2072 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -119,77 +119,6 @@ unsigned GetMapImageTextureTarget(cc::ContextProvider* context_provider) {
namespace cc {
-class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient {
- public:
- static scoped_ptr<LayerTreeHostImplTimeSourceAdapter> Create(
- LayerTreeHostImpl* layer_tree_host_impl,
- scoped_refptr<DelayBasedTimeSource> time_source) {
- return make_scoped_ptr(
- new LayerTreeHostImplTimeSourceAdapter(layer_tree_host_impl,
- time_source));
- }
- virtual ~LayerTreeHostImplTimeSourceAdapter() {
- time_source_->SetClient(NULL);
- time_source_->SetActive(false);
- }
-
- virtual void OnTimerTick() OVERRIDE {
- // In single threaded mode we attempt to simulate changing the current
- // thread by maintaining a fake thread id. When we switch from one
- // thread to another, we construct DebugScopedSetXXXThread objects that
- // update the thread id. This lets DCHECKS that ensure we're on the
- // right thread to work correctly in single threaded mode. The problem
- // here is that the timer tasks are run via the message loop, and when
- // they run, we've had no chance to construct a DebugScopedSetXXXThread
- // object. The result is that we report that we're running on the main
- // thread. In multi-threaded mode, this timer is run on the compositor
- // thread, so to keep this consistent in single-threaded mode, we'll
- // construct a DebugScopedSetImplThread object. There is no need to do
- // this in multi-threaded mode since the real thread id's will be
- // correct. In fact, setting fake thread id's interferes with the real
- // thread id's and causes breakage.
- scoped_ptr<DebugScopedSetImplThread> set_impl_thread;
- if (!layer_tree_host_impl_->proxy()->HasImplThread()) {
- set_impl_thread.reset(
- new DebugScopedSetImplThread(layer_tree_host_impl_->proxy()));
- }
-
- // TODO(enne): This should probably happen post-animate.
- if (layer_tree_host_impl_->pending_tree()) {
- layer_tree_host_impl_->pending_tree()->UpdateDrawProperties();
- layer_tree_host_impl_->ManageTiles();
- }
-
- layer_tree_host_impl_->Animate(
- layer_tree_host_impl_->CurrentFrameTimeTicks());
- layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true);
- bool start_ready_animations = true;
- layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
- layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
- }
-
- void SetActive(bool active) {
- if (active != time_source_->Active())
- time_source_->SetActive(active);
- }
-
- bool Active() const { return time_source_->Active(); }
-
- private:
- LayerTreeHostImplTimeSourceAdapter(
- LayerTreeHostImpl* layer_tree_host_impl,
- scoped_refptr<DelayBasedTimeSource> time_source)
- : layer_tree_host_impl_(layer_tree_host_impl),
- time_source_(time_source) {
- time_source_->SetClient(this);
- }
-
- LayerTreeHostImpl* layer_tree_host_impl_;
- scoped_refptr<DelayBasedTimeSource> time_source_;
-
- DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImplTimeSourceAdapter);
-};
-
LayerTreeHostImpl::FrameData::FrameData()
: contains_incomplete_tile(false), has_no_damage(false) {}
@@ -213,7 +142,8 @@ LayerTreeHostImpl::LayerTreeHostImpl(
RenderingStatsInstrumentation* rendering_stats_instrumentation,
SharedBitmapManager* manager,
int id)
- : client_(client),
+ : BaseBeginFrameSource(0),
+ client_(client),
proxy_(proxy),
use_gpu_rasterization_(false),
input_handler_client_(NULL),
@@ -334,8 +264,6 @@ void LayerTreeHostImpl::CommitComplete() {
ManageTiles();
} else {
active_tree_->set_needs_update_draw_properties();
- if (time_source_client_adapter_ && time_source_client_adapter_->Active())
- DCHECK(active_tree_->root_layer());
}
client_->SendManagedMemoryStats();
@@ -939,28 +867,6 @@ void LayerTreeHostImpl::MainThreadHasStoppedFlinging() {
input_handler_client_->MainThreadHasStoppedFlinging();
}
-void LayerTreeHostImpl::UpdateBackgroundAnimateTicking(
- bool should_background_tick) {
- DCHECK(proxy_->IsImplThread());
- if (should_background_tick)
- DCHECK(active_tree_->root_layer());
-
- bool enabled = should_background_tick && needs_animate_layers();
-
- // Lazily create the time_source adapter so that we can vary the interval for
- // testing.
- if (!time_source_client_adapter_) {
- time_source_client_adapter_ = LayerTreeHostImplTimeSourceAdapter::Create(
- this,
- DelayBasedTimeSource::Create(
- LowFrequencyAnimationInterval(),
- proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner()
- : proxy_->MainThreadTaskRunner()));
- }
-
- time_source_client_adapter_->SetActive(enabled);
-}
-
void LayerTreeHostImpl::DidAnimateScrollOffset() {
client_->SetNeedsCommitOnImplThread();
client_->RenewTreePriority();
@@ -1329,7 +1235,7 @@ void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) {
}
void LayerTreeHostImpl::BeginFrame(const BeginFrameArgs& args) {
- client_->BeginFrame(args);
+ frame_sink_->BeginFrame(args);
}
void LayerTreeHostImpl::DidSwapBuffers() {
@@ -1564,11 +1470,15 @@ bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) {
return true;
}
-void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) {
+void LayerTreeHostImpl::OnGenerateChange(bool generate_frames) {
if (output_surface_)
- output_surface_->SetNeedsBeginFrame(enable);
+ output_surface_->SetNeedsBeginFrame(generate_frames);
else
- DCHECK(!enable);
+ DCHECK(!generate_frames);
+}
+
+std::string LayerTreeHostImpl::TypeString() const {
+ return "LayerTreeHostImpl";
}
void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) {
@@ -1748,8 +1658,6 @@ void LayerTreeHostImpl::ActivatePendingTree() {
if (!tree_activation_callback_.is_null())
tree_activation_callback_.Run();
- if (time_source_client_adapter_ && time_source_client_adapter_->Active())
- DCHECK(active_tree_->root_layer());
devtools_instrumentation::DidActivateLayerTree(
id_, active_tree_->source_frame_number());
}
@@ -2020,7 +1928,7 @@ bool LayerTreeHostImpl::InitializeRenderer(
void LayerTreeHostImpl::CommitVSyncParameters(base::TimeTicks timebase,
base::TimeDelta interval) {
- client_->CommitVSyncParameters(timebase, interval);
+ // fsink_->UpdateTimebaseAndInterval(timebase, interval);
}
void LayerTreeHostImpl::DeferredInitialize() {
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698