• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
22 class SkTransparentShader : public SkShader {
23 public:
SkTransparentShader()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
getFactory()33     virtual Factory getFactory() { return Create; }
flatten(SkFlattenableWriteBuffer & buffer)34     virtual void flatten(SkFlattenableWriteBuffer& buffer)
35     {
36         this->INHERITED::flatten(buffer);
37     }
38 
39 private:
40     // these are a cache from the call to setContext()
41     const SkBitmap* fDevice;
42     uint8_t         fAlpha;
43 
SkTransparentShader(SkFlattenableReadBuffer & buffer)44     SkTransparentShader(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {}
45 
Create(SkFlattenableReadBuffer & buffer)46     static SkFlattenable* Create(SkFlattenableReadBuffer& buffer)
47     {
48         return SkNEW_ARGS(SkTransparentShader, (buffer));
49     }
50 
51     typedef SkShader INHERITED;
52 };
53 
54 #endif
55 
56