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

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

Issue 1880873002: Revert "Revert of Pass effects directly to fontcache (patchset #8 id:140001 of https://codereview.c… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
« no previous file with comments | « src/core/SkPaint.cpp ('k') | src/core/SkScalerContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // Generate A8 from LCD source (for GDI and CoreGraphics). 203 // Generate A8 from LCD source (for GDI and CoreGraphics).
194 // only meaningful if fMaskFormat is kA8 204 // only meaningful if fMaskFormat is kA8
195 kGenA8FromLCD_Flag = 0x0800, // could be 0x200 (bit meaning depen dent on fMaskFormat) 205 kGenA8FromLCD_Flag = 0x0800, // could be 0x200 (bit meaning depen dent on fMaskFormat)
196 }; 206 };
197 207
198 // computed values 208 // computed values
199 enum { 209 enum {
200 kHinting_Mask = kHintingBit1_Flag | kHintingBit2_Flag, 210 kHinting_Mask = kHintingBit1_Flag | kHintingBit2_Flag,
201 }; 211 };
202 212
203 213 SkScalerContext(SkTypeface*, const SkScalerContextEffects&, const SkDescript or*);
204 SkScalerContext(SkTypeface*, const SkDescriptor*);
205 virtual ~SkScalerContext(); 214 virtual ~SkScalerContext();
206 215
207 SkTypeface* getTypeface() const { return fTypeface.get(); } 216 SkTypeface* getTypeface() const { return fTypeface.get(); }
208 217
209 SkMask::Format getMaskFormat() const { 218 SkMask::Format getMaskFormat() const {
210 return (SkMask::Format)fRec.fMaskFormat; 219 return (SkMask::Format)fRec.fMaskFormat;
211 } 220 }
212 221
213 bool isSubpixel() const { 222 bool isSubpixel() const {
214 return SkToBool(fRec.fFlags & kSubpixelPositioning_Flag); 223 return SkToBool(fRec.fFlags & kSubpixelPositioning_Flag);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 void* data); 262 void* data);
254 263
255 static void MakeRec(const SkPaint&, const SkSurfaceProps* surfaceProps, 264 static void MakeRec(const SkPaint&, const SkSurfaceProps* surfaceProps,
256 const SkMatrix*, Rec* rec); 265 const SkMatrix*, Rec* rec);
257 static inline void PostMakeRec(const SkPaint&, Rec*); 266 static inline void PostMakeRec(const SkPaint&, Rec*);
258 267
259 static SkMaskGamma::PreBlend GetMaskPreBlend(const Rec& rec); 268 static SkMaskGamma::PreBlend GetMaskPreBlend(const Rec& rec);
260 269
261 const Rec& getRec() const { return fRec; } 270 const Rec& getRec() const { return fRec; }
262 271
272 SkScalerContextEffects getEffects() const {
273 return { fPathEffect.get(), fMaskFilter.get(), fRasterizer.get() };
274 }
275
263 /** 276 /**
264 * Return the axis (if any) that the baseline for horizontal text should lan d on. 277 * Return the axis (if any) that the baseline for horizontal text should lan d on.
265 * As an example, the identity matrix will return kX_SkAxisAlignment 278 * As an example, the identity matrix will return kX_SkAxisAlignment
266 */ 279 */
267 SkAxisAlignment computeAxisAlignmentForHText(); 280 SkAxisAlignment computeAxisAlignmentForHText();
268 281
269
270 protected: 282 protected:
271 Rec fRec; 283 Rec fRec;
272 284
273 /** Generates the contents of glyph.fAdvanceX and glyph.fAdvanceY. 285 /** Generates the contents of glyph.fAdvanceX and glyph.fAdvanceY.
274 * May call getMetrics if that would be just as fast. 286 * May call getMetrics if that would be just as fast.
275 */ 287 */
276 virtual void generateAdvance(SkGlyph* glyph) = 0; 288 virtual void generateAdvance(SkGlyph* glyph) = 0;
277 289
278 /** Generates the contents of glyph.fWidth, fHeight, fTop, fLeft, 290 /** Generates the contents of glyph.fWidth, fHeight, fTop, fLeft,
279 * as well as fAdvanceX and fAdvanceY if not already set. 291 * as well as fAdvanceX and fAdvanceY if not already set.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 */ 331 */
320 virtual SkUnichar generateGlyphToChar(uint16_t glyphId); 332 virtual SkUnichar generateGlyphToChar(uint16_t glyphId);
321 333
322 void forceGenerateImageFromPath() { fGenerateImageFromPath = true; } 334 void forceGenerateImageFromPath() { fGenerateImageFromPath = true; }
323 void forceOffGenerateImageFromPath() { fGenerateImageFromPath = false; } 335 void forceOffGenerateImageFromPath() { fGenerateImageFromPath = false; }
324 336
325 private: 337 private:
326 friend class SkRandomScalerContext; // For debug purposes 338 friend class SkRandomScalerContext; // For debug purposes
327 339
328 // never null 340 // never null
329 SkAutoTUnref<SkTypeface> fTypeface; 341 sk_sp<SkTypeface> fTypeface;
330 342
331 // optional object, which may be null 343 // optional objects, which may be null
332 SkPathEffect* fPathEffect; 344 sk_sp<SkPathEffect> fPathEffect;
333 SkMaskFilter* fMaskFilter; 345 sk_sp<SkMaskFilter> fMaskFilter;
334 SkRasterizer* fRasterizer; 346 sk_sp<SkRasterizer> fRasterizer;
335 347
336 // if this is set, we draw the image from a path, rather than 348 // if this is set, we draw the image from a path, rather than
337 // calling generateImage. 349 // calling generateImage.
338 bool fGenerateImageFromPath; 350 bool fGenerateImageFromPath;
339 351
340 void internalGetPath(const SkGlyph& glyph, SkPath* fillPath, 352 void internalGetPath(const SkGlyph& glyph, SkPath* fillPath,
341 SkPath* devPath, SkMatrix* fillToDevMatrix); 353 SkPath* devPath, SkMatrix* fillToDevMatrix);
342 354
343 // returns the right context from our link-list for this char. If no match 355 // returns the right context from our link-list for this char. If no match
344 // is found it returns nullptr. If a match is found then the glyphID param i s 356 // is found it returns nullptr. If a match is found then the glyphID param i s
(...skipping 23 matching lines...) Expand all
368 return static_cast<SkPaint::Hinting>(hint); 380 return static_cast<SkPaint::Hinting>(hint);
369 } 381 }
370 382
371 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) { 383 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) {
372 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) | 384 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) |
373 (hinting << SkScalerContext::kHinting_Shift); 385 (hinting << SkScalerContext::kHinting_Shift);
374 } 386 }
375 387
376 388
377 #endif 389 #endif
OLDNEW
« no previous file with comments | « src/core/SkPaint.cpp ('k') | src/core/SkScalerContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698