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

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

Issue 609663003: cc: Remove use of PassAs() and constructor-casting with scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cc-passas: PassAs-presubmit-warning Created 6 years, 2 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/tiled_layer_unittest.cc ('k') | cc/layers/ui_resource_layer_impl.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui_resource_layer.h" 5 #include "cc/layers/ui_resource_layer.h"
6 6
7 #include "cc/layers/ui_resource_layer_impl.h" 7 #include "cc/layers/ui_resource_layer_impl.h"
8 #include "cc/resources/prioritized_resource.h" 8 #include "cc/resources/prioritized_resource.h"
9 #include "cc/resources/resource_update.h" 9 #include "cc/resources/resource_update.h"
10 #include "cc/resources/resource_update_queue.h" 10 #include "cc/resources/resource_update_queue.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 vertex_opacity_[0] = 1.0f; 62 vertex_opacity_[0] = 1.0f;
63 vertex_opacity_[1] = 1.0f; 63 vertex_opacity_[1] = 1.0f;
64 vertex_opacity_[2] = 1.0f; 64 vertex_opacity_[2] = 1.0f;
65 vertex_opacity_[3] = 1.0f; 65 vertex_opacity_[3] = 1.0f;
66 } 66 }
67 67
68 UIResourceLayer::~UIResourceLayer() {} 68 UIResourceLayer::~UIResourceLayer() {}
69 69
70 scoped_ptr<LayerImpl> UIResourceLayer::CreateLayerImpl( 70 scoped_ptr<LayerImpl> UIResourceLayer::CreateLayerImpl(
71 LayerTreeImpl* tree_impl) { 71 LayerTreeImpl* tree_impl) {
72 return UIResourceLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); 72 return UIResourceLayerImpl::Create(tree_impl, id());
73 } 73 }
74 74
75 void UIResourceLayer::SetUV(const gfx::PointF& top_left, 75 void UIResourceLayer::SetUV(const gfx::PointF& top_left,
76 const gfx::PointF& bottom_right) { 76 const gfx::PointF& bottom_right) {
77 if (uv_top_left_ == top_left && uv_bottom_right_ == bottom_right) 77 if (uv_top_left_ == top_left && uv_bottom_right_ == bottom_right)
78 return; 78 return;
79 uv_top_left_ = top_left; 79 uv_top_left_ = top_left;
80 uv_bottom_right_ = bottom_right; 80 uv_bottom_right_ = bottom_right;
81 SetNeedsCommit(); 81 SetNeedsCommit();
82 } 82 }
(...skipping 22 matching lines...) Expand all
105 if (host == layer_tree_host()) 105 if (host == layer_tree_host())
106 return; 106 return;
107 107
108 Layer::SetLayerTreeHost(host); 108 Layer::SetLayerTreeHost(host);
109 109
110 // Recreate the resource hold against the new LTH. 110 // Recreate the resource hold against the new LTH.
111 RecreateUIResourceHolder(); 111 RecreateUIResourceHolder();
112 } 112 }
113 113
114 void UIResourceLayer::RecreateUIResourceHolder() { 114 void UIResourceLayer::RecreateUIResourceHolder() {
115 ui_resource_holder_.reset(); 115 ui_resource_holder_ = nullptr;
116 if (layer_tree_host() && !bitmap_.empty()) { 116 if (layer_tree_host() && !bitmap_.empty()) {
117 ui_resource_holder_ = 117 ui_resource_holder_ =
118 ScopedUIResourceHolder::Create(layer_tree_host(), bitmap_); 118 ScopedUIResourceHolder::Create(layer_tree_host(), bitmap_);
119 } 119 }
120 UpdateDrawsContent(HasDrawableContent()); 120 UpdateDrawsContent(HasDrawableContent());
121 } 121 }
122 122
123 void UIResourceLayer::SetBitmap(const SkBitmap& skbitmap) { 123 void UIResourceLayer::SetBitmap(const SkBitmap& skbitmap) {
124 bitmap_ = skbitmap; 124 bitmap_ = skbitmap;
125 125
126 RecreateUIResourceHolder(); 126 RecreateUIResourceHolder();
127 SetNeedsCommit(); 127 SetNeedsCommit();
128 } 128 }
129 129
130 void UIResourceLayer::SetUIResourceId(UIResourceId resource_id) { 130 void UIResourceLayer::SetUIResourceId(UIResourceId resource_id) {
131 if (ui_resource_holder_ && ui_resource_holder_->id() == resource_id) 131 if (ui_resource_holder_ && ui_resource_holder_->id() == resource_id)
132 return; 132 return;
133 133
134 if (resource_id) { 134 if (resource_id)
135 ui_resource_holder_ = SharedUIResourceHolder::Create(resource_id); 135 ui_resource_holder_ = SharedUIResourceHolder::Create(resource_id);
136 } else { 136 else
137 ui_resource_holder_.reset(); 137 ui_resource_holder_ = nullptr;
138 }
139 138
140 UpdateDrawsContent(HasDrawableContent()); 139 UpdateDrawsContent(HasDrawableContent());
141 SetNeedsCommit(); 140 SetNeedsCommit();
142 } 141 }
143 142
144 bool UIResourceLayer::HasDrawableContent() const { 143 bool UIResourceLayer::HasDrawableContent() const {
145 return ui_resource_holder_ && ui_resource_holder_->id() && 144 return ui_resource_holder_ && ui_resource_holder_->id() &&
146 Layer::HasDrawableContent(); 145 Layer::HasDrawableContent();
147 } 146 }
148 147
149 void UIResourceLayer::PushPropertiesTo(LayerImpl* layer) { 148 void UIResourceLayer::PushPropertiesTo(LayerImpl* layer) {
150 Layer::PushPropertiesTo(layer); 149 Layer::PushPropertiesTo(layer);
151 UIResourceLayerImpl* layer_impl = static_cast<UIResourceLayerImpl*>(layer); 150 UIResourceLayerImpl* layer_impl = static_cast<UIResourceLayerImpl*>(layer);
152 151
153 if (!ui_resource_holder_) { 152 if (!ui_resource_holder_) {
154 layer_impl->SetUIResourceId(0); 153 layer_impl->SetUIResourceId(0);
155 } else { 154 } else {
156 DCHECK(layer_tree_host()); 155 DCHECK(layer_tree_host());
157 156
158 gfx::Size image_size = 157 gfx::Size image_size =
159 layer_tree_host()->GetUIResourceSize(ui_resource_holder_->id()); 158 layer_tree_host()->GetUIResourceSize(ui_resource_holder_->id());
160 layer_impl->SetUIResourceId(ui_resource_holder_->id()); 159 layer_impl->SetUIResourceId(ui_resource_holder_->id());
161 layer_impl->SetImageBounds(image_size); 160 layer_impl->SetImageBounds(image_size);
162 layer_impl->SetUV(uv_top_left_, uv_bottom_right_); 161 layer_impl->SetUV(uv_top_left_, uv_bottom_right_);
163 layer_impl->SetVertexOpacity(vertex_opacity_); 162 layer_impl->SetVertexOpacity(vertex_opacity_);
164 } 163 }
165 } 164 }
166 165
167 } // namespace cc 166 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/tiled_layer_unittest.cc ('k') | cc/layers/ui_resource_layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698