blob: 5e87609bf89a491f2cbb2a4380c64b1fa4bc0394 [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SkTransparentShader_DEFINED
18#define SkTransparentShader_DEFINED
19
20#include "SkShader.h"
21
22class SkTransparentShader : public SkShader {
23public:
24 SkTransparentShader() {}
25 virtual uint32_t getFlags();
26 virtual bool setContext( const SkBitmap& device,
27 const SkPaint& paint,
28 const SkMatrix& matrix);
29 virtual void shadeSpan(int x, int y, SkPMColor[], int count);
30 virtual void shadeSpan16(int x, int y, uint16_t span[], int count);
31
32 // overrides for SkFlattenable
33 virtual Factory getFactory() { return Create; }
mike@reedtribe.org6b919c32011-04-20 11:17:30 +000034 virtual void flatten(SkFlattenableWriteBuffer& buffer) {
reed@android.com8a1c16f2008-12-17 15:59:43 +000035 this->INHERITED::flatten(buffer);
36 }
37
38private:
39 // these are a cache from the call to setContext()
40 const SkBitmap* fDevice;
41 uint8_t fAlpha;
42
43 SkTransparentShader(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {}
44
mike@reedtribe.org6b919c32011-04-20 11:17:30 +000045 static SkFlattenable* Create(SkFlattenableReadBuffer& buffer) {
reed@android.com8a1c16f2008-12-17 15:59:43 +000046 return SkNEW_ARGS(SkTransparentShader, (buffer));
47 }
48
49 typedef SkShader INHERITED;
50};
51
52#endif
53