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

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

Issue 1015173002: Let text contexts fall back directly to paths (Closed) Base URL: https://skia.googlesource.com/skia.git@text-blob-to-context
Patch Set: feedback inc Created 5 years, 9 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/GrStencilAndCoverTextContext.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 24 matching lines...) Expand all
35 static const int kSmallDFFontSize = 32; 35 static const int kSmallDFFontSize = 32;
36 static const int kSmallDFFontLimit = 32; 36 static const int kSmallDFFontLimit = 32;
37 static const int kMediumDFFontSize = 72; 37 static const int kMediumDFFontSize = 72;
38 static const int kMediumDFFontLimit = 72; 38 static const int kMediumDFFontLimit = 72;
39 static const int kLargeDFFontSize = 162; 39 static const int kLargeDFFontSize = 162;
40 40
41 static const int kVerticesPerGlyph = 4; 41 static const int kVerticesPerGlyph = 4;
42 static const int kIndicesPerGlyph = 6; 42 static const int kIndicesPerGlyph = 6;
43 43
44 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context, 44 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context,
45 SkGpuDevice* gpuDevice,
45 const SkDeviceProperties& properties, 46 const SkDeviceProperties& properties,
46 bool enable) 47 bool enable)
47 : GrTextContext(context, pro perties) { 48 : GrTextContext(context, gpuDevice, properties) {
48 #if SK_FORCE_DISTANCE_FIELD_TEXT 49 #if SK_FORCE_DISTANCE_FIELD_TEXT
49 fEnableDFRendering = true; 50 fEnableDFRendering = true;
50 #else 51 #else
51 fEnableDFRendering = enable; 52 fEnableDFRendering = enable;
52 #endif 53 #endif
53 fStrike = NULL; 54 fStrike = NULL;
54 fGammaTexture = NULL; 55 fGammaTexture = NULL;
55 56
56 fEffectTextureUniqueID = SK_InvalidUniqueID; 57 fEffectTextureUniqueID = SK_InvalidUniqueID;
57 fEffectColor = GrColor_ILLEGAL; 58 fEffectColor = GrColor_ILLEGAL;
58 fEffectFlags = kInvalid_DistanceFieldEffectFlag; 59 fEffectFlags = kInvalid_DistanceFieldEffectFlag;
59 60
60 fVertices = NULL; 61 fVertices = NULL;
61 fCurrVertex = 0; 62 fCurrVertex = 0;
62 fAllocVertexCount = 0; 63 fAllocVertexCount = 0;
63 fTotalVertexCount = 0; 64 fTotalVertexCount = 0;
64 fCurrTexture = NULL; 65 fCurrTexture = NULL;
65 66
66 fVertexBounds.setLargestInverted(); 67 fVertexBounds.setLargestInverted();
67 } 68 }
68 69
69 GrDistanceFieldTextContext* GrDistanceFieldTextContext::Create(GrContext* contex t, 70 GrDistanceFieldTextContext* GrDistanceFieldTextContext::Create(GrContext* contex t,
71 SkGpuDevice* gpuD evice,
70 const SkDevicePro perties& props, 72 const SkDevicePro perties& props,
71 bool enable) { 73 bool enable) {
72 GrDistanceFieldTextContext* textContext = SkNEW_ARGS(GrDistanceFieldTextCont ext, 74 GrDistanceFieldTextContext* textContext = SkNEW_ARGS(GrDistanceFieldTextCont ext,
73 (context, props, enable )); 75 (context, gpuDevice, pr ops, enable));
74 textContext->fFallbackTextContext = GrBitmapTextContext::Create(context, pro ps); 76 textContext->fFallbackTextContext = GrBitmapTextContext::Create(context, gpu Device, props);
75 77
76 return textContext; 78 return textContext;
77 } 79 }
78 80
79 GrDistanceFieldTextContext::~GrDistanceFieldTextContext() { 81 GrDistanceFieldTextContext::~GrDistanceFieldTextContext() {
80 SkSafeSetNull(fGammaTexture); 82 SkSafeSetNull(fGammaTexture);
81 } 83 }
82 84
83 bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint, const SkMatrix& v iewMatrix) { 85 bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint, const SkMatrix& v iewMatrix) {
84 // TODO: support perspective (need getMaxScale replacement) 86 // TODO: support perspective (need getMaxScale replacement)
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 alignX = SkScalarHalf(alignX); 265 alignX = SkScalarHalf(alignX);
264 alignY = SkScalarHalf(alignY); 266 alignY = SkScalarHalf(alignY);
265 } else if (skPaint.getTextAlign() == SkPaint::kLeft_Align) { 267 } else if (skPaint.getTextAlign() == SkPaint::kLeft_Align) {
266 alignX = 0; 268 alignX = 0;
267 alignY = 0; 269 alignY = 0;
268 } 270 }
269 x -= alignX; 271 x -= alignX;
270 y -= alignY; 272 y -= alignY;
271 SkPoint offset = SkPoint::Make(x, y); 273 SkPoint offset = SkPoint::Make(x, y);
272 274
273 this->drawPosText(rt, clip, paint, skPaint, viewMatrix, text, byteLength, po sitions.begin(), 2, 275 this->onDrawPosText(rt, clip, paint, skPaint, viewMatrix, text, byteLength, positions.begin(),
274 offset); 276 2, offset);
275 } 277 }
276 278
277 void GrDistanceFieldTextContext::onDrawPosText(GrRenderTarget* rt, const GrClip& clip, 279 void GrDistanceFieldTextContext::onDrawPosText(GrRenderTarget* rt, const GrClip& clip,
278 const GrPaint& paint, 280 const GrPaint& paint,
279 const SkPaint& skPaint, const SkM atrix& viewMatrix, 281 const SkPaint& skPaint, const SkM atrix& viewMatrix,
280 const char text[], size_t byteLen gth, 282 const char text[], size_t byteLen gth,
281 const SkScalar pos[], int scalars PerPosition, 283 const SkScalar pos[], int scalars PerPosition,
282 const SkPoint& offset) { 284 const SkPoint& offset) {
283 285
284 SkASSERT(byteLength == 0 || text != NULL); 286 SkASSERT(byteLength == 0 || text != NULL);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 } 360 }
359 } 361 }
360 } 362 }
361 pos += scalarsPerPosition; 363 pos += scalarsPerPosition;
362 } 364 }
363 } 365 }
364 366
365 this->finish(); 367 this->finish();
366 368
367 if (fallbackTxt.count() > 0) { 369 if (fallbackTxt.count() > 0) {
368 fFallbackTextContext->drawPosText(rt, clip, paint, skPaint, viewMatrix, fallbackTxt.begin(), 370 fFallbackTextContext->onDrawPosText(rt, clip, paint, skPaint, viewMatrix ,
jvanverth1 2015/03/18 22:25:25 This concerns me. It removes the check as to wheth
369 fallbackTxt.count(), fallbackPos.begin (), 371 fallbackTxt.begin(), fallbackTxt.cou nt(),
370 scalarsPerPosition, offset); 372 fallbackPos.begin(), scalarsPerPosit ion, offset);
371 } 373 }
372 } 374 }
373 375
374 static inline GrColor skcolor_to_grcolor_nopremultiply(SkColor c) { 376 static inline GrColor skcolor_to_grcolor_nopremultiply(SkColor c) {
375 unsigned r = SkColorGetR(c); 377 unsigned r = SkColorGetR(c);
376 unsigned g = SkColorGetG(c); 378 unsigned g = SkColorGetG(c);
377 unsigned b = SkColorGetB(c); 379 unsigned b = SkColorGetB(c);
378 return GrColorPackRGBA(r, g, b, 0xff); 380 return GrColorPackRGBA(r, g, b, 0xff);
379 } 381 }
380 382
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 } 720 }
719 } 721 }
720 722
721 inline void GrDistanceFieldTextContext::finish() { 723 inline void GrDistanceFieldTextContext::finish() {
722 this->flush(); 724 this->flush();
723 fTotalVertexCount = 0; 725 fTotalVertexCount = 0;
724 726
725 GrTextContext::finish(); 727 GrTextContext::finish();
726 } 728 }
727 729
OLDNEW
« no previous file with comments | « src/gpu/GrDistanceFieldTextContext.h ('k') | src/gpu/GrStencilAndCoverTextContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698