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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 GrTextureParams gammaParams(SkShader::kClamp_TileMode, GrTextureParams::kNon
e_FilterMode); | 124 GrTextureParams gammaParams(SkShader::kClamp_TileMode, GrTextureParams::kNon
e_FilterMode); |
125 | 125 |
126 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); | 126 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
127 | 127 |
128 // set up any flags | 128 // set up any flags |
129 uint32_t flags = 0; | 129 uint32_t flags = 0; |
130 flags |= fTextMatrix.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag :
0; | 130 flags |= fTextMatrix.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag :
0; |
131 flags |= fUseLCDText ? kUseLCD_DistanceFieldEffectFlag : 0; | 131 flags |= fUseLCDText ? kUseLCD_DistanceFieldEffectFlag : 0; |
132 flags |= fUseLCDText && fTextMatrix.rectStaysRect() ? | 132 flags |= fUseLCDText && fTextMatrix.rectStaysRect() ? |
133 kRectToRect_DistanceFieldEffectFlag : 0; | 133 kRectToRect_DistanceFieldEffectFlag : 0; |
134 bool useBGR = SkDeviceProperties::Geometry::kBGR_Layout == | 134 bool useBGR = fDeviceProperties.useBGR(); |
135 fDeviceProperties.fGeometry.getLayout(); | |
136 flags |= fUseLCDText && useBGR ? kBGR_DistanceFieldEffectFlag : 0; | 135 flags |= fUseLCDText && useBGR ? kBGR_DistanceFieldEffectFlag : 0; |
137 | 136 |
138 // see if we need to create a new effect | 137 // see if we need to create a new effect |
139 if (textureUniqueID != fEffectTextureUniqueID || | 138 if (textureUniqueID != fEffectTextureUniqueID || |
140 filteredColor != fEffectColor || | 139 filteredColor != fEffectColor || |
141 flags != fEffectFlags) { | 140 flags != fEffectFlags) { |
142 if (fUseLCDText) { | 141 if (fUseLCDText) { |
143 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol
or); | 142 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol
or); |
144 fCachedEffect.reset(GrDistanceFieldLCDTextureEffect::Create(fCurrTex
ture, | 143 fCachedEffect.reset(GrDistanceFieldLCDTextureEffect::Create(fCurrTex
ture, |
145 params, | 144 params, |
146 fGammaTe
xture, | 145 fGammaTe
xture, |
147 gammaPar
ams, | 146 gammaPar
ams, |
148 colorNoP
reMul, | 147 colorNoP
reMul, |
149 flags)); | 148 flags)); |
150 } else { | 149 } else { |
151 #ifdef SK_GAMMA_APPLY_TO_A8 | 150 #ifdef SK_GAMMA_APPLY_TO_A8 |
152 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDevicePropertie
s.fGamma, | 151 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDevicePropertie
s.getGamma(), |
153 filteredColor); | 152 filteredColor); |
154 fCachedEffect.reset(GrDistanceFieldTextureEffect::Create(fCurrTextur
e, | 153 fCachedEffect.reset(GrDistanceFieldTextureEffect::Create(fCurrTextur
e, |
155 params, | 154 params, |
156 fGammaTextu
re, | 155 fGammaTextu
re, |
157 gammaParams
, | 156 gammaParams
, |
158 lum/255.f, | 157 lum/255.f, |
159 flags)); | 158 flags)); |
160 #else | 159 #else |
161 fCachedEffect.reset(GrDistanceFieldTextureEffect::Create(fCurrTextur
e, | 160 fCachedEffect.reset(GrDistanceFieldTextureEffect::Create(fCurrTextur
e, |
162 params, fla
gs)); | 161 params, fla
gs)); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 GrTexture** gammaTexture) { | 492 GrTexture** gammaTexture) { |
494 if (NULL == *gammaTexture) { | 493 if (NULL == *gammaTexture) { |
495 int width, height; | 494 int width, height; |
496 size_t size; | 495 size_t size; |
497 | 496 |
498 #ifdef SK_GAMMA_CONTRAST | 497 #ifdef SK_GAMMA_CONTRAST |
499 SkScalar contrast = SK_GAMMA_CONTRAST; | 498 SkScalar contrast = SK_GAMMA_CONTRAST; |
500 #else | 499 #else |
501 SkScalar contrast = 0.5f; | 500 SkScalar contrast = 0.5f; |
502 #endif | 501 #endif |
503 SkScalar paintGamma = deviceProperties.fGamma; | 502 SkScalar paintGamma = deviceProperties.getGamma(); |
504 SkScalar deviceGamma = deviceProperties.fGamma; | 503 SkScalar deviceGamma = deviceProperties.getGamma(); |
505 | 504 |
506 size = SkScalerContext::GetGammaLUTSize(contrast, paintGamma, deviceGamm
a, | 505 size = SkScalerContext::GetGammaLUTSize(contrast, paintGamma, deviceGamm
a, |
507 &width, &height); | 506 &width, &height); |
508 | 507 |
509 SkAutoTArray<uint8_t> data((int)size); | 508 SkAutoTArray<uint8_t> data((int)size); |
510 SkScalerContext::GetGammaLUTData(contrast, paintGamma, deviceGamma, data
.get()); | 509 SkScalerContext::GetGammaLUTData(contrast, paintGamma, deviceGamma, data
.get()); |
511 | 510 |
512 // TODO: Update this to use the cache rather than directly creating a te
xture. | 511 // TODO: Update this to use the cache rather than directly creating a te
xture. |
513 GrTextureDesc desc; | 512 GrTextureDesc desc; |
514 desc.fFlags = kDynamicUpdate_GrTextureFlagBit; | 513 desc.fFlags = kDynamicUpdate_GrTextureFlagBit; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 SkScalarToFixed(x) - (glyph.fAdvanceX >> a
lignShift), | 661 SkScalarToFixed(x) - (glyph.fAdvanceX >> a
lignShift), |
663 SkScalarToFixed(y) - (glyph.fAdvanceY >> a
lignShift), | 662 SkScalarToFixed(y) - (glyph.fAdvanceY >> a
lignShift), |
664 fontScaler); | 663 fontScaler); |
665 } | 664 } |
666 pos += scalarsPerPosition; | 665 pos += scalarsPerPosition; |
667 } | 666 } |
668 } | 667 } |
669 | 668 |
670 this->finish(); | 669 this->finish(); |
671 } | 670 } |
OLD | NEW |