Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: src/gpu/text/GrStencilAndCoverTextContext.cpp

Issue 1988923002: Remove GrRenderTarget from GrPipelineBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to ToT Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/text/GrAtlasTextContext.h ('k') | src/gpu/vk/GrVkStencilAttachment.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 "GrStencilAndCoverTextContext.h" 8 #include "GrStencilAndCoverTextContext.h"
9 #include "GrAtlasTextContext.h" 9 #include "GrAtlasTextContext.h"
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 const GrClip& clip, const GrPaint& p aint, 75 const GrClip& clip, const GrPaint& p aint,
76 const SkPaint& skPaint, const SkMatr ix& viewMatrix, 76 const SkPaint& skPaint, const SkMatr ix& viewMatrix,
77 const SkSurfaceProps& props, 77 const SkSurfaceProps& props,
78 const char text[], size_t byteLength , 78 const char text[], size_t byteLength ,
79 SkScalar x, SkScalar y, const SkIRec t& clipBounds) { 79 SkScalar x, SkScalar y, const SkIRec t& clipBounds) {
80 if (context->abandoned()) { 80 if (context->abandoned()) {
81 return; 81 return;
82 } else if (this->canDraw(skPaint, viewMatrix)) { 82 } else if (this->canDraw(skPaint, viewMatrix)) {
83 if (skPaint.getTextSize() > 0) { 83 if (skPaint.getTextSize() > 0) {
84 TextRun run(skPaint); 84 TextRun run(skPaint);
85 GrPipelineBuilder pipelineBuilder(paint, dc->isUnifiedMultisampled( )); 85 GrPipelineBuilder pipelineBuilder(paint, dc->isUnifiedMultisampled() );
86 pipelineBuilder.setRenderTarget(dc->accessRenderTarget());
87 run.setText(text, byteLength, x, y); 86 run.setText(text, byteLength, x, y);
88 run.draw(context, dc, &pipelineBuilder, clip, paint.getColor(), view Matrix, props, 0, 0, 87 run.draw(context, dc, &pipelineBuilder, clip, paint.getColor(), view Matrix, props, 0, 0,
89 clipBounds, fFallbackTextContext, skPaint); 88 clipBounds, fFallbackTextContext, skPaint);
90 } 89 }
91 return; 90 return;
92 } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix, props, 91 } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix, props,
93 *context->caps()->shaderCaps())) { 92 *context->caps()->shaderCaps())) {
94 fFallbackTextContext->drawText(context, dc, clip, paint, skPaint, viewMa trix, props, text, 93 fFallbackTextContext->drawText(context, dc, clip, paint, skPaint, viewMa trix, props, text,
95 byteLength, x, y, clipBounds); 94 byteLength, x, y, clipBounds);
96 return; 95 return;
(...skipping 14 matching lines...) Expand all
111 size_t byteLength, 110 size_t byteLength,
112 const SkScalar pos[], 111 const SkScalar pos[],
113 int scalarsPerPosition, 112 int scalarsPerPosition,
114 const SkPoint& offset, 113 const SkPoint& offset,
115 const SkIRect& clipBounds) { 114 const SkIRect& clipBounds) {
116 if (context->abandoned()) { 115 if (context->abandoned()) {
117 return; 116 return;
118 } else if (this->canDraw(skPaint, viewMatrix)) { 117 } else if (this->canDraw(skPaint, viewMatrix)) {
119 if (skPaint.getTextSize() > 0) { 118 if (skPaint.getTextSize() > 0) {
120 TextRun run(skPaint); 119 TextRun run(skPaint);
121 GrPipelineBuilder pipelineBuilder(paint, dc->isUnifiedMultisampled( )); 120 GrPipelineBuilder pipelineBuilder(paint, dc->isUnifiedMultisampled() );
122 pipelineBuilder.setRenderTarget(dc->accessRenderTarget());
123 run.setPosText(text, byteLength, pos, scalarsPerPosition, offset); 121 run.setPosText(text, byteLength, pos, scalarsPerPosition, offset);
124 run.draw(context, dc, &pipelineBuilder, clip, paint.getColor(), view Matrix, props, 0, 0, 122 run.draw(context, dc, &pipelineBuilder, clip, paint.getColor(), view Matrix, props, 0, 0,
125 clipBounds, fFallbackTextContext, skPaint); 123 clipBounds, fFallbackTextContext, skPaint);
126 } 124 }
127 return; 125 return;
128 } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix, props, 126 } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix, props,
129 *context->caps()->shaderCaps())) { 127 *context->caps()->shaderCaps())) {
130 fFallbackTextContext->drawPosText(context, dc, clip, paint, skPaint, vie wMatrix, props, 128 fFallbackTextContext->drawPosText(context, dc, clip, paint, skPaint, vie wMatrix, props,
131 text, byteLength, pos, 129 text, byteLength, pos,
132 scalarsPerPosition, offset, clipBounds ); 130 scalarsPerPosition, offset, clipBounds );
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 drawFilter, clipBounds); 218 drawFilter, clipBounds);
221 return; 219 return;
222 } 220 }
223 221
224 GrPaint paint; 222 GrPaint paint;
225 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, dc->isGammaCorrect(), &p aint)) { 223 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, dc->isGammaCorrect(), &p aint)) {
226 return; 224 return;
227 } 225 }
228 226
229 const TextBlob& blob = this->findOrCreateTextBlob(skBlob, skPaint); 227 const TextBlob& blob = this->findOrCreateTextBlob(skBlob, skPaint);
230 GrPipelineBuilder pipelineBuilder(paint, dc->isUnifiedMultisampled()); 228 GrPipelineBuilder pipelineBuilder(paint, dc->isUnifiedMultisampled());
231 pipelineBuilder.setRenderTarget(dc->accessRenderTarget());
232 229
233 TextBlob::Iter iter(blob); 230 TextBlob::Iter iter(blob);
234 for (TextRun* run = iter.get(); run; run = iter.next()) { 231 for (TextRun* run = iter.get(); run; run = iter.next()) {
235 run->draw(context, dc, &pipelineBuilder, clip, paint.getColor(), viewMat rix, props, x, y, 232 run->draw(context, dc, &pipelineBuilder, clip, paint.getColor(), viewMat rix, props, x, y,
236 clipBounds, fFallbackTextContext, skPaint); 233 clipBounds, fFallbackTextContext, skPaint);
237 run->releaseGlyphCache(); 234 run->releaseGlyphCache();
238 } 235 }
239 } 236 }
240 237
241 static inline int style_key_cnt(const GrStyle& style) { 238 static inline int style_key_cnt(const GrStyle& style) {
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 fallback->init(fFont, fTextRatio); 588 fallback->init(fFont, fTextRatio);
592 } 589 }
593 fallback->appendGlyph(glyph.getGlyphID(), pos); 590 fallback->appendGlyph(glyph.getGlyphID(), pos);
594 } else { 591 } else {
595 fInstanceData->append(glyph.getGlyphID(), fTextInverseRatio * pos.x(), 592 fInstanceData->append(glyph.getGlyphID(), fTextInverseRatio * pos.x(),
596 fTextInverseRatio * pos.y()); 593 fTextInverseRatio * pos.y());
597 } 594 }
598 } 595 }
599 596
600 void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx, 597 void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx,
601 GrDrawContext* dc, 598 GrDrawContext* drawContext,
602 GrPipelineBuilder* pipelineBuil der, 599 GrPipelineBuilder* pipelineBuil der,
603 const GrClip& clip, 600 const GrClip& clip,
604 GrColor color, 601 GrColor color,
605 const SkMatrix& viewMatrix, 602 const SkMatrix& viewMatrix,
606 const SkSurfaceProps& props, 603 const SkSurfaceProps& props,
607 SkScalar x, SkScalar y, 604 SkScalar x, SkScalar y,
608 const SkIRect& clipBounds, 605 const SkIRect& clipBounds,
609 GrAtlasTextContext* fallbackTex tContext, 606 GrAtlasTextContext* fallbackTex tContext,
610 const SkPaint& originalSkPaint) const { 607 const SkPaint& originalSkPaint) const {
611 SkASSERT(fInstanceData); 608 SkASSERT(fInstanceData);
612 SkASSERT(dc->accessRenderTarget()->isStencilBufferMultisampled() || !fFont.i sAntiAlias()); 609 SkASSERT(drawContext->isStencilBufferMultisampled() || !fFont.isAntiAlias()) ;
613 610
614 if (fInstanceData->count()) { 611 if (fInstanceData->count()) {
615 pipelineBuilder->setState(GrPipelineBuilder::kHWAntialias_Flag, fFont.is AntiAlias()); 612 pipelineBuilder->setState(GrPipelineBuilder::kHWAntialias_Flag, fFont.is AntiAlias());
616 613
617 static constexpr GrUserStencilSettings kCoverPass( 614 static constexpr GrUserStencilSettings kCoverPass(
618 GrUserStencilSettings::StaticInit< 615 GrUserStencilSettings::StaticInit<
619 0x0000, 616 0x0000,
620 GrUserStencilTest::kNotEqual, // Stencil pass accounts for clip. 617 GrUserStencilTest::kNotEqual, // Stencil pass accounts for clip.
621 0xffff, 618 0xffff,
622 GrUserStencilOp::kZero, 619 GrUserStencilOp::kZero,
623 GrUserStencilOp::kKeep, 620 GrUserStencilOp::kKeep,
624 0xffff>() 621 0xffff>()
625 ); 622 );
626 623
627 pipelineBuilder->setUserStencil(&kCoverPass); 624 pipelineBuilder->setUserStencil(&kCoverPass);
628 625
629 SkAutoTUnref<GrPathRange> glyphs(this->createGlyphs(ctx)); 626 SkAutoTUnref<GrPathRange> glyphs(this->createGlyphs(ctx));
630 if (fLastDrawnGlyphsID != glyphs->getUniqueID()) { 627 if (fLastDrawnGlyphsID != glyphs->getUniqueID()) {
631 // Either this is the first draw or the glyphs object was purged sin ce last draw. 628 // Either this is the first draw or the glyphs object was purged sin ce last draw.
632 glyphs->loadPathsIfNeeded(fInstanceData->indices(), fInstanceData->c ount()); 629 glyphs->loadPathsIfNeeded(fInstanceData->indices(), fInstanceData->c ount());
633 fLastDrawnGlyphsID = glyphs->getUniqueID(); 630 fLastDrawnGlyphsID = glyphs->getUniqueID();
634 } 631 }
635 632
636 // Don't compute a bounding box. For dst copy texture, we'll opt instead for it to just copy 633 // Don't compute a bounding box. For dst copy texture, we'll opt instead for it to just copy
637 // the entire dst. Realistically this is a moot point, because any conte xt that supports 634 // the entire dst. Realistically this is a moot point, because any conte xt that supports
638 // NV_path_rendering will also support NV_blend_equation_advanced. 635 // NV_path_rendering will also support NV_blend_equation_advanced.
639 // For clipping we'll just skip any optimizations based on the bounds. T his does, however, 636 // For clipping we'll just skip any optimizations based on the bounds. T his does, however,
640 // hurt batching. 637 // hurt batching.
641 SkRect bounds = SkRect::MakeIWH(pipelineBuilder->getRenderTarget()->widt h(), 638 const SkRect bounds = SkRect::MakeIWH(drawContext->width(), drawContext- >height());
642 pipelineBuilder->getRenderTarget()->heig ht());
643 639
644 SkAutoTUnref<GrDrawBatch> batch( 640 SkAutoTUnref<GrDrawBatch> batch(
645 GrDrawPathRangeBatch::Create(viewMatrix, fTextRatio, fTextInverseRat io * x, 641 GrDrawPathRangeBatch::Create(viewMatrix, fTextRatio, fTextInverseRat io * x,
646 fTextInverseRatio * y, color, 642 fTextInverseRatio * y, color,
647 GrPathRendering::kWinding_FillType, gly phs, fInstanceData, 643 GrPathRendering::kWinding_FillType, gly phs, fInstanceData,
648 bounds)); 644 bounds));
649 645
650 dc->drawBatch(*pipelineBuilder, clip, batch); 646 drawContext->drawBatch(*pipelineBuilder, clip, batch);
651 } 647 }
652 648
653 if (fFallbackTextBlob) { 649 if (fFallbackTextBlob) {
654 SkPaint fallbackSkPaint(originalSkPaint); 650 SkPaint fallbackSkPaint(originalSkPaint);
655 fStyle.strokeRec().applyToPaint(&fallbackSkPaint); 651 fStyle.strokeRec().applyToPaint(&fallbackSkPaint);
656 if (!fStyle.isSimpleFill()) { 652 if (!fStyle.isSimpleFill()) {
657 fallbackSkPaint.setStrokeWidth(fStyle.strokeRec().getWidth() * fText Ratio); 653 fallbackSkPaint.setStrokeWidth(fStyle.strokeRec().getWidth() * fText Ratio);
658 } 654 }
659 655
660 fallbackTextContext->drawTextBlob(ctx, dc, clip, fallbackSkPaint, viewMa trix, props, 656 fallbackTextContext->drawTextBlob(ctx, drawContext, clip, fallbackSkPain t, viewMatrix,
661 fFallbackTextBlob, x, y, nullptr, clip Bounds); 657 props, fFallbackTextBlob, x, y, nullpt r, clipBounds);
662 } 658 }
663 } 659 }
664 660
665 SkGlyphCache* GrStencilAndCoverTextContext::TextRun::getGlyphCache() const { 661 SkGlyphCache* GrStencilAndCoverTextContext::TextRun::getGlyphCache() const {
666 if (!fDetachedGlyphCache) { 662 if (!fDetachedGlyphCache) {
667 fDetachedGlyphCache = fFont.detachCache(nullptr, SkPaint::kNone_ScalerCo ntextFlags, 663 fDetachedGlyphCache = fFont.detachCache(nullptr, SkPaint::kNone_ScalerCo ntextFlags,
668 nullptr); 664 nullptr);
669 } 665 }
670 return fDetachedGlyphCache; 666 return fDetachedGlyphCache;
671 } 667 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 } 729 }
734 730
735 const SkTextBlob* GrStencilAndCoverTextContext::FallbackBlobBuilder::buildIfNeed ed(int *count) { 731 const SkTextBlob* GrStencilAndCoverTextContext::FallbackBlobBuilder::buildIfNeed ed(int *count) {
736 *count = fCount; 732 *count = fCount;
737 if (fCount) { 733 if (fCount) {
738 this->flush(); 734 this->flush();
739 return fBuilder->build(); 735 return fBuilder->build();
740 } 736 }
741 return nullptr; 737 return nullptr;
742 } 738 }
OLDNEW
« no previous file with comments | « src/gpu/text/GrAtlasTextContext.h ('k') | src/gpu/vk/GrVkStencilAttachment.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698