class SkArenaAlloc; class SkAutoDescriptor; class SkDescriptor; class SkDrawable; class SkFont; class SkMaskFilter; class SkPathEffect; enumclass SkFontHinting; struct SkFontMetrics;
//The following typedef hides from the rest of the implementation the number of //most significant bits to consider when creating mask gamma tables. Two bits //per channel was chosen as a balance between fidelity (more bits) and cache //sizes (fewer bits). Three bits per channel was chosen when #303942; (used by //the Chrome UI) turned out too green. typedef SkTMaskGamma<3, 3, 3> SkMaskGamma;
// This will be set if to the paint's foreground color if // kNeedsForegroundColor is set, which will usually be the case for COLRv0 and // COLRv1 fonts.
uint32_t fForegroundColor{SK_ColorBLACK};
private: //These describe the parameters to create (uniquely identify) the pre-blend.
uint32_t fLumBits;
uint8_t fDeviceGamma; //2.6, (0.0, 4.0) gamma, 0.0 for sRGB const uint8_t fReservedAlign2{0};
uint8_t fContrast; //0.8+1, [0.0, 1.0] artificial contrast const uint8_t fReservedAlign{0};
// Warning: when adding members note that the size of this structure // must be a multiple of 4. SkDescriptor requires that its arguments be // multiples of four and this structure is put in an SkDescriptor in // SkPaint::MakeRecAndEffects.
/** The kind of scale which will be applied by the underlying port (pre-matrix). */ enumclass PreMatrixScale {
kFull, // The underlying port can apply both x and y scale.
kVertical, // The underlying port can only apply a y scale.
kVerticalInteger // The underlying port can only apply an integer y scale.
}; /** *Computeusefulmatricesforusewithsizinginunderlyinglibraries. * *Therearetwokindsoftextsize,a'requested/logicalsize'whichislikeaskingforsize *'12'anda'real'sizewhichisthesizeafterthematrixisapplied.Thematricesproduced *bythismethodarebasedonthe'real'size.Thismethodeffectivelyfindsthetotaldevice *matrixanddecomposesitinvariousways. * *Themostusefuldecompositionisinto'scale'and'remaining'.The'scale'isappliedfirst *andthenthe'remaining'tofullyapplythetotalmatrix.Thisdecompositionisusefulwhen *thetextsize('scale')mayhavemeaningapartfromthetotalmatrix.Thisistruewhen *hinting,andsometimestrueforotherpropertiesaswell. * *Thesecond(optional)decompositionisof'remaining'intoanon-rotationalpart *'remainingWithoutRotation'andarotationalpart'remainingRotation'.The'scale'isapplied *first,then'remainingWithoutRotation',then'remainingRotation'tofullyapplythetotal *matrix.Thisdecompositionishelpfulwhenonlyhorizontalmetricscanbetrusted,sothe *'scale'and'remainingWithoutRotation'willbehandledbytheunderlyinglibrary,but *thefinalrotation'remainingRotation'willbehandledmanually. * *The'total'matrixisalso(optionally)available.Thisisusefulincaseswherethe *underlyinglibrarywillnotbeused,oftenwhenworkingdirectlywithfontdata. * *Theparameters'scale'and'remaining'arerequired,theotherpointersmaybenullptr. * *@parampreMatrixScalethekindofscaletoextractfromthetotalmatrix. *@paramscalethescaleextractedfromthetotalmatrix(bothvaluespositive). *@paramremainingapplyafterscaletoapplythetotalmatrix. *@paramremainingWithoutRotationapplyafterscaletoapplythetotalmatrixsansrotation. *@paramremainingRotationapplyafterremainingWithoutRotationtoapplythetotalmatrix. *@paramtotalthetotalmatrix. *@returnfalseifthematrixwassingular.Theoutputwillbevalidbutnotinvertible.
*/ bool computeMatrices(PreMatrixScale preMatrixScale,
SkVector* scale, SkMatrix* remaining,
SkMatrix* remainingWithoutRotation = nullptr,
SkMatrix* remainingRotation = nullptr,
SkMatrix* total = nullptr) const;
// setLuminanceColor forces the alpha to be 0xFF because the blitter that draws the glyph // will apply the alpha from the paint. Don't apply the alpha twice. void setLuminanceColor(SkColor c);
class SkScalerContext {
public: enum Flags {
kFrameAndFill_Flag = 0x0001,
kUnused = 0x0002,
kEmbeddedBitmapText_Flag = 0x0004,
kEmbolden_Flag = 0x0008,
kSubpixelPositioning_Flag = 0x0010,
kForceAutohinting_Flag = 0x0020, // Use auto instead of bytcode hinting if hinting.
// together, these two flags resulting in a two bit value which matches // up with the SkPaint::Hinting enum.
kHinting_Shift = 7, // to shift into the other flags above
kHintingBit1_Flag = 0x0080,
kHintingBit2_Flag = 0x0100,
// Pixel geometry information. // only meaningful if fMaskFormat is kLCD16
kLCD_Vertical_Flag = 0x0200, // else Horizontal
kLCD_BGROrder_Flag = 0x0400, // else RGB order
// Generate A8 from LCD source (for GDI and CoreGraphics). // only meaningful if fMaskFormat is kA8
kGenA8FromLCD_Flag = 0x0800, // could be 0x200 (bit meaning dependent on fMaskFormat)
kLinearMetrics_Flag = 0x1000,
kBaselineSnap_Flag = 0x2000,
/** Return the size in bytes of the associated gamma lookup table
*/ static size_t GetGammaLUTSize(SkScalar contrast, SkScalar deviceGamma, int* width, int* height);
/** Get the associated gamma lookup table. The 'data' pointer must point to pre-allocated *memory,withsizeinbytesgreaterthanorequaltothereturnvalueofgetGammaLUTSize(). * *Ifthelookuptablehasn'tbeeninitialized(e.g.,it'slinear),thiswillreturnfalse.
*/ staticbool GetGammaLUTData(SkScalar contrast, SkScalar deviceGamma, uint8_t* data);
// If we are creating rec and effects from a font only, then there is no device around either. staticvoid MakeRecAndEffectsFromFont(const SkFont& font,
SkScalerContextRec* rec,
SkScalerContextEffects* effects) {
SkPaint paint; return MakeRecAndEffects(
font, paint, SkSurfaceProps(),
SkScalerContextFlags::kNone, SkMatrix::I(), rec, effects);
}
/** Return the glyph's outline, or if the glyph cannot be converted to one, return {}. *Doesnotapplysubpixelpositioningtothepath.
*/
[[nodiscard]] virtual std::optional<GeneratedPath> generatePath(const SkGlyph&) = 0;
/** Returns the drawable for the glyph (if any). * *Thegenerateddrawablewillbelifetimescopedtothelifetimeofthisscalercontext. *Thismeansthedrawablemayrefertothescalercontextandassociatedfontdata. * *Thedrawabledoesnotneedtobeflattenable(e.g.implementgetFactoryandgetTypeName). *AnynecessaryserializationwillbedonewithmakePictureSnapshot.
*/
virtual sk_sp<SkDrawable> generateDrawable(const SkGlyph&); // TODO: = 0
/** Retrieves font metrics. */
virtual void generateFontMetrics(SkFontMetrics*) = 0;
private: friendclass PathText; // For debug purposes friendclass PathTextBench; // For debug purposes friendclass RandomScalerContext; // For debug purposes friendclass SkScalerContext_proxy;
// In order for a SkScalerContext to be in use this typeface must exist. // The SkScalerContext does not keep a reference to this typeface, so this reference may be // a dangling reference when the SkScalerContext is destroyed.
SkTypeface& fTypeface;
// optional objects, which may be null
sk_sp<SkPathEffect> fPathEffect;
sk_sp<SkMaskFilter> fMaskFilter;
// if this is set, we draw the image from a path, rather than // calling generateImage. constbool fGenerateImageFromPath;
protected: // SkMaskGamma::PreBlend converts linear masks to gamma correcting masks. // Visible to subclasses so that generateImage can apply the pre-blend directly. const SkMaskGamma::PreBlend fPreBlend;
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.