OLD | NEW |
| (Empty) |
1 /* libs/graphics/sgl/SkBitmapSamplerTemplate.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 /* this guy is pulled in multiple times, with the following symbols defined eac
h time: | |
19 | |
20 #define BITMAP_CLASSNAME_PREFIX(name) ARGB32##name | |
21 #defube BITMAP_PIXEL_TO_PMCOLOR(bitmap, x, y) *bitmap.getAddr32(x, y) | |
22 */ | |
23 | |
24 class BITMAP_CLASSNAME_PREFIX(_Point_Sampler) : public SkBitmapSampler { | |
25 public: | |
26 BITMAP_CLASSNAME_PREFIX(_Point_Sampler)(const SkBitmap& bm, SkShader::TileMo
de tmx, SkShader::TileMode tmy) | |
27 : SkBitmapSampler(bm, false, tmx, tmy) | |
28 { | |
29 } | |
30 | |
31 virtual SkPMColor sample(SkFixed x, SkFixed y) const | |
32 { | |
33 x = fTileProcX(SkFixedFloor(x), fMaxX); | |
34 y = fTileProcY(SkFixedFloor(y), fMaxY); | |
35 return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y); | |
36 } | |
37 }; | |
38 | |
39 | |
40 class BITMAP_CLASSNAME_PREFIX(_Point_Clamp_Sampler) : public SkBitmapSampler { | |
41 public: | |
42 BITMAP_CLASSNAME_PREFIX(_Point_Clamp_Sampler)(const SkBitmap& bm) | |
43 : SkBitmapSampler(bm, false, SkShader::kClamp_TileMode, SkShader::kClamp
_TileMode) | |
44 { | |
45 } | |
46 | |
47 virtual SkPMColor sample(SkFixed x, SkFixed y) const | |
48 { | |
49 x = do_clamp(SkFixedFloor(x), fMaxX); | |
50 y = do_clamp(SkFixedFloor(y), fMaxY); | |
51 return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y); | |
52 } | |
53 }; | |
54 | |
55 class BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Pow2_Sampler) : public SkBitmapSampl
er { | |
56 public: | |
57 BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Pow2_Sampler)(const SkBitmap& bm) | |
58 : SkBitmapSampler(bm, false, SkShader::kRepeat_TileMode, SkShader::kRepe
at_TileMode) | |
59 { | |
60 } | |
61 | |
62 virtual SkPMColor sample(SkFixed x, SkFixed y) const | |
63 { | |
64 x = do_repeat_pow2(SkFixedFloor(x), fMaxX); | |
65 y = do_repeat_pow2(SkFixedFloor(y), fMaxY); | |
66 return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y); | |
67 } | |
68 }; | |
69 | |
70 class BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Mod_Sampler) : public SkBitmapSample
r { | |
71 public: | |
72 BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Mod_Sampler)(const SkBitmap& bm) | |
73 : SkBitmapSampler(bm, false, SkShader::kRepeat_TileMode, SkShader::kRepe
at_TileMode) | |
74 { | |
75 } | |
76 | |
77 virtual SkPMColor sample(SkFixed x, SkFixed y) const | |
78 { | |
79 x = do_repeat_mod(SkFixedFloor(x), fMaxX); | |
80 y = do_repeat_mod(SkFixedFloor(y), fMaxY); | |
81 return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y); | |
82 } | |
83 }; | |
84 | |
85 class BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Pow2_Sampler) : public SkBitmapSampl
er { | |
86 public: | |
87 BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Pow2_Sampler)(const SkBitmap& bm) | |
88 : SkBitmapSampler(bm, false, SkShader::kMirror_TileMode, SkShader::kMirr
or_TileMode) | |
89 { | |
90 } | |
91 | |
92 virtual SkPMColor sample(SkFixed x, SkFixed y) const | |
93 { | |
94 x = do_mirror_pow2(SkFixedFloor(x), fMaxX); | |
95 y = do_mirror_pow2(SkFixedFloor(y), fMaxY); | |
96 return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y); | |
97 } | |
98 }; | |
99 | |
100 class BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Mod_Sampler) : public SkBitmapSample
r { | |
101 public: | |
102 BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Mod_Sampler)(const SkBitmap& bm) | |
103 : SkBitmapSampler(bm, false, SkShader::kMirror_TileMode, SkShader::kMirr
or_TileMode) | |
104 { | |
105 } | |
106 | |
107 virtual SkPMColor sample(SkFixed x, SkFixed y) const | |
108 { | |
109 x = do_mirror_mod(SkFixedFloor(x), fMaxX); | |
110 y = do_mirror_mod(SkFixedFloor(y), fMaxY); | |
111 return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y); | |
112 } | |
113 }; | |
114 | |
115 #undef BITMAP_CLASSNAME_PREFIX | |
116 #undef BITMAP_PIXEL_TO_PMCOLOR | |
OLD | NEW |