blob: 9af9d2e8970aa2b54a29fc18f3ce0d979f9421f6 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
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
reed@android.com8a1c16f2008-12-17 15:59:43 +00009
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 setContext(const SkBitmap&, const SkPaint&, const SkMatrix&);
22 virtual uint32_t getFlags() { return fFlags; }
23 virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count);
24 virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count);
25 virtual void beginSession();
26 virtual void endSession();
reed@google.com7c2f27d2011-03-07 19:29:00 +000027 virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*,
28 SkScalar* twoPointRadialParams) const;
reed@android.com8a1c16f2008-12-17 15:59:43 +000029
30 static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty);
31
reed@google.com7c2f27d2011-03-07 19:29:00 +000032 static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
reed@android.com8a1c16f2008-12-17 15:59:43 +000033 return SkNEW_ARGS(SkBitmapProcShader, (buffer));
34 }
35
36 // override from flattenable
37 virtual bool toDumpString(SkString* str) const;
38
39protected:
40 SkBitmapProcShader(SkFlattenableReadBuffer& );
41 virtual void flatten(SkFlattenableWriteBuffer& );
42 virtual Factory getFactory() { return CreateProc; }
43
44 SkBitmap fRawBitmap; // experimental for RLE encoding
45 SkBitmapProcState fState;
46 uint32_t fFlags;
47
reed@google.com7c2f27d2011-03-07 19:29:00 +000048private:
reed@android.com8a1c16f2008-12-17 15:59:43 +000049 typedef SkShader INHERITED;
50};
51
52#endif