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

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

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 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
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_client.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 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 } 344 }
345 345
346 bool Layer::HasAncestor(const Layer* ancestor) const { 346 bool Layer::HasAncestor(const Layer* ancestor) const {
347 for (const Layer* layer = parent(); layer; layer = layer->parent()) { 347 for (const Layer* layer = parent(); layer; layer = layer->parent()) {
348 if (layer == ancestor) 348 if (layer == ancestor)
349 return true; 349 return true;
350 } 350 }
351 return false; 351 return false;
352 } 352 }
353 353
354 void Layer::RequestCopyOfOutput( 354 void Layer::RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> request) {
355 scoped_ptr<CopyOutputRequest> request) {
356 DCHECK(IsPropertyChangeAllowed()); 355 DCHECK(IsPropertyChangeAllowed());
357 if (void* source = request->source()) { 356 if (void* source = request->source()) {
358 auto it = std::find_if(copy_requests_.begin(), copy_requests_.end(), 357 auto it =
359 [source](const scoped_ptr<CopyOutputRequest>& x) { 358 std::find_if(copy_requests_.begin(), copy_requests_.end(),
360 return x->source() == source; 359 [source](const std::unique_ptr<CopyOutputRequest>& x) {
361 }); 360 return x->source() == source;
361 });
362 if (it != copy_requests_.end()) 362 if (it != copy_requests_.end())
363 copy_requests_.erase(it); 363 copy_requests_.erase(it);
364 } 364 }
365 if (request->IsEmpty()) 365 if (request->IsEmpty())
366 return; 366 return;
367 copy_requests_.push_back(std::move(request)); 367 copy_requests_.push_back(std::move(request));
368 SetSubtreePropertyChanged(); 368 SetSubtreePropertyChanged();
369 SetNeedsCommit(); 369 SetNeedsCommit();
370 } 370 }
371 371
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 } 1089 }
1090 1090
1091 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) { 1091 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) {
1092 DCHECK(IsPropertyChangeAllowed()); 1092 DCHECK(IsPropertyChangeAllowed());
1093 if (position_constraint_ == constraint) 1093 if (position_constraint_ == constraint)
1094 return; 1094 return;
1095 position_constraint_ = constraint; 1095 position_constraint_ = constraint;
1096 SetNeedsCommit(); 1096 SetNeedsCommit();
1097 } 1097 }
1098 1098
1099 static void RunCopyCallbackOnMainThread(scoped_ptr<CopyOutputRequest> request, 1099 static void RunCopyCallbackOnMainThread(
1100 scoped_ptr<CopyOutputResult> result) { 1100 std::unique_ptr<CopyOutputRequest> request,
1101 std::unique_ptr<CopyOutputResult> result) {
1101 request->SendResult(std::move(result)); 1102 request->SendResult(std::move(result));
1102 } 1103 }
1103 1104
1104 static void PostCopyCallbackToMainThread( 1105 static void PostCopyCallbackToMainThread(
1105 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, 1106 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner,
1106 scoped_ptr<CopyOutputRequest> request, 1107 std::unique_ptr<CopyOutputRequest> request,
1107 scoped_ptr<CopyOutputResult> result) { 1108 std::unique_ptr<CopyOutputResult> result) {
1108 main_thread_task_runner->PostTask(FROM_HERE, 1109 main_thread_task_runner->PostTask(FROM_HERE,
1109 base::Bind(&RunCopyCallbackOnMainThread, 1110 base::Bind(&RunCopyCallbackOnMainThread,
1110 base::Passed(&request), 1111 base::Passed(&request),
1111 base::Passed(&result))); 1112 base::Passed(&result)));
1112 } 1113 }
1113 1114
1114 void Layer::PushPropertiesTo(LayerImpl* layer) { 1115 void Layer::PushPropertiesTo(LayerImpl* layer) {
1115 TRACE_EVENT0("cc", "Layer::PushPropertiesTo"); 1116 TRACE_EVENT0("cc", "Layer::PushPropertiesTo");
1116 DCHECK(layer_tree_host_); 1117 DCHECK(layer_tree_host_);
1117 1118
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 // active tree. To do so, avoid scrolling the pending tree along with it 1236 // active tree. To do so, avoid scrolling the pending tree along with it
1236 // instead of trying to undo that scrolling later. 1237 // instead of trying to undo that scrolling later.
1237 if (ScrollOffsetAnimationWasInterrupted()) 1238 if (ScrollOffsetAnimationWasInterrupted())
1238 layer_tree_host() 1239 layer_tree_host()
1239 ->property_trees() 1240 ->property_trees()
1240 ->scroll_tree.SetScrollOffsetClobberActiveValue(layer->id()); 1241 ->scroll_tree.SetScrollOffsetClobberActiveValue(layer->id());
1241 1242
1242 { 1243 {
1243 TRACE_EVENT0("cc", "Layer::PushPropertiesTo::CopyOutputRequests"); 1244 TRACE_EVENT0("cc", "Layer::PushPropertiesTo::CopyOutputRequests");
1244 // Wrap the copy_requests_ in a PostTask to the main thread. 1245 // Wrap the copy_requests_ in a PostTask to the main thread.
1245 std::vector<scoped_ptr<CopyOutputRequest>> main_thread_copy_requests; 1246 std::vector<std::unique_ptr<CopyOutputRequest>> main_thread_copy_requests;
1246 for (auto it = copy_requests_.begin(); it != copy_requests_.end(); ++it) { 1247 for (auto it = copy_requests_.begin(); it != copy_requests_.end(); ++it) {
1247 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = 1248 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner =
1248 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); 1249 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner();
1249 scoped_ptr<CopyOutputRequest> original_request = std::move(*it); 1250 std::unique_ptr<CopyOutputRequest> original_request = std::move(*it);
1250 const CopyOutputRequest& original_request_ref = *original_request; 1251 const CopyOutputRequest& original_request_ref = *original_request;
1251 scoped_ptr<CopyOutputRequest> main_thread_request = 1252 std::unique_ptr<CopyOutputRequest> main_thread_request =
1252 CopyOutputRequest::CreateRelayRequest( 1253 CopyOutputRequest::CreateRelayRequest(
1253 original_request_ref, 1254 original_request_ref,
1254 base::Bind(&PostCopyCallbackToMainThread, main_thread_task_runner, 1255 base::Bind(&PostCopyCallbackToMainThread, main_thread_task_runner,
1255 base::Passed(&original_request))); 1256 base::Passed(&original_request)));
1256 main_thread_copy_requests.push_back(std::move(main_thread_request)); 1257 main_thread_copy_requests.push_back(std::move(main_thread_request));
1257 } 1258 }
1258 if (!copy_requests_.empty() && layer_tree_host_) 1259 if (!copy_requests_.empty() && layer_tree_host_)
1259 layer_tree_host_->property_trees()->needs_rebuild = true; 1260 layer_tree_host_->property_trees()->needs_rebuild = true;
1260 1261
1261 copy_requests_.clear(); 1262 copy_requests_.clear();
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 int child_id = base.clip_children_ids(i); 1568 int child_id = base.clip_children_ids(i);
1568 scoped_refptr<Layer> child = layer_tree_host_->LayerById(child_id); 1569 scoped_refptr<Layer> child = layer_tree_host_->LayerById(child_id);
1569 clip_children_->insert(child.get()); 1570 clip_children_->insert(child.get());
1570 } 1571 }
1571 1572
1572 scroll_offset_ = ProtoToScrollOffset(base.scroll_offset()); 1573 scroll_offset_ = ProtoToScrollOffset(base.scroll_offset());
1573 1574
1574 update_rect_.Union(ProtoToRect(base.update_rect())); 1575 update_rect_.Union(ProtoToRect(base.update_rect()));
1575 } 1576 }
1576 1577
1577 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { 1578 std::unique_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) {
1578 return LayerImpl::Create(tree_impl, layer_id_); 1579 return LayerImpl::Create(tree_impl, layer_id_);
1579 } 1580 }
1580 1581
1581 bool Layer::DrawsContent() const { 1582 bool Layer::DrawsContent() const {
1582 return draws_content_; 1583 return draws_content_;
1583 } 1584 }
1584 1585
1585 bool Layer::HasDrawableContent() const { 1586 bool Layer::HasDrawableContent() const {
1586 return is_drawable_; 1587 return is_drawable_;
1587 } 1588 }
(...skipping 30 matching lines...) Expand all
1618 DCHECK_EQ(layer_tree_host_->source_frame_number(), 1619 DCHECK_EQ(layer_tree_host_->source_frame_number(),
1619 paint_properties_.source_frame_number) << 1620 paint_properties_.source_frame_number) <<
1620 "SavePaintProperties must be called for any layer that is painted."; 1621 "SavePaintProperties must be called for any layer that is painted.";
1621 return false; 1622 return false;
1622 } 1623 }
1623 1624
1624 bool Layer::IsSuitableForGpuRasterization() const { 1625 bool Layer::IsSuitableForGpuRasterization() const {
1625 return true; 1626 return true;
1626 } 1627 }
1627 1628
1628 scoped_ptr<base::trace_event::ConvertableToTraceFormat> Layer::TakeDebugInfo() { 1629 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
1630 Layer::TakeDebugInfo() {
1629 if (client_) 1631 if (client_)
1630 return client_->TakeDebugInfo(this); 1632 return client_->TakeDebugInfo(this);
1631 else 1633 else
1632 return nullptr; 1634 return nullptr;
1633 } 1635 }
1634 1636
1635 void Layer::SetHasRenderSurface(bool has_render_surface) { 1637 void Layer::SetHasRenderSurface(bool has_render_surface) {
1636 if (has_render_surface_ == has_render_surface) 1638 if (has_render_surface_ == has_render_surface)
1637 return; 1639 return;
1638 has_render_surface_ = has_render_surface; 1640 has_render_surface_ = has_render_surface;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 ->data.num_copy_requests_in_subtree; 1838 ->data.num_copy_requests_in_subtree;
1837 } 1839 }
1838 1840
1839 gfx::Transform Layer::screen_space_transform() const { 1841 gfx::Transform Layer::screen_space_transform() const {
1840 DCHECK_NE(transform_tree_index_, -1); 1842 DCHECK_NE(transform_tree_index_, -1);
1841 return draw_property_utils::ScreenSpaceTransform( 1843 return draw_property_utils::ScreenSpaceTransform(
1842 this, layer_tree_host_->property_trees()->transform_tree); 1844 this, layer_tree_host_->property_trees()->transform_tree);
1843 } 1845 }
1844 1846
1845 } // namespace cc 1847 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698