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/heads_up_display_layer.h"
7 #include "base/debug/trace_event.h"
8 #include "cc/heads_up_display_layer_impl.h"
9 #include "cc/layer_tree_host.h"
13 scoped_refptr
<HeadsUpDisplayLayer
> HeadsUpDisplayLayer::create()
15 return make_scoped_refptr(new HeadsUpDisplayLayer());
18 HeadsUpDisplayLayer::HeadsUpDisplayLayer()
21 setBounds(gfx::Size(256, 128));
24 HeadsUpDisplayLayer::~HeadsUpDisplayLayer()
28 void HeadsUpDisplayLayer::update(ResourceUpdateQueue
&, const OcclusionTracker
*, RenderingStats
&)
30 const LayerTreeDebugState
& debugState
= layerTreeHost()->debugState();
31 int maxTextureSize
= layerTreeHost()->rendererCapabilities().maxTextureSize
;
34 gfx::Transform matrix
;
35 matrix
.MakeIdentity();
37 if (debugState
.showPlatformLayerTree
|| debugState
.showHudRects()) {
38 int width
= std::min(maxTextureSize
, layerTreeHost()->layoutViewportSize().width());
39 int height
= std::min(maxTextureSize
, layerTreeHost()->layoutViewportSize().height());
40 bounds
= gfx::Size(width
, height
);
42 bounds
= gfx::Size(256, 128);
43 matrix
.Translate(layerTreeHost()->layoutViewportSize().width() - 256, 0);
50 bool HeadsUpDisplayLayer::drawsContent() const
55 void HeadsUpDisplayLayer::setFontAtlas(scoped_ptr
<FontAtlas
> fontAtlas
)
57 m_fontAtlas
= fontAtlas
.Pass();
61 scoped_ptr
<LayerImpl
> HeadsUpDisplayLayer::createLayerImpl()
63 return HeadsUpDisplayLayerImpl::create(m_layerId
).PassAs
<LayerImpl
>();
66 void HeadsUpDisplayLayer::pushPropertiesTo(LayerImpl
* layerImpl
)
68 Layer::pushPropertiesTo(layerImpl
);
73 HeadsUpDisplayLayerImpl
* hudLayerImpl
= static_cast<HeadsUpDisplayLayerImpl
*>(layerImpl
);
74 hudLayerImpl
->setFontAtlas(m_fontAtlas
.Pass());