summaryrefslogtreecommitdiffstats
path: root/cc/content_layer.h
blob: cad68d1f7af5833ce57a28e95d051cf8efc6f4f3 (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
// Copyright 2010 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 CC_CONTENT_LAYER_H_
#define CC_CONTENT_LAYER_H_

#include "base/basictypes.h"
#include "cc/cc_export.h"
#include "cc/layer_painter.h"
#include "cc/tiled_layer.h"

class SkCanvas;

namespace cc {

class ContentLayerClient;
class LayerUpdater;

class CC_EXPORT ContentLayerPainter : public LayerPainter {
public:
    static scoped_ptr<ContentLayerPainter> create(ContentLayerClient*);

    virtual void paint(SkCanvas*, gfx::Rect contentRect, gfx::RectF& opaque) OVERRIDE;

private:
    explicit ContentLayerPainter(ContentLayerClient*);

    ContentLayerClient* m_client;

    DISALLOW_COPY_AND_ASSIGN(ContentLayerPainter);
};

// A layer that renders its contents into an SkCanvas.
class CC_EXPORT ContentLayer : public TiledLayer {
public:
    static scoped_refptr<ContentLayer> create(ContentLayerClient*);

    void clearClient() { m_client = 0; }
    bool useLCDText() const { return m_useLCDText; }

    virtual bool drawsContent() const OVERRIDE;
    virtual void setTexturePriorities(const PriorityCalculator&) OVERRIDE;
    virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&) OVERRIDE;
    virtual bool needMoreUpdates() OVERRIDE;

    virtual void setContentsOpaque(bool) OVERRIDE;

protected:
    explicit ContentLayer(ContentLayerClient*);
    virtual ~ContentLayer();

private:
    virtual LayerUpdater* updater() const OVERRIDE;
    virtual void createUpdaterIfNeeded() OVERRIDE;

    void updateUseLCDText();
    // Called when LCD text setting is about to potentially change.
    // If this function returns true, the setting is allowed to change.
    // If it returns false, the setting is not changed.
    bool useLCDTextWillChange() const;
    void useLCDTextDidChange();

    ContentLayerClient* m_client;
    scoped_refptr<LayerUpdater> m_updater;

    bool m_useLCDText;
    int m_lcdTextChangeCount;
    static const int kLCDTextMaxChangeCount;
};

}
#endif  // CC_CONTENT_LAYER_H_