GrTextStrike* GrFontCache::generateStrike(GrFontScaler* scaler) { GrMaskFormat format = scaler->getMaskFormat(); GrPixelConfig config = mask_format_to_pixel_config(format); int atlasIndex = mask_format_to_atlas_index(format); if (NULL == fAtlases[atlasIndex]) { SkISize textureSize = SkISize::Make(GR_ATLAS_TEXTURE_WIDTH, GR_ATLAS_TEXTURE_HEIGHT); fAtlases[atlasIndex] = SkNEW_ARGS(GrAtlas, (fGpu, config, kNone_GrTextureFlags, textureSize, GR_NUM_PLOTS_X, GR_NUM_PLOTS_Y, true)); } GrTextStrike* strike = SkNEW_ARGS(GrTextStrike, (this, scaler->getKey(), format, fAtlases[atlasIndex])); fCache.add(strike); if (fHead) { fHead->fPrev = strike; } else { SkASSERT(NULL == fTail); fTail = strike; } strike->fPrev = NULL; strike->fNext = fHead; fHead = strike; return strike; }
GrPlot* GrFontCache::addToAtlas(GrMaskFormat format, GrAtlas::ClientPlotUsage* usage, int width, int height, const void* image, SkIPoint16* loc) { GrPixelConfig config = mask_format_to_pixel_config(format); int atlasIndex = mask_format_to_atlas_index(format); if (NULL == fAtlases[atlasIndex]) { SkISize textureSize = SkISize::Make(GR_ATLAS_TEXTURE_WIDTH, GR_ATLAS_TEXTURE_HEIGHT); fAtlases[atlasIndex] = SkNEW_ARGS(GrAtlas, (fGpu, config, kNone_GrSurfaceFlags, textureSize, GR_NUM_PLOTS_X, GR_NUM_PLOTS_Y, true)); } return fAtlases[atlasIndex]->addToAtlas(usage, width, height, image, loc); }
bool GrAtlasManager::initAtlas(GrMaskFormat format) { int index = MaskFormatToAtlasIndex(format); if (fAtlases[index] == nullptr) { GrPixelConfig config = mask_format_to_pixel_config(format); SkISize atlasDimensions = fAtlasConfigs.atlasDimensions(format); SkISize numPlots = fAtlasConfigs.numPlots(format); fAtlases[index] = GrDrawOpAtlas::Make( fProxyProvider, config, atlasDimensions.width(), atlasDimensions.height(), numPlots.width(), numPlots.height(), fAllowMultitexturing, &GrGlyphCache::HandleEviction, fGlyphCache); if (!fAtlases[index]) { return false; } } return true; }