aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image/SkImage_Base.h
blob: 4ff6a25965166beca7f6aef96008936f8e8929fd (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
/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkImage_Base_DEFINED
#define SkImage_Base_DEFINED

#include "SkImage.h"

class SkImage_Base : public SkImage {
public:
    SkImage_Base(int width, int height) : INHERITED(width, height) {}

    virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const = 0;
    virtual void onDrawRect(SkCanvas*, const SkRect* src,
                                  const SkRect& dst, const SkPaint*) const = 0;

    // Default impl calls onDraw
    virtual bool onReadPixels(SkBitmap*, const SkIRect& subset) const;

    virtual const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const {
        return NULL;
    }

    virtual GrTexture* onGetTexture() const { return NULL; }

    // return a read-only copy of the pixels. We promise to not modify them,
    // but only inspect them (or encode them).
    virtual bool getROPixels(SkBitmap*) const { return false; }

    virtual SkShader* onNewShader(SkShader::TileMode,
                                  SkShader::TileMode,
                                  const SkMatrix* localMatrix) const { return NULL; };
private:
    typedef SkImage INHERITED;
};

#endif