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

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

Issue 15435003: cc: Add CopyAsBitmapRequest class to hold the readback callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nolint Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/output/copy_output_request.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "cc/animation/animation_registrar.h" 9 #include "cc/animation/animation_registrar.h"
10 #include "cc/animation/scrollbar_animation_controller.h" 10 #include "cc/animation/scrollbar_animation_controller.h"
11 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" 11 #include "cc/animation/scrollbar_animation_controller_linear_fade.h"
12 #include "cc/base/math_util.h" 12 #include "cc/base/math_util.h"
13 #include "cc/debug/debug_colors.h" 13 #include "cc/debug/debug_colors.h"
14 #include "cc/debug/layer_tree_debug_state.h" 14 #include "cc/debug/layer_tree_debug_state.h"
15 #include "cc/debug/traced_value.h" 15 #include "cc/debug/traced_value.h"
16 #include "cc/input/layer_scroll_offset_delegate.h" 16 #include "cc/input/layer_scroll_offset_delegate.h"
17 #include "cc/layers/quad_sink.h" 17 #include "cc/layers/quad_sink.h"
18 #include "cc/layers/scrollbar_layer_impl.h" 18 #include "cc/layers/scrollbar_layer_impl.h"
19 #include "cc/output/copy_output_request.h"
19 #include "cc/quads/debug_border_draw_quad.h" 20 #include "cc/quads/debug_border_draw_quad.h"
20 #include "cc/trees/layer_tree_impl.h" 21 #include "cc/trees/layer_tree_impl.h"
21 #include "cc/trees/layer_tree_settings.h" 22 #include "cc/trees/layer_tree_settings.h"
22 #include "cc/trees/proxy.h" 23 #include "cc/trees/proxy.h"
23 #include "ui/gfx/point_conversions.h" 24 #include "ui/gfx/point_conversions.h"
24 #include "ui/gfx/quad_f.h" 25 #include "ui/gfx/quad_f.h"
25 #include "ui/gfx/rect_conversions.h" 26 #include "ui/gfx/rect_conversions.h"
26 27
27 namespace cc { 28 namespace cc {
28 29
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 layer_animation_controller_ = 66 layer_animation_controller_ =
66 registrar->GetAnimationControllerForId(layer_id_); 67 registrar->GetAnimationControllerForId(layer_id_);
67 layer_animation_controller_->AddValueObserver(this); 68 layer_animation_controller_->AddValueObserver(this);
68 } 69 }
69 70
70 LayerImpl::~LayerImpl() { 71 LayerImpl::~LayerImpl() {
71 #ifndef NDEBUG 72 #ifndef NDEBUG
72 DCHECK(!between_will_draw_and_did_draw_); 73 DCHECK(!between_will_draw_and_did_draw_);
73 #endif 74 #endif
74 75
75 for (size_t i = 0; i < request_copy_callbacks_.size(); ++i)
76 request_copy_callbacks_[i].Run(scoped_ptr<SkBitmap>());
77
78 layer_tree_impl_->UnregisterLayer(this); 76 layer_tree_impl_->UnregisterLayer(this);
79 layer_animation_controller_->RemoveValueObserver(this); 77 layer_animation_controller_->RemoveValueObserver(this);
80 } 78 }
81 79
82 void LayerImpl::AddChild(scoped_ptr<LayerImpl> child) { 80 void LayerImpl::AddChild(scoped_ptr<LayerImpl> child) {
83 child->set_parent(this); 81 child->set_parent(this);
84 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl()); 82 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl());
85 children_.push_back(child.Pass()); 83 children_.push_back(child.Pass());
86 layer_tree_impl()->set_needs_update_draw_properties(); 84 layer_tree_impl()->set_needs_update_draw_properties();
87 } 85 }
(...skipping 13 matching lines...) Expand all
101 } 99 }
102 100
103 void LayerImpl::ClearChildList() { 101 void LayerImpl::ClearChildList() {
104 if (children_.empty()) 102 if (children_.empty())
105 return; 103 return;
106 104
107 children_.clear(); 105 children_.clear();
108 layer_tree_impl()->set_needs_update_draw_properties(); 106 layer_tree_impl()->set_needs_update_draw_properties();
109 } 107 }
110 108
111 void LayerImpl::PassRequestCopyCallbacks( 109 void LayerImpl::PassCopyRequests(ScopedPtrVector<CopyOutputRequest>* requests) {
112 std::vector<RenderPass::RequestCopyAsBitmapCallback>* callbacks) { 110 if (requests->empty())
113 if (callbacks->empty())
114 return; 111 return;
115 112
116 request_copy_callbacks_.insert(request_copy_callbacks_.end(), 113 copy_requests_.insert_and_take(copy_requests_.end(), *requests);
117 callbacks->begin(), 114 requests->clear();
118 callbacks->end());
119 callbacks->clear();
120 115
121 NoteLayerPropertyChangedForSubtree(); 116 NoteLayerPropertyChangedForSubtree();
122 } 117 }
123 118
124 void LayerImpl::TakeRequestCopyCallbacks( 119 void LayerImpl::TakeCopyRequests(ScopedPtrVector<CopyOutputRequest>* requests) {
125 std::vector<RenderPass::RequestCopyAsBitmapCallback>* callbacks) { 120 if (copy_requests_.empty())
126 if (request_copy_callbacks_.empty())
127 return; 121 return;
128 122
129 callbacks->insert(callbacks->end(), 123 requests->insert_and_take(requests->end(), copy_requests_);
130 request_copy_callbacks_.begin(), 124 copy_requests_.clear();
131 request_copy_callbacks_.end());
132 request_copy_callbacks_.clear();
133 } 125 }
134 126
135 void LayerImpl::CreateRenderSurface() { 127 void LayerImpl::CreateRenderSurface() {
136 DCHECK(!draw_properties_.render_surface); 128 DCHECK(!draw_properties_.render_surface);
137 draw_properties_.render_surface = 129 draw_properties_.render_surface =
138 make_scoped_ptr(new RenderSurfaceImpl(this)); 130 make_scoped_ptr(new RenderSurfaceImpl(this));
139 draw_properties_.render_target = this; 131 draw_properties_.render_target = this;
140 } 132 }
141 133
142 void LayerImpl::ClearRenderSurface() { 134 void LayerImpl::ClearRenderSurface() {
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 layer->SetPositionConstraint(position_constraint_); 374 layer->SetPositionConstraint(position_constraint_);
383 layer->SetPreserves3d(preserves_3d()); 375 layer->SetPreserves3d(preserves_3d());
384 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); 376 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_);
385 layer->SetSublayerTransform(sublayer_transform_); 377 layer->SetSublayerTransform(sublayer_transform_);
386 layer->SetTransform(transform_); 378 layer->SetTransform(transform_);
387 379
388 layer->SetScrollable(scrollable_); 380 layer->SetScrollable(scrollable_);
389 layer->SetScrollOffset(scroll_offset_); 381 layer->SetScrollOffset(scroll_offset_);
390 layer->SetMaxScrollOffset(max_scroll_offset_); 382 layer->SetMaxScrollOffset(max_scroll_offset_);
391 383
392 layer->PassRequestCopyCallbacks(&request_copy_callbacks_); 384 layer->PassCopyRequests(&copy_requests_);
393 385
394 // If the main thread commits multiple times before the impl thread actually 386 // If the main thread commits multiple times before the impl thread actually
395 // draws, then damage tracking will become incorrect if we simply clobber the 387 // draws, then damage tracking will become incorrect if we simply clobber the
396 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. 388 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e.
397 // union) any update changes that have occurred on the main thread. 389 // union) any update changes that have occurred on the main thread.
398 update_rect_.Union(layer->update_rect()); 390 update_rect_.Union(layer->update_rect());
399 layer->set_update_rect(update_rect_); 391 layer->set_update_rect(update_rect_);
400 392
401 layer->SetScrollDelta(layer->ScrollDelta() - layer->sent_scroll_delta()); 393 layer->SetScrollDelta(layer->ScrollDelta() - layer->sent_scroll_delta());
402 layer->SetSentScrollDelta(gfx::Vector2d()); 394 layer->SetSentScrollDelta(gfx::Vector2d());
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 1028
1037 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } 1029 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; }
1038 1030
1039 scoped_ptr<base::Value> LayerImpl::AsValue() const { 1031 scoped_ptr<base::Value> LayerImpl::AsValue() const {
1040 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 1032 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
1041 AsValueInto(state.get()); 1033 AsValueInto(state.get());
1042 return state.PassAs<base::Value>(); 1034 return state.PassAs<base::Value>();
1043 } 1035 }
1044 1036
1045 } // namespace cc 1037 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/output/copy_output_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698