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/heads_up_display_layer_impl.h" | 5 #include "cc/layers/heads_up_display_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 ++it) { | 90 ++it) { |
91 if (!resource_provider->InUseByConsumer((*it)->id())) { | 91 if (!resource_provider->InUseByConsumer((*it)->id())) { |
92 resources_.swap(it, resources_.end() - 1); | 92 resources_.swap(it, resources_.end() - 1); |
93 return; | 93 return; |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 scoped_ptr<ScopedResource> resource = | 97 scoped_ptr<ScopedResource> resource = |
98 ScopedResource::Create(resource_provider); | 98 ScopedResource::Create(resource_provider); |
99 resource->Allocate(internal_content_bounds_, | 99 resource->Allocate(internal_content_bounds_, |
100 ResourceProvider::TextureHintImmutable, RGBA_8888); | 100 ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888); |
101 resources_.push_back(resource.Pass()); | 101 resources_.push_back(resource.Pass()); |
102 } | 102 } |
103 | 103 |
104 class ResourceSizeIsEqualTo { | 104 class ResourceSizeIsEqualTo { |
105 public: | 105 public: |
106 explicit ResourceSizeIsEqualTo(const gfx::Size& size_) | 106 explicit ResourceSizeIsEqualTo(const gfx::Size& size_) |
107 : compare_size_(size_) {} | 107 : compare_size_(size_) {} |
108 | 108 |
109 bool operator()(const ScopedResource* resource) { | 109 bool operator()(const ScopedResource* resource) { |
110 return resource->size() == compare_size_; | 110 return resource->size() == compare_size_; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 DrawHudContents(hud_surface_->getCanvas()); | 203 DrawHudContents(hud_surface_->getCanvas()); |
204 | 204 |
205 hud_surface_->getCanvas()->restore(); | 205 hud_surface_->getCanvas()->restore(); |
206 } | 206 } |
207 | 207 |
208 TRACE_EVENT0("cc", "UploadHudTexture"); | 208 TRACE_EVENT0("cc", "UploadHudTexture"); |
209 SkImageInfo info; | 209 SkImageInfo info; |
210 size_t row_bytes = 0; | 210 size_t row_bytes = 0; |
211 const void* pixels = hud_surface_->getCanvas()->peekPixels(&info, &row_bytes); | 211 const void* pixels = hud_surface_->getCanvas()->peekPixels(&info, &row_bytes); |
212 DCHECK(pixels); | 212 DCHECK(pixels); |
213 gfx::Rect content_rect(internal_content_bounds_); | |
214 DCHECK(info.colorType() == kN32_SkColorType); | 213 DCHECK(info.colorType() == kN32_SkColorType); |
215 resource_provider->SetPixels(resources_.back()->id(), | 214 resource_provider->CopyToResource(resources_.back()->id(), |
216 static_cast<const uint8_t*>(pixels), | 215 static_cast<const uint8_t*>(pixels), |
217 content_rect, | 216 internal_content_bounds_); |
218 content_rect, | |
219 gfx::Vector2d()); | |
220 } | 217 } |
221 | 218 |
222 void HeadsUpDisplayLayerImpl::ReleaseResources() { | 219 void HeadsUpDisplayLayerImpl::ReleaseResources() { |
223 resources_.clear(); | 220 resources_.clear(); |
224 } | 221 } |
225 | 222 |
226 void HeadsUpDisplayLayerImpl::UpdateHudContents() { | 223 void HeadsUpDisplayLayerImpl::UpdateHudContents() { |
227 const LayerTreeDebugState& debug_state = layer_tree_impl()->debug_state(); | 224 const LayerTreeDebugState& debug_state = layer_tree_impl()->debug_state(); |
228 | 225 |
229 // Don't update numbers every frame so text is readable. | 226 // Don't update numbers every frame so text is readable. |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 return "cc::HeadsUpDisplayLayerImpl"; | 832 return "cc::HeadsUpDisplayLayerImpl"; |
836 } | 833 } |
837 | 834 |
838 void HeadsUpDisplayLayerImpl::AsValueInto( | 835 void HeadsUpDisplayLayerImpl::AsValueInto( |
839 base::trace_event::TracedValue* dict) const { | 836 base::trace_event::TracedValue* dict) const { |
840 LayerImpl::AsValueInto(dict); | 837 LayerImpl::AsValueInto(dict); |
841 dict->SetString("layer_name", "Heads Up Display Layer"); | 838 dict->SetString("layer_name", "Heads Up Display Layer"); |
842 } | 839 } |
843 | 840 |
844 } // namespace cc | 841 } // namespace cc |
OLD | NEW |