Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
SkScalerContext Class Referenceabstract

#include <SkScalerContext.h>

Inheritance diagram for SkScalerContext:
RandomScalerContext SkFontationsScalerContext SkScalerContextProxy SkScalerContext_DW SkScalerContext_FreeType SkTestScalerContext SkUserScalerContext

Classes

struct  GlyphMetrics
 

Public Types

enum  Flags {
  kFrameAndFill_Flag = 0x0001 , kUnused = 0x0002 , kEmbeddedBitmapText_Flag = 0x0004 , kEmbolden_Flag = 0x0008 ,
  kSubpixelPositioning_Flag = 0x0010 , kForceAutohinting_Flag = 0x0020 , kHinting_Shift = 7 , kHintingBit1_Flag = 0x0080 ,
  kHintingBit2_Flag = 0x0100 , kLCD_Vertical_Flag = 0x0200 , kLCD_BGROrder_Flag = 0x0400 , kGenA8FromLCD_Flag = 0x0800 ,
  kLinearMetrics_Flag = 0x1000 , kBaselineSnap_Flag = 0x2000 , kNeedsForegroundColor_Flag = 0x4000
}
 
enum  { kHinting_Mask = kHintingBit1_Flag | kHintingBit2_Flag }
 

Public Member Functions

 SkScalerContext (sk_sp< SkTypeface >, const SkScalerContextEffects &, const SkDescriptor *)
 
virtual ~SkScalerContext ()
 
SkTypefacegetTypeface () const
 
SkMask::Format getMaskFormat () const
 
bool isSubpixel () const
 
bool isLinearMetrics () const
 
bool isVertical () const
 
SkGlyph makeGlyph (SkPackedGlyphID, SkArenaAlloc *)
 
void getImage (const SkGlyph &)
 
void getPath (SkGlyph &, SkArenaAlloc *)
 
sk_sp< SkDrawablegetDrawable (SkGlyph &)
 
void getFontMetrics (SkFontMetrics *)
 
const SkScalerContextRecgetRec () const
 
SkScalerContextEffects getEffects () const
 
SkAxisAlignment computeAxisAlignmentForHText () const
 

Static Public Member Functions

static size_t GetGammaLUTSize (SkScalar contrast, SkScalar deviceGamma, int *width, int *height)
 
static bool GetGammaLUTData (SkScalar contrast, SkScalar deviceGamma, uint8_t *data)
 
static void MakeRecAndEffects (const SkFont &font, const SkPaint &paint, const SkSurfaceProps &surfaceProps, SkScalerContextFlags scalerContextFlags, const SkMatrix &deviceMatrix, SkScalerContextRec *rec, SkScalerContextEffects *effects)
 
static void MakeRecAndEffectsFromFont (const SkFont &font, SkScalerContextRec *rec, SkScalerContextEffects *effects)
 
static std::unique_ptr< SkScalerContextMakeEmpty (sk_sp< SkTypeface > typeface, const SkScalerContextEffects &effects, const SkDescriptor *desc)
 
static SkDescriptorAutoDescriptorGivenRecAndEffects (const SkScalerContextRec &rec, const SkScalerContextEffects &effects, SkAutoDescriptor *ad)
 
static std::unique_ptr< SkDescriptorDescriptorGivenRecAndEffects (const SkScalerContextRec &rec, const SkScalerContextEffects &effects)
 
static void DescriptorBufferGiveRec (const SkScalerContextRec &rec, void *buffer)
 
static bool CheckBufferSizeForRec (const SkScalerContextRec &rec, const SkScalerContextEffects &effects, size_t size)
 
static SkMaskGamma::PreBlend GetMaskPreBlend (const SkScalerContextRec &rec)
 
static SkDescriptorCreateDescriptorAndEffectsUsingPaint (const SkFont &, const SkPaint &, const SkSurfaceProps &, SkScalerContextFlags scalerContextFlags, const SkMatrix &deviceMatrix, SkAutoDescriptor *ad, SkScalerContextEffects *effects)
 

Protected Member Functions

virtual GlyphMetrics generateMetrics (const SkGlyph &, SkArenaAlloc *)=0
 
virtual void generateImage (const SkGlyph &glyph, void *imageBuffer)=0
 
virtual bool generatePath (const SkGlyph &, SkPath *)=0
 
virtual sk_sp< SkDrawablegenerateDrawable (const SkGlyph &)
 
virtual void generateFontMetrics (SkFontMetrics *)=0
 
void forceGenerateImageFromPath ()
 
void forceOffGenerateImageFromPath ()
 

Static Protected Member Functions

static void GenerateMetricsFromPath (SkGlyph *glyph, const SkPath &path, SkMask::Format format, bool verticalLCD, bool a8FromLCD, bool hairline)
 
static void SaturateGlyphBounds (SkGlyph *glyph, SkRect &&)
 
static void SaturateGlyphBounds (SkGlyph *glyph, SkIRect const &)
 
static void GenerateImageFromPath (SkMaskBuilder &dst, const SkPath &path, const SkMaskGamma::PreBlend &maskPreBlend, bool doBGR, bool verticalLCD, bool a8FromLCD, bool hairline)
 

Protected Attributes

SkScalerContextRec fRec
 
const SkMaskGamma::PreBlend fPreBlend
 

Friends

class PathText
 
class PathTextBench
 
class RandomScalerContext
 

Detailed Description

Definition at line 252 of file SkScalerContext.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kHinting_Mask 

Definition at line 283 of file SkScalerContext.h.

◆ Flags

Enumerator
kFrameAndFill_Flag 
kUnused 
kEmbeddedBitmapText_Flag 
kEmbolden_Flag 
kSubpixelPositioning_Flag 
kForceAutohinting_Flag 
kHinting_Shift 
kHintingBit1_Flag 
kHintingBit2_Flag 
kLCD_Vertical_Flag 
kLCD_BGROrder_Flag 
kGenA8FromLCD_Flag 
kLinearMetrics_Flag 
kBaselineSnap_Flag 
kNeedsForegroundColor_Flag 

Definition at line 254 of file SkScalerContext.h.

254 {
255 kFrameAndFill_Flag = 0x0001,
256 kUnused = 0x0002,
258 kEmbolden_Flag = 0x0008,
260 kForceAutohinting_Flag = 0x0020, // Use auto instead of bytcode hinting if hinting.
261
262 // together, these two flags resulting in a two bit value which matches
263 // up with the SkPaint::Hinting enum.
264 kHinting_Shift = 7, // to shift into the other flags above
265 kHintingBit1_Flag = 0x0080,
266 kHintingBit2_Flag = 0x0100,
267
268 // Pixel geometry information.
269 // only meaningful if fMaskFormat is kLCD16
270 kLCD_Vertical_Flag = 0x0200, // else Horizontal
271 kLCD_BGROrder_Flag = 0x0400, // else RGB order
272
273 // Generate A8 from LCD source (for GDI and CoreGraphics).
274 // only meaningful if fMaskFormat is kA8
275 kGenA8FromLCD_Flag = 0x0800, // could be 0x200 (bit meaning dependent on fMaskFormat)
276 kLinearMetrics_Flag = 0x1000,
277 kBaselineSnap_Flag = 0x2000,
278
280 };

Constructor & Destructor Documentation

◆ SkScalerContext()

SkScalerContext::SkScalerContext ( sk_sp< SkTypeface typeface,
const SkScalerContextEffects effects,
const SkDescriptor desc 
)

Definition at line 88 of file SkScalerContext.cpp.

90 : fRec(PreprocessRec(*typeface, effects, *desc))
91 , fTypeface(std::move(typeface))
92 , fPathEffect(sk_ref_sp(effects.fPathEffect))
93 , fMaskFilter(sk_ref_sp(effects.fMaskFilter))
94 // Initialize based on our settings. Subclasses can also force this.
95 , fGenerateImageFromPath(fRec.fFrameWidth >= 0 || fPathEffect != nullptr)
96
98{
99 if constexpr (kSkScalerContextDumpRec) {
100 SkDebugf("SkScalerContext checksum %x count %u length %u\n",
101 desc->getChecksum(), desc->getCount(), desc->getLength());
102 SkDebugf("%s", fRec.dump().c_str());
103 SkDebugf(" effects %p\n", desc->findEntry(kEffects_SkDescriptorTag, nullptr));
104 }
105}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381
#define kEffects_SkDescriptorTag
SkScalerContextRec fRec
const SkMaskGamma::PreBlend fPreBlend
static SkMaskGamma::PreBlend GetMaskPreBlend(const SkScalerContextRec &rec)
const char * c_str() const
Definition: SkString.h:133
SkPathEffect * fPathEffect
SkMaskFilter * fMaskFilter
SkString dump() const

◆ ~SkScalerContext()

SkScalerContext::~SkScalerContext ( )
virtual

Definition at line 107 of file SkScalerContext.cpp.

107{}

Member Function Documentation

◆ AutoDescriptorGivenRecAndEffects()

SkDescriptor * SkScalerContext::AutoDescriptorGivenRecAndEffects ( const SkScalerContextRec rec,
const SkScalerContextEffects effects,
SkAutoDescriptor ad 
)
static

Definition at line 1244 of file SkScalerContext.cpp.

1248{
1249 SkBinaryWriteBuffer buf({});
1250
1251 ad->reset(calculate_size_and_flatten(rec, effects, &buf));
1252 generate_descriptor(rec, buf, ad->getDesc());
1253
1254 return ad->getDesc();
1255}
static void generate_descriptor(const SkScalerContextRec &rec, const SkBinaryWriteBuffer &effectBuffer, SkDescriptor *desc)
static size_t calculate_size_and_flatten(const SkScalerContextRec &rec, const SkScalerContextEffects &effects, SkBinaryWriteBuffer *effectBuffer)
SkDescriptor * getDesc() const
Definition: SkDescriptor.h:103
void reset(size_t size)

◆ CheckBufferSizeForRec()

bool SkScalerContext::CheckBufferSizeForRec ( const SkScalerContextRec rec,
const SkScalerContextEffects effects,
size_t  size 
)
static

Definition at line 1273 of file SkScalerContext.cpp.

1275 {
1276 SkBinaryWriteBuffer buf({});
1277 return size >= calculate_size_and_flatten(rec, effects, &buf);
1278}
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259

◆ computeAxisAlignmentForHText()

SkAxisAlignment SkScalerContext::computeAxisAlignmentForHText ( ) const

Return the axis (if any) that the baseline for horizontal text should land on. As an example, the identity matrix will return SkAxisAlignment::kX.

Definition at line 977 of file SkScalerContext.cpp.

977 {
979}
SkAxisAlignment computeAxisAlignmentForHText() const

◆ CreateDescriptorAndEffectsUsingPaint()

SkDescriptor * SkScalerContext::CreateDescriptorAndEffectsUsingPaint ( const SkFont font,
const SkPaint paint,
const SkSurfaceProps surfaceProps,
SkScalerContextFlags  scalerContextFlags,
const SkMatrix deviceMatrix,
SkAutoDescriptor ad,
SkScalerContextEffects effects 
)
static

Definition at line 1203 of file SkScalerContext.cpp.

1207{
1209 MakeRecAndEffects(font, paint, surfaceProps, scalerContextFlags, deviceMatrix, &rec, effects);
1210 return AutoDescriptorGivenRecAndEffects(rec, *effects, ad);
1211}
static void MakeRecAndEffects(const SkFont &font, const SkPaint &paint, const SkSurfaceProps &surfaceProps, SkScalerContextFlags scalerContextFlags, const SkMatrix &deviceMatrix, SkScalerContextRec *rec, SkScalerContextEffects *effects)
static SkDescriptor * AutoDescriptorGivenRecAndEffects(const SkScalerContextRec &rec, const SkScalerContextEffects &effects, SkAutoDescriptor *ad)
const Paint & paint
Definition: color_source.cc:38
font
Font Metadata and Metrics.

◆ DescriptorBufferGiveRec()

void SkScalerContext::DescriptorBufferGiveRec ( const SkScalerContextRec rec,
void *  buffer 
)
static

Definition at line 1269 of file SkScalerContext.cpp.

1269 {
1271}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ DescriptorGivenRecAndEffects()

std::unique_ptr< SkDescriptor > SkScalerContext::DescriptorGivenRecAndEffects ( const SkScalerContextRec rec,
const SkScalerContextEffects effects 
)
static

Definition at line 1257 of file SkScalerContext.cpp.

1260{
1261 SkBinaryWriteBuffer buf({});
1262
1263 auto desc = SkDescriptor::Alloc(calculate_size_and_flatten(rec, effects, &buf));
1264 generate_descriptor(rec, buf, desc.get());
1265
1266 return desc;
1267}
static std::unique_ptr< SkDescriptor > Alloc(size_t length)

◆ forceGenerateImageFromPath()

void SkScalerContext::forceGenerateImageFromPath ( )
inlineprotected

Definition at line 443 of file SkScalerContext.h.

443{ fGenerateImageFromPath = true; }

◆ forceOffGenerateImageFromPath()

void SkScalerContext::forceOffGenerateImageFromPath ( )
inlineprotected

Definition at line 444 of file SkScalerContext.h.

444{ fGenerateImageFromPath = false; }

◆ generateDrawable()

sk_sp< SkDrawable > SkScalerContext::generateDrawable ( const SkGlyph )
protectedvirtual

Returns the drawable for the glyph (if any).

The generated drawable will be lifetime scoped to the lifetime of this scaler context. This means the drawable may refer to the scaler context and associated font data.

The drawable does not need to be flattenable (e.g. implement getFactory and getTypeName). Any necessary serialization will be done with makePictureSnapshot.

Reimplemented in SkScalerContextProxy, SkScalerContext_FreeType, SkScalerContext_DW, RandomScalerContext, SkFontationsScalerContext, and SkUserScalerContext.

Definition at line 752 of file SkScalerContext.cpp.

752 {
753 return nullptr;
754}

◆ generateFontMetrics()

virtual void SkScalerContext::generateFontMetrics ( SkFontMetrics )
protectedpure virtual

◆ generateImage()

virtual void SkScalerContext::generateImage ( const SkGlyph glyph,
void *  imageBuffer 
)
protectedpure virtual

Generates the contents of glyph.fImage. When called, glyph.fImage will be pointing to a pre-allocated, uninitialized region of memory of size glyph.imageSize(). This method may not change glyph.fMaskFormat.

Because glyph.imageSize() will determine the size of fImage, generateMetrics will be called before generateImage.

Implemented in SkScalerContextProxy, SkScalerContext_FreeType, RandomScalerContext, SkTestScalerContext, SkScalerContext_DW, SkFontationsScalerContext, and SkUserScalerContext.

◆ GenerateImageFromPath()

void SkScalerContext::GenerateImageFromPath ( SkMaskBuilder dst,
const SkPath path,
const SkMaskGamma::PreBlend maskPreBlend,
bool  doBGR,
bool  verticalLCD,
bool  a8FromLCD,
bool  hairline 
)
staticprotected

Definition at line 498 of file SkScalerContext.cpp.

501{
502 SkASSERT(dstMask.fFormat == SkMask::kBW_Format ||
503 dstMask.fFormat == SkMask::kA8_Format ||
504 dstMask.fFormat == SkMask::kLCD16_Format);
505
508 const SkPath* pathToUse = &path;
509
510 int srcW = dstMask.fBounds.width();
511 int srcH = dstMask.fBounds.height();
512 int dstW = srcW;
513 int dstH = srcH;
514
516 matrix.setTranslate(-SkIntToScalar(dstMask.fBounds.fLeft),
517 -SkIntToScalar(dstMask.fBounds.fTop));
518
519 paint.setStroke(hairline);
520 paint.setAntiAlias(SkMask::kBW_Format != dstMask.fFormat);
521
522 const bool fromLCD = (dstMask.fFormat == SkMask::kLCD16_Format) ||
523 (dstMask.fFormat == SkMask::kA8_Format && a8FromLCD);
524 const bool intermediateDst = fromLCD || dstMask.fFormat == SkMask::kBW_Format;
525 if (fromLCD) {
526 if (verticalLCD) {
527 dstW = 4*dstH - 8;
528 dstH = srcW;
529 matrix.setAll(0, 4, -SkIntToScalar(dstMask.fBounds.fTop + 1) * 4,
530 1, 0, -SkIntToScalar(dstMask.fBounds.fLeft),
531 0, 0, 1);
532 } else {
533 dstW = 4*dstW - 8;
534 matrix.setAll(4, 0, -SkIntToScalar(dstMask.fBounds.fLeft + 1) * 4,
535 0, 1, -SkIntToScalar(dstMask.fBounds.fTop),
536 0, 0, 1);
537 }
538
539 // LCD hairline doesn't line up with the pixels, so do it the expensive way.
541 if (hairline) {
542 rec.setStrokeStyle(1.0f, false);
543 rec.setStrokeParams(SkPaint::kButt_Cap, SkPaint::kRound_Join, 0.0f);
544 }
545 if (rec.needToApply() && rec.applyToPath(&strokePath, path)) {
546 pathToUse = &strokePath;
547 paint.setStyle(SkPaint::kFill_Style);
548 }
549 }
550
552 clip.setRect(SkIRect::MakeWH(dstW, dstH));
553
554 const SkImageInfo info = SkImageInfo::MakeA8(dstW, dstH);
556
557 if (intermediateDst) {
558 if (!dst.tryAlloc(info)) {
559 // can't allocate offscreen, so empty the mask and return
560 sk_bzero(dstMask.image(), dstMask.computeImageSize());
561 return;
562 }
563 } else {
564 dst.reset(info, dstMask.image(), dstMask.fRowBytes);
565 }
566 sk_bzero(dst.writable_addr(), dst.computeByteSize());
567
569 draw.fBlitterChooser = SkA8Blitter_Choose;
570 draw.fDst = dst;
571 draw.fRC = &clip;
572 draw.fCTM = &matrix;
573 draw.drawPath(*pathToUse, paint);
574
575 switch (dstMask.fFormat) {
577 packA8ToA1(dstMask, dst.addr8(0, 0), dst.rowBytes());
578 break;
580 if (fromLCD) {
581 pack4xHToMask(dst, dstMask, maskPreBlend, doBGR, verticalLCD);
582 } else if (maskPreBlend.isApplicable()) {
583 applyLUTToA8Mask(dstMask, maskPreBlend.fG);
584 }
585 break;
587 pack4xHToMask(dst, dstMask, maskPreBlend, doBGR, verticalLCD);
588 break;
589 default:
590 break;
591 }
592}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
sk_bzero(glyphs, sizeof(glyphs))
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkBlitter * SkA8Blitter_Choose(const SkPixmap &dst, const SkMatrix &ctm, const SkPaint &paint, SkArenaAlloc *alloc, bool drawCoverage, sk_sp< SkShader > clipShader, const SkSurfaceProps &)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
#define SkIntToScalar(x)
Definition: SkScalar.h:57
static void applyLUTToA8Mask(SkMaskBuilder &mask, const uint8_t *lut)
static void pack4xHToMask(const SkPixmap &src, SkMaskBuilder &dst, const SkMaskGamma::PreBlend &maskPreBlend, const bool doBGR, const bool doVert)
static void packA8ToA1(SkMaskBuilder &dstMask, const uint8_t *src, size_t srcRB)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
@ kButt_Cap
no stroke extension
Definition: SkPaint.h:334
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
@ kRound_Join
adds circle
Definition: SkPaint.h:360
Definition: SkPath.h:59
const uint8_t * fG
Definition: SkMaskGamma.h:203
bool isApplicable() const
Definition: SkMaskGamma.h:200
static void strokePath(SkCanvas *canvas, const SkPath &path)
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
dst
Definition: cp.py:12
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition: SkRect.h:56
static SkImageInfo MakeA8(int width, int height)
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
Definition: SkMask.h:28
@ kLCD16_Format
565 alpha for r/g/b
Definition: SkMask.h:31
@ kBW_Format
1bit per pixel mask (e.g. monochrome)
Definition: SkMask.h:27

◆ generateMetrics()

virtual GlyphMetrics SkScalerContext::generateMetrics ( const SkGlyph ,
SkArenaAlloc  
)
protectedpure virtual

◆ GenerateMetricsFromPath()

void SkScalerContext::GenerateMetricsFromPath ( SkGlyph glyph,
const SkPath path,
SkMask::Format  format,
bool  verticalLCD,
bool  a8FromLCD,
bool  hairline 
)
staticprotected

Definition at line 226 of file SkScalerContext.cpp.

229{
230 // Only BW, A8, and LCD16 can be produced from paths.
231 if (glyph->fMaskFormat != SkMask::kBW_Format &&
232 glyph->fMaskFormat != SkMask::kA8_Format &&
233 glyph->fMaskFormat != SkMask::kLCD16_Format)
234 {
235 glyph->fMaskFormat = SkMask::kA8_Format;
236 }
237
238 SkRect bounds = devPath.getBounds();
239 if (!bounds.isEmpty()) {
240 const bool fromLCD = (glyph->fMaskFormat == SkMask::kLCD16_Format) ||
241 (glyph->fMaskFormat == SkMask::kA8_Format && a8FromLCD);
242
243 const bool needExtraWidth = (fromLCD && !verticalLCD) || hairline;
244 const bool needExtraHeight = (fromLCD && verticalLCD) || hairline;
245 if (needExtraWidth) {
246 bounds.roundOut(&bounds);
247 bounds.outset(1, 0);
248 }
249 if (needExtraHeight) {
250 bounds.roundOut(&bounds);
251 bounds.outset(0, 1);
252 }
253 }
254 SaturateGlyphBounds(glyph, std::move(bounds));
255}
static void SaturateGlyphBounds(SkGlyph *glyph, SkRect &&)
Optional< SkRect > bounds
Definition: SkRecords.h:189

◆ generatePath()

virtual bool SkScalerContext::generatePath ( const SkGlyph ,
SkPath  
)
protectedpure virtual

Sets the passed path to the glyph outline. If this cannot be done the path is set to empty; Does not apply subpixel positioning to the path.

Returns
false if this glyph does not have any path.

Implemented in SkScalerContext_DW, RandomScalerContext, SkScalerContextProxy, SkScalerContext_FreeType, SkFontationsScalerContext, SkUserScalerContext, and SkTestScalerContext.

◆ getDrawable()

sk_sp< SkDrawable > SkScalerContext::getDrawable ( SkGlyph glyph)

Definition at line 748 of file SkScalerContext.cpp.

748 {
749 return this->generateDrawable(glyph);
750}
virtual sk_sp< SkDrawable > generateDrawable(const SkGlyph &)

◆ getEffects()

SkScalerContextEffects SkScalerContext::getEffects ( ) const
inline

Definition at line 364 of file SkScalerContext.h.

364 {
365 return { fPathEffect.get(), fMaskFilter.get() };
366 }
T * get() const
Definition: SkRefCnt.h:303

◆ getFontMetrics()

void SkScalerContext::getFontMetrics ( SkFontMetrics fm)

Definition at line 756 of file SkScalerContext.cpp.

756 {
757 SkASSERT(fm);
758 this->generateFontMetrics(fm);
759}
virtual void generateFontMetrics(SkFontMetrics *)=0

◆ GetGammaLUTData()

bool SkScalerContext::GetGammaLUTData ( SkScalar  contrast,
SkScalar  deviceGamma,
uint8_t *  data 
)
static

Get the associated gamma lookup table. The 'data' pointer must point to pre-allocated memory, with size in bytes greater than or equal to the return value of getGammaLUTSize().

If the lookup table hasn't been initialized (e.g., it's linear), this will return false.

Definition at line 184 of file SkScalerContext.cpp.

184 {
187 SkScalerContextRec::InternalContrastFromExternal(contrast),
188 SkScalerContextRec::InternalGammaFromExternal(deviceGamma));
189 const uint8_t* gammaTables = maskGamma.getGammaTables();
190 if (!gammaTables) {
191 return false;
192 }
193
194 int width, height;
196 size_t size = width*height * sizeof(uint8_t);
197 memcpy(data, gammaTables, size);
198 return true;
199}
static SkMutex & mask_gamma_cache_mutex()
void getGammaTableDimensions(int *tableWidth, int *numTables) const
Definition: SkMaskGamma.h:144
const uint8_t * getGammaTables() const
Definition: SkMaskGamma.h:154
int32_t height
int32_t width
static const SkMaskGamma & CachedMaskGamma(uint8_t contrast, uint8_t gamma)
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ GetGammaLUTSize()

size_t SkScalerContext::GetGammaLUTSize ( SkScalar  contrast,
SkScalar  deviceGamma,
int width,
int height 
)
static

Return the size in bytes of the associated gamma lookup table

Definition at line 171 of file SkScalerContext.cpp.

172 {
175 SkScalerContextRec::InternalContrastFromExternal(contrast),
176 SkScalerContextRec::InternalGammaFromExternal(deviceGamma));
177
179 size_t size = (*width)*(*height)*sizeof(uint8_t);
180
181 return size;
182}

◆ getImage()

void SkScalerContext::getImage ( const SkGlyph origGlyph)

Definition at line 594 of file SkScalerContext.cpp.

594 {
595 SkASSERT(origGlyph.fAdvancesBoundsFormatAndInitialPathDone);
596
597 const SkGlyph* unfilteredGlyph = &origGlyph;
598 // in case we need to call generateImage on a mask-format that is different
599 // (i.e. larger) than what our caller allocated by looking at origGlyph.
600 SkAutoMalloc tmpGlyphImageStorage;
601 SkGlyph tmpGlyph;
602 SkSTArenaAlloc<sizeof(SkGlyph::PathData)> tmpGlyphPathDataStorage;
603 if (fMaskFilter) {
604 // need the original bounds, sans our maskfilter
605 sk_sp<SkMaskFilter> mf = std::move(fMaskFilter);
606 tmpGlyph = this->makeGlyph(origGlyph.getPackedID(), &tmpGlyphPathDataStorage);
607 fMaskFilter = std::move(mf);
608
609 // Use the origGlyph storage for the temporary unfiltered mask if it will fit.
610 if (tmpGlyph.fMaskFormat == origGlyph.fMaskFormat &&
611 tmpGlyph.imageSize() <= origGlyph.imageSize())
612 {
613 tmpGlyph.fImage = origGlyph.fImage;
614 } else {
615 tmpGlyphImageStorage.reset(tmpGlyph.imageSize());
616 tmpGlyph.fImage = tmpGlyphImageStorage.get();
617 }
618 unfilteredGlyph = &tmpGlyph;
619 }
620
621 if (!fGenerateImageFromPath) {
622 generateImage(*unfilteredGlyph, unfilteredGlyph->fImage);
623 } else {
624 SkASSERT(origGlyph.setPathHasBeenCalled());
625 const SkPath* devPath = origGlyph.path();
626
627 if (!devPath) {
628 generateImage(*unfilteredGlyph, unfilteredGlyph->fImage);
629 } else {
630 SkMaskBuilder mask(static_cast<uint8_t*>(unfilteredGlyph->fImage),
631 unfilteredGlyph->iRect(), unfilteredGlyph->rowBytes(),
632 unfilteredGlyph->maskFormat());
633 SkASSERT(SkMask::kARGB32_Format != origGlyph.fMaskFormat);
634 SkASSERT(SkMask::kARGB32_Format != mask.fFormat);
638 const bool hairline = origGlyph.pathIsHairline();
639 GenerateImageFromPath(mask, *devPath, fPreBlend, doBGR, doVert, a8LCD, hairline);
640 }
641 }
642
643 if (fMaskFilter) {
644 // k3D_Format should not be mask filtered.
645 SkASSERT(SkMask::k3D_Format != unfilteredGlyph->fMaskFormat);
646
647 SkMaskBuilder srcMask;
648 SkAutoMaskFreeImage srcMaskOwnedImage(nullptr);
649 SkMatrix m;
651
652 if (as_MFB(fMaskFilter)->filterMask(&srcMask, unfilteredGlyph->mask(), m, nullptr)) {
653 // Filter succeeded; srcMask.fImage was allocated.
654 srcMaskOwnedImage.reset(srcMask.image());
655 } else if (unfilteredGlyph->fImage == tmpGlyphImageStorage.get()) {
656 // Filter did nothing; unfiltered mask is independent of origGlyph.fImage.
657 srcMask = SkMaskBuilder(static_cast<uint8_t*>(unfilteredGlyph->fImage),
658 unfilteredGlyph->iRect(), unfilteredGlyph->rowBytes(),
659 unfilteredGlyph->maskFormat());
660 } else if (origGlyph.iRect() == unfilteredGlyph->iRect()) {
661 // Filter did nothing; the unfiltered mask is in origGlyph.fImage and matches.
662 return;
663 } else {
664 // Filter did nothing; the unfiltered mask is in origGlyph.fImage and conflicts.
665 srcMask = SkMaskBuilder(static_cast<uint8_t*>(unfilteredGlyph->fImage),
666 unfilteredGlyph->iRect(), unfilteredGlyph->rowBytes(),
667 unfilteredGlyph->maskFormat());
668 size_t imageSize = unfilteredGlyph->imageSize();
669 tmpGlyphImageStorage.reset(imageSize);
670 srcMask.image() = static_cast<uint8_t*>(tmpGlyphImageStorage.get());
671 memcpy(srcMask.image(), unfilteredGlyph->fImage, imageSize);
672 }
673
674 SkASSERT_RELEASE(srcMask.fFormat == origGlyph.fMaskFormat);
675 SkMaskBuilder dstMask = SkMaskBuilder(static_cast<uint8_t*>(origGlyph.fImage),
676 origGlyph.iRect(), origGlyph.rowBytes(),
677 origGlyph.maskFormat());
678 SkIRect origBounds = dstMask.fBounds;
679
680 // Find the intersection of src and dst while updating the fImages.
681 if (srcMask.fBounds.fTop < dstMask.fBounds.fTop) {
682 int32_t topDiff = dstMask.fBounds.fTop - srcMask.fBounds.fTop;
683 srcMask.image() += srcMask.fRowBytes * topDiff;
684 srcMask.bounds().fTop = dstMask.fBounds.fTop;
685 }
686 if (dstMask.fBounds.fTop < srcMask.fBounds.fTop) {
687 int32_t topDiff = srcMask.fBounds.fTop - dstMask.fBounds.fTop;
688 dstMask.image() += dstMask.fRowBytes * topDiff;
689 dstMask.bounds().fTop = srcMask.fBounds.fTop;
690 }
691
692 if (srcMask.fBounds.fLeft < dstMask.fBounds.fLeft) {
693 int32_t leftDiff = dstMask.fBounds.fLeft - srcMask.fBounds.fLeft;
694 srcMask.image() += leftDiff;
695 srcMask.bounds().fLeft = dstMask.fBounds.fLeft;
696 }
697 if (dstMask.fBounds.fLeft < srcMask.fBounds.fLeft) {
698 int32_t leftDiff = srcMask.fBounds.fLeft - dstMask.fBounds.fLeft;
699 dstMask.image() += leftDiff;
700 dstMask.bounds().fLeft = srcMask.fBounds.fLeft;
701 }
702
703 if (srcMask.fBounds.fBottom < dstMask.fBounds.fBottom) {
704 dstMask.bounds().fBottom = srcMask.fBounds.fBottom;
705 }
706 if (dstMask.fBounds.fBottom < srcMask.fBounds.fBottom) {
707 srcMask.bounds().fBottom = dstMask.fBounds.fBottom;
708 }
709
710 if (srcMask.fBounds.fRight < dstMask.fBounds.fRight) {
711 dstMask.bounds().fRight = srcMask.fBounds.fRight;
712 }
713 if (dstMask.fBounds.fRight < srcMask.fBounds.fRight) {
714 srcMask.bounds().fRight = dstMask.fBounds.fRight;
715 }
716
717 SkASSERT(srcMask.fBounds == dstMask.fBounds);
718 int width = srcMask.fBounds.width();
719 int height = srcMask.fBounds.height();
720 int dstRB = dstMask.fRowBytes;
721 int srcRB = srcMask.fRowBytes;
722
723 const uint8_t* src = srcMask.fImage;
724 uint8_t* dst = dstMask.image();
725
726 if (SkMask::k3D_Format == srcMask.fFormat) {
727 // we have to copy 3 times as much
728 height *= 3;
729 }
730
731 // If not filling the full original glyph, clear it out first.
732 if (dstMask.fBounds != origBounds) {
733 sk_bzero(origGlyph.fImage, origGlyph.fHeight * origGlyph.rowBytes());
734 }
735
736 while (--height >= 0) {
737 memcpy(dst, src, width);
738 src += srcRB;
739 dst += dstRB;
740 }
741 }
742}
#define SkASSERT_RELEASE(cond)
Definition: SkAssert.h:100
SkMaskFilterBase * as_MFB(SkMaskFilter *mf)
std::unique_ptr< uint8_t, SkFunctionObject< SkMaskBuilder::FreeImage > > SkAutoMaskFreeImage
Definition: SkMask.h:316
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
void * reset(size_t size=0, OnShrink shrink=kAlloc_OnShrink)
Definition: SkAutoMalloc.h:53
void * get()
Definition: SkAutoMalloc.h:64
bool setPathHasBeenCalled() const
Definition: SkGlyph.h:486
size_t rowBytes() const
Definition: SkGlyph.cpp:233
size_t imageSize() const
Definition: SkGlyph.cpp:241
SkMask mask() const
Definition: SkGlyph.cpp:125
const SkPath * path() const
Definition: SkGlyph.cpp:284
SkMask::Format maskFormat() const
Definition: SkGlyph.h:500
bool pathIsHairline() const
Definition: SkGlyph.cpp:293
SkIRect iRect() const
Definition: SkGlyph.h:505
SkPackedGlyphID getPackedID() const
Definition: SkGlyph.h:430
virtual void generateImage(const SkGlyph &glyph, void *imageBuffer)=0
static void GenerateImageFromPath(SkMaskBuilder &dst, const SkPath &path, const SkMaskGamma::PreBlend &maskPreBlend, bool doBGR, bool verticalLCD, bool a8FromLCD, bool hairline)
SkGlyph makeGlyph(SkPackedGlyphID, SkArenaAlloc *)
Definition: SkRect.h:32
int32_t fBottom
larger y-axis bounds
Definition: SkRect.h:36
constexpr int32_t height() const
Definition: SkRect.h:165
int32_t fTop
smaller y-axis bounds
Definition: SkRect.h:34
constexpr int32_t width() const
Definition: SkRect.h:158
int32_t fLeft
smaller x-axis bounds
Definition: SkRect.h:33
int32_t fRight
larger x-axis bounds
Definition: SkRect.h:35
SkIRect & bounds()
Definition: SkMask.h:237
uint8_t *& image()
Definition: SkMask.h:236
const uint32_t fRowBytes
Definition: SkMask.h:43
@ k3D_Format
3 8bit per pixl planes: alpha, mul, add
Definition: SkMask.h:29
@ kARGB32_Format
SkPMColor.
Definition: SkMask.h:30
uint8_t const *const fImage
Definition: SkMask.h:41
const SkIRect fBounds
Definition: SkMask.h:42
const Format fFormat
Definition: SkMask.h:44
void getMatrixFrom2x2(SkMatrix *) const

◆ getMaskFormat()

SkMask::Format SkScalerContext::getMaskFormat ( ) const
inline

Definition at line 292 of file SkScalerContext.h.

292 {
293 return fRec.fMaskFormat;
294 }
SkMask::Format fMaskFormat

◆ GetMaskPreBlend()

SkMaskGamma::PreBlend SkScalerContext::GetMaskPreBlend ( const SkScalerContextRec rec)
static

Expands fDeviceGamma, fContrast, and fLumBits into a mask pre-blend.

Definition at line 162 of file SkScalerContext.cpp.

162 {
164
165 const SkMaskGamma& maskGamma = rec.cachedMaskGamma();
166
167 // TODO: remove CanonicalColor when we to fix up Chrome layout tests.
168 return maskGamma.preBlend(rec.getLuminanceColor());
169}
PreBlend preBlend(SkColor color) const
Definition: SkMaskGamma.h:209
const SkMaskGamma & cachedMaskGamma() const
SkColor getLuminanceColor() const

◆ getPath()

void SkScalerContext::getPath ( SkGlyph glyph,
SkArenaAlloc alloc 
)

Definition at line 744 of file SkScalerContext.cpp.

744 {
745 this->internalGetPath(glyph, alloc);
746}

◆ getRec()

const SkScalerContextRec & SkScalerContext::getRec ( ) const
inline

Definition at line 362 of file SkScalerContext.h.

362{ return fRec; }

◆ getTypeface()

SkTypeface * SkScalerContext::getTypeface ( ) const
inline

Definition at line 290 of file SkScalerContext.h.

290{ return fTypeface.get(); }

◆ isLinearMetrics()

bool SkScalerContext::isLinearMetrics ( ) const
inline

Definition at line 300 of file SkScalerContext.h.

300 {
302 }

◆ isSubpixel()

bool SkScalerContext::isSubpixel ( ) const
inline

Definition at line 296 of file SkScalerContext.h.

296 {
298 }

◆ isVertical()

bool SkScalerContext::isVertical ( ) const
inline

Definition at line 305 of file SkScalerContext.h.

305{ return false; }

◆ MakeEmpty()

std::unique_ptr< SkScalerContext > SkScalerContext::MakeEmpty ( sk_sp< SkTypeface typeface,
const SkScalerContextEffects effects,
const SkDescriptor desc 
)
static

Definition at line 1280 of file SkScalerContext.cpp.

1282 {
1283 class SkScalerContext_Empty : public SkScalerContext {
1284 public:
1285 SkScalerContext_Empty(sk_sp<SkTypeface> typeface, const SkScalerContextEffects& effects,
1286 const SkDescriptor* desc)
1287 : SkScalerContext(std::move(typeface), effects, desc) {}
1288
1289 protected:
1290 GlyphMetrics generateMetrics(const SkGlyph& glyph, SkArenaAlloc*) override {
1291 return {glyph.maskFormat()};
1292 }
1293 void generateImage(const SkGlyph&, void*) override {}
1294 bool generatePath(const SkGlyph& glyph, SkPath* path) override {
1295 path->reset();
1296 return false;
1297 }
1298 void generateFontMetrics(SkFontMetrics* metrics) override {
1299 if (metrics) {
1300 sk_bzero(metrics, sizeof(*metrics));
1301 }
1302 }
1303 };
1304
1305 return std::make_unique<SkScalerContext_Empty>(std::move(typeface), effects, desc);
1306}
virtual GlyphMetrics generateMetrics(const SkGlyph &, SkArenaAlloc *)=0
virtual bool generatePath(const SkGlyph &, SkPath *)=0
Definition: ref_ptr.h:256

◆ makeGlyph()

SkGlyph SkScalerContext::makeGlyph ( SkPackedGlyphID  packedID,
SkArenaAlloc alloc 
)

Definition at line 201 of file SkScalerContext.cpp.

201 {
202 return internalMakeGlyph(packedID, fRec.fMaskFormat, alloc);
203}

◆ MakeRecAndEffects()

void SkScalerContext::MakeRecAndEffects ( const SkFont font,
const SkPaint paint,
const SkSurfaceProps surfaceProps,
SkScalerContextFlags  scalerContextFlags,
const SkMatrix deviceMatrix,
SkScalerContextRec rec,
SkScalerContextEffects effects 
)
static

Definition at line 1053 of file SkScalerContext.cpp.

1058 {
1059 SkASSERT(!deviceMatrix.hasPerspective());
1060
1061 sk_bzero(rec, sizeof(SkScalerContextRec));
1062
1063 SkTypeface* typeface = font.getTypeface();
1064
1065 rec->fTypefaceID = typeface->uniqueID();
1066 rec->fTextSize = font.getSize();
1067 rec->fPreScaleX = font.getScaleX();
1068 rec->fPreSkewX = font.getSkewX();
1069
1070 bool checkPost2x2 = false;
1071
1072 const SkMatrix::TypeMask mask = deviceMatrix.getType();
1073 if (mask & SkMatrix::kScale_Mask) {
1074 rec->fPost2x2[0][0] = sk_relax(deviceMatrix.getScaleX());
1075 rec->fPost2x2[1][1] = sk_relax(deviceMatrix.getScaleY());
1076 checkPost2x2 = true;
1077 } else {
1078 rec->fPost2x2[0][0] = rec->fPost2x2[1][1] = SK_Scalar1;
1079 }
1080 if (mask & SkMatrix::kAffine_Mask) {
1081 rec->fPost2x2[0][1] = sk_relax(deviceMatrix.getSkewX());
1082 rec->fPost2x2[1][0] = sk_relax(deviceMatrix.getSkewY());
1083 checkPost2x2 = true;
1084 } else {
1085 rec->fPost2x2[0][1] = rec->fPost2x2[1][0] = 0;
1086 }
1087
1088 SkPaint::Style style = paint.getStyle();
1089 SkScalar strokeWidth = paint.getStrokeWidth();
1090
1091 unsigned flags = 0;
1092
1093 if (font.isEmbolden()) {
1094#ifdef SK_USE_FREETYPE_EMBOLDEN
1096#else
1097 SkScalar fakeBoldScale = SkScalarInterpFunc(font.getSize(),
1101 SkScalar extra = font.getSize() * fakeBoldScale;
1102
1103 if (style == SkPaint::kFill_Style) {
1105 strokeWidth = extra; // ignore paint's strokeWidth if it was "fill"
1106 } else {
1107 strokeWidth += extra;
1108 }
1109#endif
1110 }
1111
1112 if (style != SkPaint::kFill_Style && strokeWidth >= 0) {
1113 rec->fFrameWidth = strokeWidth;
1114 rec->fMiterLimit = paint.getStrokeMiter();
1115 rec->fStrokeJoin = SkToU8(paint.getStrokeJoin());
1116 rec->fStrokeCap = SkToU8(paint.getStrokeCap());
1117
1118 if (style == SkPaint::kStrokeAndFill_Style) {
1120 }
1121 } else {
1122 rec->fFrameWidth = -1;
1123 rec->fMiterLimit = 0;
1124 rec->fStrokeJoin = 0;
1125 rec->fStrokeCap = 0;
1126 }
1127
1129
1130 if (SkMask::kLCD16_Format == rec->fMaskFormat) {
1131 if (too_big_for_lcd(*rec, checkPost2x2)) {
1134 } else {
1135 SkPixelGeometry geometry = surfaceProps.pixelGeometry();
1136
1137 switch (geometry) {
1139 // eeek, can't support LCD
1142 break;
1144 // our default, do nothing.
1145 break;
1148 break;
1151 break;
1155 break;
1156 }
1157 }
1158 }
1159
1160 if (font.isEmbeddedBitmaps()) {
1162 }
1163 if (font.isSubpixel()) {
1165 }
1166 if (font.isForceAutoHinting()) {
1168 }
1169 if (font.isLinearMetrics()) {
1171 }
1172 if (font.isBaselineSnap()) {
1174 }
1175 if (typeface->glyphMaskNeedsCurrentColor()) {
1177 rec->fForegroundColor = paint.getColor();
1178 }
1179 rec->fFlags = SkToU16(flags);
1180
1181 // these modify fFlags, so do them after assigning fFlags
1182 rec->setHinting(font.getHinting());
1184
1185 // The paint color is always converted to the device colr space,
1186 // so the paint gamma is now always equal to the device gamma.
1187 // The math in SkMaskGamma can handle them being different,
1188 // but it requires superluminous masks when
1189 // Ex : deviceGamma(x) < paintGamma(x) and x is sufficiently large.
1190 rec->setDeviceGamma(surfaceProps.textGamma());
1191 rec->setContrast(surfaceProps.textContrast());
1192
1193 if (!SkToBool(scalerContextFlags & SkScalerContextFlags::kFakeGamma)) {
1194 rec->ignoreGamma();
1195 }
1196 if (!SkToBool(scalerContextFlags & SkScalerContextFlags::kBoostContrast)) {
1197 rec->setContrast(0);
1198 }
1199
1200 new (effects) SkScalerContextEffects{paint};
1201}
static const int strokeWidth
Definition: BlurTest.cpp:60
#define SK_Scalar1
Definition: SkScalar.h:18
SkScalar SkScalarInterpFunc(SkScalar searchKey, const SkScalar keys[], const SkScalar values[], int length)
Definition: SkScalar.cpp:11
static SkScalar sk_relax(SkScalar x)
static bool too_big_for_lcd(const SkScalerContextRec &rec, bool checkPost2x2)
static SkMask::Format compute_mask_format(const SkFont &font)
SkPixelGeometry
@ kUnknown_SkPixelGeometry
@ kRGB_V_SkPixelGeometry
@ kBGR_H_SkPixelGeometry
@ kRGB_H_SkPixelGeometry
@ kBGR_V_SkPixelGeometry
static const SkScalar kStdFakeBoldInterpValues[]
static const int kStdFakeBoldInterpLength
static const SkScalar kStdFakeBoldInterpKeys[]
constexpr uint16_t SkToU16(S x)
Definition: SkTo.h:24
constexpr uint8_t SkToU8(S x)
Definition: SkTo.h:22
SkScalar getSkewY() const
Definition: SkMatrix.h:430
SkScalar getSkewX() const
Definition: SkMatrix.h:438
SkScalar getScaleX() const
Definition: SkMatrix.h:415
SkScalar getScaleY() const
Definition: SkMatrix.h:422
bool hasPerspective() const
Definition: SkMatrix.h:312
@ kScale_Mask
scale SkMatrix
Definition: SkMatrix.h:194
@ kAffine_Mask
skew or rotate SkMatrix
Definition: SkMatrix.h:195
TypeMask getType() const
Definition: SkMatrix.h:207
static SkColor ComputeLuminanceColor(const SkPaint &)
@ kStrokeAndFill_Style
sets to stroke and fill geometry
Definition: SkPaint.h:195
SkScalar textGamma() const
SkPixelGeometry pixelGeometry() const
SkScalar textContrast() const
SkTypefaceID uniqueID() const
Definition: SkTypeface.h:101
float SkScalar
Definition: extension.cpp:12
FlutterSemanticsFlag flags
void setDeviceGamma(SkScalar g)
void setContrast(SkScalar c)
SkTypefaceID fTypefaceID
SkScalar fPost2x2[2][2]
void setHinting(SkFontHinting)
void setLuminanceColor(SkColor c)

◆ MakeRecAndEffectsFromFont()

static void SkScalerContext::MakeRecAndEffectsFromFont ( const SkFont font,
SkScalerContextRec rec,
SkScalerContextEffects effects 
)
inlinestatic

Definition at line 333 of file SkScalerContext.h.

335 {
337 return MakeRecAndEffects(
340 }
static const SkMatrix & I()
Definition: SkMatrix.cpp:1544

◆ SaturateGlyphBounds() [1/2]

void SkScalerContext::SaturateGlyphBounds ( SkGlyph glyph,
SkIRect const &  r 
)
staticprotected

Definition at line 219 of file SkScalerContext.cpp.

219 {
220 glyph->fLeft = sk_saturate_cast<int16_t>(r.fLeft);
221 glyph->fTop = sk_saturate_cast<int16_t>(r.fTop);
222 glyph->fWidth = sk_saturate_cast<uint16_t>(r.width64());
223 glyph->fHeight = sk_saturate_cast<uint16_t>(r.height64());
224}

◆ SaturateGlyphBounds() [2/2]

void SkScalerContext::SaturateGlyphBounds ( SkGlyph glyph,
SkRect &&  r 
)
staticprotected

Definition at line 212 of file SkScalerContext.cpp.

212 {
213 r.roundOut(&r);
214 glyph->fLeft = sk_saturate_cast<int16_t>(r.fLeft);
215 glyph->fTop = sk_saturate_cast<int16_t>(r.fTop);
216 glyph->fWidth = sk_saturate_cast<uint16_t>(r.width());
217 glyph->fHeight = sk_saturate_cast<uint16_t>(r.height());
218}
SkScalar fLeft
smaller x-axis bounds
Definition: extension.cpp:14
void roundOut(SkIRect *dst) const
Definition: SkRect.h:1241
constexpr float height() const
Definition: SkRect.h:769
constexpr float width() const
Definition: SkRect.h:762
SkScalar fTop
smaller y-axis bounds
Definition: extension.cpp:15

Friends And Related Function Documentation

◆ PathText

friend class PathText
friend

Definition at line 447 of file SkScalerContext.h.

◆ PathTextBench

friend class PathTextBench
friend

Definition at line 448 of file SkScalerContext.h.

◆ RandomScalerContext

friend class RandomScalerContext
friend

Definition at line 449 of file SkScalerContext.h.

Member Data Documentation

◆ fPreBlend

const SkMaskGamma::PreBlend SkScalerContext::fPreBlend
protected

Definition at line 472 of file SkScalerContext.h.

◆ fRec

SkScalerContextRec SkScalerContext::fRec
protected

Definition at line 381 of file SkScalerContext.h.


The documentation for this class was generated from the following files: