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::TEXTURE_HINT_IMMUTABLE, RGBA_8888); | 100 ResourceProvider::TextureHintImmutable, 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_); |
213 DCHECK(info.colorType() == kN32_SkColorType); | 214 DCHECK(info.colorType() == kN32_SkColorType); |
214 resource_provider->CopyToResource(resources_.back()->id(), | 215 resource_provider->SetPixels(resources_.back()->id(), |
215 static_cast<const uint8_t*>(pixels), | 216 static_cast<const uint8_t*>(pixels), |
216 internal_content_bounds_); | 217 content_rect, |
| 218 content_rect, |
| 219 gfx::Vector2d()); |
217 } | 220 } |
218 | 221 |
219 void HeadsUpDisplayLayerImpl::ReleaseResources() { | 222 void HeadsUpDisplayLayerImpl::ReleaseResources() { |
220 resources_.clear(); | 223 resources_.clear(); |
221 } | 224 } |
222 | 225 |
223 void HeadsUpDisplayLayerImpl::UpdateHudContents() { | 226 void HeadsUpDisplayLayerImpl::UpdateHudContents() { |
224 const LayerTreeDebugState& debug_state = layer_tree_impl()->debug_state(); | 227 const LayerTreeDebugState& debug_state = layer_tree_impl()->debug_state(); |
225 | 228 |
226 // Don't update numbers every frame so text is readable. | 229 // Don't update numbers every frame so text is readable. |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 return "cc::HeadsUpDisplayLayerImpl"; | 835 return "cc::HeadsUpDisplayLayerImpl"; |
833 } | 836 } |
834 | 837 |
835 void HeadsUpDisplayLayerImpl::AsValueInto( | 838 void HeadsUpDisplayLayerImpl::AsValueInto( |
836 base::trace_event::TracedValue* dict) const { | 839 base::trace_event::TracedValue* dict) const { |
837 LayerImpl::AsValueInto(dict); | 840 LayerImpl::AsValueInto(dict); |
838 dict->SetString("layer_name", "Heads Up Display Layer"); | 841 dict->SetString("layer_name", "Heads Up Display Layer"); |
839 } | 842 } |
840 | 843 |
841 } // namespace cc | 844 } // namespace cc |
OLD | NEW |