SkBitmapProcShader.h revision 54924243c1b65b3ee6d8fa064b50a9b1bb2a19a5
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    // override from flattenable
34    virtual bool toDumpString(SkString* str) const;
35    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader)
36
37protected:
38    SkBitmapProcShader(SkFlattenableReadBuffer& );
39    virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
40
41    SkBitmap          fRawBitmap;   // experimental for RLE encoding
42    SkBitmapProcState fState;
43    uint32_t          fFlags;
44
45private:
46    typedef SkShader INHERITED;
47};
48
49#endif
50