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 :
16 0 : class BITMAP_CLASSNAME_PREFIX(_Point_Sampler) : public SkBitmapSampler {
17 : public:
18 0 : BITMAP_CLASSNAME_PREFIX(_Point_Sampler)(const SkBitmap& bm, SkShader::TileMode tmx, SkShader::TileMode tmy)
19 0 : : SkBitmapSampler(bm, false, tmx, tmy)
20 : {
21 0 : }
22 :
23 0 : virtual SkPMColor sample(SkFixed x, SkFixed y) const
24 : {
25 0 : x = fTileProcX(SkFixedFloor(x), fMaxX);
26 0 : y = fTileProcY(SkFixedFloor(y), fMaxY);
27 0 : return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
28 : }
29 : };
30 :
31 :
32 0 : class BITMAP_CLASSNAME_PREFIX(_Point_Clamp_Sampler) : public SkBitmapSampler {
33 : public:
34 0 : BITMAP_CLASSNAME_PREFIX(_Point_Clamp_Sampler)(const SkBitmap& bm)
35 0 : : SkBitmapSampler(bm, false, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode)
36 : {
37 0 : }
38 :
39 0 : virtual SkPMColor sample(SkFixed x, SkFixed y) const
40 : {
41 0 : x = do_clamp(SkFixedFloor(x), fMaxX);
42 0 : y = do_clamp(SkFixedFloor(y), fMaxY);
43 0 : return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
44 : }
45 : };
46 :
47 0 : class BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Pow2_Sampler) : public SkBitmapSampler {
48 : public:
49 0 : BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Pow2_Sampler)(const SkBitmap& bm)
50 0 : : SkBitmapSampler(bm, false, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode)
51 : {
52 0 : }
53 :
54 0 : virtual SkPMColor sample(SkFixed x, SkFixed y) const
55 : {
56 0 : x = do_repeat_pow2(SkFixedFloor(x), fMaxX);
57 0 : y = do_repeat_pow2(SkFixedFloor(y), fMaxY);
58 0 : return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
59 : }
60 : };
61 :
62 0 : class BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Mod_Sampler) : public SkBitmapSampler {
63 : public:
64 0 : BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Mod_Sampler)(const SkBitmap& bm)
65 0 : : SkBitmapSampler(bm, false, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode)
66 : {
67 0 : }
68 :
69 0 : virtual SkPMColor sample(SkFixed x, SkFixed y) const
70 : {
71 0 : x = do_repeat_mod(SkFixedFloor(x), fMaxX);
72 0 : y = do_repeat_mod(SkFixedFloor(y), fMaxY);
73 0 : return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
74 : }
75 : };
76 :
77 0 : class BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Pow2_Sampler) : public SkBitmapSampler {
78 : public:
79 0 : BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Pow2_Sampler)(const SkBitmap& bm)
80 0 : : SkBitmapSampler(bm, false, SkShader::kMirror_TileMode, SkShader::kMirror_TileMode)
81 : {
82 0 : }
83 :
84 0 : virtual SkPMColor sample(SkFixed x, SkFixed y) const
85 : {
86 0 : x = do_mirror_pow2(SkFixedFloor(x), fMaxX);
87 0 : y = do_mirror_pow2(SkFixedFloor(y), fMaxY);
88 0 : return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
89 : }
90 : };
91 :
92 0 : class BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Mod_Sampler) : public SkBitmapSampler {
93 : public:
94 0 : BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Mod_Sampler)(const SkBitmap& bm)
95 0 : : SkBitmapSampler(bm, false, SkShader::kMirror_TileMode, SkShader::kMirror_TileMode)
96 : {
97 0 : }
98 :
99 0 : virtual SkPMColor sample(SkFixed x, SkFixed y) const
100 : {
101 0 : x = do_mirror_mod(SkFixedFloor(x), fMaxX);
102 0 : y = do_mirror_mod(SkFixedFloor(y), fMaxY);
103 0 : return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
104 : }
105 : };
106 :
107 : #undef BITMAP_CLASSNAME_PREFIX
108 : #undef BITMAP_PIXEL_TO_PMCOLOR
|