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

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

Issue 652273002: add gamma value to deviceproperties (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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/core/SkPaint.cpp ('k') | no next file » | 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 "GrDrawTarget.h" 10 #include "GrDrawTarget.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 GrTexture** gammaTexture) { 162 GrTexture** gammaTexture) {
163 if (NULL == *gammaTexture) { 163 if (NULL == *gammaTexture) {
164 int width, height; 164 int width, height;
165 size_t size; 165 size_t size;
166 166
167 #ifdef SK_GAMMA_CONTRAST 167 #ifdef SK_GAMMA_CONTRAST
168 SkScalar contrast = SK_GAMMA_CONTRAST; 168 SkScalar contrast = SK_GAMMA_CONTRAST;
169 #else 169 #else
170 SkScalar contrast = 0.5f; 170 SkScalar contrast = 0.5f;
171 #endif 171 #endif
172 SkScalar paintGamma = deviceProperties.getGamma(); 172 SkScalar paintGamma = deviceProperties.gamma();
173 SkScalar deviceGamma = deviceProperties.getGamma(); 173 SkScalar deviceGamma = deviceProperties.gamma();
174 174
175 size = SkScalerContext::GetGammaLUTSize(contrast, paintGamma, deviceGamm a, 175 size = SkScalerContext::GetGammaLUTSize(contrast, paintGamma, deviceGamm a,
176 &width, &height); 176 &width, &height);
177 177
178 SkAutoTArray<uint8_t> data((int)size); 178 SkAutoTArray<uint8_t> data((int)size);
179 SkScalerContext::GetGammaLUTData(contrast, paintGamma, deviceGamma, data .get()); 179 SkScalerContext::GetGammaLUTData(contrast, paintGamma, deviceGamma, data .get());
180 180
181 // TODO: Update this to use the cache rather than directly creating a te xture. 181 // TODO: Update this to use the cache rather than directly creating a te xture.
182 GrTextureDesc desc; 182 GrTextureDesc desc;
183 desc.fFlags = kDynamicUpdate_GrTextureFlagBit; 183 desc.fFlags = kDynamicUpdate_GrTextureFlagBit;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 351
352 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); 352 uint32_t textureUniqueID = fCurrTexture->getUniqueID();
353 const SkMatrix& ctm = fContext->getMatrix(); 353 const SkMatrix& ctm = fContext->getMatrix();
354 354
355 // set up any flags 355 // set up any flags
356 uint32_t flags = 0; 356 uint32_t flags = 0;
357 flags |= ctm.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0; 357 flags |= ctm.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0;
358 flags |= fUseLCDText ? kUseLCD_DistanceFieldEffectFlag : 0; 358 flags |= fUseLCDText ? kUseLCD_DistanceFieldEffectFlag : 0;
359 flags |= fUseLCDText && ctm.rectStaysRect() ? 359 flags |= fUseLCDText && ctm.rectStaysRect() ?
360 kRectToRect_DistanceFieldEffectFlag : 0; 360 kRectToRect_DistanceFieldEffectFlag : 0;
361 bool useBGR = SkPixelGeometryIsBGR(fDeviceProperties.fPixelGeometry); 361 bool useBGR = SkPixelGeometryIsBGR(fDeviceProperties.pixelGeometry());
362 flags |= fUseLCDText && useBGR ? kBGR_DistanceFieldEffectFlag : 0; 362 flags |= fUseLCDText && useBGR ? kBGR_DistanceFieldEffectFlag : 0;
363 363
364 // see if we need to create a new effect 364 // see if we need to create a new effect
365 if (textureUniqueID != fEffectTextureUniqueID || 365 if (textureUniqueID != fEffectTextureUniqueID ||
366 filteredColor != fEffectColor || 366 filteredColor != fEffectColor ||
367 flags != fEffectFlags) { 367 flags != fEffectFlags) {
368 if (fUseLCDText) { 368 if (fUseLCDText) {
369 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol or); 369 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol or);
370 fCachedGeometryProcessor.reset(GrDistanceFieldLCDTextureEffect::Crea te(fCurrTexture, 370 fCachedGeometryProcessor.reset(GrDistanceFieldLCDTextureEffect::Crea te(fCurrTexture,
371 params, 371 params,
372 fGammaTexture, 372 fGammaTexture,
373 gammaParams, 373 gammaParams,
374 colorNoPreMul, 374 colorNoPreMul,
375 flags)); 375 flags));
376 } else { 376 } else {
377 #ifdef SK_GAMMA_APPLY_TO_A8 377 #ifdef SK_GAMMA_APPLY_TO_A8
378 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDevicePropertie s.getGamma(), 378 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDevicePropertie s.gamma(),
379 filteredColor); 379 filteredColor);
380 fCachedGeometryProcessor.reset(GrDistanceFieldTextureEffect::Create( fCurrTexture, 380 fCachedGeometryProcessor.reset(GrDistanceFieldTextureEffect::Create( fCurrTexture,
381 params, 381 params,
382 fGammaTexture, 382 fGammaTexture,
383 gammaParams, 383 gammaParams,
384 lum/255.f, 384 lum/255.f,
385 flags)); 385 flags));
386 #else 386 #else
387 fCachedGeometryProcessor.reset(GrDistanceFieldTextureEffect::Create( fCurrTexture, 387 fCachedGeometryProcessor.reset(GrDistanceFieldTextureEffect::Create( fCurrTexture,
388 params, flags)); 388 params, flags));
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 fVertexBounds.setLargestInverted(); 667 fVertexBounds.setLargestInverted();
668 } 668 }
669 } 669 }
670 670
671 inline void GrDistanceFieldTextContext::finish() { 671 inline void GrDistanceFieldTextContext::finish() {
672 this->flush(); 672 this->flush();
673 673
674 GrTextContext::finish(); 674 GrTextContext::finish();
675 } 675 }
676 676
OLDNEW
« no previous file with comments | « src/core/SkPaint.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698