OLD | NEW |
| (Empty) |
1 /* libs/graphics/sgl/SkBitmapShader.h | |
2 ** | |
3 ** Copyright 2006, The Android Open Source Project | |
4 ** | |
5 ** Licensed under the Apache License, Version 2.0 (the "License"); | |
6 ** you may not use this file except in compliance with the License. | |
7 ** You may obtain a copy of the License at | |
8 ** | |
9 ** http://www.apache.org/licenses/LICENSE-2.0 | |
10 ** | |
11 ** Unless required by applicable law or agreed to in writing, software | |
12 ** distributed under the License is distributed on an "AS IS" BASIS, | |
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 ** See the License for the specific language governing permissions and | |
15 ** limitations under the License. | |
16 */ | |
17 | |
18 #ifndef SkBitmapShader_DEFINED | |
19 #define SkBitmapShader_DEFINED | |
20 | |
21 #include "SkShader.h" | |
22 #include "SkBitmap.h" | |
23 #include "SkPaint.h" | |
24 | |
25 class SkBitmapShader : public SkShader { | |
26 public: | |
27 SkBitmapShader( const SkBitmap& src, | |
28 bool doFilter, TileMode tx, TileMode ty); | |
29 | |
30 virtual bool setContext(const SkBitmap&, const SkPaint& paint, const
SkMatrix&); | |
31 virtual uint32_t getFlags() { return fFlags; } | |
32 | |
33 protected: | |
34 SkBitmapShader(SkFlattenableReadBuffer& ); | |
35 virtual void flatten(SkFlattenableWriteBuffer& ); | |
36 virtual Factory getFactory() { return CreateProc; } | |
37 const SkBitmap& getSrcBitmap() const | |
38 { | |
39 #ifdef SK_SUPPORT_MIPMAP | |
40 return fMipSrcBitmap; | |
41 #else | |
42 return fOrigSrcBitmap; | |
43 #endif | |
44 } | |
45 bool getFilterBitmap() const { return fFilterBitmap != 0; } | |
46 TileMode getTileModeX() const { return (TileMode)fTileModeX; } | |
47 TileMode getTileModeY() const { return (TileMode)fTileModeY; } | |
48 SkFixed getMipLevel() const | |
49 { | |
50 #ifdef SK_SUPPORT_MIPMAP | |
51 return fMipLevel; | |
52 #else | |
53 return 0; | |
54 #endif | |
55 } | |
56 | |
57 private: | |
58 static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { | |
59 return SkNEW_ARGS(SkBitmapShader, (buffer)); } | |
60 #ifdef SK_SUPPORT_MIPMAP | |
61 SkFixed fMipLevel; | |
62 SkBitmap fMipSrcBitmap; // the chosen level (in setContext) | |
63 #endif | |
64 SkBitmap fOrigSrcBitmap; | |
65 uint8_t fFilterBitmap; | |
66 uint8_t fTileModeX; | |
67 uint8_t fTileModeY; | |
68 uint8_t fFlags; | |
69 | |
70 typedef SkShader INHERITED; | |
71 }; | |
72 | |
73 #endif | |
OLD | NEW |