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

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

Issue 956083002: Revert of Pass clip to context (Closed) Base URL: https://skia.googlesource.com/skia.git@pass_down_rendertarget
Patch Set: Created 5 years, 10 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/GrBitmapTextContext.h ('k') | src/gpu/GrClip.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 2013 Google Inc. 2 * Copyright 2013 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 "GrBitmapTextContext.h" 8 #include "GrBitmapTextContext.h"
9 #include "GrAtlas.h" 9 #include "GrAtlas.h"
10 #include "GrDefaultGeoProcFactory.h" 10 #include "GrDefaultGeoProcFactory.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 GrBitmapTextContext* GrBitmapTextContext::Create(GrContext* context, 64 GrBitmapTextContext* GrBitmapTextContext::Create(GrContext* context,
65 const SkDeviceProperties& props ) { 65 const SkDeviceProperties& props ) {
66 return SkNEW_ARGS(GrBitmapTextContext, (context, props)); 66 return SkNEW_ARGS(GrBitmapTextContext, (context, props));
67 } 67 }
68 68
69 bool GrBitmapTextContext::canDraw(const SkPaint& paint, const SkMatrix& viewMatr ix) { 69 bool GrBitmapTextContext::canDraw(const SkPaint& paint, const SkMatrix& viewMatr ix) {
70 return !SkDraw::ShouldDrawTextAsPaths(paint, viewMatrix); 70 return !SkDraw::ShouldDrawTextAsPaths(paint, viewMatrix);
71 } 71 }
72 72
73 inline void GrBitmapTextContext::init(GrRenderTarget* rt, const GrClip& clip, 73 inline void GrBitmapTextContext::init(GrRenderTarget* rt, const GrPaint& paint,
74 const GrPaint& paint, const SkPaint& skPai nt) { 74 const SkPaint& skPaint) {
75 GrTextContext::init(rt, clip, paint, skPaint); 75 GrTextContext::init(rt, paint, skPaint);
76 76
77 fStrike = NULL; 77 fStrike = NULL;
78 78
79 fCurrTexture = NULL; 79 fCurrTexture = NULL;
80 fCurrVertex = 0; 80 fCurrVertex = 0;
81 81
82 fVertices = NULL; 82 fVertices = NULL;
83 fAllocVertexCount = 0; 83 fAllocVertexCount = 0;
84 fTotalVertexCount = 0; 84 fTotalVertexCount = 0;
85 } 85 }
86 86
87 void GrBitmapTextContext::onDrawText(GrRenderTarget* rt, const GrClip& clip, 87 void GrBitmapTextContext::onDrawText(GrRenderTarget* rt, const GrPaint& paint,
88 const GrPaint& paint, const SkPaint& skPain t, 88 const SkPaint& skPaint,
89 const SkMatrix& viewMatrix, 89 const SkMatrix& viewMatrix,
90 const char text[], size_t byteLength, 90 const char text[], size_t byteLength,
91 SkScalar x, SkScalar y) { 91 SkScalar x, SkScalar y) {
92 SkASSERT(byteLength == 0 || text != NULL); 92 SkASSERT(byteLength == 0 || text != NULL);
93 93
94 // nothing to draw 94 // nothing to draw
95 if (text == NULL || byteLength == 0 /*|| fRC->isEmpty()*/) { 95 if (text == NULL || byteLength == 0 /*|| fRC->isEmpty()*/) {
96 return; 96 return;
97 } 97 }
98 98
99 this->init(rt, clip, paint, skPaint); 99 this->init(rt, paint, skPaint);
100 100
101 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc(); 101 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
102 102
103 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &viewMatrix); 103 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &viewMatrix);
104 SkGlyphCache* cache = autoCache.getCache(); 104 SkGlyphCache* cache = autoCache.getCache();
105 GrFontScaler* fontScaler = GetGrFontScaler(cache); 105 GrFontScaler* fontScaler = GetGrFontScaler(cache);
106 106
107 // transform our starting point 107 // transform our starting point
108 { 108 {
109 SkPoint loc; 109 SkPoint loc;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 fontScaler); 177 fontScaler);
178 } 178 }
179 179
180 fx += glyph.fAdvanceX; 180 fx += glyph.fAdvanceX;
181 fy += glyph.fAdvanceY; 181 fy += glyph.fAdvanceY;
182 } 182 }
183 183
184 this->finish(); 184 this->finish();
185 } 185 }
186 186
187 void GrBitmapTextContext::onDrawPosText(GrRenderTarget* rt, const GrClip& clip, 187 void GrBitmapTextContext::onDrawPosText(GrRenderTarget* rt, const GrPaint& paint ,
188 const GrPaint& paint, const SkPaint& skP aint, 188 const SkPaint& skPaint,
189 const SkMatrix& viewMatrix, 189 const SkMatrix& viewMatrix,
190 const char text[], size_t byteLength, 190 const char text[], size_t byteLength,
191 const SkScalar pos[], int scalarsPerPosi tion, 191 const SkScalar pos[], int scalarsPerPosi tion,
192 const SkPoint& offset) { 192 const SkPoint& offset) {
193 SkASSERT(byteLength == 0 || text != NULL); 193 SkASSERT(byteLength == 0 || text != NULL);
194 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); 194 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
195 195
196 // nothing to draw 196 // nothing to draw
197 if (text == NULL || byteLength == 0/* || fRC->isEmpty()*/) { 197 if (text == NULL || byteLength == 0/* || fRC->isEmpty()*/) {
198 return; 198 return;
199 } 199 }
200 200
201 this->init(rt, clip, paint, skPaint); 201 this->init(rt, paint, skPaint);
202 202
203 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc(); 203 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
204 204
205 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &viewMatrix); 205 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &viewMatrix);
206 SkGlyphCache* cache = autoCache.getCache(); 206 SkGlyphCache* cache = autoCache.getCache();
207 GrFontScaler* fontScaler = GetGrFontScaler(cache); 207 GrFontScaler* fontScaler = GetGrFontScaler(cache);
208 208
209 // if we have RGB, then we won't have any SkShaders so no need to use a loca lmatrix, but for 209 // if we have RGB, then we won't have any SkShaders so no need to use a loca lmatrix, but for
210 // performance reasons we just invert here instead 210 // performance reasons we just invert here instead
211 if (!viewMatrix.invert(&fLocalMatrix)) { 211 if (!viewMatrix.invert(&fLocalMatrix)) {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 448
449 // flush any accumulated draws before drawing this glyph as a path. 449 // flush any accumulated draws before drawing this glyph as a path.
450 this->flush(); 450 this->flush();
451 451
452 SkMatrix translate; 452 SkMatrix translate;
453 translate.setTranslate(SkFixedToScalar(vx - SkIntToFixed(glyph->fBounds. fLeft)), 453 translate.setTranslate(SkFixedToScalar(vx - SkIntToFixed(glyph->fBounds. fLeft)),
454 SkFixedToScalar(vy - SkIntToFixed(glyph->fBounds. fTop))); 454 SkFixedToScalar(vy - SkIntToFixed(glyph->fBounds. fTop)));
455 SkPath tmpPath(*glyph->fPath); 455 SkPath tmpPath(*glyph->fPath);
456 tmpPath.transform(translate); 456 tmpPath.transform(translate);
457 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); 457 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle);
458 fContext->drawPath(fRenderTarget, fClip, fPaint, SkMatrix::I(), tmpPath, strokeInfo); 458 fContext->drawPath(fRenderTarget, fPaint, SkMatrix::I(), tmpPath, stroke Info);
459 459
460 // remove this glyph from the vertices we need to allocate 460 // remove this glyph from the vertices we need to allocate
461 fTotalVertexCount -= kVerticesPerGlyph; 461 fTotalVertexCount -= kVerticesPerGlyph;
462 return; 462 return;
463 } 463 }
464 464
465 SkASSERT(glyph->fPlot); 465 SkASSERT(glyph->fPlot);
466 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken(); 466 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken();
467 glyph->fPlot->setDrawToken(drawToken); 467 glyph->fPlot->setDrawToken(drawToken);
468 468
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 } 623 }
624 } 624 }
625 625
626 inline void GrBitmapTextContext::finish() { 626 inline void GrBitmapTextContext::finish() {
627 this->flush(); 627 this->flush();
628 fTotalVertexCount = 0; 628 fTotalVertexCount = 0;
629 629
630 GrTextContext::finish(); 630 GrTextContext::finish();
631 } 631 }
632 632
OLDNEW
« no previous file with comments | « src/gpu/GrBitmapTextContext.h ('k') | src/gpu/GrClip.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698