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

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

Issue 1494083003: Reduce calls sites where both the GrDrawContext & GrRenderTarget are both passed (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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/GrStencilAndCoverTextContext.h ('k') | src/gpu/GrTextContext.h » ('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 "GrDrawContext.h" 10 #include "GrDrawContext.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 if (SkPathEffect* pe = skPaint.getPathEffect()) { 65 if (SkPathEffect* pe = skPaint.getPathEffect()) {
66 if (pe->asADash(nullptr) != SkPathEffect::kDash_DashType) { 66 if (pe->asADash(nullptr) != SkPathEffect::kDash_DashType) {
67 return false; 67 return false;
68 } 68 }
69 } 69 }
70 // No hairlines. They would require new paths with customized strokes for ev ery new draw matrix. 70 // No hairlines. They would require new paths with customized strokes for ev ery new draw matrix.
71 return SkPaint::kStroke_Style != skPaint.getStyle() || 0 != skPaint.getStrok eWidth(); 71 return SkPaint::kStroke_Style != skPaint.getStyle() || 0 != skPaint.getStrok eWidth();
72 } 72 }
73 73
74 void GrStencilAndCoverTextContext::onDrawText(GrDrawContext* dc, GrRenderTarget* rt, 74 void GrStencilAndCoverTextContext::onDrawText(GrDrawContext* dc,
75 const GrClip& clip, 75 const GrClip& clip,
76 const GrPaint& paint, 76 const GrPaint& paint,
77 const SkPaint& skPaint, 77 const SkPaint& skPaint,
78 const SkMatrix& viewMatrix, 78 const SkMatrix& viewMatrix,
79 const char text[], 79 const char text[],
80 size_t byteLength, 80 size_t byteLength,
81 SkScalar x, SkScalar y, 81 SkScalar x, SkScalar y,
82 const SkIRect& clipBounds) { 82 const SkIRect& clipBounds) {
83 TextRun run(skPaint); 83 TextRun run(skPaint);
84 GrPipelineBuilder pipelineBuilder(paint, rt, clip); 84 GrPipelineBuilder pipelineBuilder(paint, dc->accessRenderTarget(), clip);
85 run.setText(text, byteLength, x, y); 85 run.setText(text, byteLength, x, y);
86 run.draw(fContext, dc, &pipelineBuilder, paint.getColor(), viewMatrix, 0, 0, clipBounds, 86 run.draw(fContext, dc, &pipelineBuilder, paint.getColor(), viewMatrix, 0, 0, clipBounds,
87 fFallbackTextContext, skPaint); 87 fFallbackTextContext, skPaint);
88 } 88 }
89 89
90 void GrStencilAndCoverTextContext::onDrawPosText(GrDrawContext* dc, GrRenderTarg et* rt, 90 void GrStencilAndCoverTextContext::onDrawPosText(GrDrawContext* dc,
91 const GrClip& clip, 91 const GrClip& clip,
92 const GrPaint& paint, 92 const GrPaint& paint,
93 const SkPaint& skPaint, 93 const SkPaint& skPaint,
94 const SkMatrix& viewMatrix, 94 const SkMatrix& viewMatrix,
95 const char text[], 95 const char text[],
96 size_t byteLength, 96 size_t byteLength,
97 const SkScalar pos[], 97 const SkScalar pos[],
98 int scalarsPerPosition, 98 int scalarsPerPosition,
99 const SkPoint& offset, 99 const SkPoint& offset,
100 const SkIRect& clipBounds) { 100 const SkIRect& clipBounds) {
101 TextRun run(skPaint); 101 TextRun run(skPaint);
102 GrPipelineBuilder pipelineBuilder(paint, rt, clip); 102 GrPipelineBuilder pipelineBuilder(paint, dc->accessRenderTarget(), clip);
103 run.setPosText(text, byteLength, pos, scalarsPerPosition, offset); 103 run.setPosText(text, byteLength, pos, scalarsPerPosition, offset);
104 run.draw(fContext, dc, &pipelineBuilder, paint.getColor(), viewMatrix, 0, 0, clipBounds, 104 run.draw(fContext, dc, &pipelineBuilder, paint.getColor(), viewMatrix, 0, 0, clipBounds,
105 fFallbackTextContext, skPaint); 105 fFallbackTextContext, skPaint);
106 } 106 }
107 107
108 void GrStencilAndCoverTextContext::drawTextBlob(GrDrawContext* dc, GrRenderTarge t* rt, 108 void GrStencilAndCoverTextContext::drawTextBlob(GrDrawContext* dc,
109 const GrClip& clip, const SkPain t& skPaint, 109 const GrClip& clip, const SkPain t& skPaint,
110 const SkMatrix& viewMatrix, 110 const SkMatrix& viewMatrix,
111 const SkTextBlob* skBlob, SkScal ar x, SkScalar y, 111 const SkTextBlob* skBlob, SkScal ar x, SkScalar y,
112 SkDrawFilter* drawFilter, 112 SkDrawFilter* drawFilter,
113 const SkIRect& clipBounds) { 113 const SkIRect& clipBounds) {
114 if (!this->internalCanDraw(skPaint)) { 114 if (!this->internalCanDraw(skPaint)) {
115 fFallbackTextContext->drawTextBlob(dc, rt, clip, skPaint, viewMatrix, sk Blob, x, y, 115 fFallbackTextContext->drawTextBlob(dc, clip, skPaint, viewMatrix, skBlob , x, y,
116 drawFilter, clipBounds); 116 drawFilter, clipBounds);
117 return; 117 return;
118 } 118 }
119 119
120 if (drawFilter || skPaint.getPathEffect()) { 120 if (drawFilter || skPaint.getPathEffect()) {
121 // This draw can't be cached. 121 // This draw can't be cached.
122 INHERITED::drawTextBlob(dc, rt, clip, skPaint, viewMatrix, skBlob, x, y, drawFilter, 122 INHERITED::drawTextBlob(dc, clip, skPaint, viewMatrix, skBlob, x, y, dra wFilter,
123 clipBounds); 123 clipBounds);
124 return; 124 return;
125 } 125 }
126 126
127 if (fContext->abandoned()) { 127 if (fContext->abandoned()) {
128 return; 128 return;
129 } 129 }
130 130
131 GrPaint paint; 131 GrPaint paint;
132 if (!SkPaintToGrPaint(fContext, skPaint, viewMatrix, &paint)) { 132 if (!SkPaintToGrPaint(fContext, skPaint, viewMatrix, &paint)) {
133 return; 133 return;
134 } 134 }
135 135
136 const TextBlob& blob = this->findOrCreateTextBlob(skBlob, skPaint); 136 const TextBlob& blob = this->findOrCreateTextBlob(skBlob, skPaint);
137 GrPipelineBuilder pipelineBuilder(paint, rt, clip); 137 GrPipelineBuilder pipelineBuilder(paint, dc->accessRenderTarget(), clip);
138 138
139 TextBlob::Iter iter(blob); 139 TextBlob::Iter iter(blob);
140 for (TextRun* run = iter.get(); run; run = iter.next()) { 140 for (TextRun* run = iter.get(); run; run = iter.next()) {
141 run->draw(fContext, dc, &pipelineBuilder, paint.getColor(), viewMatrix, x, y, clipBounds, 141 run->draw(fContext, dc, &pipelineBuilder, paint.getColor(), viewMatrix, x, y, clipBounds,
142 fFallbackTextContext, skPaint); 142 fFallbackTextContext, skPaint);
143 run->releaseGlyphCache(); 143 run->releaseGlyphCache();
144 } 144 }
145 } 145 }
146 146
147 const GrStencilAndCoverTextContext::TextBlob& 147 const GrStencilAndCoverTextContext::TextBlob&
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx, 478 void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx,
479 GrDrawContext* dc, 479 GrDrawContext* dc,
480 GrPipelineBuilder* pipelineBuil der, 480 GrPipelineBuilder* pipelineBuil der,
481 GrColor color, 481 GrColor color,
482 const SkMatrix& viewMatrix, 482 const SkMatrix& viewMatrix,
483 SkScalar x, SkScalar y, 483 SkScalar x, SkScalar y,
484 const SkIRect& clipBounds, 484 const SkIRect& clipBounds,
485 GrTextContext* fallbackTextCont ext, 485 GrTextContext* fallbackTextCont ext,
486 const SkPaint& originalSkPaint) const { 486 const SkPaint& originalSkPaint) const {
487 SkASSERT(fDraw); 487 SkASSERT(fDraw);
488 SkASSERT(pipelineBuilder->getRenderTarget()->isStencilBufferMultisampled() | | 488 SkASSERT(dc->accessRenderTarget()->isStencilBufferMultisampled() || !fFont.i sAntiAlias());
489 !fFont.isAntiAlias());
490 489
491 if (fDraw->count()) { 490 if (fDraw->count()) {
492 pipelineBuilder->setState(GrPipelineBuilder::kHWAntialias_Flag, fFont.is AntiAlias()); 491 pipelineBuilder->setState(GrPipelineBuilder::kHWAntialias_Flag, fFont.is AntiAlias());
493 492
494 GR_STATIC_CONST_SAME_STENCIL(kStencilPass, 493 GR_STATIC_CONST_SAME_STENCIL(kStencilPass,
495 kZero_StencilOp, 494 kZero_StencilOp,
496 kKeep_StencilOp, 495 kKeep_StencilOp,
497 kNotEqual_StencilFunc, 496 kNotEqual_StencilFunc,
498 0xffff, 497 0xffff,
499 0x0000, 498 0x0000,
(...skipping 28 matching lines...) Expand all
528 GrPathRendering::kWinding_FillType, bounds); 527 GrPathRendering::kWinding_FillType, bounds);
529 } 528 }
530 529
531 if (fFallbackTextBlob) { 530 if (fFallbackTextBlob) {
532 SkPaint fallbackSkPaint(originalSkPaint); 531 SkPaint fallbackSkPaint(originalSkPaint);
533 fStroke.applyToPaint(&fallbackSkPaint); 532 fStroke.applyToPaint(&fallbackSkPaint);
534 if (!fStroke.isFillStyle()) { 533 if (!fStroke.isFillStyle()) {
535 fallbackSkPaint.setStrokeWidth(fStroke.getWidth() * fTextRatio); 534 fallbackSkPaint.setStrokeWidth(fStroke.getWidth() * fTextRatio);
536 } 535 }
537 536
538 fallbackTextContext->drawTextBlob(dc, pipelineBuilder->getRenderTarget() , 537 fallbackTextContext->drawTextBlob(dc, pipelineBuilder->clip(), fallbackS kPaint, viewMatrix,
539 pipelineBuilder->clip(), fallbackSkPai nt, viewMatrix,
540 fFallbackTextBlob, x, y, nullptr, clip Bounds); 538 fFallbackTextBlob, x, y, nullptr, clip Bounds);
541 } 539 }
542 } 540 }
543 541
544 SkGlyphCache* GrStencilAndCoverTextContext::TextRun::getGlyphCache() const { 542 SkGlyphCache* GrStencilAndCoverTextContext::TextRun::getGlyphCache() const {
545 if (!fDetachedGlyphCache) { 543 if (!fDetachedGlyphCache) {
546 fDetachedGlyphCache = fFont.detachCache(nullptr, nullptr, true /*ignoreG amma*/); 544 fDetachedGlyphCache = fFont.detachCache(nullptr, nullptr, true /*ignoreG amma*/);
547 } 545 }
548 return fDetachedGlyphCache; 546 return fDetachedGlyphCache;
549 } 547 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 fBuffIdx = 0; 607 fBuffIdx = 0;
610 } 608 }
611 609
612 const SkTextBlob* GrStencilAndCoverTextContext::FallbackBlobBuilder::buildIfInit ialized() { 610 const SkTextBlob* GrStencilAndCoverTextContext::FallbackBlobBuilder::buildIfInit ialized() {
613 if (!this->isInitialized()) { 611 if (!this->isInitialized()) {
614 return nullptr; 612 return nullptr;
615 } 613 }
616 this->flush(); 614 this->flush();
617 return fBuilder->build(); 615 return fBuilder->build();
618 } 616 }
OLDNEW
« no previous file with comments | « src/gpu/GrStencilAndCoverTextContext.h ('k') | src/gpu/GrTextContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698