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()
20 , m_hasFontAtlas(false)
22 setBounds(gfx::Size(256, 128));
25 HeadsUpDisplayLayer::~HeadsUpDisplayLayer()
29 void HeadsUpDisplayLayer::update(ResourceUpdateQueue
&, const OcclusionTracker
*, RenderingStats
&)
31 const LayerTreeDebugState
& debugState
= layerTreeHost()->debugState();
32 int maxTextureSize
= layerTreeHost()->rendererCapabilities().maxTextureSize
;
35 gfx::Transform matrix
;
36 matrix
.MakeIdentity();
38 if (debugState
.showPlatformLayerTree
|| debugState
.showHudRects()) {
39 int width
= std::min(maxTextureSize
, layerTreeHost()->layoutViewportSize().width());
40 int height
= std::min(maxTextureSize
, layerTreeHost()->layoutViewportSize().height());
41 bounds
= gfx::Size(width
, height
);
43 bounds
= gfx::Size(256, 128);
44 matrix
.Translate(layerTreeHost()->layoutViewportSize().width() - 256, 0);
51 bool HeadsUpDisplayLayer::drawsContent() const
56 void HeadsUpDisplayLayer::setFontAtlas(scoped_ptr
<FontAtlas
> fontAtlas
)
58 m_fontAtlas
= fontAtlas
.Pass();
59 m_hasFontAtlas
= true;
62 scoped_ptr
<LayerImpl
> HeadsUpDisplayLayer::createLayerImpl(LayerTreeHostImpl
* hostImpl
)
64 return HeadsUpDisplayLayerImpl::create(hostImpl
, m_layerId
).PassAs
<LayerImpl
>();
67 void HeadsUpDisplayLayer::pushPropertiesTo(LayerImpl
* layerImpl
)
69 Layer::pushPropertiesTo(layerImpl
);
74 HeadsUpDisplayLayerImpl
* hudLayerImpl
= static_cast<HeadsUpDisplayLayerImpl
*>(layerImpl
);
75 hudLayerImpl
->setFontAtlas(m_fontAtlas
.Pass());