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

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

Issue 144283002: Add factory class for generating various flavors of GrTextContext. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add placement delete for ManagedTextContext Created 6 years, 11 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 | « include/gpu/SkGpuDevice.h ('k') | src/gpu/GrDistanceFieldTextContext.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 "GrDrawTarget.h" 10 #include "GrDrawTarget.h"
11 #include "GrFontScaler.h" 11 #include "GrFontScaler.h"
12 #include "GrIndexBuffer.h" 12 #include "GrIndexBuffer.h"
13 #include "GrTextStrike.h" 13 #include "GrTextStrike.h"
14 #include "GrTextStrike_impl.h" 14 #include "GrTextStrike_impl.h"
15 #include "SkColorPriv.h" 15 #include "SkColorPriv.h"
16 #include "SkPath.h" 16 #include "SkPath.h"
17 #include "SkRTConf.h" 17 #include "SkRTConf.h"
18 #include "SkStrokeRec.h" 18 #include "SkStrokeRec.h"
19 #include "effects/GrCustomCoordsTextureEffect.h" 19 #include "effects/GrCustomCoordsTextureEffect.h"
20 20
21 static const int kGlyphCoordsAttributeIndex = 1; 21 static const int kGlyphCoordsAttributeIndex = 1;
22 22
23 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, 23 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false,
24 "Dump the contents of the font cache before every purge."); 24 "Dump the contents of the font cache before every purge.");
25 25
26 GrBitmapTextContext::GrBitmapTextContext(GrContext* context, const GrPaint& pain t, 26 GrBitmapTextContext::GrBitmapTextContext(GrContext* context, const GrPaint& pain t,
27 SkColor color) : 27 const SkPaint& skPaint) :
28 GrTextContext(context, paint) { 28 GrTextContext(context, paint, skPaint) {
29 fAutoMatrix.setIdentity(fContext, &fPaint); 29 fAutoMatrix.setIdentity(fContext, &fPaint);
30 30
31 fSkPaintColor = color;
32
33 fStrike = NULL; 31 fStrike = NULL;
34 32
35 fCurrTexture = NULL; 33 fCurrTexture = NULL;
36 fCurrVertex = 0; 34 fCurrVertex = 0;
37 35
38 fVertices = NULL; 36 fVertices = NULL;
39 fMaxVertices = 0; 37 fMaxVertices = 0;
40 } 38 }
41 39
42 GrBitmapTextContext::~GrBitmapTextContext() { 40 GrBitmapTextContext::~GrBitmapTextContext() {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } else if (!GrPixelConfigIsAlphaOnly(fCurrTexture->config())) { 74 } else if (!GrPixelConfigIsAlphaOnly(fCurrTexture->config())) {
77 if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() || 75 if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() ||
78 kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() || 76 kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() ||
79 fPaint.numColorStages()) { 77 fPaint.numColorStages()) {
80 GrPrintf("LCD Text will not draw correctly.\n"); 78 GrPrintf("LCD Text will not draw correctly.\n");
81 } 79 }
82 // We don't use the GrPaint's color in this case because it's been p remultiplied by 80 // We don't use the GrPaint's color in this case because it's been p remultiplied by
83 // alpha. Instead we feed in a non-premultiplied color, and multiply its alpha by 81 // alpha. Instead we feed in a non-premultiplied color, and multiply its alpha by
84 // the mask texture color. The end result is that we get 82 // the mask texture color. The end result is that we get
85 // mask*paintAlpha*paintColor + (1-mask*paintAlpha)*dstCo lor 83 // mask*paintAlpha*paintColor + (1-mask*paintAlpha)*dstCo lor
86 int a = SkColorGetA(fSkPaintColor); 84 int a = SkColorGetA(fSkPaint.getColor());
87 // paintAlpha 85 // paintAlpha
88 drawState->setColor(SkColorSetARGB(a, a, a, a)); 86 drawState->setColor(SkColorSetARGB(a, a, a, a));
89 // paintColor 87 // paintColor
90 drawState->setBlendConstant(skcolor_to_grcolor_nopremultiply(fSkPain tColor)); 88 drawState->setBlendConstant(skcolor_to_grcolor_nopremultiply(fSkPain t.getColor()));
91 drawState->setBlendFunc(kConstC_GrBlendCoeff, kISC_GrBlendCoeff); 89 drawState->setBlendFunc(kConstC_GrBlendCoeff, kISC_GrBlendCoeff);
92 } else { 90 } else {
93 // set back to normal in case we took LCD path previously. 91 // set back to normal in case we took LCD path previously.
94 drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDstBlen dCoeff()); 92 drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDstBlen dCoeff());
95 drawState->setColor(fPaint.getColor()); 93 drawState->setColor(fPaint.getColor());
96 } 94 }
97 95
98 int nGlyphs = fCurrVertex / 4; 96 int nGlyphs = fCurrVertex / 4;
99 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); 97 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
100 fDrawTarget->drawIndexedInstances(kTriangles_GrPrimitiveType, 98 fDrawTarget->drawIndexedInstances(kTriangles_GrPrimitiveType,
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 SkFixedToFloat(vx + width), 260 SkFixedToFloat(vx + width),
263 SkFixedToFloat(vy + height), 261 SkFixedToFloat(vy + height),
264 2 * sizeof(SkPoint)); 262 2 * sizeof(SkPoint));
265 fVertices[2*fCurrVertex+1].setRectFan(SkFixedToFloat(texture->normalizeFixed X(tx)), 263 fVertices[2*fCurrVertex+1].setRectFan(SkFixedToFloat(texture->normalizeFixed X(tx)),
266 SkFixedToFloat(texture->normalizeFixed Y(ty)), 264 SkFixedToFloat(texture->normalizeFixed Y(ty)),
267 SkFixedToFloat(texture->normalizeFixed X(tx + width)), 265 SkFixedToFloat(texture->normalizeFixed X(tx + width)),
268 SkFixedToFloat(texture->normalizeFixed Y(ty + height)), 266 SkFixedToFloat(texture->normalizeFixed Y(ty + height)),
269 2 * sizeof(SkPoint)); 267 2 * sizeof(SkPoint));
270 fCurrVertex += 4; 268 fCurrVertex += 4;
271 } 269 }
OLDNEW
« no previous file with comments | « include/gpu/SkGpuDevice.h ('k') | src/gpu/GrDistanceFieldTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698