OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrConfigConversionEffect.h" | 8 #include "GrConfigConversionEffect.h" |
9 #include "GrContext.h" | 9 #include "GrContext.h" |
10 #include "GrTBackendEffectFactory.h" | 10 #include "GrTBackendEffectFactory.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 uint32_t* srcData = data.get(); | 147 uint32_t* srcData = data.get(); |
148 uint32_t* firstRead = data.get() + 256 * 256; | 148 uint32_t* firstRead = data.get() + 256 * 256; |
149 uint32_t* secondRead = data.get() + 2 * 256 * 256; | 149 uint32_t* secondRead = data.get() + 2 * 256 * 256; |
150 | 150 |
151 // Fill with every possible premultiplied A, color channel value. There will
be 256-y duplicate | 151 // Fill with every possible premultiplied A, color channel value. There will
be 256-y duplicate |
152 // values in row y. We set r,g, and b to the same value since they are handl
ed identically. | 152 // values in row y. We set r,g, and b to the same value since they are handl
ed identically. |
153 for (int y = 0; y < 256; ++y) { | 153 for (int y = 0; y < 256; ++y) { |
154 for (int x = 0; x < 256; ++x) { | 154 for (int x = 0; x < 256; ++x) { |
155 uint8_t* color = reinterpret_cast<uint8_t*>(&srcData[256*y + x]); | 155 uint8_t* color = reinterpret_cast<uint8_t*>(&srcData[256*y + x]); |
156 color[3] = y; | 156 color[3] = y; |
157 color[2] = GrMin(x, y); | 157 color[2] = SkTMin(x, y); |
158 color[1] = GrMin(x, y); | 158 color[1] = SkTMin(x, y); |
159 color[0] = GrMin(x, y); | 159 color[0] = SkTMin(x, y); |
160 } | 160 } |
161 } | 161 } |
162 | 162 |
163 GrTextureDesc desc; | 163 GrTextureDesc desc; |
164 desc.fFlags = kRenderTarget_GrTextureFlagBit | | 164 desc.fFlags = kRenderTarget_GrTextureFlagBit | |
165 kNoStencil_GrTextureFlagBit; | 165 kNoStencil_GrTextureFlagBit; |
166 desc.fWidth = 256; | 166 desc.fWidth = 256; |
167 desc.fHeight = 256; | 167 desc.fHeight = 256; |
168 desc.fConfig = kRGBA_8888_GrPixelConfig; | 168 desc.fConfig = kRGBA_8888_GrPixelConfig; |
169 | 169 |
(...skipping 13 matching lines...) Expand all Loading... |
183 | 183 |
184 static const PMConversion kConversionRules[][2] = { | 184 static const PMConversion kConversionRules[][2] = { |
185 {kDivByAlpha_RoundDown_PMConversion, kMulByAlpha_RoundUp_PMConversion}, | 185 {kDivByAlpha_RoundDown_PMConversion, kMulByAlpha_RoundUp_PMConversion}, |
186 {kDivByAlpha_RoundUp_PMConversion, kMulByAlpha_RoundDown_PMConversion}, | 186 {kDivByAlpha_RoundUp_PMConversion, kMulByAlpha_RoundDown_PMConversion}, |
187 }; | 187 }; |
188 | 188 |
189 GrContext::AutoWideOpenIdentityDraw awoid(context, NULL); | 189 GrContext::AutoWideOpenIdentityDraw awoid(context, NULL); |
190 | 190 |
191 bool failed = true; | 191 bool failed = true; |
192 | 192 |
193 for (size_t i = 0; i < GR_ARRAY_COUNT(kConversionRules) && failed; ++i) { | 193 for (size_t i = 0; i < SK_ARRAY_COUNT(kConversionRules) && failed; ++i) { |
194 *pmToUPMRule = kConversionRules[i][0]; | 194 *pmToUPMRule = kConversionRules[i][0]; |
195 *upmToPMRule = kConversionRules[i][1]; | 195 *upmToPMRule = kConversionRules[i][1]; |
196 | 196 |
197 static const SkRect kDstRect = SkRect::MakeWH(SkIntToScalar(256), SkIntT
oScalar(256)); | 197 static const SkRect kDstRect = SkRect::MakeWH(SkIntToScalar(256), SkIntT
oScalar(256)); |
198 static const SkRect kSrcRect = SkRect::MakeWH(SK_Scalar1, SK_Scalar1); | 198 static const SkRect kSrcRect = SkRect::MakeWH(SK_Scalar1, SK_Scalar1); |
199 // We do a PM->UPM draw from dataTex to readTex and read the data. Then
we do a UPM->PM draw | 199 // We do a PM->UPM draw from dataTex to readTex and read the data. Then
we do a UPM->PM draw |
200 // from readTex to tempTex followed by a PM->UPM draw to readTex and fin
ally read the data. | 200 // from readTex to tempTex followed by a PM->UPM draw to readTex and fin
ally read the data. |
201 // We then verify that two reads produced the same values. | 201 // We then verify that two reads produced the same values. |
202 | 202 |
203 AutoEffectUnref pmToUPM1(SkNEW_ARGS(GrConfigConversionEffect, (dataTex, | 203 AutoEffectUnref pmToUPM1(SkNEW_ARGS(GrConfigConversionEffect, (dataTex, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 // The PM conversions assume colors are 0..255 | 268 // The PM conversions assume colors are 0..255 |
269 return NULL; | 269 return NULL; |
270 } | 270 } |
271 AutoEffectUnref effect(SkNEW_ARGS(GrConfigConversionEffect, (texture, | 271 AutoEffectUnref effect(SkNEW_ARGS(GrConfigConversionEffect, (texture, |
272 swapRedAndB
lue, | 272 swapRedAndB
lue, |
273 pmConversio
n, | 273 pmConversio
n, |
274 matrix))); | 274 matrix))); |
275 return CreateEffectRef(effect); | 275 return CreateEffectRef(effect); |
276 } | 276 } |
277 } | 277 } |
OLD | NEW |