| OLD | NEW | 
|---|
| 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 "cc/heads_up_display_layer.h" | 5 #include "cc/heads_up_display_layer.h" | 
| 6 | 6 | 
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" | 
| 8 #include "cc/heads_up_display_layer_impl.h" | 8 #include "cc/heads_up_display_layer_impl.h" | 
| 9 #include "cc/layer_tree_host.h" | 9 #include "cc/layer_tree_host.h" | 
| 10 | 10 | 
| 11 namespace cc { | 11 namespace cc { | 
| 12 | 12 | 
| 13 scoped_refptr<HeadsUpDisplayLayer> HeadsUpDisplayLayer::create() | 13 scoped_refptr<HeadsUpDisplayLayer> HeadsUpDisplayLayer::create() | 
| 14 { | 14 { | 
| 15     return make_scoped_refptr(new HeadsUpDisplayLayer()); | 15     return make_scoped_refptr(new HeadsUpDisplayLayer()); | 
| 16 } | 16 } | 
| 17 | 17 | 
| 18 HeadsUpDisplayLayer::HeadsUpDisplayLayer() | 18 HeadsUpDisplayLayer::HeadsUpDisplayLayer() | 
| 19     : Layer() | 19     : Layer() | 
| 20     , m_showFPSCounter(false) |  | 
| 21 { | 20 { | 
| 22     setBounds(gfx::Size(256, 128)); | 21     setBounds(gfx::Size(256, 128)); | 
| 23 } | 22 } | 
| 24 | 23 | 
| 25 HeadsUpDisplayLayer::~HeadsUpDisplayLayer() | 24 HeadsUpDisplayLayer::~HeadsUpDisplayLayer() | 
| 26 { | 25 { | 
| 27 } | 26 } | 
| 28 | 27 | 
| 29 void HeadsUpDisplayLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, 
    RenderingStats&) | 28 void HeadsUpDisplayLayer::update(ResourceUpdateQueue&, const OcclusionTracker*, 
    RenderingStats&) | 
| 30 { | 29 { | 
| 31     const LayerTreeSettings& settings = layerTreeHost()->settings(); | 30     const LayerTreeDebugState& debugState = layerTreeHost()->debugState(); | 
| 32     int maxTextureSize = layerTreeHost()->rendererCapabilities().maxTextureSize; | 31     int maxTextureSize = layerTreeHost()->rendererCapabilities().maxTextureSize; | 
| 33 | 32 | 
| 34     gfx::Size bounds; | 33     gfx::Size bounds; | 
| 35     gfx::Transform matrix; | 34     gfx::Transform matrix; | 
| 36     matrix.MakeIdentity(); | 35     matrix.MakeIdentity(); | 
| 37 | 36 | 
| 38     if (settings.showPlatformLayerTree || settings.showDebugRects()) { | 37     if (debugState.showPlatformLayerTree || debugState.showHudRects()) { | 
| 39         int width = std::min(maxTextureSize, layerTreeHost()->deviceViewportSize
    ().width()); | 38         int width = std::min(maxTextureSize, layerTreeHost()->deviceViewportSize
    ().width()); | 
| 40         int height = std::min(maxTextureSize, layerTreeHost()->deviceViewportSiz
    e().height()); | 39         int height = std::min(maxTextureSize, layerTreeHost()->deviceViewportSiz
    e().height()); | 
| 41         bounds = gfx::Size(width, height); | 40         bounds = gfx::Size(width, height); | 
| 42     } else { | 41     } else { | 
| 43         bounds = gfx::Size(256, 128); | 42         bounds = gfx::Size(256, 128); | 
| 44         matrix.Translate(layerTreeHost()->deviceViewportSize().width() - 256, 0)
    ; | 43         matrix.Translate(layerTreeHost()->deviceViewportSize().width() - 256, 0)
    ; | 
| 45     } | 44     } | 
| 46 | 45 | 
| 47     setBounds(bounds); | 46     setBounds(bounds); | 
| 48     setTransform(matrix); | 47     setTransform(matrix); | 
| 49 } | 48 } | 
| 50 | 49 | 
| 51 bool HeadsUpDisplayLayer::drawsContent() const | 50 bool HeadsUpDisplayLayer::drawsContent() const | 
| 52 { | 51 { | 
| 53     return true; | 52     return true; | 
| 54 } | 53 } | 
| 55 | 54 | 
| 56 void HeadsUpDisplayLayer::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas) | 55 void HeadsUpDisplayLayer::setFontAtlas(scoped_ptr<FontAtlas> fontAtlas) | 
| 57 { | 56 { | 
| 58     m_fontAtlas = fontAtlas.Pass(); | 57     m_fontAtlas = fontAtlas.Pass(); | 
| 59     setNeedsCommit(); | 58     setNeedsCommit(); | 
| 60 } | 59 } | 
| 61 | 60 | 
| 62 void HeadsUpDisplayLayer::setShowFPSCounter(bool show) |  | 
| 63 { |  | 
| 64     m_showFPSCounter = show; |  | 
| 65     setNeedsCommit(); |  | 
| 66 } |  | 
| 67 |  | 
| 68 scoped_ptr<LayerImpl> HeadsUpDisplayLayer::createLayerImpl() | 61 scoped_ptr<LayerImpl> HeadsUpDisplayLayer::createLayerImpl() | 
| 69 { | 62 { | 
| 70     return HeadsUpDisplayLayerImpl::create(m_layerId).PassAs<LayerImpl>(); | 63     return HeadsUpDisplayLayerImpl::create(m_layerId).PassAs<LayerImpl>(); | 
| 71 } | 64 } | 
| 72 | 65 | 
| 73 void HeadsUpDisplayLayer::pushPropertiesTo(LayerImpl* layerImpl) | 66 void HeadsUpDisplayLayer::pushPropertiesTo(LayerImpl* layerImpl) | 
| 74 { | 67 { | 
| 75     Layer::pushPropertiesTo(layerImpl); | 68     Layer::pushPropertiesTo(layerImpl); | 
| 76 | 69 | 
|  | 70     if (!m_fontAtlas) | 
|  | 71         return; | 
|  | 72 | 
| 77     HeadsUpDisplayLayerImpl* hudLayerImpl = static_cast<HeadsUpDisplayLayerImpl*
    >(layerImpl); | 73     HeadsUpDisplayLayerImpl* hudLayerImpl = static_cast<HeadsUpDisplayLayerImpl*
    >(layerImpl); | 
| 78     hudLayerImpl->setShowFPSCounter(m_showFPSCounter); | 74     hudLayerImpl->setFontAtlas(m_fontAtlas.Pass()); | 
| 79 |  | 
| 80     if (m_fontAtlas.get()) |  | 
| 81         hudLayerImpl->setFontAtlas(m_fontAtlas.Pass()); |  | 
| 82 } | 75 } | 
| 83 | 76 | 
| 84 }  // namespace cc | 77 }  // namespace cc | 
| OLD | NEW | 
|---|