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
3 // found in the LICENSE file.
5 #include "cc/layers/heads_up_display_layer.h"
9 #include "base/trace_event/trace_event.h"
10 #include "cc/layers/heads_up_display_layer_impl.h"
11 #include "cc/trees/layer_tree_host.h"
15 scoped_refptr
<HeadsUpDisplayLayer
> HeadsUpDisplayLayer::Create(
16 const LayerSettings
& settings
) {
17 return make_scoped_refptr(new HeadsUpDisplayLayer(settings
));
20 HeadsUpDisplayLayer::HeadsUpDisplayLayer(const LayerSettings
& settings
)
23 UpdateDrawsContent(HasDrawableContent());
26 HeadsUpDisplayLayer::~HeadsUpDisplayLayer() {}
28 void HeadsUpDisplayLayer::PrepareForCalculateDrawProperties(
29 const gfx::Size
& device_viewport
, float device_scale_factor
) {
30 gfx::Size device_viewport_in_layout_pixels
= gfx::Size(
31 device_viewport
.width() / device_scale_factor
,
32 device_viewport
.height() / device_scale_factor
);
35 gfx::Transform matrix
;
36 matrix
.MakeIdentity();
38 if (layer_tree_host()->debug_state().ShowHudRects()) {
39 int max_texture_size
=
40 layer_tree_host()->GetRendererCapabilities().max_texture_size
;
41 bounds
.SetSize(std::min(max_texture_size
,
42 device_viewport_in_layout_pixels
.width()),
43 std::min(max_texture_size
,
44 device_viewport_in_layout_pixels
.height()));
47 bounds
.SetSize(size
, size
);
48 matrix
.Translate(device_viewport_in_layout_pixels
.width() - size
, 0.0);
55 bool HeadsUpDisplayLayer::HasDrawableContent() const {
59 scoped_ptr
<LayerImpl
> HeadsUpDisplayLayer::CreateLayerImpl(
60 LayerTreeImpl
* tree_impl
) {
61 return HeadsUpDisplayLayerImpl::Create(tree_impl
, layer_id_
);