SkBitmapProcShader.h revision 8a1c16ff38322f0210116fa7293eb8817c7e477e
18a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/* libs/graphics/sgl/SkBitmapShader.h 28a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com** 38a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com** Copyright 2006, The Android Open Source Project 48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com** 58a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com** Licensed under the Apache License, Version 2.0 (the "License"); 68a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com** you may not use this file except in compliance with the License. 78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com** You may obtain a copy of the License at 88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com** 98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com** http://www.apache.org/licenses/LICENSE-2.0 108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com** 118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com** Unless required by applicable law or agreed to in writing, software 128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com** distributed under the License is distributed on an "AS IS" BASIS, 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com** See the License for the specific language governing permissions and 158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com** limitations under the License. 168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/ 178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkBitmapProcShader_DEFINED 198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkBitmapProcShader_DEFINED 208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkShader.h" 228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkBitmapProcState.h" 238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkBitmapProcShader : public SkShader { 258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBitmapProcShader(const SkBitmap& src, TileMode tx, TileMode ty); 278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // overrides from SkShader 298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool setContext(const SkBitmap&, const SkPaint&, const SkMatrix&); 308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual uint32_t getFlags() { return fFlags; } 318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count); 328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count); 338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void beginSession(); 348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void endSession(); 358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool asABitmap(SkBitmap*, SkMatrix*, TileMode*); 368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty); 388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { 408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return SkNEW_ARGS(SkBitmapProcShader, (buffer)); 418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // override from flattenable 448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool toDumpString(SkString* str) const; 458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprotected: 478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBitmapProcShader(SkFlattenableReadBuffer& ); 488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void flatten(SkFlattenableWriteBuffer& ); 498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual Factory getFactory() { return CreateProc; } 508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBitmap fRawBitmap; // experimental for RLE encoding 528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBitmapProcState fState; 538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com uint32_t fFlags; 548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com typedef SkShader INHERITED; 578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 60