summaryrefslogtreecommitdiffstats
path: root/cc/skpicture_canvas_layer_updater.h
blob: 5fe8e1a4fd9a53fb261912d907d83229229ba2a5 (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
// Copyright 2011 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 SkPictureCanvasLayerUpdater_h
#define SkPictureCanvasLayerUpdater_h

#include "cc/canvas_layer_updater.h"
#include "third_party/skia/include/core/SkPicture.h"

class SkCanvas;

namespace cc {

class LayerPainter;

// This class records the contentRect into an SkPicture. Subclasses, provide
// different implementations of tile updating based on this recorded picture.
// The BitmapSkPictureCanvasLayerUpdater and
// FrameBufferSkPictureCanvasLayerUpdater are two examples of such
// implementations.
class SkPictureCanvasLayerUpdater : public CanvasLayerUpdater {
public:
    class Texture : public LayerUpdater::Texture {
    public:
        Texture(SkPictureCanvasLayerUpdater*, scoped_ptr<PrioritizedTexture>);
        virtual ~Texture();

        virtual void update(TextureUpdateQueue&, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE;

    private:
        SkPictureCanvasLayerUpdater* updater() { return m_updater; }

        SkPictureCanvasLayerUpdater* m_updater;
    };

    static scoped_refptr<SkPictureCanvasLayerUpdater> create(scoped_ptr<LayerPainter>);

    virtual scoped_ptr<LayerUpdater::Texture> createTexture(PrioritizedTextureManager*) OVERRIDE;
    virtual void setOpaque(bool) OVERRIDE;

protected:
    explicit SkPictureCanvasLayerUpdater(scoped_ptr<LayerPainter>);
    virtual ~SkPictureCanvasLayerUpdater();

    virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, float contentsWidthScale, float contentsHeightScale, IntRect& resultingOpaqueRect, RenderingStats&) OVERRIDE;
    void drawPicture(SkCanvas*);
    void updateTexture(TextureUpdateQueue& queue, PrioritizedTexture* texture, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate);

    bool layerIsOpaque() const { return m_layerIsOpaque; }

private:
    // Recording canvas.
    SkPicture m_picture;
    // True when it is known that all output pixels will be opaque.
    bool m_layerIsOpaque;
};

} // namespace cc
#endif // SkPictureCanvasLayerUpdater_h