OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/nine_patch_layer.h" | 5 #include "cc/layers/nine_patch_layer.h" |
6 | 6 |
7 #include "cc/layers/nine_patch_layer_impl.h" | 7 #include "cc/layers/nine_patch_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 15 matching lines...) Expand all Loading... |
26 return NinePatchLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); | 26 return NinePatchLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); |
27 } | 27 } |
28 | 28 |
29 void NinePatchLayer::SetTexturePriorities( | 29 void NinePatchLayer::SetTexturePriorities( |
30 const PriorityCalculator& priority_calc) { | 30 const PriorityCalculator& priority_calc) { |
31 if (resource_ && !resource_->texture()->resource_manager()) { | 31 if (resource_ && !resource_->texture()->resource_manager()) { |
32 // Release the resource here, as it is no longer tied to a resource manager. | 32 // Release the resource here, as it is no longer tied to a resource manager. |
33 resource_.reset(); | 33 resource_.reset(); |
34 if (!bitmap_.isNull()) | 34 if (!bitmap_.isNull()) |
35 CreateResource(); | 35 CreateResource(); |
36 } else if (needs_display_ && bitmap_dirty_ && DrawsContent()) { | 36 } else if (bitmap_dirty_ && DrawsContent()) { |
37 CreateResource(); | 37 CreateResource(); |
38 } | 38 } |
39 | 39 |
40 if (resource_) { | 40 if (resource_) { |
41 resource_->texture()->set_request_priority( | 41 resource_->texture()->set_request_priority( |
42 PriorityCalculator::UIPriority(true)); | 42 PriorityCalculator::UIPriority(true)); |
43 GLenum texture_format = | 43 GLenum texture_format = |
44 layer_tree_host()->GetRendererCapabilities().best_texture_format; | 44 layer_tree_host()->GetRendererCapabilities().best_texture_format; |
45 resource_->texture()->SetDimensions( | 45 resource_->texture()->SetDimensions( |
46 gfx::Size(bitmap_.width(), bitmap_.height()), texture_format); | 46 gfx::Size(bitmap_.width(), bitmap_.height()), texture_format); |
(...skipping 29 matching lines...) Expand all Loading... |
76 void NinePatchLayer::CreateUpdaterIfNeeded() { | 76 void NinePatchLayer::CreateUpdaterIfNeeded() { |
77 if (updater_.get()) | 77 if (updater_.get()) |
78 return; | 78 return; |
79 | 79 |
80 updater_ = ImageLayerUpdater::Create(); | 80 updater_ = ImageLayerUpdater::Create(); |
81 } | 81 } |
82 | 82 |
83 void NinePatchLayer::CreateResource() { | 83 void NinePatchLayer::CreateResource() { |
84 DCHECK(!bitmap_.isNull()); | 84 DCHECK(!bitmap_.isNull()); |
85 CreateUpdaterIfNeeded(); | 85 CreateUpdaterIfNeeded(); |
86 updater_->set_bitmap(bitmap_); | 86 updater_->SetBitmap(bitmap_); |
87 needs_display_ = false; | |
88 | 87 |
89 if (!resource_) { | 88 if (!resource_) { |
90 resource_ = updater_->CreateResource( | 89 resource_ = updater_->CreateResource( |
91 layer_tree_host()->contents_texture_manager()); | 90 layer_tree_host()->contents_texture_manager()); |
92 } | 91 } |
93 } | 92 } |
94 | 93 |
95 bool NinePatchLayer::DrawsContent() const { | 94 bool NinePatchLayer::DrawsContent() const { |
96 bool draws = !bitmap_.isNull() && | 95 bool draws = !bitmap_.isNull() && |
97 Layer::DrawsContent() && | 96 Layer::DrawsContent() && |
98 bitmap_.width() && | 97 bitmap_.width() && |
99 bitmap_.height(); | 98 bitmap_.height(); |
100 return draws; | 99 return draws; |
101 } | 100 } |
102 | 101 |
103 void NinePatchLayer::PushPropertiesTo(LayerImpl* layer) { | 102 void NinePatchLayer::PushPropertiesTo(LayerImpl* layer) { |
104 Layer::PushPropertiesTo(layer); | 103 Layer::PushPropertiesTo(layer); |
105 NinePatchLayerImpl* layer_impl = static_cast<NinePatchLayerImpl*>(layer); | 104 NinePatchLayerImpl* layer_impl = static_cast<NinePatchLayerImpl*>(layer); |
106 | 105 |
107 if (resource_) { | 106 if (resource_) { |
108 DCHECK(!bitmap_.isNull()); | 107 DCHECK(!bitmap_.isNull()); |
109 layer_impl->SetResourceId(resource_->texture()->resource_id()); | 108 layer_impl->SetResourceId(resource_->texture()->resource_id()); |
110 layer_impl->SetLayout( | 109 layer_impl->SetLayout( |
111 gfx::Size(bitmap_.width(), bitmap_.height()), image_aperture_); | 110 gfx::Size(bitmap_.width(), bitmap_.height()), image_aperture_); |
112 } | 111 } |
113 } | 112 } |
114 | 113 |
115 } // namespace cc | 114 } // namespace cc |
OLD | NEW |