SkBitmapProcShader.h revision 1adcf8859cc9414591038e440e3f22382c8e4aa0
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 void endContext();
24    virtual uint32_t getFlags() { return fFlags; }
25    virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count);
26    virtual ShadeProc asAShadeProc(void** ctx) SK_OVERRIDE;
27    virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count);
28    virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const;
29
30    static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty);
31
32    // override from flattenable
33    virtual bool toDumpString(SkString* str) const;
34    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader)
35
36protected:
37    SkBitmapProcShader(SkFlattenableReadBuffer& );
38    virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
39
40    SkBitmap          fRawBitmap;   // experimental for RLE encoding
41    SkBitmapProcState fState;
42    uint32_t          fFlags;
43
44private:
45    typedef SkShader INHERITED;
46};
47
48#endif
49