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 = SkPixelGeometryIsBGR(fDeviceProperties.fPixelGeometry); |
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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 GrTexture** gammaTexture) { | 494 GrTexture** gammaTexture) { |
496 if (NULL == *gammaTexture) { | 495 if (NULL == *gammaTexture) { |
497 int width, height; | 496 int width, height; |
498 size_t size; | 497 size_t size; |
499 | 498 |
500 #ifdef SK_GAMMA_CONTRAST | 499 #ifdef SK_GAMMA_CONTRAST |
501 SkScalar contrast = SK_GAMMA_CONTRAST; | 500 SkScalar contrast = SK_GAMMA_CONTRAST; |
502 #else | 501 #else |
503 SkScalar contrast = 0.5f; | 502 SkScalar contrast = 0.5f; |
504 #endif | 503 #endif |
505 SkScalar paintGamma = deviceProperties.fGamma; | 504 SkScalar paintGamma = deviceProperties.getGamma(); |
506 SkScalar deviceGamma = deviceProperties.fGamma; | 505 SkScalar deviceGamma = deviceProperties.getGamma(); |
507 | 506 |
508 size = SkScalerContext::GetGammaLUTSize(contrast, paintGamma, deviceGamm
a, | 507 size = SkScalerContext::GetGammaLUTSize(contrast, paintGamma, deviceGamm
a, |
509 &width, &height); | 508 &width, &height); |
510 | 509 |
511 SkAutoTArray<uint8_t> data((int)size); | 510 SkAutoTArray<uint8_t> data((int)size); |
512 SkScalerContext::GetGammaLUTData(contrast, paintGamma, deviceGamma, data
.get()); | 511 SkScalerContext::GetGammaLUTData(contrast, paintGamma, deviceGamma, data
.get()); |
513 | 512 |
514 // TODO: Update this to use the cache rather than directly creating a te
xture. | 513 // TODO: Update this to use the cache rather than directly creating a te
xture. |
515 GrTextureDesc desc; | 514 GrTextureDesc desc; |
516 desc.fFlags = kDynamicUpdate_GrTextureFlagBit; | 515 desc.fFlags = kDynamicUpdate_GrTextureFlagBit; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 SkScalarToFixed(x) - (glyph.fAdvanceX >> a
lignShift), | 663 SkScalarToFixed(x) - (glyph.fAdvanceX >> a
lignShift), |
665 SkScalarToFixed(y) - (glyph.fAdvanceY >> a
lignShift), | 664 SkScalarToFixed(y) - (glyph.fAdvanceY >> a
lignShift), |
666 fontScaler); | 665 fontScaler); |
667 } | 666 } |
668 pos += scalarsPerPosition; | 667 pos += scalarsPerPosition; |
669 } | 668 } |
670 } | 669 } |
671 | 670 |
672 this->finish(); | 671 this->finish(); |
673 } | 672 } |
OLD | NEW |