summaryrefslogtreecommitdiffstats
path: root/cc/bitmap_skpicture_content_layer_updater.h
blob: db09eb77ce15833c751c64921d886b0a49ea09cd (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
// 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_SKPICTURE_CONTENT_LAYER_UPDATER_H_
#define CC_BITMAP_SKPICTURE_CONTENT_LAYER_UPDATER_H_

#include "cc/skpicture_content_layer_updater.h"
#include "third_party/skia/include/core/SkBitmap.h"

namespace cc {

// This class records the contentRect into an SkPicture, then software rasterizes
// the SkPicture into bitmaps for each tile. This implements Settings::perTilePainting.
class BitmapSkPictureContentLayerUpdater : public SkPictureContentLayerUpdater {
public:
    class Resource : public ContentLayerUpdater::Resource {
    public:
        Resource(BitmapSkPictureContentLayerUpdater*, scoped_ptr<PrioritizedResource>);

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

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

        SkBitmap m_bitmap;
        BitmapSkPictureContentLayerUpdater* m_updater;
    };

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

    virtual scoped_ptr<LayerUpdater::Resource> createResource(PrioritizedResourceManager*) OVERRIDE;
    void paintContentsRect(SkCanvas*, const gfx::Rect& sourceRect, RenderingStats&);

private:
    explicit BitmapSkPictureContentLayerUpdater(scoped_ptr<LayerPainter>);
    virtual ~BitmapSkPictureContentLayerUpdater();
};

}  // namespace cc

#endif  // CC_BITMAP_SKPICTURE_CONTENT_LAYER_UPDATER_H_