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

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

Issue 2317753002: cc: Abstract the LayerTreeHost. (Closed)
Patch Set: Rebase Created 4 years, 3 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
« no previous file with comments | « cc/layers/heads_up_display_layer.cc ('k') | cc/layers/painted_scrollbar_layer.cc » ('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 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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.h" 5 #include "cc/layers/layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 base::Passed(&result))); 1125 base::Passed(&result)));
1126 } 1126 }
1127 1127
1128 void Layer::PushPropertiesTo(LayerImpl* layer) { 1128 void Layer::PushPropertiesTo(LayerImpl* layer) {
1129 TRACE_EVENT0("cc", "Layer::PushPropertiesTo"); 1129 TRACE_EVENT0("cc", "Layer::PushPropertiesTo");
1130 DCHECK(layer_tree_host_); 1130 DCHECK(layer_tree_host_);
1131 1131
1132 // If we did not SavePaintProperties() for the layer this frame, then push the 1132 // If we did not SavePaintProperties() for the layer this frame, then push the
1133 // real property values, not the paint property values. 1133 // real property values, not the paint property values.
1134 bool use_paint_properties = paint_properties_.source_frame_number == 1134 bool use_paint_properties = paint_properties_.source_frame_number ==
1135 layer_tree_host_->source_frame_number(); 1135 layer_tree_host_->SourceFrameNumber();
1136 1136
1137 layer->SetBackgroundColor(inputs_.background_color); 1137 layer->SetBackgroundColor(inputs_.background_color);
1138 layer->SetSafeOpaqueBackgroundColor(safe_opaque_background_color_); 1138 layer->SetSafeOpaqueBackgroundColor(safe_opaque_background_color_);
1139 layer->SetBounds(use_paint_properties ? paint_properties_.bounds 1139 layer->SetBounds(use_paint_properties ? paint_properties_.bounds
1140 : inputs_.bounds); 1140 : inputs_.bounds);
1141 1141
1142 #if defined(NDEBUG) 1142 #if defined(NDEBUG)
1143 if (frame_viewer_instrumentation::IsTracingLayerTreeSnapshots()) 1143 if (frame_viewer_instrumentation::IsTracingLayerTreeSnapshots())
1144 layer->SetDebugInfo(TakeDebugInfo()); 1144 layer->SetDebugInfo(TakeDebugInfo());
1145 #else 1145 #else
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 layer_property_changed_ = false; 1202 layer_property_changed_ = false;
1203 inputs_.update_rect = gfx::Rect(); 1203 inputs_.update_rect = gfx::Rect();
1204 1204
1205 layer_tree_->RemoveLayerShouldPushProperties(this); 1205 layer_tree_->RemoveLayerShouldPushProperties(this);
1206 } 1206 }
1207 1207
1208 void Layer::TakeCopyRequests( 1208 void Layer::TakeCopyRequests(
1209 std::vector<std::unique_ptr<CopyOutputRequest>>* requests) { 1209 std::vector<std::unique_ptr<CopyOutputRequest>>* requests) {
1210 for (auto& it : inputs_.copy_requests) { 1210 for (auto& it : inputs_.copy_requests) {
1211 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = 1211 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner =
1212 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); 1212 layer_tree_host()->GetTaskRunnerProvider()->MainThreadTaskRunner();
1213 std::unique_ptr<CopyOutputRequest> original_request = std::move(it); 1213 std::unique_ptr<CopyOutputRequest> original_request = std::move(it);
1214 const CopyOutputRequest& original_request_ref = *original_request; 1214 const CopyOutputRequest& original_request_ref = *original_request;
1215 std::unique_ptr<CopyOutputRequest> main_thread_request = 1215 std::unique_ptr<CopyOutputRequest> main_thread_request =
1216 CopyOutputRequest::CreateRelayRequest( 1216 CopyOutputRequest::CreateRelayRequest(
1217 original_request_ref, 1217 original_request_ref,
1218 base::Bind(&PostCopyCallbackToMainThread, main_thread_task_runner, 1218 base::Bind(&PostCopyCallbackToMainThread, main_thread_task_runner,
1219 base::Passed(&original_request))); 1219 base::Passed(&original_request)));
1220 if (main_thread_request->has_area()) { 1220 if (main_thread_request->has_area()) {
1221 main_thread_request->set_area(gfx::IntersectRects( 1221 main_thread_request->set_area(gfx::IntersectRects(
1222 main_thread_request->area(), gfx::Rect(bounds()))); 1222 main_thread_request->area(), gfx::Rect(bounds())));
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 DCHECK(proto.has_id()); 1338 DCHECK(proto.has_id());
1339 DCHECK_EQ(inputs_.layer_id, proto.id()); 1339 DCHECK_EQ(inputs_.layer_id, proto.id());
1340 FromLayerSpecificPropertiesProto(proto); 1340 FromLayerSpecificPropertiesProto(proto);
1341 } 1341 }
1342 1342
1343 void Layer::LayerSpecificPropertiesToProto(proto::LayerProperties* proto) { 1343 void Layer::LayerSpecificPropertiesToProto(proto::LayerProperties* proto) {
1344 proto::BaseLayerProperties* base = proto->mutable_base(); 1344 proto::BaseLayerProperties* base = proto->mutable_base();
1345 1345
1346 bool use_paint_properties = layer_tree_host_ && 1346 bool use_paint_properties = layer_tree_host_ &&
1347 paint_properties_.source_frame_number == 1347 paint_properties_.source_frame_number ==
1348 layer_tree_host_->source_frame_number(); 1348 layer_tree_host_->SourceFrameNumber();
1349 1349
1350 Point3FToProto(inputs_.transform_origin, base->mutable_transform_origin()); 1350 Point3FToProto(inputs_.transform_origin, base->mutable_transform_origin());
1351 base->set_background_color(inputs_.background_color); 1351 base->set_background_color(inputs_.background_color);
1352 base->set_safe_opaque_background_color(safe_opaque_background_color_); 1352 base->set_safe_opaque_background_color(safe_opaque_background_color_);
1353 SizeToProto(use_paint_properties ? paint_properties_.bounds : inputs_.bounds, 1353 SizeToProto(use_paint_properties ? paint_properties_.bounds : inputs_.bounds,
1354 base->mutable_bounds()); 1354 base->mutable_bounds());
1355 1355
1356 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372. 1356 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372.
1357 1357
1358 base->set_transform_free_index(transform_tree_index_); 1358 base->set_transform_free_index(transform_tree_index_);
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 int Layer::NumDescendantsThatDrawContent() const { 1560 int Layer::NumDescendantsThatDrawContent() const {
1561 return num_descendants_that_draw_content_; 1561 return num_descendants_that_draw_content_;
1562 } 1562 }
1563 1563
1564 void Layer::SavePaintProperties() { 1564 void Layer::SavePaintProperties() {
1565 DCHECK(layer_tree_host_); 1565 DCHECK(layer_tree_host_);
1566 1566
1567 // TODO(reveman): Save all layer properties that we depend on not 1567 // TODO(reveman): Save all layer properties that we depend on not
1568 // changing until PushProperties() has been called. crbug.com/231016 1568 // changing until PushProperties() has been called. crbug.com/231016
1569 paint_properties_.bounds = inputs_.bounds; 1569 paint_properties_.bounds = inputs_.bounds;
1570 paint_properties_.source_frame_number = 1570 paint_properties_.source_frame_number = layer_tree_host_->SourceFrameNumber();
1571 layer_tree_host_->source_frame_number();
1572 } 1571 }
1573 1572
1574 bool Layer::Update() { 1573 bool Layer::Update() {
1575 DCHECK(layer_tree_host_); 1574 DCHECK(layer_tree_host_);
1576 DCHECK_EQ(layer_tree_host_->source_frame_number(), 1575 DCHECK_EQ(layer_tree_host_->SourceFrameNumber(),
1577 paint_properties_.source_frame_number) << 1576 paint_properties_.source_frame_number)
1578 "SavePaintProperties must be called for any layer that is painted."; 1577 << "SavePaintProperties must be called for any layer that is painted.";
1579 return false; 1578 return false;
1580 } 1579 }
1581 1580
1582 bool Layer::IsSuitableForGpuRasterization() const { 1581 bool Layer::IsSuitableForGpuRasterization() const {
1583 return true; 1582 return true;
1584 } 1583 }
1585 1584
1586 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 1585 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
1587 Layer::TakeDebugInfo() { 1586 Layer::TakeDebugInfo() {
1588 if (inputs_.client) 1587 if (inputs_.client)
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); 1881 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId);
1883 return draw_property_utils::ScreenSpaceTransform( 1882 return draw_property_utils::ScreenSpaceTransform(
1884 this, layer_tree_->property_trees()->transform_tree); 1883 this, layer_tree_->property_trees()->transform_tree);
1885 } 1884 }
1886 1885
1887 LayerTree* Layer::GetLayerTree() const { 1886 LayerTree* Layer::GetLayerTree() const {
1888 return layer_tree_; 1887 return layer_tree_;
1889 } 1888 }
1890 1889
1891 } // namespace cc 1890 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/heads_up_display_layer.cc ('k') | cc/layers/painted_scrollbar_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698