| 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.h" | 5 #include "cc/layers/heads_up_display_layer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> |
| 8 | 9 |
| 9 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 10 #include "cc/layers/heads_up_display_layer_impl.h" | 11 #include "cc/layers/heads_up_display_layer_impl.h" |
| 11 #include "cc/trees/layer_tree_host.h" | 12 #include "cc/trees/layer_tree_host.h" |
| 12 | 13 |
| 13 namespace cc { | 14 namespace cc { |
| 14 | 15 |
| 15 scoped_refptr<HeadsUpDisplayLayer> HeadsUpDisplayLayer::Create() { | 16 scoped_refptr<HeadsUpDisplayLayer> HeadsUpDisplayLayer::Create() { |
| 16 return make_scoped_refptr(new HeadsUpDisplayLayer()); | 17 return make_scoped_refptr(new HeadsUpDisplayLayer()); |
| 17 } | 18 } |
| 18 | 19 |
| 19 HeadsUpDisplayLayer::HeadsUpDisplayLayer() {} | 20 HeadsUpDisplayLayer::HeadsUpDisplayLayer() {} |
| 20 | 21 |
| 21 HeadsUpDisplayLayer::~HeadsUpDisplayLayer() {} | 22 HeadsUpDisplayLayer::~HeadsUpDisplayLayer() {} |
| 22 | 23 |
| 23 void HeadsUpDisplayLayer::PrepareForCalculateDrawProperties( | 24 void HeadsUpDisplayLayer::PrepareForCalculateDrawProperties( |
| 24 gfx::Size device_viewport, float device_scale_factor) { | 25 gfx::Size device_viewport, float device_scale_factor) { |
| 25 gfx::Size device_viewport_in_layout_pixels = gfx::Size( | 26 gfx::Size device_viewport_in_layout_pixels = gfx::Size( |
| 26 device_viewport.width() / device_scale_factor, | 27 device_viewport.width() / device_scale_factor, |
| 27 device_viewport.height() / device_scale_factor); | 28 device_viewport.height() / device_scale_factor); |
| 28 | 29 |
| 29 gfx::Size bounds; | 30 gfx::Size bounds; |
| 30 gfx::Transform matrix; | 31 gfx::Transform matrix; |
| 31 matrix.MakeIdentity(); | 32 matrix.MakeIdentity(); |
| 32 | 33 |
| 34 bool is_tracing; |
| 35 TRACE_EVENT_CATEGORY_GROUP_ENABLED("cc", &is_tracing); |
| 36 if (is_tracing) |
| 37 SetDebugName("Heads Up Display Layer"); |
| 38 else |
| 39 SetDebugName(std::string()); |
| 40 |
| 33 if (layer_tree_host()->debug_state().ShowHudRects()) { | 41 if (layer_tree_host()->debug_state().ShowHudRects()) { |
| 34 int max_texture_size = | 42 int max_texture_size = |
| 35 layer_tree_host()->GetRendererCapabilities().max_texture_size; | 43 layer_tree_host()->GetRendererCapabilities().max_texture_size; |
| 36 bounds.SetSize(std::min(max_texture_size, | 44 bounds.SetSize(std::min(max_texture_size, |
| 37 device_viewport_in_layout_pixels.width()), | 45 device_viewport_in_layout_pixels.width()), |
| 38 std::min(max_texture_size, | 46 std::min(max_texture_size, |
| 39 device_viewport_in_layout_pixels.height())); | 47 device_viewport_in_layout_pixels.height())); |
| 40 } else { | 48 } else { |
| 41 int size = 256; | 49 int size = 256; |
| 42 bounds.SetSize(size, size); | 50 bounds.SetSize(size, size); |
| 43 matrix.Translate(device_viewport_in_layout_pixels.width() - size, 0.0); | 51 matrix.Translate(device_viewport_in_layout_pixels.width() - size, 0.0); |
| 44 } | 52 } |
| 45 | 53 |
| 46 SetBounds(bounds); | 54 SetBounds(bounds); |
| 47 SetTransform(matrix); | 55 SetTransform(matrix); |
| 48 } | 56 } |
| 49 | 57 |
| 50 bool HeadsUpDisplayLayer::DrawsContent() const { return true; } | 58 bool HeadsUpDisplayLayer::DrawsContent() const { return true; } |
| 51 | 59 |
| 52 scoped_ptr<LayerImpl> HeadsUpDisplayLayer::CreateLayerImpl( | 60 scoped_ptr<LayerImpl> HeadsUpDisplayLayer::CreateLayerImpl( |
| 53 LayerTreeImpl* tree_impl) { | 61 LayerTreeImpl* tree_impl) { |
| 54 return HeadsUpDisplayLayerImpl::Create(tree_impl, layer_id_). | 62 return HeadsUpDisplayLayerImpl::Create(tree_impl, layer_id_). |
| 55 PassAs<LayerImpl>(); | 63 PassAs<LayerImpl>(); |
| 56 } | 64 } |
| 57 | 65 |
| 58 } // namespace cc | 66 } // namespace cc |
| OLD | NEW |