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 "GrTBackendProcessorFactory.h" | 10 #include "GrTBackendProcessorFactory.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 for (int y = 0; y < 256; ++y) { | 167 for (int y = 0; y < 256; ++y) { |
168 for (int x = 0; x < 256; ++x) { | 168 for (int x = 0; x < 256; ++x) { |
169 uint8_t* color = reinterpret_cast<uint8_t*>(&srcData[256*y + x]); | 169 uint8_t* color = reinterpret_cast<uint8_t*>(&srcData[256*y + x]); |
170 color[3] = y; | 170 color[3] = y; |
171 color[2] = SkTMin(x, y); | 171 color[2] = SkTMin(x, y); |
172 color[1] = SkTMin(x, y); | 172 color[1] = SkTMin(x, y); |
173 color[0] = SkTMin(x, y); | 173 color[0] = SkTMin(x, y); |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 GrTextureDesc desc; | 177 GrSurfaceDesc desc; |
178 desc.fFlags = kRenderTarget_GrTextureFlagBit | | 178 desc.fFlags = kRenderTarget_GrSurfaceFlag | |
179 kNoStencil_GrTextureFlagBit; | 179 kNoStencil_GrSurfaceFlag; |
180 desc.fWidth = 256; | 180 desc.fWidth = 256; |
181 desc.fHeight = 256; | 181 desc.fHeight = 256; |
182 desc.fConfig = kRGBA_8888_GrPixelConfig; | 182 desc.fConfig = kRGBA_8888_GrPixelConfig; |
183 | 183 |
184 SkAutoTUnref<GrTexture> readTex(context->createUncachedTexture(desc, NULL, 0
)); | 184 SkAutoTUnref<GrTexture> readTex(context->createUncachedTexture(desc, NULL, 0
)); |
185 if (!readTex.get()) { | 185 if (!readTex.get()) { |
186 return; | 186 return; |
187 } | 187 } |
188 SkAutoTUnref<GrTexture> tempTex(context->createUncachedTexture(desc, NULL, 0
)); | 188 SkAutoTUnref<GrTexture> tempTex(context->createUncachedTexture(desc, NULL, 0
)); |
189 if (!tempTex.get()) { | 189 if (!tempTex.get()) { |
190 return; | 190 return; |
191 } | 191 } |
192 desc.fFlags = kNone_GrTextureFlags; | 192 desc.fFlags = kNone_GrSurfaceFlags; |
193 SkAutoTUnref<GrTexture> dataTex(context->createUncachedTexture(desc, data, 0
)); | 193 SkAutoTUnref<GrTexture> dataTex(context->createUncachedTexture(desc, data, 0
)); |
194 if (!dataTex.get()) { | 194 if (!dataTex.get()) { |
195 return; | 195 return; |
196 } | 196 } |
197 | 197 |
198 static const PMConversion kConversionRules[][2] = { | 198 static const PMConversion kConversionRules[][2] = { |
199 {kDivByAlpha_RoundDown_PMConversion, kMulByAlpha_RoundUp_PMConversion}, | 199 {kDivByAlpha_RoundDown_PMConversion, kMulByAlpha_RoundUp_PMConversion}, |
200 {kDivByAlpha_RoundUp_PMConversion, kMulByAlpha_RoundDown_PMConversion}, | 200 {kDivByAlpha_RoundUp_PMConversion, kMulByAlpha_RoundDown_PMConversion}, |
201 }; | 201 }; |
202 | 202 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 kNone_PMConversion != pmConversion) { | 274 kNone_PMConversion != pmConversion) { |
275 // The PM conversions assume colors are 0..255 | 275 // The PM conversions assume colors are 0..255 |
276 return NULL; | 276 return NULL; |
277 } | 277 } |
278 return SkNEW_ARGS(GrConfigConversionEffect, (texture, | 278 return SkNEW_ARGS(GrConfigConversionEffect, (texture, |
279 swapRedAndBlue, | 279 swapRedAndBlue, |
280 pmConversion, | 280 pmConversion, |
281 matrix)); | 281 matrix)); |
282 } | 282 } |
283 } | 283 } |
OLD | NEW |