OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrAtlasTextBlob.h" | 8 #include "GrAtlasTextBlob.h" |
9 | 9 |
10 #include "GrBlurUtils.h" | 10 #include "GrBlurUtils.h" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 geometry.fColor = subRunColor; | 293 geometry.fColor = subRunColor; |
294 geometry.fX = x; | 294 geometry.fX = x; |
295 geometry.fY = y; | 295 geometry.fY = y; |
296 batch->init(); | 296 batch->init(); |
297 | 297 |
298 return batch; | 298 return batch; |
299 } | 299 } |
300 | 300 |
301 inline | 301 inline |
302 void GrAtlasTextBlob::flushRun(GrDrawContext* dc, GrPipelineBuilder* pipelineBui
lder, | 302 void GrAtlasTextBlob::flushRun(GrDrawContext* dc, GrPipelineBuilder* pipelineBui
lder, |
303 int run, const SkMatrix& viewMatrix, SkScalar x,
SkScalar y, | 303 const GrClip& clip, int run, const SkMatrix& view
Matrix, SkScalar x, |
304 GrColor color, | 304 SkScalar y, GrColor color, |
305 const SkPaint& skPaint, const SkSurfaceProps& pro
ps, | 305 const SkPaint& skPaint, const SkSurfaceProps& pro
ps, |
306 const GrDistanceFieldAdjustTable* distanceAdjustT
able, | 306 const GrDistanceFieldAdjustTable* distanceAdjustT
able, |
307 GrBatchFontCache* cache) { | 307 GrBatchFontCache* cache) { |
308 for (int subRun = 0; subRun < fRuns[run].fSubRunInfo.count(); subRun++) { | 308 for (int subRun = 0; subRun < fRuns[run].fSubRunInfo.count(); subRun++) { |
309 const Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun]; | 309 const Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun]; |
310 int glyphCount = info.glyphCount(); | 310 int glyphCount = info.glyphCount(); |
311 if (0 == glyphCount) { | 311 if (0 == glyphCount) { |
312 continue; | 312 continue; |
313 } | 313 } |
314 | 314 |
315 SkAutoTUnref<GrDrawBatch> batch(this->createBatch(info, glyphCount, run, | 315 SkAutoTUnref<GrDrawBatch> batch(this->createBatch(info, glyphCount, run, |
316 subRun, viewMatrix, x,
y, color, | 316 subRun, viewMatrix, x,
y, color, |
317 skPaint, props, | 317 skPaint, props, |
318 distanceAdjustTable, d
c->isGammaCorrect(), | 318 distanceAdjustTable, d
c->isGammaCorrect(), |
319 cache)); | 319 cache)); |
320 dc->drawBatch(pipelineBuilder, batch); | 320 dc->drawBatch(pipelineBuilder, clip, batch); |
321 } | 321 } |
322 } | 322 } |
323 | 323 |
324 static void calculate_translation(bool applyVM, | 324 static void calculate_translation(bool applyVM, |
325 const SkMatrix& newViewMatrix, SkScalar newX,
SkScalar newY, | 325 const SkMatrix& newViewMatrix, SkScalar newX,
SkScalar newY, |
326 const SkMatrix& currentViewMatrix, SkScalar cu
rrentX, | 326 const SkMatrix& currentViewMatrix, SkScalar cu
rrentX, |
327 SkScalar currentY, SkScalar* transX, SkScalar*
transY) { | 327 SkScalar currentY, SkScalar* transX, SkScalar*
transY) { |
328 if (applyVM) { | 328 if (applyVM) { |
329 *transX = newViewMatrix.getTranslateX() + | 329 *transX = newViewMatrix.getTranslateX() + |
330 newViewMatrix.getScaleX() * (newX - currentX) + | 330 newViewMatrix.getScaleX() * (newX - currentX) + |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 const GrDistanceFieldAdjustTable* distanceAdju
stTable, | 409 const GrDistanceFieldAdjustTable* distanceAdju
stTable, |
410 const SkPaint& skPaint, | 410 const SkPaint& skPaint, |
411 const GrPaint& grPaint, | 411 const GrPaint& grPaint, |
412 SkDrawFilter* drawFilter, | 412 SkDrawFilter* drawFilter, |
413 const GrClip& clip, | 413 const GrClip& clip, |
414 const SkMatrix& viewMatrix, | 414 const SkMatrix& viewMatrix, |
415 const SkIRect& clipBounds, | 415 const SkIRect& clipBounds, |
416 SkScalar x, SkScalar y) { | 416 SkScalar x, SkScalar y) { |
417 // We loop through the runs of the blob, flushing each. If any run is too l
arge, then we flush | 417 // We loop through the runs of the blob, flushing each. If any run is too l
arge, then we flush |
418 // it as paths | 418 // it as paths |
419 GrPipelineBuilder pipelineBuilder(grPaint, dc->accessRenderTarget(), clip); | 419 GrPipelineBuilder pipelineBuilder(grPaint, dc->accessRenderTarget()); |
420 | 420 |
421 GrColor color = grPaint.getColor(); | 421 GrColor color = grPaint.getColor(); |
422 | 422 |
423 SkTextBlobRunIterator it(blob); | 423 SkTextBlobRunIterator it(blob); |
424 for (int run = 0; !it.done(); it.next(), run++) { | 424 for (int run = 0; !it.done(); it.next(), run++) { |
425 if (fRuns[run].fDrawAsPaths) { | 425 if (fRuns[run].fDrawAsPaths) { |
426 this->flushRunAsPaths(context, dc, props, it, clip, skPaint, | 426 this->flushRunAsPaths(context, dc, props, it, clip, skPaint, |
427 drawFilter, viewMatrix, clipBounds, x, y); | 427 drawFilter, viewMatrix, clipBounds, x, y); |
428 continue; | 428 continue; |
429 } | 429 } |
430 this->flushRun(dc, &pipelineBuilder, run, viewMatrix, x, y, color, skPai
nt, props, | 430 this->flushRun(dc, &pipelineBuilder, clip, run, viewMatrix, x, y, color,
skPaint, props, |
431 distanceAdjustTable, context->getBatchFontCache()); | 431 distanceAdjustTable, context->getBatchFontCache()); |
432 } | 432 } |
433 | 433 |
434 // Now flush big glyphs | 434 // Now flush big glyphs |
435 this->flushBigGlyphs(context, dc, clip, skPaint, viewMatrix, x, y, clipBound
s); | 435 this->flushBigGlyphs(context, dc, clip, skPaint, viewMatrix, x, y, clipBound
s); |
436 } | 436 } |
437 | 437 |
438 void GrAtlasTextBlob::flushThrowaway(GrContext* context, | 438 void GrAtlasTextBlob::flushThrowaway(GrContext* context, |
439 GrDrawContext* dc, | 439 GrDrawContext* dc, |
440 const SkSurfaceProps& props, | 440 const SkSurfaceProps& props, |
441 const GrDistanceFieldAdjustTable* distanceA
djustTable, | 441 const GrDistanceFieldAdjustTable* distanceA
djustTable, |
442 const SkPaint& skPaint, | 442 const SkPaint& skPaint, |
443 const GrPaint& grPaint, | 443 const GrPaint& grPaint, |
444 const GrClip& clip, | 444 const GrClip& clip, |
445 const SkMatrix& viewMatrix, | 445 const SkMatrix& viewMatrix, |
446 const SkIRect& clipBounds, | 446 const SkIRect& clipBounds, |
447 SkScalar x, SkScalar y) { | 447 SkScalar x, SkScalar y) { |
448 GrPipelineBuilder pipelineBuilder(grPaint, dc->accessRenderTarget(), clip); | 448 GrPipelineBuilder pipelineBuilder(grPaint, dc->accessRenderTarget()); |
449 | 449 |
450 GrColor color = grPaint.getColor(); | 450 GrColor color = grPaint.getColor(); |
451 for (int run = 0; run < fRunCount; run++) { | 451 for (int run = 0; run < fRunCount; run++) { |
452 this->flushRun(dc, &pipelineBuilder, run, viewMatrix, x, y, color, skPai
nt, props, | 452 this->flushRun(dc, &pipelineBuilder, clip, run, viewMatrix, x, y, color,
skPaint, props, |
453 distanceAdjustTable, context->getBatchFontCache()); | 453 distanceAdjustTable, context->getBatchFontCache()); |
454 } | 454 } |
455 | 455 |
456 // Now flush big glyphs | 456 // Now flush big glyphs |
457 this->flushBigGlyphs(context, dc, clip, skPaint, viewMatrix, x, y, clipBound
s); | 457 this->flushBigGlyphs(context, dc, clip, skPaint, viewMatrix, x, y, clipBound
s); |
458 } | 458 } |
459 | 459 |
460 GrDrawBatch* GrAtlasTextBlob::test_createBatch( | 460 GrDrawBatch* GrAtlasTextBlob::test_createBatch( |
461 int glyphCount, int run, int subRu
n, | 461 int glyphCount, int run, int subRu
n, |
462 const SkMatrix& viewMatrix, SkScal
ar x, SkScalar y, | 462 const SkMatrix& viewMatrix, SkScal
ar x, SkScalar y, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 | 557 |
558 void GrAtlasTextBlob::Run::SubRunInfo::computeTranslation(const SkMatrix& viewMa
trix, | 558 void GrAtlasTextBlob::Run::SubRunInfo::computeTranslation(const SkMatrix& viewMa
trix, |
559 SkScalar x, SkScalar y
, SkScalar* transX, | 559 SkScalar x, SkScalar y
, SkScalar* transX, |
560 SkScalar* transY) { | 560 SkScalar* transY) { |
561 calculate_translation(!this->drawAsDistanceFields(), viewMatrix, x, y, | 561 calculate_translation(!this->drawAsDistanceFields(), viewMatrix, x, y, |
562 fCurrentViewMatrix, fX, fY, transX, transY); | 562 fCurrentViewMatrix, fX, fY, transX, transY); |
563 fCurrentViewMatrix = viewMatrix; | 563 fCurrentViewMatrix = viewMatrix; |
564 fX = x; | 564 fX = x; |
565 fY = y; | 565 fY = y; |
566 } | 566 } |
OLD | NEW |