|
47 | 47 | #include "src/gpu/GrTracing.h" |
48 | 48 | #include "src/gpu/SkGr.h" |
49 | 49 | #include "src/gpu/effects/GrBicubicEffect.h" |
50 | | -#include "src/gpu/effects/GrDistanceFieldGeoProc.h" |
51 | 50 | #include "src/gpu/effects/GrRRectEffect.h" |
52 | 51 | #include "src/gpu/geometry/GrQuad.h" |
53 | 52 | #include "src/gpu/geometry/GrQuadUtils.h" |
@@ -480,137 +479,6 @@ void GrRenderTargetContext::drawTextPaths(const GrClip* clip, |
480 | 479 | } |
481 | 480 | } |
482 | 481 |
|
483 | | -static SkPMColor4f generate_filtered_color(const SkPaint& paint, const GrColorInfo& colorInfo) { |
484 | | - SkColor4f c = paint.getColor4f(); |
485 | | - if (auto* xform = colorInfo.colorSpaceXformFromSRGB()) { |
486 | | - c = xform->apply(c); |
487 | | - } |
488 | | - if (auto* cf = paint.getColorFilter()) { |
489 | | - c = cf->filterColor4f(c, colorInfo.colorSpace(), colorInfo.colorSpace()); |
490 | | - } |
491 | | - return c.premul(); |
492 | | -} |
493 | | - |
494 | | -std::tuple<const GrClip*, std::unique_ptr<GrDrawOp>> |
495 | | -GrRenderTargetContext::makeAtlasTextOp(const GrClip* clip, |
496 | | - const SkMatrixProvider& viewMatrix, |
497 | | - const SkGlyphRunList& glyphRunList, |
498 | | - GrTextBlob::SubRun* subRun) { |
499 | | - SkASSERT(subRun->glyphCount() != 0); |
500 | | - |
501 | | - SkPoint drawOrigin = glyphRunList.origin(); |
502 | | - const SkPaint& drawPaint = glyphRunList.paint(); |
503 | | - const SkMatrix& drawMatrix = viewMatrix.localToDevice(); |
504 | | - GrRecordingContext* context = this->fContext; |
505 | | - GrOpMemoryPool* pool = context->priv().opMemoryPool(); |
506 | | - const GrColorInfo& colorInfo = this->colorInfo(); |
507 | | - |
508 | | - // We can clip geometrically using clipRect and ignore clip if we're not using SDFs or |
509 | | - // transformed glyphs, and we have an axis-aligned rectangular non-AA clip. |
510 | | - std::unique_ptr<GrDrawOp> op; |
511 | | - if (!subRun->drawAsDistanceFields()) { |
512 | | - SkIRect clipRect = SkIRect::MakeEmpty(); |
513 | | - if (!subRun->needsTransform()) { |
514 | | - // We only need to do clipping work if the SubRun isn't contained by the clip |
515 | | - SkRect subRunBounds = subRun->deviceRect(drawMatrix, drawOrigin); |
516 | | - SkRect renderTargetBounds = SkRect::MakeWH(this->width(), this->height()); |
517 | | - if (clip == nullptr && !renderTargetBounds.intersects(subRunBounds)) { |
518 | | - // If the SubRun is completely outside, don't add an op for it. |
519 | | - return {nullptr, nullptr}; |
520 | | - } else if (clip != nullptr) { |
521 | | - GrClip::PreClipResult result = clip->preApply(subRunBounds); |
522 | | - if (result.fEffect == GrClip::Effect::kClipped) { |
523 | | - if (result.fIsRRect && result.fRRect.isRect() && |
524 | | - result.fAA == GrAA::kNo) { |
525 | | - // Clip geometrically during onPrepare using clipRect. |
526 | | - result.fRRect.getBounds().round(&clipRect); |
527 | | - clip = nullptr; |
528 | | - } |
529 | | - } else if (result.fEffect == GrClip::Effect::kClippedOut) { |
530 | | - return {nullptr, nullptr}; |
531 | | - } |
532 | | - } |
533 | | - } |
534 | | - |
535 | | - if (!clipRect.isEmpty()) { SkASSERT(clip == nullptr); } |
536 | | - |
537 | | - // Produce the Bitmap Op. |
538 | | - GrPaint grPaint; |
539 | | - if (kARGB_GrMaskFormat == subRun->maskFormat()) { |
540 | | - SkPaintToGrPaintWithPrimitiveColor( |
541 | | - context, colorInfo, drawPaint, viewMatrix, &grPaint); |
542 | | - } else { |
543 | | - SkPaintToGrPaint(context, colorInfo, drawPaint, viewMatrix, &grPaint); |
544 | | - } |
545 | | - |
546 | | - // This is the color the op will use to draw. |
547 | | - SkPMColor4f drawingColor = generate_filtered_color(drawPaint, colorInfo); |
548 | | - |
549 | | - GrAtlasTextOp::MaskType maskType = [&]() { |
550 | | - switch (subRun->maskFormat()) { |
551 | | - case kA8_GrMaskFormat: return GrAtlasTextOp::kGrayscaleCoverageMask_MaskType; |
552 | | - case kA565_GrMaskFormat: return GrAtlasTextOp::kLCDCoverageMask_MaskType; |
553 | | - case kARGB_GrMaskFormat: return GrAtlasTextOp::kColorBitmapMask_MaskType; |
554 | | - // Needed to placate some compilers. |
555 | | - default: return GrAtlasTextOp::kGrayscaleCoverageMask_MaskType; |
556 | | - } |
557 | | - }(); |
558 | | - |
559 | | - op = pool->allocate<GrAtlasTextOp>(maskType, |
560 | | - std::move(grPaint), |
561 | | - subRun, |
562 | | - drawMatrix, |
563 | | - drawOrigin, |
564 | | - clipRect, |
565 | | - drawingColor, |
566 | | - 0, |
567 | | - false, |
568 | | - 0); |
569 | | - } else { |
570 | | - GrPaint grPaint; |
571 | | - SkPaintToGrPaint(context, colorInfo, drawPaint, viewMatrix, &grPaint); |
572 | | - |
573 | | - // This is the color the op will use to draw. |
574 | | - SkPMColor4f drawingColor = generate_filtered_color(drawPaint, colorInfo); |
575 | | - |
576 | | - const SkSurfaceProps& props = this->surfaceProps(); |
577 | | - bool isBGR = SkPixelGeometryIsBGR(props.pixelGeometry()); |
578 | | - bool isLCD = subRun->hasUseLCDText() && SkPixelGeometryIsH(props.pixelGeometry()); |
579 | | - using MT = GrAtlasTextOp::MaskType; |
580 | | - MT maskType = !subRun->isAntiAliased() ? MT::kAliasedDistanceField_MaskType |
581 | | - : isLCD ? (isBGR ? MT::kLCDBGRDistanceField_MaskType |
582 | | - : MT::kLCDDistanceField_MaskType) |
583 | | - : MT::kGrayscaleDistanceField_MaskType; |
584 | | - |
585 | | - bool useGammaCorrectDistanceTable = colorInfo.isLinearlyBlended(); |
586 | | - uint32_t DFGPFlags = drawMatrix.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0; |
587 | | - DFGPFlags |= drawMatrix.isScaleTranslate() ? kScaleOnly_DistanceFieldEffectFlag : 0; |
588 | | - DFGPFlags |= drawMatrix.hasPerspective() ? kPerspective_DistanceFieldEffectFlag : 0; |
589 | | - DFGPFlags |= useGammaCorrectDistanceTable ? kGammaCorrect_DistanceFieldEffectFlag : 0; |
590 | | - DFGPFlags |= MT::kAliasedDistanceField_MaskType == maskType ? |
591 | | - kAliased_DistanceFieldEffectFlag : 0; |
592 | | - |
593 | | - if (isLCD) { |
594 | | - DFGPFlags |= kUseLCD_DistanceFieldEffectFlag; |
595 | | - DFGPFlags |= MT::kLCDBGRDistanceField_MaskType == maskType ? |
596 | | - kBGR_DistanceFieldEffectFlag : 0; |
597 | | - } |
598 | | - |
599 | | - op = pool->allocate<GrAtlasTextOp>(maskType, |
600 | | - std::move(grPaint), |
601 | | - subRun, |
602 | | - drawMatrix, |
603 | | - drawOrigin, |
604 | | - SkIRect::MakeEmpty(), |
605 | | - drawingColor, |
606 | | - SkPaintPriv::ComputeLuminanceColor(drawPaint), |
607 | | - useGammaCorrectDistanceTable, |
608 | | - DFGPFlags); |
609 | | - } |
610 | | - |
611 | | - return {clip, std::move(op)}; |
612 | | -} |
613 | | - |
614 | 482 | void GrRenderTargetContext::drawGlyphRunList(const GrClip* clip, |
615 | 483 | const SkMatrixProvider& viewMatrix, |
616 | 484 | const SkGlyphRunList& glyphRunList) { |
@@ -694,7 +562,7 @@ void GrRenderTargetContext::drawGlyphRunList(const GrClip* clip, |
694 | 562 | if (subRun->drawAsPaths()) { |
695 | 563 | this->drawTextPaths(clip, viewMatrix, glyphRunList, subRun); |
696 | 564 | } else { |
697 | | - auto [drawingClip, op] = this->makeAtlasTextOp(clip, viewMatrix, glyphRunList, subRun); |
| 565 | + auto [drawingClip, op] = subRun->makeAtlasTextOp(clip, viewMatrix, glyphRunList, this); |
698 | 566 | if (op != nullptr) { |
699 | 567 | this->addDrawOp(drawingClip, std::move(op)); |
700 | 568 | } |
|
0 commit comments