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/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 158 |
159 gfx::Rect layer_rect(bounds()); | 159 gfx::Rect layer_rect(bounds()); |
160 DCHECK(bitmap->config() == SkBitmap::kARGB_8888_Config); | 160 DCHECK(bitmap->config() == SkBitmap::kARGB_8888_Config); |
161 resource_provider->SetPixels(hud_resource_->id(), | 161 resource_provider->SetPixels(hud_resource_->id(), |
162 static_cast<const uint8_t*>(bitmap->getPixels()), | 162 static_cast<const uint8_t*>(bitmap->getPixels()), |
163 layer_rect, | 163 layer_rect, |
164 layer_rect, | 164 layer_rect, |
165 gfx::Vector2d()); | 165 gfx::Vector2d()); |
166 } | 166 } |
167 | 167 |
168 void HeadsUpDisplayLayerImpl::DidDraw(ResourceProvider* resource_provider) { | |
169 LayerImpl::DidDraw(resource_provider); | |
170 | |
171 if (!hud_resource_->id()) | |
172 return; | |
173 | |
174 // FIXME: the following assert will not be true when sending resources to a | |
175 // parent compositor. We will probably need to hold on to hud_resource_ for | |
176 // longer, and have several HUD textures in the pipeline. | |
177 DCHECK(!resource_provider->InUseByConsumer(hud_resource_->id())); | |
178 } | |
179 | |
180 void HeadsUpDisplayLayerImpl::DidLoseOutputSurface() { hud_resource_.reset(); } | 168 void HeadsUpDisplayLayerImpl::DidLoseOutputSurface() { hud_resource_.reset(); } |
181 | 169 |
182 bool HeadsUpDisplayLayerImpl::LayerIsAlwaysDamaged() const { return true; } | 170 bool HeadsUpDisplayLayerImpl::LayerIsAlwaysDamaged() const { return true; } |
183 | 171 |
184 void HeadsUpDisplayLayerImpl::UpdateHudContents() { | 172 void HeadsUpDisplayLayerImpl::UpdateHudContents() { |
185 const LayerTreeDebugState& debug_state = layer_tree_impl()->debug_state(); | 173 const LayerTreeDebugState& debug_state = layer_tree_impl()->debug_state(); |
186 | 174 |
187 // Don't update numbers every frame so text is readable. | 175 // Don't update numbers every frame so text is readable. |
188 base::TimeTicks now = layer_tree_impl()->CurrentFrameTimeTicks(); | 176 base::TimeTicks now = layer_tree_impl()->CurrentFrameTimeTicks(); |
189 if (base::TimeDelta(now - time_of_last_graph_update_).InSecondsF() > 0.25f) { | 177 if (base::TimeDelta(now - time_of_last_graph_update_).InSecondsF() > 0.25f) { |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 } | 673 } |
686 | 674 |
687 canvas->restore(); | 675 canvas->restore(); |
688 } | 676 } |
689 | 677 |
690 const char* HeadsUpDisplayLayerImpl::LayerTypeAsString() const { | 678 const char* HeadsUpDisplayLayerImpl::LayerTypeAsString() const { |
691 return "HeadsUpDisplayLayer"; | 679 return "HeadsUpDisplayLayer"; |
692 } | 680 } |
693 | 681 |
694 } // namespace cc | 682 } // namespace cc |
OLD | NEW |