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 16 class SkBitmapProcShader : public SkShader { 17 public: 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 40 SK_DECLARE_FLATTENABLE_REGISTRAR() 41 protected: 42 SkBitmapProcShader(SkFlattenableReadBuffer& ); 43 virtual void flatten(SkFlattenableWriteBuffer& ); 44 virtual Factory getFactory() { return CreateProc; } 45 46 SkBitmap fRawBitmap; // experimental for RLE encoding 47 SkBitmapProcState fState; 48 uint32_t fFlags; 49 50 private: 51 typedef SkShader INHERITED; 52 }; 53 54 #endif 55