summaryrefslogtreecommitdiffstats
path: root/cc/bitmap_content_layer_updater.h
blob: f951a55dcd845afbec5e491056c78be2b603d7e9 (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
// 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 CC_BITMAP_CONTENT_LAYER_UPDATER_H_
#define CC_BITMAP_CONTENT_LAYER_UPDATER_H_

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

class SkCanvas;

namespace cc {

class LayerPainter;

// This class rasterizes the contentRect into a skia bitmap canvas. It then updates
// textures by copying from the canvas into the texture, using MapSubImage if
// possible.
class CC_EXPORT BitmapContentLayerUpdater : public ContentLayerUpdater {
public:
    class Resource : public LayerUpdater::Resource {
    public:
        Resource(BitmapContentLayerUpdater*, scoped_ptr<PrioritizedResource>);
        virtual ~Resource();

        virtual void update(ResourceUpdateQueue&, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE;

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

        BitmapContentLayerUpdater* m_updater;
    };

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

    virtual scoped_ptr<LayerUpdater::Resource> createResource(PrioritizedResourceManager*) OVERRIDE;
    virtual void prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size& tileSize, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats&) OVERRIDE;
    void updateTexture(ResourceUpdateQueue&, PrioritizedResource*, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate);

    virtual void setOpaque(bool) OVERRIDE;

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

    scoped_ptr<SkCanvas> m_canvas;
    gfx::Size m_canvasSize;
    bool m_opaque;
};

}  // namespace cc

#endif  // CC_BITMAP_CONTENT_LAYER_UPDATER_H_