blob: 71145b7acb5a8ab3763923c7256c421628539e5d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/heads_up_display_layer.h"
#include "base/debug/trace_event.h"
#include "cc/heads_up_display_layer_impl.h"
#include "cc/layer_tree_host.h"
namespace cc {
scoped_refptr<HeadsUpDisplayLayer> HeadsUpDisplayLayer::create()
{
return make_scoped_refptr(new HeadsUpDisplayLayer());
}
HeadsUpDisplayLayer::HeadsUpDisplayLayer()
: Layer()
, m_hasFontAtlas(false)
{
setBounds(gfx::Size(256, 128));
}
HeadsUpDisplayLayer::~HeadsUpDisplayLayer()
{
}
void HeadsUpDisplayLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&)
{
const LayerTreeDebugState& debugState = layerTreeHost()->debugState();
int maxTextureSize = layerTreeHost()->rendererCapabilities().maxTextureSize;
gfx::Size bounds;
gfx::Transform matrix;
matrix.MakeIdentity();
if (debugState.showPlatformLayerTree || debugState.showHudRects()) {
int width = std::min(maxTextureSize, layerTreeHost()->layoutViewportSize().width());
int height = std::min(maxTextureSize, layerTreeHost()->layoutViewportSize().height());
bounds = gfx::Size(width, height);
} else {
bounds = gfx::Size(256, 128);
matrix.Translate(layerTreeHost()->layoutViewportSize().width() - 256, 0);
}
setBounds(bounds);
setTransform(matrix);
}
bool HeadsUpDisplayLayer::drawsContent() const
{
return true;
}
void HeadsUpDisplayLayer::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas)
{
m_fontAtlas = fontAtlas.Pass();
m_hasFontAtlas = true;
}
scoped_ptr<LayerImpl> HeadsUpDisplayLayer::createLayerImpl(LayerTreeImpl* treeImpl)
{
return HeadsUpDisplayLayerImpl::create(treeImpl, m_layerId).PassAs<LayerImpl>();
}
void HeadsUpDisplayLayer::pushPropertiesTo(LayerImpl* layerImpl)
{
Layer::pushPropertiesTo(layerImpl);
if (!m_fontAtlas)
return;
HeadsUpDisplayLayerImpl* hudLayerImpl = static_cast<HeadsUpDisplayLayerImpl*>(layerImpl);
hudLayerImpl->setFontAtlas(m_fontAtlas.Pass());
}
} // namespace cc
|