summaryrefslogtreecommitdiffstats
path: root/cc/bitmap_skpicture_content_layer_updater.h
blob: 7b2bf1fb2d9e69371fa93fa5ce668abb4798e7a3 (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 BitmapSkPictureContentLayerUpdater_h
#define BitmapSkPictureContentLayerUpdater_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<PrioritizedTexture>);

        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(PrioritizedTextureManager*) OVERRIDE;
    void paintContentsRect(SkCanvas*, const gfx::Rect& sourceRect, RenderingStats&);

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

}  // namespace cc

#endif  // BitmapSkPictureContentLayerUpdater_h