summaryrefslogtreecommitdiffstats
path: root/cc/heads_up_display_layer_impl.h
blob: b17644a38508db3dc3443adfa6a9c9f9d670363a (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
// 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.

#ifndef CCHeadsUpDisplayLayerImpl_h
#define CCHeadsUpDisplayLayerImpl_h

#include "base/memory/scoped_ptr.h"
#include "cc/font_atlas.h"
#include "cc/layer_impl.h"
#include "cc/scoped_texture.h"

class SkCanvas;

namespace cc {

class DebugRectHistory;
class FontAtlas;
class FrameRateCounter;

class HeadsUpDisplayLayerImpl : public LayerImpl {
public:
    static scoped_ptr<HeadsUpDisplayLayerImpl> create(int id)
    {
        return make_scoped_ptr(new HeadsUpDisplayLayerImpl(id));
    }
    virtual ~HeadsUpDisplayLayerImpl();

    void setFontAtlas(scoped_ptr<FontAtlas>);

    virtual void willDraw(ResourceProvider*) OVERRIDE;
    virtual void appendQuads(QuadSink&, AppendQuadsData&) OVERRIDE;
    void updateHudTexture(ResourceProvider*);
    virtual void didDraw(ResourceProvider*) OVERRIDE;

    virtual void didLoseContext() OVERRIDE;

    virtual bool layerIsAlwaysDamaged() const OVERRIDE;

private:
    explicit HeadsUpDisplayLayerImpl(int);

    virtual const char* layerTypeAsString() const OVERRIDE;

    void drawHudContents(SkCanvas*);
    void drawFPSCounter(SkCanvas*, FrameRateCounter*, int top, int height);
    void drawFPSCounterText(SkCanvas*, FrameRateCounter*, int top, int width, int height);
    void drawDebugRects(SkCanvas*, DebugRectHistory*);

    scoped_ptr<FontAtlas> m_fontAtlas;
    scoped_ptr<ScopedTexture> m_hudTexture;
    scoped_ptr<SkCanvas> m_hudCanvas;
};

}  // namespace cc

#endif // CCHeadsUpDisplayLayerImpl_h