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

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

Issue 582963002: Solo gp (Closed) Base URL: https://skia.googlesource.com/skia.git@no_peb
Patch Set: feddback inc Created 6 years, 3 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
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 "SkColorFilter.h" 10 #include "SkColorFilter.h"
(...skipping 20 matching lines...) Expand all
31 static const int kSmallDFFontSize = 32; 31 static const int kSmallDFFontSize = 32;
32 static const int kSmallDFFontLimit = 32; 32 static const int kSmallDFFontLimit = 32;
33 static const int kMediumDFFontSize = 64; 33 static const int kMediumDFFontSize = 64;
34 static const int kMediumDFFontLimit = 64; 34 static const int kMediumDFFontLimit = 64;
35 static const int kLargeDFFontSize = 128; 35 static const int kLargeDFFontSize = 128;
36 36
37 namespace { 37 namespace {
38 // position + texture coord 38 // position + texture coord
39 extern const GrVertexAttrib gTextVertexAttribs[] = { 39 extern const GrVertexAttrib gTextVertexAttribs[] = {
40 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBindin g}, 40 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBindin g},
41 {kVec2f_GrVertexAttribType, sizeof(SkPoint) , kEffect_GrVertexAttribBinding} 41 {kVec2f_GrVertexAttribType, sizeof(SkPoint) , kGeometryProcessor_GrVertexAtt ribBinding}
42 }; 42 };
43 43
44 static const size_t kTextVASize = 2 * sizeof(SkPoint); 44 static const size_t kTextVASize = 2 * sizeof(SkPoint);
45 45
46 // position + color + texture coord 46 // position + color + texture coord
47 extern const GrVertexAttrib gTextVertexWithColorAttribs[] = { 47 extern const GrVertexAttrib gTextVertexWithColorAttribs[] = {
48 {kVec2f_GrVertexAttribType, 0, kPosition_Gr VertexAttribBinding}, 48 {kVec2f_GrVertexAttribType, 0, kPosition_Gr VertexAttribBinding},
49 {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVer texAttribBinding}, 49 {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVer texAttribBinding},
50 {kVec2f_GrVertexAttribType, sizeof(SkPoint) + sizeof(GrColor), kEffect_GrVe rtexAttribBinding} 50 {kVec2f_GrVertexAttribType, sizeof(SkPoint) + sizeof(GrColor), kGeometryPro cessor_GrVertexAttribBinding}
51 }; 51 };
52 52
53 static const size_t kTextVAColorSize = 2 * sizeof(SkPoint) + sizeof(GrColor); 53 static const size_t kTextVAColorSize = 2 * sizeof(SkPoint) + sizeof(GrColor);
54 54
55 }; 55 };
56 56
57 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context, 57 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context,
58 const SkDeviceProperties& properties, 58 const SkDeviceProperties& properties,
59 bool enable) 59 bool enable)
60 : GrTextContext(context, pro perties) { 60 : GrTextContext(context, pro perties) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 kRectToRect_DistanceFieldEffectFlag : 0; 133 kRectToRect_DistanceFieldEffectFlag : 0;
134 bool useBGR = SkPixelGeometryIsBGR(fDeviceProperties.fPixelGeometry); 134 bool useBGR = SkPixelGeometryIsBGR(fDeviceProperties.fPixelGeometry);
135 flags |= fUseLCDText && useBGR ? kBGR_DistanceFieldEffectFlag : 0; 135 flags |= fUseLCDText && useBGR ? kBGR_DistanceFieldEffectFlag : 0;
136 136
137 // see if we need to create a new effect 137 // see if we need to create a new effect
138 if (textureUniqueID != fEffectTextureUniqueID || 138 if (textureUniqueID != fEffectTextureUniqueID ||
139 filteredColor != fEffectColor || 139 filteredColor != fEffectColor ||
140 flags != fEffectFlags) { 140 flags != fEffectFlags) {
141 if (fUseLCDText) { 141 if (fUseLCDText) {
142 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol or); 142 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol or);
143 fCachedEffect.reset(GrDistanceFieldLCDTextureEffect::Create(fCurrTex ture, 143 fCachedGeometryProcessor.reset(
144 params, 144 GrDistanceFieldLCDTextureEffect::Create(fCurrTexture,
145 fGammaTe xture, 145 params,
146 gammaPar ams, 146 fGammaTexture,
147 colorNoP reMul, 147 gammaParams,
148 flags)); 148 colorNoPreMul,
149 flags));
149 } else { 150 } else {
150 #ifdef SK_GAMMA_APPLY_TO_A8 151 #ifdef SK_GAMMA_APPLY_TO_A8
151 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDevicePropertie s.getGamma(), 152 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDevicePropertie s.getGamma(),
152 filteredColor); 153 filteredColor);
153 fCachedEffect.reset(GrDistanceFieldTextureEffect::Create(fCurrTextur e, 154 fCachedGeometryProcessor.reset(
154 params, 155 GrDistanceFieldTextureEffect::Create(fCurrTexture,
155 fGammaTextu re, 156 params,
156 gammaParams , 157 fGammaTexture,
157 lum/255.f, 158 gammaParams,
158 flags)); 159 lum/255.f,
160 flags));
159 #else 161 #else
160 fCachedEffect.reset(GrDistanceFieldTextureEffect::Create(fCurrTextur e, 162 fCachedGeometryProcessor.reset(GrDistanceFieldTextureEffect::Create( fCurrTexture,
161 params, fla gs)); 163 params, flags));
162 #endif 164 #endif
163 } 165 }
164 fEffectTextureUniqueID = textureUniqueID; 166 fEffectTextureUniqueID = textureUniqueID;
165 fEffectColor = filteredColor; 167 fEffectColor = filteredColor;
166 fEffectFlags = flags; 168 fEffectFlags = flags;
167 } 169 }
168 170
169 } 171 }
170 172
171 void GrDistanceFieldTextContext::flushGlyphs() { 173 void GrDistanceFieldTextContext::flushGlyphs() {
(...skipping 14 matching lines...) Expand all
186 SkColor filteredColor; 188 SkColor filteredColor;
187 SkColorFilter* colorFilter = fSkPaint.getColorFilter(); 189 SkColorFilter* colorFilter = fSkPaint.getColorFilter();
188 if (colorFilter) { 190 if (colorFilter) {
189 filteredColor = colorFilter->filterColor(fSkPaint.getColor()); 191 filteredColor = colorFilter->filterColor(fSkPaint.getColor());
190 } else { 192 } else {
191 filteredColor = fSkPaint.getColor(); 193 filteredColor = fSkPaint.getColor();
192 } 194 }
193 this->setupCoverageEffect(filteredColor); 195 this->setupCoverageEffect(filteredColor);
194 196
195 // Effects could be stored with one of the cache objects (atlas?) 197 // Effects could be stored with one of the cache objects (atlas?)
196 drawState->setGeometryProcessor(fCachedEffect.get()); 198 drawState->setGeometryProcessor(fCachedGeometryProcessor.get());
197 199
198 // Set draw state 200 // Set draw state
199 if (fUseLCDText) { 201 if (fUseLCDText) {
200 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol or); 202 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol or);
201 if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() || 203 if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() ||
202 kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() || 204 kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() ||
203 fPaint.numColorStages()) { 205 fPaint.numColorStages()) {
204 GrPrintf("LCD Text will not draw correctly.\n"); 206 GrPrintf("LCD Text will not draw correctly.\n");
205 } 207 }
206 SkASSERT(!drawState->hasColorVertexAttribute()); 208 SkASSERT(!drawState->hasColorVertexAttribute());
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 SkScalarToFixed(x) - (glyph.fAdvanceX >> a lignShift), 665 SkScalarToFixed(x) - (glyph.fAdvanceX >> a lignShift),
664 SkScalarToFixed(y) - (glyph.fAdvanceY >> a lignShift), 666 SkScalarToFixed(y) - (glyph.fAdvanceY >> a lignShift),
665 fontScaler); 667 fontScaler);
666 } 668 }
667 pos += scalarsPerPosition; 669 pos += scalarsPerPosition;
668 } 670 }
669 } 671 }
670 672
671 this->finish(); 673 this->finish();
672 } 674 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698