| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 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 SkDrawProcs_DEFINED | 8 #ifndef SkDrawProcs_DEFINED |
| 9 #define SkDrawProcs_DEFINED | 9 #define SkDrawProcs_DEFINED |
| 10 | 10 |
| 11 #include "SkBlitter.h" | |
| 12 #include "SkDraw.h" | 11 #include "SkDraw.h" |
| 13 #include "SkGlyph.h" | 12 #include "SkGlyph.h" |
| 14 | 13 |
| 15 class SkAAClip; | |
| 16 class SkBlitter; | |
| 17 | |
| 18 struct SkDraw1Glyph { | |
| 19 const SkDraw* fDraw; | |
| 20 const SkRegion* fClip; | |
| 21 const SkAAClip* fAAClip; | |
| 22 SkBlitter* fBlitter; | |
| 23 SkGlyphCache* fCache; | |
| 24 const SkPaint* fPaint; | |
| 25 SkIRect fClipBounds; | |
| 26 /** Half the sampling frequency of the rasterized glyph in x. */ | |
| 27 SkScalar fHalfSampleX; | |
| 28 /** Half the sampling frequency of the rasterized glyph in y. */ | |
| 29 SkScalar fHalfSampleY; | |
| 30 | |
| 31 /** Draws one glyph. | |
| 32 * | |
| 33 * The x and y are pre-biased, so implementations may just truncate them. | |
| 34 * i.e. half the sampling frequency has been added. | |
| 35 * e.g. 1/2 or 1/(2^(SkGlyph::kSubBits+1)) has already been added. | |
| 36 * This added bias can be found in fHalfSampleX,Y. | |
| 37 */ | |
| 38 typedef void (*Proc)(const SkDraw1Glyph&, Sk48Dot16 x, Sk48Dot16 y, const Sk
Glyph&); | |
| 39 | |
| 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; | |
| 56 }; | |
| 57 | |
| 58 struct SkDrawProcs { | |
| 59 SkDraw1Glyph::Proc fD1GProc; | |
| 60 }; | |
| 61 | |
| 62 bool SkDrawTreatAAStrokeAsHairline(SkScalar strokeWidth, const SkMatrix&, | 14 bool SkDrawTreatAAStrokeAsHairline(SkScalar strokeWidth, const SkMatrix&, |
| 63 SkScalar* coverage); | 15 SkScalar* coverage); |
| 64 | 16 |
| 65 /** | 17 /** |
| 66 * If the current paint is set to stroke and the stroke-width when applied to | 18 * If the current paint is set to stroke and the stroke-width when applied to |
| 67 * the matrix is <= 1.0, then this returns true, and sets coverage (simulating | 19 * the matrix is <= 1.0, then this returns true, and sets coverage (simulating |
| 68 * a stroke by drawing a hairline with partial coverage). If any of these | 20 * a stroke by drawing a hairline with partial coverage). If any of these |
| 69 * conditions are false, then this returns false and coverage is ignored. | 21 * conditions are false, then this returns false and coverage is ignored. |
| 70 */ | 22 */ |
| 71 inline bool SkDrawTreatAsHairline(const SkPaint& paint, const SkMatrix& matrix, | 23 inline bool SkDrawTreatAsHairline(const SkPaint& paint, const SkMatrix& matrix, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 SkASSERT(SkPaint::kRight_Align == fAlign); | 57 SkASSERT(SkPaint::kRight_Align == fAlign); |
| 106 dst->set(loc.fX - SkFixedToScalar(glyph.fAdvanceX), | 58 dst->set(loc.fX - SkFixedToScalar(glyph.fAdvanceX), |
| 107 loc.fY - SkFixedToScalar(glyph.fAdvanceY)); | 59 loc.fY - SkFixedToScalar(glyph.fAdvanceY)); |
| 108 } | 60 } |
| 109 } | 61 } |
| 110 private: | 62 private: |
| 111 const SkPaint::Align fAlign; | 63 const SkPaint::Align fAlign; |
| 112 }; | 64 }; |
| 113 | 65 |
| 114 #endif | 66 #endif |
| OLD | NEW |