00001 /* 00002 * Copyright (C) 2006 The Android Open Source Project 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef SkTransparentShader_DEFINED 00018 #define SkTransparentShader_DEFINED 00019 00020 #include "SkShader.h" 00021 00022 class SkTransparentShader : public SkShader { 00023 public: 00024 SkTransparentShader() {} 00025 virtual uint32_t getFlags(); 00026 virtual bool setContext( const SkBitmap& device, 00027 const SkPaint& paint, 00028 const SkMatrix& matrix); 00029 virtual void shadeSpan(int x, int y, SkPMColor[], int count); 00030 virtual void shadeSpan16(int x, int y, uint16_t span[], int count); 00031 00032 // overrides for SkFlattenable 00033 virtual Factory getFactory() { return Create; } 00034 virtual void flatten(SkFlattenableWriteBuffer& buffer) 00035 { 00036 this->INHERITED::flatten(buffer); 00037 } 00038 00039 private: 00040 // these are a cache from the call to setContext() 00041 const SkBitmap* fDevice; 00042 uint8_t fAlpha; 00043 00044 SkTransparentShader(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} 00045 00046 static SkFlattenable* Create(SkFlattenableReadBuffer& buffer) 00047 { 00048 return SkNEW_ARGS(SkTransparentShader, (buffer)); 00049 } 00050 00051 typedef SkShader INHERITED; 00052 }; 00053 00054 #endif 00055