Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: trunk/src/core/SkScalerContext.h

Issue 12706010: Add SkTypeface* parameter to SkScalerContext (and its callers) (Closed) Base URL: http://skia.googlecode.com/svn/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 SkScalerContext_DEFINED 8 #ifndef SkScalerContext_DEFINED
9 #define SkScalerContext_DEFINED 9 #define SkScalerContext_DEFINED
10 10
11 #include "SkMask.h" 11 #include "SkMask.h"
12 #include "SkMaskGamma.h" 12 #include "SkMaskGamma.h"
13 #include "SkMatrix.h" 13 #include "SkMatrix.h"
14 #include "SkPaint.h" 14 #include "SkPaint.h"
15 15 #include "SkTypeface.h"
16 #ifdef SK_BUILD_FOR_ANDROID
17 //For SkFontID
18 #include "SkTypeface.h"
19 #endif
20 16
21 struct SkGlyph; 17 struct SkGlyph;
22 class SkDescriptor; 18 class SkDescriptor;
23 class SkMaskFilter; 19 class SkMaskFilter;
24 class SkPathEffect; 20 class SkPathEffect;
25 class SkRasterizer; 21 class SkRasterizer;
26 22
27 /* 23 /*
28 * To allow this to be forward-declared, it must be its own typename, rather 24 * To allow this to be forward-declared, it must be its own typename, rather
29 * than a nested struct inside SkScalerContext (where it started). 25 * than a nested struct inside SkScalerContext (where it started).
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // Perhaps we can store this (instead) in fMaskFormat, in hight bit? 138 // Perhaps we can store this (instead) in fMaskFormat, in hight bit?
143 kGenA8FromLCD_Flag = 0x0800, 139 kGenA8FromLCD_Flag = 0x0800,
144 }; 140 };
145 141
146 // computed values 142 // computed values
147 enum { 143 enum {
148 kHinting_Mask = kHintingBit1_Flag | kHintingBit2_Flag, 144 kHinting_Mask = kHintingBit1_Flag | kHintingBit2_Flag,
149 }; 145 };
150 146
151 147
152 SkScalerContext(const SkDescriptor* desc); 148 SkScalerContext(SkTypeface*, const SkDescriptor*);
153 virtual ~SkScalerContext(); 149 virtual ~SkScalerContext();
154 150
151 SkTypeface* getTypeface() const { return fTypeface; }
152
155 SkMask::Format getMaskFormat() const { 153 SkMask::Format getMaskFormat() const {
156 return (SkMask::Format)fRec.fMaskFormat; 154 return (SkMask::Format)fRec.fMaskFormat;
157 } 155 }
158 156
159 bool isSubpixel() const { 157 bool isSubpixel() const {
160 return SkToBool(fRec.fFlags & kSubpixelPositioning_Flag); 158 return SkToBool(fRec.fFlags & kSubpixelPositioning_Flag);
161 } 159 }
162 160
163 // remember our glyph offset/base 161 // remember our glyph offset/base
164 void setBaseGlyphCount(unsigned baseGlyphCount) { 162 void setBaseGlyphCount(unsigned baseGlyphCount) {
(...skipping 25 matching lines...) Expand all
190 188
191 // This function must be public for SkTypeface_android.h, but should not be 189 // This function must be public for SkTypeface_android.h, but should not be
192 // called by other callers 190 // called by other callers
193 SkFontID findTypefaceIdForChar(SkUnichar uni); 191 SkFontID findTypefaceIdForChar(SkUnichar uni);
194 #endif 192 #endif
195 193
196 static inline void MakeRec(const SkPaint&, const SkDeviceProperties* deviceP roperties, 194 static inline void MakeRec(const SkPaint&, const SkDeviceProperties* deviceP roperties,
197 const SkMatrix*, Rec* rec); 195 const SkMatrix*, Rec* rec);
198 static inline void PostMakeRec(const SkPaint&, Rec*); 196 static inline void PostMakeRec(const SkPaint&, Rec*);
199 197
200 static SkScalerContext* Create(const SkDescriptor*);
201 static SkMaskGamma::PreBlend GetMaskPreBlend(const Rec& rec); 198 static SkMaskGamma::PreBlend GetMaskPreBlend(const Rec& rec);
202 199
203 protected: 200 protected:
204 Rec fRec; 201 Rec fRec;
205 unsigned fBaseGlyphCount; 202 unsigned fBaseGlyphCount;
206 203
207 virtual unsigned generateGlyphCount() = 0; 204 virtual unsigned generateGlyphCount() = 0;
208 virtual uint16_t generateCharToGlyph(SkUnichar) = 0; 205 virtual uint16_t generateCharToGlyph(SkUnichar) = 0;
209 virtual void generateAdvance(SkGlyph*) = 0; 206 virtual void generateAdvance(SkGlyph*) = 0;
210 virtual void generateMetrics(SkGlyph*) = 0; 207 virtual void generateMetrics(SkGlyph*) = 0;
211 virtual void generateImage(const SkGlyph&) = 0; 208 virtual void generateImage(const SkGlyph&) = 0;
212 virtual void generatePath(const SkGlyph&, SkPath*) = 0; 209 virtual void generatePath(const SkGlyph&, SkPath*) = 0;
213 virtual void generateFontMetrics(SkPaint::FontMetrics* mX, 210 virtual void generateFontMetrics(SkPaint::FontMetrics* mX,
214 SkPaint::FontMetrics* mY) = 0; 211 SkPaint::FontMetrics* mY) = 0;
215 // default impl returns 0, indicating failure. 212 // default impl returns 0, indicating failure.
216 virtual SkUnichar generateGlyphToChar(uint16_t); 213 virtual SkUnichar generateGlyphToChar(uint16_t);
217 214
218 void forceGenerateImageFromPath() { fGenerateImageFromPath = true; } 215 void forceGenerateImageFromPath() { fGenerateImageFromPath = true; }
219 216
220 private: 217 private:
218 SkTypeface* fTypeface;
bungeman-skia 2013/03/15 16:12:44 SkAutoTUnref<SkTypeface> would be nice, since it d
reed1 2013/03/15 17:46:44 Done.
221 SkPathEffect* fPathEffect; 219 SkPathEffect* fPathEffect;
222 SkMaskFilter* fMaskFilter; 220 SkMaskFilter* fMaskFilter;
223 SkRasterizer* fRasterizer; 221 SkRasterizer* fRasterizer;
224 222
225 // if this is set, we draw the image from a path, rather than 223 // if this is set, we draw the image from a path, rather than
226 // calling generateImage. 224 // calling generateImage.
227 bool fGenerateImageFromPath; 225 bool fGenerateImageFromPath;
228 226
229 void internalGetPath(const SkGlyph& glyph, SkPath* fillPath, 227 void internalGetPath(const SkGlyph& glyph, SkPath* fillPath,
230 SkPath* devPath, SkMatrix* fillToDevMatrix); 228 SkPath* devPath, SkMatrix* fillToDevMatrix);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 return static_cast<SkPaint::Hinting>(hint); 281 return static_cast<SkPaint::Hinting>(hint);
284 } 282 }
285 283
286 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) { 284 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) {
287 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) | 285 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) |
288 (hinting << SkScalerContext::kHinting_Shift); 286 (hinting << SkScalerContext::kHinting_Shift);
289 } 287 }
290 288
291 289
292 #endif 290 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698