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

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

Issue 2661523003: cc: Merge LayerTree into the LayerTreeHost. (Closed)
Patch Set: auto Created 3 years, 10 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/texture_layer_unittest.cc ('k') | cc/output/bsp_tree_perftest.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 "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "cc/layers/ui_resource_layer_impl.h" 9 #include "cc/layers/ui_resource_layer_impl.h"
10 #include "cc/resources/scoped_ui_resource.h" 10 #include "cc/resources/scoped_ui_resource.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 Layer::SetLayerTreeHost(host); 69 Layer::SetLayerTreeHost(host);
70 70
71 // Recreate the resource held against the new LTH. 71 // Recreate the resource held against the new LTH.
72 RecreateUIResourceIdFromBitmap(); 72 RecreateUIResourceIdFromBitmap();
73 73
74 UpdateDrawsContent(HasDrawableContent()); 74 UpdateDrawsContent(HasDrawableContent());
75 } 75 }
76 76
77 void UIResourceLayer::SetBitmap(const SkBitmap& bitmap) { 77 void UIResourceLayer::SetBitmap(const SkBitmap& bitmap) {
78 bitmap_ = bitmap; 78 bitmap_ = bitmap;
79 if (!GetLayerTree()) 79 if (!layer_tree_host())
80 return; 80 return;
81 SetUIResourceIdInternal( 81 SetUIResourceIdInternal(
82 layer_tree_host()->GetUIResourceManager()->GetOrCreateUIResource(bitmap)); 82 layer_tree_host()->GetUIResourceManager()->GetOrCreateUIResource(bitmap));
83 } 83 }
84 84
85 void UIResourceLayer::SetUIResourceId(UIResourceId resource_id) { 85 void UIResourceLayer::SetUIResourceId(UIResourceId resource_id) {
86 // Even if the ID is not changing we should drop the bitmap. The ID is 0 when 86 // Even if the ID is not changing we should drop the bitmap. The ID is 0 when
87 // there's no layer tree. When setting an id (even if to 0), we should no 87 // there's no layer tree. When setting an id (even if to 0), we should no
88 // longer keep the bitmap. 88 // longer keep the bitmap.
89 bitmap_.reset(); 89 bitmap_.reset();
90 if (resource_id_ == resource_id) 90 if (resource_id_ == resource_id)
91 return; 91 return;
92 SetUIResourceIdInternal(resource_id); 92 SetUIResourceIdInternal(resource_id);
93 } 93 }
94 94
95 bool UIResourceLayer::HasDrawableContent() const { 95 bool UIResourceLayer::HasDrawableContent() const {
96 return resource_id_ && Layer::HasDrawableContent(); 96 return resource_id_ && Layer::HasDrawableContent();
97 } 97 }
98 98
99 void UIResourceLayer::PushPropertiesTo(LayerImpl* layer) { 99 void UIResourceLayer::PushPropertiesTo(LayerImpl* layer) {
100 Layer::PushPropertiesTo(layer); 100 Layer::PushPropertiesTo(layer);
101 TRACE_EVENT0("cc", "UIResourceLayer::PushPropertiesTo"); 101 TRACE_EVENT0("cc", "UIResourceLayer::PushPropertiesTo");
102 UIResourceLayerImpl* layer_impl = static_cast<UIResourceLayerImpl*>(layer); 102 UIResourceLayerImpl* layer_impl = static_cast<UIResourceLayerImpl*>(layer);
103 103
104 layer_impl->SetUIResourceId(resource_id_); 104 layer_impl->SetUIResourceId(resource_id_);
105 if (resource_id_) { 105 if (resource_id_) {
106 DCHECK(GetLayerTree()); 106 DCHECK(layer_tree_host());
107 107
108 gfx::Size image_size = 108 gfx::Size image_size =
109 layer_tree_host()->GetUIResourceManager()->GetUIResourceSize( 109 layer_tree_host()->GetUIResourceManager()->GetUIResourceSize(
110 resource_id_); 110 resource_id_);
111 layer_impl->SetImageBounds(image_size); 111 layer_impl->SetImageBounds(image_size);
112 layer_impl->SetUV(uv_top_left_, uv_bottom_right_); 112 layer_impl->SetUV(uv_top_left_, uv_bottom_right_);
113 layer_impl->SetVertexOpacity(vertex_opacity_); 113 layer_impl->SetVertexOpacity(vertex_opacity_);
114 } 114 }
115 } 115 }
116 116
117 void UIResourceLayer::RecreateUIResourceIdFromBitmap() { 117 void UIResourceLayer::RecreateUIResourceIdFromBitmap() {
118 if (!bitmap_.empty()) 118 if (!bitmap_.empty())
119 SetBitmap(bitmap_); 119 SetBitmap(bitmap_);
120 } 120 }
121 121
122 void UIResourceLayer::SetUIResourceIdInternal(UIResourceId resource_id) { 122 void UIResourceLayer::SetUIResourceIdInternal(UIResourceId resource_id) {
123 resource_id_ = resource_id; 123 resource_id_ = resource_id;
124 UpdateDrawsContent(HasDrawableContent()); 124 UpdateDrawsContent(HasDrawableContent());
125 SetNeedsCommit(); 125 SetNeedsCommit();
126 } 126 }
127 127
128 } // namespace cc 128 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/texture_layer_unittest.cc ('k') | cc/output/bsp_tree_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698