OLD | NEW |
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 "SkColorFilter.h" | 10 #include "SkColorFilter.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "SkDraw.h" | 21 #include "SkDraw.h" |
22 #include "SkGpuDevice.h" | 22 #include "SkGpuDevice.h" |
23 #include "SkPath.h" | 23 #include "SkPath.h" |
24 #include "SkRTConf.h" | 24 #include "SkRTConf.h" |
25 #include "SkStrokeRec.h" | 25 #include "SkStrokeRec.h" |
26 #include "effects/GrDistanceFieldTextureEffect.h" | 26 #include "effects/GrDistanceFieldTextureEffect.h" |
27 | 27 |
28 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, | 28 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, |
29 "Dump the contents of the font cache before every purge."); | 29 "Dump the contents of the font cache before every purge."); |
30 | 30 |
31 static const int kGlyphCoordsNoColorAttributeIndex = 1; | |
32 static const int kGlyphCoordsWithColorAttributeIndex = 2; | |
33 | |
34 static const int kSmallDFFontSize = 32; | 31 static const int kSmallDFFontSize = 32; |
35 static const int kSmallDFFontLimit = 32; | 32 static const int kSmallDFFontLimit = 32; |
36 static const int kMediumDFFontSize = 64; | 33 static const int kMediumDFFontSize = 64; |
37 static const int kMediumDFFontLimit = 64; | 34 static const int kMediumDFFontLimit = 64; |
38 static const int kLargeDFFontSize = 128; | 35 static const int kLargeDFFontSize = 128; |
39 | 36 |
40 namespace { | 37 namespace { |
41 // position + texture coord | 38 // position + texture coord |
42 extern const GrVertexAttrib gTextVertexAttribs[] = { | 39 extern const GrVertexAttrib gTextVertexAttribs[] = { |
43 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBindin
g}, | 40 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBindin
g}, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 SkColor filteredColor; | 186 SkColor filteredColor; |
190 SkColorFilter* colorFilter = fSkPaint.getColorFilter(); | 187 SkColorFilter* colorFilter = fSkPaint.getColorFilter(); |
191 if (colorFilter) { | 188 if (colorFilter) { |
192 filteredColor = colorFilter->filterColor(fSkPaint.getColor()); | 189 filteredColor = colorFilter->filterColor(fSkPaint.getColor()); |
193 } else { | 190 } else { |
194 filteredColor = fSkPaint.getColor(); | 191 filteredColor = fSkPaint.getColor(); |
195 } | 192 } |
196 this->setupCoverageEffect(filteredColor); | 193 this->setupCoverageEffect(filteredColor); |
197 | 194 |
198 // Effects could be stored with one of the cache objects (atlas?) | 195 // Effects could be stored with one of the cache objects (atlas?) |
199 int coordsIdx = drawState->hasColorVertexAttribute() ? kGlyphCoordsWithC
olorAttributeIndex : | 196 drawState->setGeometryProcessor(fCachedEffect.get()); |
200 kGlyphCoordsNoCol
orAttributeIndex; | |
201 drawState->addCoverageEffect(fCachedEffect.get(), coordsIdx); | |
202 | 197 |
203 // Set draw state | 198 // Set draw state |
204 if (fUseLCDText) { | 199 if (fUseLCDText) { |
205 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol
or); | 200 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol
or); |
206 if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() || | 201 if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() || |
207 kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() || | 202 kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() || |
208 fPaint.numColorStages()) { | 203 fPaint.numColorStages()) { |
209 GrPrintf("LCD Text will not draw correctly.\n"); | 204 GrPrintf("LCD Text will not draw correctly.\n"); |
210 } | 205 } |
211 SkASSERT(!drawState->hasColorVertexAttribute()); | 206 SkASSERT(!drawState->hasColorVertexAttribute()); |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 SkScalarToFixed(x) - (glyph.fAdvanceX >> a
lignShift), | 647 SkScalarToFixed(x) - (glyph.fAdvanceX >> a
lignShift), |
653 SkScalarToFixed(y) - (glyph.fAdvanceY >> a
lignShift), | 648 SkScalarToFixed(y) - (glyph.fAdvanceY >> a
lignShift), |
654 fontScaler); | 649 fontScaler); |
655 } | 650 } |
656 pos += scalarsPerPosition; | 651 pos += scalarsPerPosition; |
657 } | 652 } |
658 } | 653 } |
659 | 654 |
660 this->finish(); | 655 this->finish(); |
661 } | 656 } |
OLD | NEW |