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

Side by Side Diff: src/gpu/GrDistanceFieldTextContext.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/GrDistanceFieldTextContext.h ('k') | src/gpu/GrPipelineBuilder.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 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 "GrDistanceFieldTextContext.h" 8 #include "GrDistanceFieldTextContext.h"
9 #include "GrAtlas.h" 9 #include "GrAtlas.h"
10 #include "GrBitmapTextContext.h" 10 #include "GrBitmapTextContext.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 106
107 // TODO: add some stroking support 107 // TODO: add some stroking support
108 if (paint.getStyle() != SkPaint::kFill_Style) { 108 if (paint.getStyle() != SkPaint::kFill_Style) {
109 return false; 109 return false;
110 } 110 }
111 111
112 return true; 112 return true;
113 } 113 }
114 114
115 inline void GrDistanceFieldTextContext::init(GrRenderTarget* rt, const GrClip& c lip, 115 inline void GrDistanceFieldTextContext::init(GrRenderTarget* rt, const GrPaint& paint,
116 const GrPaint& paint, const SkPaint & skPaint) { 116 const SkPaint& skPaint) {
117 GrTextContext::init(rt, clip, paint, skPaint); 117 GrTextContext::init(rt, paint, skPaint);
118 118
119 fStrike = NULL; 119 fStrike = NULL;
120 120
121 const SkMatrix& ctm = fViewMatrix; 121 const SkMatrix& ctm = fViewMatrix;
122 122
123 // getMaxScale doesn't support perspective, so neither do we at the moment 123 // getMaxScale doesn't support perspective, so neither do we at the moment
124 SkASSERT(!ctm.hasPerspective()); 124 SkASSERT(!ctm.hasPerspective());
125 SkScalar maxScale = ctm.getMaxScale(); 125 SkScalar maxScale = ctm.getMaxScale();
126 SkScalar textSize = fSkPaint.getTextSize(); 126 SkScalar textSize = fSkPaint.getTextSize();
127 SkScalar scaledTextSize = textSize; 127 SkScalar scaledTextSize = textSize;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 if (NULL == *gammaTexture) { 200 if (NULL == *gammaTexture) {
201 return; 201 return;
202 } 202 }
203 203
204 (*gammaTexture)->writePixels(0, 0, width, height, 204 (*gammaTexture)->writePixels(0, 0, width, height,
205 (*gammaTexture)->config(), data.get(), 0, 205 (*gammaTexture)->config(), data.get(), 0,
206 GrContext::kDontFlush_PixelOpsFlag); 206 GrContext::kDontFlush_PixelOpsFlag);
207 } 207 }
208 } 208 }
209 209
210 void GrDistanceFieldTextContext::onDrawText(GrRenderTarget* rt, const GrClip& cl ip, 210 void GrDistanceFieldTextContext::onDrawText(GrRenderTarget* rt, const GrPaint& p aint,
211 const GrPaint& paint,
212 const SkPaint& skPaint, const SkMatr ix& viewMatrix, 211 const SkPaint& skPaint, const SkMatr ix& viewMatrix,
213 const char text[], size_t byteLength , 212 const char text[], size_t byteLength ,
214 SkScalar x, SkScalar y) { 213 SkScalar x, SkScalar y) {
215 SkASSERT(byteLength == 0 || text != NULL); 214 SkASSERT(byteLength == 0 || text != NULL);
216 215
217 // nothing to draw 216 // nothing to draw
218 if (text == NULL || byteLength == 0) { 217 if (text == NULL || byteLength == 0) {
219 return; 218 return;
220 } 219 }
221 220
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 alignX = SkScalarHalf(alignX); 261 alignX = SkScalarHalf(alignX);
263 alignY = SkScalarHalf(alignY); 262 alignY = SkScalarHalf(alignY);
264 } else if (skPaint.getTextAlign() == SkPaint::kLeft_Align) { 263 } else if (skPaint.getTextAlign() == SkPaint::kLeft_Align) {
265 alignX = 0; 264 alignX = 0;
266 alignY = 0; 265 alignY = 0;
267 } 266 }
268 x -= alignX; 267 x -= alignX;
269 y -= alignY; 268 y -= alignY;
270 SkPoint offset = SkPoint::Make(x, y); 269 SkPoint offset = SkPoint::Make(x, y);
271 270
272 this->drawPosText(rt, clip, paint, skPaint, viewMatrix, text, byteLength, po sitions.begin(), 2, 271 this->drawPosText(rt, paint, skPaint, viewMatrix, text, byteLength, position s.begin(), 2,
273 offset); 272 offset);
274 } 273 }
275 274
276 void GrDistanceFieldTextContext::onDrawPosText(GrRenderTarget* rt, const GrClip& clip, 275 void GrDistanceFieldTextContext::onDrawPosText(GrRenderTarget* rt, const GrPaint & paint,
277 const GrPaint& paint,
278 const SkPaint& skPaint, const SkM atrix& viewMatrix, 276 const SkPaint& skPaint, const SkM atrix& viewMatrix,
279 const char text[], size_t byteLen gth, 277 const char text[], size_t byteLen gth,
280 const SkScalar pos[], int scalars PerPosition, 278 const SkScalar pos[], int scalars PerPosition,
281 const SkPoint& offset) { 279 const SkPoint& offset) {
282 280
283 SkASSERT(byteLength == 0 || text != NULL); 281 SkASSERT(byteLength == 0 || text != NULL);
284 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); 282 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
285 283
286 // nothing to draw 284 // nothing to draw
287 if (text == NULL || byteLength == 0 /* no raster clip? || fRC->isEmpty()*/) { 285 if (text == NULL || byteLength == 0 /* no raster clip? || fRC->isEmpty()*/) {
288 return; 286 return;
289 } 287 }
290 288
291 fViewMatrix = viewMatrix; 289 fViewMatrix = viewMatrix;
292 this->init(rt, clip, paint, skPaint); 290 this->init(rt, paint, skPaint);
293 291
294 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc(); 292 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
295 293
296 SkAutoGlyphCacheNoGamma autoCache(fSkPaint, &fDeviceProperties, NULL); 294 SkAutoGlyphCacheNoGamma autoCache(fSkPaint, &fDeviceProperties, NULL);
297 SkGlyphCache* cache = autoCache.getCache(); 295 SkGlyphCache* cache = autoCache.getCache();
298 GrFontScaler* fontScaler = GetGrFontScaler(cache); 296 GrFontScaler* fontScaler = GetGrFontScaler(cache);
299 297
300 setup_gamma_texture(fContext, cache, fDeviceProperties, &fGammaTexture); 298 setup_gamma_texture(fContext, cache, fDeviceProperties, &fGammaTexture);
301 299
302 int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); 300 int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 355 }
358 } 356 }
359 } 357 }
360 pos += scalarsPerPosition; 358 pos += scalarsPerPosition;
361 } 359 }
362 } 360 }
363 361
364 this->finish(); 362 this->finish();
365 363
366 if (fallbackTxt.count() > 0) { 364 if (fallbackTxt.count() > 0) {
367 fFallbackTextContext->drawPosText(rt, clip, paint, skPaint, viewMatrix, fallbackTxt.begin(), 365 fFallbackTextContext->drawPosText(rt, paint, skPaint, viewMatrix, fallba ckTxt.begin(),
368 fallbackTxt.count(), fallbackPos.begin (), 366 fallbackTxt.count(), fallbackPos.begin (),
369 scalarsPerPosition, offset); 367 scalarsPerPosition, offset);
370 } 368 }
371 } 369 }
372 370
373 static inline GrColor skcolor_to_grcolor_nopremultiply(SkColor c) { 371 static inline GrColor skcolor_to_grcolor_nopremultiply(SkColor c) {
374 unsigned r = SkColorGetR(c); 372 unsigned r = SkColorGetR(c);
375 unsigned g = SkColorGetG(c); 373 unsigned g = SkColorGetG(c);
376 unsigned b = SkColorGetB(c); 374 unsigned b = SkColorGetB(c);
377 return GrColorPackRGBA(r, g, b, 0xff); 375 return GrColorPackRGBA(r, g, b, 0xff);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 this->flush(); 564 this->flush();
567 565
568 SkMatrix ctm; 566 SkMatrix ctm;
569 ctm.setScale(fTextRatio, fTextRatio); 567 ctm.setScale(fTextRatio, fTextRatio);
570 ctm.postTranslate(sx - dx, sy - dy); 568 ctm.postTranslate(sx - dx, sy - dy);
571 569
572 SkPath tmpPath(*glyph->fPath); 570 SkPath tmpPath(*glyph->fPath);
573 tmpPath.transform(ctm); 571 tmpPath.transform(ctm);
574 572
575 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); 573 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle);
576 fContext->drawPath(fRenderTarget, fClip, fPaint, fViewMatrix, tmpPat h, strokeInfo); 574 fContext->drawPath(fRenderTarget, fPaint, fViewMatrix, tmpPath, stro keInfo);
577 575
578 // remove this glyph from the vertices we need to allocate 576 // remove this glyph from the vertices we need to allocate
579 fTotalVertexCount -= kVerticesPerGlyph; 577 fTotalVertexCount -= kVerticesPerGlyph;
580 return true; 578 return true;
581 } 579 }
582 } 580 }
583 581
584 SkASSERT(glyph->fPlot); 582 SkASSERT(glyph->fPlot);
585 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken(); 583 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken();
586 glyph->fPlot->setDrawToken(drawToken); 584 glyph->fPlot->setDrawToken(drawToken);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 } 715 }
718 } 716 }
719 717
720 inline void GrDistanceFieldTextContext::finish() { 718 inline void GrDistanceFieldTextContext::finish() {
721 this->flush(); 719 this->flush();
722 fTotalVertexCount = 0; 720 fTotalVertexCount = 0;
723 721
724 GrTextContext::finish(); 722 GrTextContext::finish();
725 } 723 }
726 724
OLDNEW
« no previous file with comments | « src/gpu/GrDistanceFieldTextContext.h ('k') | src/gpu/GrPipelineBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698