SkBitmapProcShader.h revision a2ca41e3afdd8fad5e0e924dec029f33918e0a67
1
2/*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
10#ifndef SkBitmapProcShader_DEFINED
11#define SkBitmapProcShader_DEFINED
12
13#include "SkShader.h"
14#include "SkBitmapProcState.h"
15
16class SkBitmapProcShader : public SkShader {
17public:
18    SkBitmapProcShader(const SkBitmap& src, TileMode tx, TileMode ty);
19
20    // overrides from SkShader
21    virtual bool isOpaque() const SK_OVERRIDE;
22    virtual bool setContext(const SkBitmap&, const SkPaint&, const SkMatrix&);
23    virtual uint32_t getFlags() { return fFlags; }
24    virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count);
25    virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count);
26    virtual void beginSession();
27    virtual void endSession();
28    virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*,
29                                 SkScalar* twoPointRadialParams) const;
30
31    static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty);
32
33    static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
34        return SkNEW_ARGS(SkBitmapProcShader, (buffer));
35    }
36
37    // override from flattenable
38    virtual bool toDumpString(SkString* str) const;
39
40protected:
41    SkBitmapProcShader(SkFlattenableReadBuffer& );
42    virtual void flatten(SkFlattenableWriteBuffer& );
43    virtual Factory getFactory() { return CreateProc; }
44
45    SkBitmap          fRawBitmap;   // experimental for RLE encoding
46    SkBitmapProcState fState;
47    uint32_t          fFlags;
48
49private:
50    typedef SkShader INHERITED;
51};
52
53#endif
54