blob: cd702793d13bf6d893243a936fa23102f56b47b2 [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
junov@chromium.orgb6e16192011-12-09 15:48:03 +000021 virtual bool isOpaque() const SK_OVERRIDE;
reed@android.com8a1c16f2008-12-17 15:59:43 +000022 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();
reed@google.com7c2f27d2011-03-07 19:29:00 +000028 virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*,
29 SkScalar* twoPointRadialParams) const;
reed@android.com8a1c16f2008-12-17 15:59:43 +000030
31 static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty);
32
reed@google.com7c2f27d2011-03-07 19:29:00 +000033 static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
reed@android.com8a1c16f2008-12-17 15:59:43 +000034 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
reed@google.com7c2f27d2011-03-07 19:29:00 +000049private:
reed@android.com8a1c16f2008-12-17 15:59:43 +000050 typedef SkShader INHERITED;
51};
52
53#endif