OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkBlitter_DEFINED | 8 #ifndef SkBlitter_DEFINED |
9 #define SkBlitter_DEFINED | 9 #define SkBlitter_DEFINED |
10 | 10 |
11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
12 #include "SkBitmapProcShader.h" | 12 #include "SkBitmapProcShader.h" |
13 #include "SkMask.h" | 13 #include "SkMask.h" |
14 #include "SkMatrix.h" | 14 #include "SkMatrix.h" |
15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
16 #include "SkRefCnt.h" | 16 #include "SkRefCnt.h" |
17 #include "SkRegion.h" | 17 #include "SkRegion.h" |
18 #include "SkShader.h" | 18 #include "SkShader.h" |
19 #include "SkSmallAllocator.h" | 19 #include "SkSmallAllocator.h" |
20 | 20 |
21 #ifdef SK_SUPPORT_LEGACY_BLITANTIH2V2 | |
22 #define SK_BLITANTIH2V2_VIRTUAL | |
23 #else | |
24 #define SK_BLITANTIH2V2_VIRTUAL virtual | |
25 #endif | |
26 | |
27 /** SkBlitter and its subclasses are responsible for actually writing pixels | 21 /** SkBlitter and its subclasses are responsible for actually writing pixels |
28 into memory. Besides efficiency, they handle clipping and antialiasing. | 22 into memory. Besides efficiency, they handle clipping and antialiasing. |
29 */ | 23 */ |
30 class SkBlitter { | 24 class SkBlitter { |
31 public: | 25 public: |
32 virtual ~SkBlitter(); | 26 virtual ~SkBlitter(); |
33 | 27 |
34 /// Blit a horizontal run of one or more pixels. | 28 /// Blit a horizontal run of one or more pixels. |
35 virtual void blitH(int x, int y, int width); | 29 virtual void blitH(int x, int y, int width); |
36 /// Blit a horizontal run of antialiased pixels; runs[] is a *sparse* | 30 /// Blit a horizontal run of antialiased pixels; runs[] is a *sparse* |
(...skipping 16 matching lines...) Expand all Loading... |
53 /// typically used for text. | 47 /// typically used for text. |
54 virtual void blitMask(const SkMask&, const SkIRect& clip); | 48 virtual void blitMask(const SkMask&, const SkIRect& clip); |
55 | 49 |
56 /** If the blitter just sets a single value for each pixel, return the | 50 /** If the blitter just sets a single value for each pixel, return the |
57 bitmap it draws into, and assign value. If not, return NULL and ignore | 51 bitmap it draws into, and assign value. If not, return NULL and ignore |
58 the value parameter. | 52 the value parameter. |
59 */ | 53 */ |
60 virtual const SkBitmap* justAnOpaqueColor(uint32_t* value); | 54 virtual const SkBitmap* justAnOpaqueColor(uint32_t* value); |
61 | 55 |
62 // (x, y), (x + 1, y) | 56 // (x, y), (x + 1, y) |
63 SK_BLITANTIH2V2_VIRTUAL void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) { | 57 virtual void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) { |
64 int16_t runs[3]; | 58 int16_t runs[3]; |
65 uint8_t aa[2]; | 59 uint8_t aa[2]; |
66 | 60 |
67 runs[0] = 1; | 61 runs[0] = 1; |
68 runs[1] = 1; | 62 runs[1] = 1; |
69 runs[2] = 0; | 63 runs[2] = 0; |
70 aa[0] = SkToU8(a0); | 64 aa[0] = SkToU8(a0); |
71 aa[1] = SkToU8(a1); | 65 aa[1] = SkToU8(a1); |
72 this->blitAntiH(x, y, aa, runs); | 66 this->blitAntiH(x, y, aa, runs); |
73 } | 67 } |
74 | 68 |
75 // (x, y), (x, y + 1) | 69 // (x, y), (x, y + 1) |
76 SK_BLITANTIH2V2_VIRTUAL void blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) { | 70 virtual void blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) { |
77 int16_t runs[2]; | 71 int16_t runs[2]; |
78 uint8_t aa[1]; | 72 uint8_t aa[1]; |
79 | 73 |
80 runs[0] = 1; | 74 runs[0] = 1; |
81 runs[1] = 0; | 75 runs[1] = 0; |
82 aa[0] = SkToU8(a0); | 76 aa[0] = SkToU8(a0); |
83 this->blitAntiH(x, y, aa, runs); | 77 this->blitAntiH(x, y, aa, runs); |
84 // reset in case the clipping blitter modified runs | 78 // reset in case the clipping blitter modified runs |
85 runs[0] = 1; | 79 runs[0] = 1; |
86 runs[1] = 0; | 80 runs[1] = 0; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 SkBlitter* apply(SkBlitter* blitter, const SkRegion* clip, | 235 SkBlitter* apply(SkBlitter* blitter, const SkRegion* clip, |
242 const SkIRect* bounds = NULL); | 236 const SkIRect* bounds = NULL); |
243 | 237 |
244 private: | 238 private: |
245 SkNullBlitter fNullBlitter; | 239 SkNullBlitter fNullBlitter; |
246 SkRectClipBlitter fRectBlitter; | 240 SkRectClipBlitter fRectBlitter; |
247 SkRgnClipBlitter fRgnBlitter; | 241 SkRgnClipBlitter fRgnBlitter; |
248 }; | 242 }; |
249 | 243 |
250 #endif | 244 #endif |
OLD | NEW |