OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #ifndef SkDrawProcs_DEFINED | 8 #ifndef SkDrawProcs_DEFINED |
9 #define SkDrawProcs_DEFINED | 9 #define SkDrawProcs_DEFINED |
10 | 10 |
| 11 #include "SkBlitter.h" |
11 #include "SkDraw.h" | 12 #include "SkDraw.h" |
12 | 13 |
13 class SkAAClip; | 14 class SkAAClip; |
14 class SkBlitter; | 15 class SkBlitter; |
15 | 16 |
16 struct SkDraw1Glyph { | 17 struct SkDraw1Glyph { |
17 const SkDraw* fDraw; | 18 const SkDraw* fDraw; |
18 SkBounder* fBounder; | 19 SkBounder* fBounder; |
19 const SkRegion* fClip; | 20 const SkRegion* fClip; |
20 const SkAAClip* fAAClip; | 21 const SkAAClip* fAAClip; |
21 SkBlitter* fBlitter; | 22 SkBlitter* fBlitter; |
22 SkGlyphCache* fCache; | 23 SkGlyphCache* fCache; |
| 24 const SkPaint* fPaint; |
23 SkIRect fClipBounds; | 25 SkIRect fClipBounds; |
24 /** Half the sampling frequency of the rasterized glyph in x. */ | 26 /** Half the sampling frequency of the rasterized glyph in x. */ |
25 SkFixed fHalfSampleX; | 27 SkFixed fHalfSampleX; |
26 /** Half the sampling frequency of the rasterized glyph in y. */ | 28 /** Half the sampling frequency of the rasterized glyph in y. */ |
27 SkFixed fHalfSampleY; | 29 SkFixed fHalfSampleY; |
28 | 30 |
29 /** Draws one glyph. | 31 /** Draws one glyph. |
30 * | 32 * |
31 * The x and y are pre-biased, so implementations may just truncate them. | 33 * The x and y are pre-biased, so implementations may just truncate them. |
32 * i.e. half the sampling frequency has been added. | 34 * i.e. half the sampling frequency has been added. |
33 * e.g. 1/2 or 1/(2^(SkGlyph::kSubBits+1)) has already been added. | 35 * e.g. 1/2 or 1/(2^(SkGlyph::kSubBits+1)) has already been added. |
34 * This added bias can be found in fHalfSampleX,Y. | 36 * This added bias can be found in fHalfSampleX,Y. |
35 */ | 37 */ |
36 typedef void (*Proc)(const SkDraw1Glyph&, SkFixed x, SkFixed y, const SkGlyp
h&); | 38 typedef void (*Proc)(const SkDraw1Glyph&, SkFixed x, SkFixed y, const SkGlyp
h&); |
37 | 39 |
38 Proc init(const SkDraw* draw, SkBlitter* blitter, SkGlyphCache* cache); | 40 Proc init(const SkDraw* draw, SkBlitter* blitter, SkGlyphCache* cache, |
| 41 const SkPaint&); |
| 42 |
| 43 // call this instead of fBlitter->blitMask() since this wrapper will handle |
| 44 // the case when the mask is ARGB32_Format |
| 45 // |
| 46 void blitMask(const SkMask& mask, const SkIRect& clip) const { |
| 47 if (SkMask::kARGB32_Format == mask.fFormat) { |
| 48 this->blitMaskAsSprite(mask); |
| 49 } else { |
| 50 fBlitter->blitMask(mask, clip); |
| 51 } |
| 52 } |
| 53 |
| 54 // mask must be kARGB32_Format |
| 55 void blitMaskAsSprite(const SkMask& mask) const; |
39 }; | 56 }; |
40 | 57 |
41 struct SkDrawProcs { | 58 struct SkDrawProcs { |
42 SkDraw1Glyph::Proc fD1GProc; | 59 SkDraw1Glyph::Proc fD1GProc; |
43 }; | 60 }; |
44 | 61 |
45 /** | 62 /** |
46 * If the current paint is set to stroke and the stroke-width when applied to | 63 * If the current paint is set to stroke and the stroke-width when applied to |
47 * the matrix is <= 1.0, then this returns true, and sets coverage (simulating | 64 * the matrix is <= 1.0, then this returns true, and sets coverage (simulating |
48 * a stroke by drawing a hairline with partial coverage). If any of these | 65 * a stroke by drawing a hairline with partial coverage). If any of these |
49 * conditions are false, then this returns false and coverage is ignored. | 66 * conditions are false, then this returns false and coverage is ignored. |
50 */ | 67 */ |
51 bool SkDrawTreatAsHairline(const SkPaint&, const SkMatrix&, SkScalar* coverage); | 68 bool SkDrawTreatAsHairline(const SkPaint&, const SkMatrix&, SkScalar* coverage); |
52 | 69 |
53 #endif | 70 #endif |
OLD | NEW |