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

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

Issue 1863013003: Pass effects directly to fontcache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: removed DUMMY effects Created 4 years, 8 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
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 #include "SkTypeface.h" 15 #include "SkTypeface.h"
16 16
17 class SkGlyph; 17 class SkGlyph;
18 class SkDescriptor; 18 class SkDescriptor;
19 class SkMaskFilter; 19 class SkMaskFilter;
20 class SkPathEffect; 20 class SkPathEffect;
21 class SkRasterizer; 21 class SkRasterizer;
22 22
23 struct SkScalerContextEffects {
24 SkScalerContextEffects() : fPathEffect(nullptr), fMaskFilter(nullptr), fRast erizer(nullptr) {}
25 SkScalerContextEffects(SkPathEffect* pe, SkMaskFilter* mf, SkRasterizer* ra)
26 : fPathEffect(pe), fMaskFilter(mf), fRasterizer(ra) {}
27
28 SkPathEffect* fPathEffect;
29 SkMaskFilter* fMaskFilter;
30 SkRasterizer* fRasterizer;
31 };
32
23 enum SkAxisAlignment { 33 enum SkAxisAlignment {
24 kNone_SkAxisAlignment, 34 kNone_SkAxisAlignment,
25 kX_SkAxisAlignment, 35 kX_SkAxisAlignment,
26 kY_SkAxisAlignment 36 kY_SkAxisAlignment
27 }; 37 };
28 38
29 /* 39 /*
30 * To allow this to be forward-declared, it must be its own typename, rather 40 * To allow this to be forward-declared, it must be its own typename, rather
31 * than a nested struct inside SkScalerContext (where it started). 41 * than a nested struct inside SkScalerContext (where it started).
32 */ 42 */
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 // Generate A8 from LCD source (for GDI and CoreGraphics). 195 // Generate A8 from LCD source (for GDI and CoreGraphics).
186 // only meaningful if fMaskFormat is kA8 196 // only meaningful if fMaskFormat is kA8
187 kGenA8FromLCD_Flag = 0x0800, // could be 0x200 (bit meaning depen dent on fMaskFormat) 197 kGenA8FromLCD_Flag = 0x0800, // could be 0x200 (bit meaning depen dent on fMaskFormat)
188 }; 198 };
189 199
190 // computed values 200 // computed values
191 enum { 201 enum {
192 kHinting_Mask = kHintingBit1_Flag | kHintingBit2_Flag, 202 kHinting_Mask = kHintingBit1_Flag | kHintingBit2_Flag,
193 }; 203 };
194 204
195 205 SkScalerContext(SkTypeface*, const SkScalerContextEffects&, const SkDescript or*);
196 SkScalerContext(SkTypeface*, const SkDescriptor*);
197 virtual ~SkScalerContext(); 206 virtual ~SkScalerContext();
198 207
199 SkTypeface* getTypeface() const { return fTypeface.get(); } 208 SkTypeface* getTypeface() const { return fTypeface.get(); }
200 209
201 SkMask::Format getMaskFormat() const { 210 SkMask::Format getMaskFormat() const {
202 return (SkMask::Format)fRec.fMaskFormat; 211 return (SkMask::Format)fRec.fMaskFormat;
203 } 212 }
204 213
205 bool isSubpixel() const { 214 bool isSubpixel() const {
206 return SkToBool(fRec.fFlags & kSubpixelPositioning_Flag); 215 return SkToBool(fRec.fFlags & kSubpixelPositioning_Flag);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 void* data); 254 void* data);
246 255
247 static void MakeRec(const SkPaint&, const SkSurfaceProps* surfaceProps, 256 static void MakeRec(const SkPaint&, const SkSurfaceProps* surfaceProps,
248 const SkMatrix*, Rec* rec); 257 const SkMatrix*, Rec* rec);
249 static inline void PostMakeRec(const SkPaint&, Rec*); 258 static inline void PostMakeRec(const SkPaint&, Rec*);
250 259
251 static SkMaskGamma::PreBlend GetMaskPreBlend(const Rec& rec); 260 static SkMaskGamma::PreBlend GetMaskPreBlend(const Rec& rec);
252 261
253 const Rec& getRec() const { return fRec; } 262 const Rec& getRec() const { return fRec; }
254 263
264 SkScalerContextEffects getEffects() const {
265 return { fPathEffect.get(), fMaskFilter.get(), fRasterizer.get() };
266 }
267
255 /** 268 /**
256 * Return the axis (if any) that the baseline for horizontal text should lan d on. 269 * Return the axis (if any) that the baseline for horizontal text should lan d on.
257 * As an example, the identity matrix will return kX_SkAxisAlignment 270 * As an example, the identity matrix will return kX_SkAxisAlignment
258 */ 271 */
259 SkAxisAlignment computeAxisAlignmentForHText(); 272 SkAxisAlignment computeAxisAlignmentForHText();
260 273
261
262 protected: 274 protected:
263 Rec fRec; 275 Rec fRec;
264 276
265 /** Generates the contents of glyph.fAdvanceX and glyph.fAdvanceY. 277 /** Generates the contents of glyph.fAdvanceX and glyph.fAdvanceY.
266 * May call getMetrics if that would be just as fast. 278 * May call getMetrics if that would be just as fast.
267 */ 279 */
268 virtual void generateAdvance(SkGlyph* glyph) = 0; 280 virtual void generateAdvance(SkGlyph* glyph) = 0;
269 281
270 /** Generates the contents of glyph.fWidth, fHeight, fTop, fLeft, 282 /** Generates the contents of glyph.fWidth, fHeight, fTop, fLeft,
271 * as well as fAdvanceX and fAdvanceY if not already set. 283 * as well as fAdvanceX and fAdvanceY if not already set.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 */ 323 */
312 virtual SkUnichar generateGlyphToChar(uint16_t glyphId); 324 virtual SkUnichar generateGlyphToChar(uint16_t glyphId);
313 325
314 void forceGenerateImageFromPath() { fGenerateImageFromPath = true; } 326 void forceGenerateImageFromPath() { fGenerateImageFromPath = true; }
315 void forceOffGenerateImageFromPath() { fGenerateImageFromPath = false; } 327 void forceOffGenerateImageFromPath() { fGenerateImageFromPath = false; }
316 328
317 private: 329 private:
318 friend class SkRandomScalerContext; // For debug purposes 330 friend class SkRandomScalerContext; // For debug purposes
319 331
320 // never null 332 // never null
321 SkAutoTUnref<SkTypeface> fTypeface; 333 sk_sp<SkTypeface> fTypeface;
322 334
323 // optional object, which may be null 335 // optional objects, which may be null
324 SkPathEffect* fPathEffect; 336 sk_sp<SkPathEffect> fPathEffect;
325 SkMaskFilter* fMaskFilter; 337 sk_sp<SkMaskFilter> fMaskFilter;
326 SkRasterizer* fRasterizer; 338 sk_sp<SkRasterizer> fRasterizer;
327 339
328 // if this is set, we draw the image from a path, rather than 340 // if this is set, we draw the image from a path, rather than
329 // calling generateImage. 341 // calling generateImage.
330 bool fGenerateImageFromPath; 342 bool fGenerateImageFromPath;
331 343
332 void internalGetPath(const SkGlyph& glyph, SkPath* fillPath, 344 void internalGetPath(const SkGlyph& glyph, SkPath* fillPath,
333 SkPath* devPath, SkMatrix* fillToDevMatrix); 345 SkPath* devPath, SkMatrix* fillToDevMatrix);
334 346
335 // returns the right context from our link-list for this char. If no match 347 // returns the right context from our link-list for this char. If no match
336 // is found it returns nullptr. If a match is found then the glyphID param i s 348 // is found it returns nullptr. If a match is found then the glyphID param i s
(...skipping 23 matching lines...) Expand all
360 return static_cast<SkPaint::Hinting>(hint); 372 return static_cast<SkPaint::Hinting>(hint);
361 } 373 }
362 374
363 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) { 375 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) {
364 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) | 376 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) |
365 (hinting << SkScalerContext::kHinting_Shift); 377 (hinting << SkScalerContext::kHinting_Shift);
366 } 378 }
367 379
368 380
369 #endif 381 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698