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

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

Issue 373113003: Keeping track of descendants that draw content instead of recalcualting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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/ui_resource_layer.h ('k') | cc/test/fake_delegated_renderer_layer_impl.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 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_.reset();
116 if (!layer_tree_host() || bitmap_.empty()) 116 if (layer_tree_host() && !bitmap_.empty()) {
117 return; 117 ui_resource_holder_ =
118 118 ScopedUIResourceHolder::Create(layer_tree_host(), bitmap_);
119 ui_resource_holder_ = 119 }
120 ScopedUIResourceHolder::Create(layer_tree_host(), bitmap_); 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_.reset();
138 } 138 }
139 139
140 UpdateDrawsContent(HasDrawableContent());
140 SetNeedsCommit(); 141 SetNeedsCommit();
141 } 142 }
142 143
143 bool UIResourceLayer::DrawsContent() const { 144 bool UIResourceLayer::HasDrawableContent() const {
144 return ui_resource_holder_ && ui_resource_holder_->id() && 145 return ui_resource_holder_ && ui_resource_holder_->id() &&
145 Layer::DrawsContent(); 146 Layer::HasDrawableContent();
146 } 147 }
147 148
148 void UIResourceLayer::PushPropertiesTo(LayerImpl* layer) { 149 void UIResourceLayer::PushPropertiesTo(LayerImpl* layer) {
149 Layer::PushPropertiesTo(layer); 150 Layer::PushPropertiesTo(layer);
150 UIResourceLayerImpl* layer_impl = static_cast<UIResourceLayerImpl*>(layer); 151 UIResourceLayerImpl* layer_impl = static_cast<UIResourceLayerImpl*>(layer);
151 152
152 if (!ui_resource_holder_) { 153 if (!ui_resource_holder_) {
153 layer_impl->SetUIResourceId(0); 154 layer_impl->SetUIResourceId(0);
154 } else { 155 } else {
155 DCHECK(layer_tree_host()); 156 DCHECK(layer_tree_host());
156 157
157 gfx::Size image_size = 158 gfx::Size image_size =
158 layer_tree_host()->GetUIResourceSize(ui_resource_holder_->id()); 159 layer_tree_host()->GetUIResourceSize(ui_resource_holder_->id());
159 layer_impl->SetUIResourceId(ui_resource_holder_->id()); 160 layer_impl->SetUIResourceId(ui_resource_holder_->id());
160 layer_impl->SetImageBounds(image_size); 161 layer_impl->SetImageBounds(image_size);
161 layer_impl->SetUV(uv_top_left_, uv_bottom_right_); 162 layer_impl->SetUV(uv_top_left_, uv_bottom_right_);
162 layer_impl->SetVertexOpacity(vertex_opacity_); 163 layer_impl->SetVertexOpacity(vertex_opacity_);
163 } 164 }
164 } 165 }
165 166
166 } // namespace cc 167 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/ui_resource_layer.h ('k') | cc/test/fake_delegated_renderer_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698