summaryrefslogtreecommitdiffstats
path: root/cc/texture_layer.h
blob: cfa5ddb16485fedef426605f3f54fa235c45d607 (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
// 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_TEXTURE_LAYER_H_
#define CC_TEXTURE_LAYER_H_

#include "cc/cc_export.h"
#include "cc/layer.h"

namespace WebKit {
class WebGraphicsContext3D;
}

namespace cc {

class TextureLayerClient;

// A Layer containing a the rendered output of a plugin instance.
class CC_EXPORT TextureLayer : public Layer {
public:
    // If this texture layer requires special preparation logic for each frame driven by
    // the compositor, pass in a non-nil client. Pass in a nil client pointer if texture updates
    // are driven by an external process.
    static scoped_refptr<TextureLayer> create(TextureLayerClient*);

    void clearClient() { m_client = 0; }

    virtual scoped_ptr<LayerImpl> createLayerImpl() OVERRIDE;

    // Sets whether this texture should be Y-flipped at draw time. Defaults to true.
    void setFlipped(bool);

    // Sets a UV transform to be used at draw time. Defaults to (0, 0, 1, 1).
    void setUVRect(const gfx::RectF&);

    // Sets whether the alpha channel is premultiplied or unpremultiplied. Defaults to true.
    void setPremultipliedAlpha(bool);

    // Sets whether this context should rate limit on damage to prevent too many frames from
    // being queued up before the compositor gets a chance to run. Requires a non-nil client.
    // Defaults to false.
    void setRateLimitContext(bool);

    // Code path for plugins which supply their own texture ID.
    void setTextureId(unsigned);

    void willModifyTexture();

    virtual void setNeedsDisplayRect(const gfx::RectF&) OVERRIDE;

    virtual void setLayerTreeHost(LayerTreeHost*) OVERRIDE;
    virtual bool drawsContent() const OVERRIDE;
    virtual void update(ResourceUpdateQueue&, const OcclusionTracker*, RenderingStats&) OVERRIDE;
    virtual void pushPropertiesTo(LayerImpl*) OVERRIDE;

protected:
    explicit TextureLayer(TextureLayerClient*);
    virtual ~TextureLayer();

private:
    TextureLayerClient* m_client;

    bool m_flipped;
    gfx::RectF m_uvRect;
    bool m_premultipliedAlpha;
    bool m_rateLimitContext;
    bool m_contextLost;
    bool m_contentCommitted;

    unsigned m_textureId;
};

}
#endif  // CC_TEXTURE_LAYER_H_