// Check for integer translate with the same 2x2 matrix. // Returns the translation, and true if the change from creation matrix to the position matrix // supports using direct glyph masks.
std::tuple<bool, SkVector> VertexFiller::CanUseDirect( const SkMatrix& creationMatrix, const SkMatrix& positionMatrix) { // The existing direct glyph info can be used if the creationMatrix, and the // positionMatrix have the same 2x2, the translation between them is integer, and no // perspective is involved. Calculate the translation in source space to a translation in // device space by mapping (0, 0) through both the creationMatrix and the positionMatrix; // take the difference.
SkVector translation = positionMatrix.mapOrigin() - creationMatrix.mapOrigin(); return {creationMatrix.getScaleX() == positionMatrix.getScaleX() &&
creationMatrix.getScaleY() == positionMatrix.getScaleY() &&
creationMatrix.getSkewX() == positionMatrix.getSkewX() &&
creationMatrix.getSkewY() == positionMatrix.getSkewY() &&
!positionMatrix.hasPerspective() && !creationMatrix.hasPerspective() &&
SkScalarIsInt(translation.x()) && SkScalarIsInt(translation.y()),
translation};
}
// Return true if the positionMatrix represents an integer translation. Return the device // bounding box of all the glyphs. If the bounding box is empty, then something went singular // and this operation should be dropped.
std::tuple<bool, SkRect> VertexFiller::deviceRectAndCheckTransform( const SkMatrix &positionMatrix) const { if (fCanDrawDirect) { constauto [directDrawCompatible, offset] = CanUseDirect(fCreationMatrix, positionMatrix);
if (directDrawCompatible) { return {true, fCreationBounds.makeOffset(offset)};
}
}
// initialPositionMatrix is singular. Do nothing. return {false, SkRect::MakeEmpty()};
}
std::tuple<SkRect, SkMatrix> VertexFiller::boundsAndDeviceMatrix(const SkMatrix& localToDevice,
SkPoint drawOrigin) const { // The baked-in matrix differs from the current localToDevice by a translation if the // upper 2x2 remains the same, and there's no perspective. Since there's no projection, // Z is irrelevant, so it's okay that fCreationMatrix is an SkMatrix and has // discarded the 3rd row/col, and can ignore those values in localToDevice. constbool compatibleMatrix = localToDevice.rc(0, 0) == fCreationMatrix.rc(0, 0) &&
localToDevice.rc(0, 1) == fCreationMatrix.rc(0, 1) &&
localToDevice.rc(1, 0) == fCreationMatrix.rc(1, 0) &&
localToDevice.rc(1, 1) == fCreationMatrix.rc(1, 1) &&
!localToDevice.hasPerspective() &&
!fCreationMatrix.hasPerspective();
if (compatibleMatrix) {
SkPoint mappedOrigin = localToDevice.mapPoint(drawOrigin); auto offset = mappedOrigin -
SkPoint{fCreationMatrix.getTranslateX(), fCreationMatrix.getTranslateY()}; if (SkScalarIsInt(offset.fX) && SkScalarIsInt(offset.fY)) { // The offset is an integer (but make sure), which means the generated mask can be // accessed without changing how texels would be sampled. return {fCreationBounds, SkMatrix::Translate(offset)};
}
}
// Otherwise compute the relative transformation from fCreationMatrix to // localToDevice, with the drawOrigin applied. If fCreationMatrix or the // concatenation is not invertible the returned Transform is marked invalid and the draw // will be automatically dropped.
SkMatrix positionMatrix = localToDevice;
positionMatrix.preTranslate(drawOrigin.x(), drawOrigin.y()); const SkMatrix viewDifference = this->viewDifference(positionMatrix); return {fCreationBounds, viewDifference};
}
} // namespace sktext::gpu
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.24 Sekunden
(vorverarbeitet am 2026-08-26)
¤
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.