224 {
225 auto resourceProvider =
target->resourceProvider();
226
227
228
229
230
233 return;
234 }
235
237
239
240 unsigned int numActiveViews;
242 if (!views) {
243 SkDebugf(
"Could not allocate backing texture for atlas\n");
244 return;
245 }
247
249#if !defined(SK_DISABLE_SDF_TEXT)
252#endif
253
254 auto primProcProxies =
target->allocPrimProcProxyPtrs(kMaxTextures);
255 for (unsigned i = 0; i < numActiveViews; ++i) {
256 primProcProxies[i] = views[i].
proxy();
257
258
259 target->sampledProxyArray()->push_back(views[i].proxy());
260 }
261
262 FlushInfo flushInfo;
263 flushInfo.fPrimProcProxies = primProcProxies;
264 flushInfo.fIndexBuffer = resourceProvider->refNonAAQuadIndexBuffer();
265
266#if !defined(SK_DISABLE_SDF_TEXT)
267 if (this->usesDistanceFields()) {
268 flushInfo.fGeometryProcessor = this->setupDfProcessor(
target->allocator(),
269 *
target->caps().shaderCaps(),
270 localMatrix, views, numActiveViews);
271 } else
272#endif
273 {
274 auto filter = fNeedsGlyphTransform ? GrSamplerState::Filter::kLinear
275 : GrSamplerState::Filter::kNearest;
276
277
280 false, fColorSpaceXform, views, numActiveViews, filter,
281 maskFormat, localMatrix, fHasPerspective);
282 }
283
284 const int vertexStride = (
int)flushInfo.fGeometryProcessor->vertexStride();
285
286
289 const int maxQuadsPerBuffer = kMaxVertexBytes / quadSize;
290
291 int allGlyphsCursor = 0;
292 const int allGlyphsEnd = fNumGlyphs;
293 int quadCursor;
294 int quadEnd;
295 char* vertices;
296
297 auto resetVertexBuffer = [&] {
298 quadCursor = 0;
299 quadEnd = std::min(maxQuadsPerBuffer, allGlyphsEnd - allGlyphsCursor);
300
301 vertices = (
char*)
target->makeVertexSpace(
302 vertexStride,
304 &flushInfo.fVertexBuffer,
305 &flushInfo.fVertexOffset);
306
307 if (!vertices || !flushInfo.fVertexBuffer) {
308 SkDebugf(
"Could not allocate vertices\n");
309 return false;
310 }
311 return true;
312 };
313
314 if (!resetVertexBuffer()) {
315 return;
316 }
317
318 for (const Geometry* geo = fHead; geo != nullptr; geo = geo->fNext) {
320 SkASSERTF((
int) subRun.vertexStride(geo->fDrawMatrix) == vertexStride,
321 "subRun stride: %d vertex buffer stride: %d\n",
322 (int)subRun.vertexStride(geo->fDrawMatrix), vertexStride);
323
329 int padding) {
331 };
332 for (int subRunCursor = 0; subRunCursor < subRunEnd;) {
333
334
335 int regenEnd = subRunCursor + std::min(subRunEnd - subRunCursor, quadEnd - quadCursor);
337 regenerateDelegate);
338
340 return;
341 }
342
343 geo->fillVertexData(vertices + quadCursor * quadSize, subRunCursor, glyphsRegenerated);
344
345 subRunCursor += glyphsRegenerated;
346 quadCursor += glyphsRegenerated;
347 allGlyphsCursor += glyphsRegenerated;
348 flushInfo.fGlyphsToFlush += glyphsRegenerated;
349
350 if (quadCursor == quadEnd || subRunCursor < subRunEnd) {
351
352
353 if (subRunCursor < subRunEnd) {
355 }
356 this->createDrawForGeneratedGlyphs(
target, &flushInfo);
357 if (quadCursor == quadEnd && allGlyphsCursor < allGlyphsEnd) {
358
359
360 if(!resetVertexBuffer()) {
361 return;
362 }
363 }
364 }
365 }
366 }
367}
#define SkASSERTF(cond, fmt,...)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static bool ok(int result)
#define ATRACE_ANDROID_FRAMEWORK_ALWAYS(fmt,...)
Type::kYUV Type::kRGBA() int(0.7 *637)
const GrSurfaceProxyView * getViews(skgpu::MaskFormat format, unsigned int *numActiveProxies)
static GrGeometryProcessor * Make(SkArenaAlloc *arena, const GrShaderCaps &caps, const SkPMColor4f &color, bool wideColor, sk_sp< GrColorSpaceXform > colorSpaceXform, const GrSurfaceProxyView *views, int numActiveViews, GrSamplerState p, skgpu::MaskFormat format, const SkMatrix &localMatrix, bool usesW)
static constexpr int kMaxTextures
static constexpr size_t kDefaultBufferSize
static constexpr int kMaxTextures
static constexpr int kMaxTextures
GrSurfaceProxy * proxy() const
bool invert(SkMatrix *inverse) const
static const SkMatrix & I()
virtual std::tuple< bool, int > regenerateAtlas(int begin, int end, RegenerateAtlasDelegate) const =0
virtual int glyphCount() const =0
static const char * begin(const StringSlice &s)
static constexpr int kVerticesPerGlyph