Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: cc/heads_up_display_layer.cc

Issue 11189037: toggle FPS counter in compositor (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: added DCHECKs and moved hasFontAtlas into HUDLayer Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/heads_up_display_layer.h" 7 #include "cc/heads_up_display_layer.h"
8 8
9 #include "CCHeadsUpDisplayLayerImpl.h" 9 #include "CCHeadsUpDisplayLayerImpl.h"
10 #include "CCLayerTreeHost.h" 10 #include "CCLayerTreeHost.h"
11 #include "base/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
12 12
13 namespace cc { 13 namespace cc {
14 14
15 scoped_refptr<HeadsUpDisplayLayerChromium> HeadsUpDisplayLayerChromium::create() 15 scoped_refptr<HeadsUpDisplayLayerChromium> HeadsUpDisplayLayerChromium::create()
16 { 16 {
17 return make_scoped_refptr(new HeadsUpDisplayLayerChromium()); 17 return make_scoped_refptr(new HeadsUpDisplayLayerChromium());
18 } 18 }
19 19
20 HeadsUpDisplayLayerChromium::HeadsUpDisplayLayerChromium() 20 HeadsUpDisplayLayerChromium::HeadsUpDisplayLayerChromium()
21 : LayerChromium() 21 : LayerChromium()
22 , m_showFPSCounter(false)
23 , m_hasFontAtlas(false)
22 { 24 {
23
24 setBounds(IntSize(512, 128)); 25 setBounds(IntSize(512, 128));
25 } 26 }
26 27
27 HeadsUpDisplayLayerChromium::~HeadsUpDisplayLayerChromium() 28 HeadsUpDisplayLayerChromium::~HeadsUpDisplayLayerChromium()
28 { 29 {
29 } 30 }
30 31
31 void HeadsUpDisplayLayerChromium::update(CCTextureUpdateQueue&, const CCOcclusio nTracker*, CCRenderingStats&) 32 void HeadsUpDisplayLayerChromium::update(CCTextureUpdateQueue&, const CCOcclusio nTracker*, CCRenderingStats&)
32 { 33 {
33 const CCLayerTreeSettings& settings = layerTreeHost()->settings(); 34 const CCLayerTreeSettings& settings = layerTreeHost()->settings();
34 int maxTextureSize = layerTreeHost()->rendererCapabilities().maxTextureSize; 35 int maxTextureSize = layerTreeHost()->rendererCapabilities().maxTextureSize;
35 36
36 IntSize bounds; 37 IntSize bounds;
37 if (settings.showPlatformLayerTree || settings.showDebugRects()) { 38 if (settings.showPlatformLayerTree || settings.showDebugRects()) {
38 bounds.setWidth(std::min(maxTextureSize, layerTreeHost()->deviceViewport Size().width())); 39 bounds.setWidth(std::min(maxTextureSize, layerTreeHost()->deviceViewport Size().width()));
39 bounds.setHeight(std::min(maxTextureSize, layerTreeHost()->deviceViewpor tSize().height())); 40 bounds.setHeight(std::min(maxTextureSize, layerTreeHost()->deviceViewpor tSize().height()));
40 } else { 41 } else {
41 bounds.setWidth(512); 42 bounds.setWidth(512);
42 bounds.setHeight(128); 43 bounds.setHeight(128);
43 } 44 }
44 45
45 setBounds(bounds); 46 setBounds(bounds);
46 } 47 }
47 48
48 bool HeadsUpDisplayLayerChromium::drawsContent() const 49 bool HeadsUpDisplayLayerChromium::drawsContent() const
49 { 50 {
50 return true; 51 return true;
enne (OOO) 2012/10/24 18:35:27 Maybe this should be hasFontAtlas()?
51 } 52 }
52 53
54 bool HeadsUpDisplayLayerChromium::hasFontAtlas() const
55 {
56 return m_hasFontAtlas;
57 }
58
53 void HeadsUpDisplayLayerChromium::setFontAtlas(scoped_ptr<CCFontAtlas> fontAtlas ) 59 void HeadsUpDisplayLayerChromium::setFontAtlas(scoped_ptr<CCFontAtlas> fontAtlas )
54 { 60 {
55 m_fontAtlas = fontAtlas.Pass(); 61 m_fontAtlas = fontAtlas.Pass();
62 m_hasFontAtlas = true;
56 setNeedsCommit(); 63 setNeedsCommit();
57 } 64 }
58 65
66 void HeadsUpDisplayLayerChromium::setShowFPSCounter(bool show)
67 {
68 m_showFPSCounter = show;
enne (OOO) 2012/10/24 18:35:27 Only setNeedsCommit if m_showFPSCounter changes va
69 setNeedsCommit();
70 }
71
59 scoped_ptr<CCLayerImpl> HeadsUpDisplayLayerChromium::createCCLayerImpl() 72 scoped_ptr<CCLayerImpl> HeadsUpDisplayLayerChromium::createCCLayerImpl()
60 { 73 {
61 return CCHeadsUpDisplayLayerImpl::create(m_layerId).PassAs<CCLayerImpl>(); 74 return CCHeadsUpDisplayLayerImpl::create(m_layerId).PassAs<CCLayerImpl>();
62 } 75 }
63 76
64 void HeadsUpDisplayLayerChromium::pushPropertiesTo(CCLayerImpl* layerImpl) 77 void HeadsUpDisplayLayerChromium::pushPropertiesTo(CCLayerImpl* layerImpl)
65 { 78 {
66 LayerChromium::pushPropertiesTo(layerImpl); 79 LayerChromium::pushPropertiesTo(layerImpl);
67 80
68 if (!m_fontAtlas.get()) 81 CCHeadsUpDisplayLayerImpl* hudLayerImpl = static_cast<CCHeadsUpDisplayLayerI mpl*>(layerImpl);
69 return; 82 hudLayerImpl->setShowFPSCounter(m_showFPSCounter);
70 83
71 CCHeadsUpDisplayLayerImpl* hudLayerImpl = static_cast<CCHeadsUpDisplayLayerI mpl*>(layerImpl); 84 if (m_fontAtlas.get())
72 hudLayerImpl->setFontAtlas(m_fontAtlas.Pass()); 85 hudLayerImpl->setFontAtlas(m_fontAtlas.Pass());
73 } 86 }
74 87
75 } 88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698