SkBitmapProcShader.h revision ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976e
169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal/* 369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * Copyright 2006 The Android Open Source Project 469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * 569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * Use of this source code is governed by a BSD-style license that can be 669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * found in the LICENSE file. 769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal */ 869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 1069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal#ifndef SkBitmapProcShader_DEFINED 1169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal#define SkBitmapProcShader_DEFINED 1269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 1369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal#include "SkShader.h" 1469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal#include "SkBitmapProcState.h" 1569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 1669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalclass SkBitmapProcShader : public SkShader { 1769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalpublic: 1869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal SkBitmapProcShader(const SkBitmap& src, TileMode tx, TileMode ty); 1969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 2069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal // overrides from SkShader 2169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal virtual bool setContext(const SkBitmap&, const SkPaint&, const SkMatrix&); 2269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal virtual uint32_t getFlags() { return fFlags; } 2369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count); 2469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count); 2569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal virtual void beginSession(); 2669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal virtual void endSession(); 2769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*, 2869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal SkScalar* twoPointRadialParams) const; 2969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 3069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty); 3169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 3269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { 3369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal return SkNEW_ARGS(SkBitmapProcShader, (buffer)); 3469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal } 3569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 3669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal // override from flattenable 3769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal virtual bool toDumpString(SkString* str) const; 3869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 3969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalprotected: 4069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal SkBitmapProcShader(SkFlattenableReadBuffer& ); 4169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal virtual void flatten(SkFlattenableWriteBuffer& ); 4269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal virtual Factory getFactory() { return CreateProc; } 4369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 4469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal SkBitmap fRawBitmap; // experimental for RLE encoding 4569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal SkBitmapProcState fState; 4669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal uint32_t fFlags; 4769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 4869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalprivate: 4969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal typedef SkShader INHERITED; 5069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal}; 5169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 5269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal#endif 5369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal