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

Side by Side Diff: src/gpu/batches/GrAtlasTextBatch.cpp

Issue 1885613002: sRGB support for distance field text. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Break long line Created 4 years, 8 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 2015 Google Inc. 2 * Copyright 2015 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 "GrAtlasTextBatch.h" 8 #include "GrAtlasTextBatch.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // TODO just use class params 254 // TODO just use class params
255 // TODO trying to figure out why lcd is so whack 255 // TODO trying to figure out why lcd is so whack
256 GrGeometryProcessor* GrAtlasTextBatch::setupDfProcessor(const SkMatrix& viewMatr ix, 256 GrGeometryProcessor* GrAtlasTextBatch::setupDfProcessor(const SkMatrix& viewMatr ix,
257 SkColor filteredColor, 257 SkColor filteredColor,
258 GrColor color, GrTexture * texture) const { 258 GrColor color, GrTexture * texture) const {
259 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBilerp_F ilterMode); 259 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBilerp_F ilterMode);
260 bool isLCD = this->isLCD(); 260 bool isLCD = this->isLCD();
261 // set up any flags 261 // set up any flags
262 uint32_t flags = viewMatrix.isSimilarity() ? kSimilarity_DistanceFieldEffect Flag : 0; 262 uint32_t flags = viewMatrix.isSimilarity() ? kSimilarity_DistanceFieldEffect Flag : 0;
263 flags |= viewMatrix.isScaleTranslate() ? kScaleOnly_DistanceFieldEffectFlag : 0; 263 flags |= viewMatrix.isScaleTranslate() ? kScaleOnly_DistanceFieldEffectFlag : 0;
264 flags |= fUseSRGBDistanceTable ? kSRGB_DistanceFieldEffectFlag : 0;
264 265
265 // see if we need to create a new effect 266 // see if we need to create a new effect
266 if (isLCD) { 267 if (isLCD) {
267 flags |= kUseLCD_DistanceFieldEffectFlag; 268 flags |= kUseLCD_DistanceFieldEffectFlag;
268 flags |= fUseBGR ? kBGR_DistanceFieldEffectFlag : 0; 269 flags |= fUseBGR ? kBGR_DistanceFieldEffectFlag : 0;
269 270
270 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredColor); 271 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredColor);
271 272
272 float redCorrection = 273 float redCorrection = fDistanceAdjustTable->getAdjustment(
273 (*fDistanceAdjustTable)[GrColorUnpackR(colorNoPreMul) >> kDistanceAd justLumShift]; 274 GrColorUnpackR(colorNoPreMul) >> kDistanceAdjustLumShift, fUseSRGBDi stanceTable);
274 float greenCorrection = 275 float greenCorrection = fDistanceAdjustTable->getAdjustment(
275 (*fDistanceAdjustTable)[GrColorUnpackG(colorNoPreMul) >> kDistanceAd justLumShift]; 276 GrColorUnpackG(colorNoPreMul) >> kDistanceAdjustLumShift, fUseSRGBDi stanceTable);
276 float blueCorrection = 277 float blueCorrection = fDistanceAdjustTable->getAdjustment(
277 (*fDistanceAdjustTable)[GrColorUnpackB(colorNoPreMul) >> kDistanceAd justLumShift]; 278 GrColorUnpackB(colorNoPreMul) >> kDistanceAdjustLumShift, fUseSRGBDi stanceTable);
278 GrDistanceFieldLCDTextGeoProc::DistanceAdjust widthAdjust = 279 GrDistanceFieldLCDTextGeoProc::DistanceAdjust widthAdjust =
279 GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(redCorrection, 280 GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(redCorrection,
280 greenCorrection, 281 greenCorrection,
281 blueCorrection); 282 blueCorrection);
282 283
283 return GrDistanceFieldLCDTextGeoProc::Create(color, 284 return GrDistanceFieldLCDTextGeoProc::Create(color,
284 viewMatrix, 285 viewMatrix,
285 texture, 286 texture,
286 params, 287 params,
287 widthAdjust, 288 widthAdjust,
288 flags, 289 flags,
289 this->usesLocalCoords()); 290 this->usesLocalCoords());
290 } else { 291 } else {
291 #ifdef SK_GAMMA_APPLY_TO_A8 292 #ifdef SK_GAMMA_APPLY_TO_A8
292 U8CPU lum = SkColorSpaceLuminance::computeLuminance(SK_GAMMA_EXPONENT, f ilteredColor); 293 U8CPU lum = SkColorSpaceLuminance::computeLuminance(SK_GAMMA_EXPONENT, f ilteredColor);
293 float correction = (*fDistanceAdjustTable)[lum >> kDistanceAdjustLumShif t]; 294 float correction = fDistanceAdjustTable->getAdjustment(
295 lum >> kDistanceAdjustLumShift, fUseSRGBDistanceTable);
294 return GrDistanceFieldA8TextGeoProc::Create(color, 296 return GrDistanceFieldA8TextGeoProc::Create(color,
295 viewMatrix, 297 viewMatrix,
296 texture, 298 texture,
297 params, 299 params,
298 correction, 300 correction,
299 flags, 301 flags,
300 this->usesLocalCoords()); 302 this->usesLocalCoords());
301 #else 303 #else
302 return GrDistanceFieldA8TextGeoProc::Create(color, 304 return GrDistanceFieldA8TextGeoProc::Create(color,
303 viewMatrix, 305 viewMatrix,
304 texture, 306 texture,
305 params, 307 params,
306 flags, 308 flags,
307 this->usesLocalCoords()); 309 this->usesLocalCoords());
308 #endif 310 #endif
309 } 311 }
310 312
311 } 313 }
312 314
313 void GrBlobRegenHelper::flush() { 315 void GrBlobRegenHelper::flush() {
314 fBatch->flush(fTarget, fFlushInfo); 316 fBatch->flush(fTarget, fFlushInfo);
315 } 317 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698