• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright 2006 The Android Open Source Project
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 
9 
10 /*  this guy is pulled in multiple times, with the following symbols defined each time:
11 
12     #define BITMAP_CLASSNAME_PREFIX(name)           ARGB32##name
13     #defube BITMAP_PIXEL_TO_PMCOLOR(bitmap, x, y)   *bitmap.getAddr32(x, y)
14 */
15 
BITMAP_CLASSNAME_PREFIX(_Point_Sampler)16 class BITMAP_CLASSNAME_PREFIX(_Point_Sampler) : public SkBitmapSampler {
17 public:
18     BITMAP_CLASSNAME_PREFIX(_Point_Sampler)(const SkBitmap& bm, SkShader::TileMode tmx, SkShader::TileMode tmy)
19         : SkBitmapSampler(bm, false, tmx, tmy)
20     {
21     }
22 
23     virtual SkPMColor sample(SkFixed x, SkFixed y) const
24     {
25         x = fTileProcX(SkFixedFloor(x), fMaxX);
26         y = fTileProcY(SkFixedFloor(y), fMaxY);
27         return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
28     }
29 };
30 
31 
BITMAP_CLASSNAME_PREFIX(_Point_Clamp_Sampler)32 class BITMAP_CLASSNAME_PREFIX(_Point_Clamp_Sampler) : public SkBitmapSampler {
33 public:
34     BITMAP_CLASSNAME_PREFIX(_Point_Clamp_Sampler)(const SkBitmap& bm)
35         : SkBitmapSampler(bm, false, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode)
36     {
37     }
38 
39     virtual SkPMColor sample(SkFixed x, SkFixed y) const
40     {
41         x = do_clamp(SkFixedFloor(x), fMaxX);
42         y = do_clamp(SkFixedFloor(y), fMaxY);
43         return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
44     }
45 };
46 
BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Pow2_Sampler)47 class BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Pow2_Sampler) : public SkBitmapSampler {
48 public:
49     BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Pow2_Sampler)(const SkBitmap& bm)
50         : SkBitmapSampler(bm, false, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode)
51     {
52     }
53 
54     virtual SkPMColor sample(SkFixed x, SkFixed y) const
55     {
56         x = do_repeat_pow2(SkFixedFloor(x), fMaxX);
57         y = do_repeat_pow2(SkFixedFloor(y), fMaxY);
58         return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
59     }
60 };
61 
BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Mod_Sampler)62 class BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Mod_Sampler) : public SkBitmapSampler {
63 public:
64     BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Mod_Sampler)(const SkBitmap& bm)
65         : SkBitmapSampler(bm, false, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode)
66     {
67     }
68 
69     virtual SkPMColor sample(SkFixed x, SkFixed y) const
70     {
71         x = do_repeat_mod(SkFixedFloor(x), fMaxX);
72         y = do_repeat_mod(SkFixedFloor(y), fMaxY);
73         return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
74     }
75 };
76 
BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Pow2_Sampler)77 class BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Pow2_Sampler) : public SkBitmapSampler {
78 public:
79     BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Pow2_Sampler)(const SkBitmap& bm)
80         : SkBitmapSampler(bm, false, SkShader::kMirror_TileMode, SkShader::kMirror_TileMode)
81     {
82     }
83 
84     virtual SkPMColor sample(SkFixed x, SkFixed y) const
85     {
86         x = do_mirror_pow2(SkFixedFloor(x), fMaxX);
87         y = do_mirror_pow2(SkFixedFloor(y), fMaxY);
88         return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
89     }
90 };
91 
BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Mod_Sampler)92 class BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Mod_Sampler) : public SkBitmapSampler {
93 public:
94     BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Mod_Sampler)(const SkBitmap& bm)
95         : SkBitmapSampler(bm, false, SkShader::kMirror_TileMode, SkShader::kMirror_TileMode)
96     {
97     }
98 
99     virtual SkPMColor sample(SkFixed x, SkFixed y) const
100     {
101         x = do_mirror_mod(SkFixedFloor(x), fMaxX);
102         y = do_mirror_mod(SkFixedFloor(y), fMaxY);
103         return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
104     }
105 };
106 
107 #undef BITMAP_CLASSNAME_PREFIX
108 #undef BITMAP_PIXEL_TO_PMCOLOR
109