35 size_t maxTextureBytes,
37 bool supportBilerpAtlas)
38 : fAllowMultitexturing{allowMultitexturing}
39 , fSupportBilerpAtlas{supportBilerpAtlas}
40 , fProxyProvider{proxyProvider}
41 , fCaps{fProxyProvider->refCaps()}
42 , fAtlasConfig{fCaps->maxTextureSize(), maxTextureBytes} { }
48 fAtlases[
i] =
nullptr;
57template <
typename INT_TYPE>
65 int rowWritesLeft =
width;
66 const uint8_t*
s =
src;
68 while (rowWritesLeft > 0) {
70 for (
int x = 7;
x >= 0 && rowWritesLeft; --
x, --rowWritesLeft) {
71 *
d++ = (mask & (1 <<
x)) ? (INT_TYPE)(~0
UL) : 0;
74 dst =
reinterpret_cast<INT_TYPE*
>(
reinterpret_cast<intptr_t
>(
dst) + dstRowBytes);
87 if (maskFormat == expectedMaskFormat) {
95 src = (
const char*)
src + srcRB;
103 const uint8_t*
bits =
reinterpret_cast<const uint8_t*
>(
src);
104 switch (expectedMaskFormat) {
105 case MaskFormat::kA8: {
106 uint8_t* bytes =
reinterpret_cast<uint8_t*
>(
dst);
110 case MaskFormat::kA565: {
111 uint16_t*
rgb565 =
reinterpret_cast<uint16_t*
>(
dst);
119 }
else if (maskFormat == MaskFormat::kA565 &&
120 expectedMaskFormat == MaskFormat::kARGB) {
124 static constexpr SkMasks masks{
125 {0b1111'1000'0000'0000, 11, 5},
126 {0b0000'0111'1110'0000, 5, 6},
127 {0b0000'0000'0001'1111, 0, 5},
133 char* dstRow = (
char*)
dst;
137 uint16_t color565 = 0;
138 memcpy(&color565,
src, a565Bpp);
144 masks.getGreen(color565),
145 masks.getRed(color565),
149 masks.getGreen(color565),
150 masks.getBlue(color565),
153 memcpy(
dst, &color8888, argbBpp);
154 src = (
const char*)
src + a565Bpp;
155 dst = (
char*)
dst + argbBpp;
170#if !defined(SK_DISABLE_SDF_TEXT)
176 if (skGlyph.
image() ==
nullptr) {
182 MaskFormat expectedMaskFormat = this->resolveMaskFormat(glyphFormat);
186 switch (srcPadding) {
190 if (fSupportBilerpAtlas) {
200#if !defined(SK_DISABLE_SDF_TEXT)
214 const int width = skGlyph.
width() + 2*padding;
216 int rowBytes =
width * bytesPerPixel;
221 void* dataPtr = storage.
get();
225 dataPtr = (
char*)(dataPtr) + rowBytes + bytesPerPixel;
230 auto errorCode = this->
addToAtlas(resourceProvider,
265 int index = MaskFormatToAtlasIndex(
format);
266 if (fAtlases[index] ==
nullptr) {
281 fAllowMultitexturing,
284 if (!fAtlases[index]) {
295std::tuple<bool, int> GlyphVector::regenerateAtlasForGanesh(
304 if (fAtlasGeneration != currentAtlasGen) {
307 fBulkUseUpdater.
reset();
314 int glyphsPlacedInAtlas = 0;
317 Glyph* gpuGlyph = variant.glyph;
320 if (!atlasManager->
hasGlyph(maskFormat, gpuGlyph)) {
323 skGlyph, gpuGlyph, srcPadding,
target->resourceProvider(), uploadTarget);
330 &fBulkUseUpdater, maskFormat, gpuGlyph,
331 tokenTracker->nextDrawToken());
332 glyphsPlacedInAtlas++;
336 if (success &&
begin + glyphsPlacedInAtlas ==
SkCount(fGlyphs)) {
342 return {success, glyphsPlacedInAtlas};
sk_bzero(glyphs, sizeof(glyphs))
static void get_packed_glyph_image(const SkGlyph &glyph, int dstRB, MaskFormat expectedMaskFormat, void *dst)
static void expand_bits(INT_TYPE *dst, const uint8_t *src, int width, int height, int dstRowBytes, int srcRowBytes)
static GrColor GrColorPackRGBA(unsigned r, unsigned g, unsigned b, unsigned a)
static constexpr size_t GrColorTypeBytesPerPixel(GrColorType ct)
static constexpr SkColorType GrColorTypeToSkColorType(GrColorType ct)
static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct)
static const uint16_t rgb565[kNumPixels]
#define SK_ABORT(message,...)
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
#define SK_DistanceFieldInset
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
constexpr int SkCount(const Container &c)
void addGlyphToBulkAndSetUseToken(skgpu::BulkUsePlotUpdater *, skgpu::MaskFormat, sktext::gpu::Glyph *, skgpu::AtlasToken)
~GrAtlasManager() override
void setUseTokenBulk(const skgpu::BulkUsePlotUpdater &updater, skgpu::AtlasToken token, skgpu::MaskFormat format)
uint64_t atlasGeneration(skgpu::MaskFormat format) const
bool hasGlyph(skgpu::MaskFormat, sktext::gpu::Glyph *)
GrDrawOpAtlas::ErrorCode addGlyphToAtlas(const SkGlyph &, sktext::gpu::Glyph *, int srcPadding, GrResourceProvider *, GrDeferredUploadTarget *)
GrAtlasManager(GrProxyProvider *, size_t maxTextureBytes, GrDrawOpAtlas::AllowMultitexturing, bool supportBilerpAtlas)
GrDrawOpAtlas::ErrorCode addToAtlas(GrResourceProvider *, GrDeferredUploadTarget *, skgpu::MaskFormat, int width, int height, const void *image, skgpu::AtlasLocator *)
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
virtual const skgpu::TokenTracker * tokenTracker()=0
SkISize atlasDimensions(skgpu::MaskFormat type) const
SkISize plotDimensions(skgpu::MaskFormat type) const
static std::unique_ptr< GrDrawOpAtlas > Make(GrProxyProvider *proxyProvider, const GrBackendFormat &format, SkColorType ct, size_t bpp, int width, int height, int plotWidth, int plotHeight, skgpu::AtlasGenerationCounter *generationCounter, AllowMultitexturing allowMultitexturing, skgpu::PlotEvictionCallback *evictor, std::string_view label)
void setLastUseToken(const skgpu::AtlasLocator &atlasLocator, skgpu::AtlasToken token)
bool hasID(const skgpu::PlotLocator &plotLocator)
ErrorCode addToAtlas(GrResourceProvider *, GrDeferredUploadTarget *, int width, int height, const void *image, skgpu::AtlasLocator *)
virtual sktext::gpu::StrikeCache * strikeCache() const =0
SkMask::Format maskFormat() const
const void * image() const
void insetSrc(int padding)
PlotLocator plotLocator() const
bool add(const skgpu::AtlasLocator &atlasLocator)
AtlasToken nextDrawToken() const
SkSpan< const Glyph * > glyphs() const
void packedGlyphIDToGlyph(StrikeCache *cache)
skgpu::AtlasLocator fAtlasLocator
static skgpu::MaskFormat FormatFromSkGlyph(SkMask::Format format)
const SkPackedGlyphID fPackedID
static const char * begin(const StringSlice &s)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
uint32_t uint32_t * format
sk_sp< const SkImage > image
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
constexpr int MaskFormatBytesPerPixel(MaskFormat format)
static constexpr SkColorType MaskFormatToColorType(MaskFormat format)
static const int kMaskFormatCount
constexpr int32_t width() const
constexpr int32_t height() const
@ kBW_Format
1bit per pixel mask (e.g. monochrome)