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

Side by Side Diff: cc/layers/layer_impl.cc

Issue 14060015: cc: Async readback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "cc/animation/animation_registrar.h" 10 #include "cc/animation/animation_registrar.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 AnimationRegistrar* registrar = layer_tree_impl_->animationRegistrar(); 62 AnimationRegistrar* registrar = layer_tree_impl_->animationRegistrar();
63 layer_animation_controller_ = 63 layer_animation_controller_ =
64 registrar->GetAnimationControllerForId(layer_id_); 64 registrar->GetAnimationControllerForId(layer_id_);
65 layer_animation_controller_->AddValueObserver(this); 65 layer_animation_controller_->AddValueObserver(this);
66 } 66 }
67 67
68 LayerImpl::~LayerImpl() { 68 LayerImpl::~LayerImpl() {
69 #ifndef NDEBUG 69 #ifndef NDEBUG
70 DCHECK(!between_will_draw_and_did_draw_); 70 DCHECK(!between_will_draw_and_did_draw_);
71 #endif 71 #endif
72
73 for (size_t i = 0; i < request_copy_callbacks_.size(); ++i)
74 request_copy_callbacks_[i].Run(scoped_ptr<SkBitmap>());
75
72 layer_tree_impl_->UnregisterLayer(this); 76 layer_tree_impl_->UnregisterLayer(this);
73 layer_animation_controller_->RemoveValueObserver(this); 77 layer_animation_controller_->RemoveValueObserver(this);
74 } 78 }
75 79
76 void LayerImpl::AddChild(scoped_ptr<LayerImpl> child) { 80 void LayerImpl::AddChild(scoped_ptr<LayerImpl> child) {
77 child->set_parent(this); 81 child->set_parent(this);
78 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl()); 82 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl());
79 children_.push_back(child.Pass()); 83 children_.push_back(child.Pass());
80 layer_tree_impl()->set_needs_update_draw_properties(); 84 layer_tree_impl()->set_needs_update_draw_properties();
81 } 85 }
(...skipping 13 matching lines...) Expand all
95 } 99 }
96 100
97 void LayerImpl::ClearChildList() { 101 void LayerImpl::ClearChildList() {
98 if (children_.empty()) 102 if (children_.empty())
99 return; 103 return;
100 104
101 children_.clear(); 105 children_.clear();
102 layer_tree_impl()->set_needs_update_draw_properties(); 106 layer_tree_impl()->set_needs_update_draw_properties();
103 } 107 }
104 108
109 void LayerImpl::PassRequestCopyCallbacks(
110 std::vector<RenderPass::RequestCopyAsBitmapCallback>* callbacks) {
111 if (callbacks->empty())
112 return;
113
114 request_copy_callbacks_.insert(request_copy_callbacks_.end(),
115 callbacks->begin(),
116 callbacks->end());
117 callbacks->clear();
118
119 NoteLayerPropertyChangedForSubtree();
120 }
121
122 void LayerImpl::TakeRequestCopyCallbacks(
123 std::vector<RenderPass::RequestCopyAsBitmapCallback>* callbacks) {
124 if (request_copy_callbacks_.empty())
125 return;
126
127 callbacks->insert(callbacks->end(),
128 request_copy_callbacks_.begin(),
129 request_copy_callbacks_.end());
130 request_copy_callbacks_.clear();
131 }
132
105 void LayerImpl::CreateRenderSurface() { 133 void LayerImpl::CreateRenderSurface() {
106 DCHECK(!draw_properties_.render_surface); 134 DCHECK(!draw_properties_.render_surface);
107 draw_properties_.render_surface = 135 draw_properties_.render_surface =
108 make_scoped_ptr(new RenderSurfaceImpl(this)); 136 make_scoped_ptr(new RenderSurfaceImpl(this));
109 draw_properties_.render_target = this; 137 draw_properties_.render_target = this;
110 } 138 }
111 139
112 void LayerImpl::ClearRenderSurface() { 140 void LayerImpl::ClearRenderSurface() {
113 draw_properties_.render_surface.reset(); 141 draw_properties_.render_surface.reset();
114 } 142 }
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 layer->SetPositionConstraint(position_constraint_); 372 layer->SetPositionConstraint(position_constraint_);
345 layer->SetPreserves3d(preserves_3d()); 373 layer->SetPreserves3d(preserves_3d());
346 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); 374 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_);
347 layer->SetSublayerTransform(sublayer_transform_); 375 layer->SetSublayerTransform(sublayer_transform_);
348 layer->SetTransform(transform_); 376 layer->SetTransform(transform_);
349 377
350 layer->SetScrollable(scrollable_); 378 layer->SetScrollable(scrollable_);
351 layer->SetScrollOffset(scroll_offset_); 379 layer->SetScrollOffset(scroll_offset_);
352 layer->SetMaxScrollOffset(max_scroll_offset_); 380 layer->SetMaxScrollOffset(max_scroll_offset_);
353 381
382 layer->PassRequestCopyCallbacks(&request_copy_callbacks_);
383
354 // If the main thread commits multiple times before the impl thread actually 384 // If the main thread commits multiple times before the impl thread actually
355 // draws, then damage tracking will become incorrect if we simply clobber the 385 // draws, then damage tracking will become incorrect if we simply clobber the
356 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. 386 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e.
357 // union) any update changes that have occurred on the main thread. 387 // union) any update changes that have occurred on the main thread.
358 update_rect_.Union(layer->update_rect()); 388 update_rect_.Union(layer->update_rect());
359 layer->set_update_rect(update_rect_); 389 layer->set_update_rect(update_rect_);
360 390
361 layer->SetScrollDelta(layer->scroll_delta() - layer->sent_scroll_delta()); 391 layer->SetScrollDelta(layer->scroll_delta() - layer->sent_scroll_delta());
362 layer->SetSentScrollDelta(gfx::Vector2d()); 392 layer->SetSentScrollDelta(gfx::Vector2d());
363 393
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 dict->Set("layer_quad", MathUtil::AsValue(layer_quad).release()); 993 dict->Set("layer_quad", MathUtil::AsValue(layer_quad).release());
964 } 994 }
965 995
966 scoped_ptr<base::Value> LayerImpl::AsValue() const { 996 scoped_ptr<base::Value> LayerImpl::AsValue() const {
967 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 997 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
968 AsValueInto(state.get()); 998 AsValueInto(state.get());
969 return state.PassAs<base::Value>(); 999 return state.PassAs<base::Value>();
970 } 1000 }
971 1001
972 } // namespace cc 1002 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/output/direct_renderer.h » ('j') | cc/output/direct_renderer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698