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 "GrDrawContext.h" | 10 #include "GrDrawContext.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 paint1.addColorFragmentProcessor(pmToUPM1); | 224 paint1.addColorFragmentProcessor(pmToUPM1); |
225 | 225 |
226 | 226 |
227 SkAutoTUnref<GrDrawContext> readDrawContext( | 227 SkAutoTUnref<GrDrawContext> readDrawContext( |
228 context->drawContext(readTex->asRenderTarget
())); | 228 context->drawContext(readTex->asRenderTarget
())); |
229 if (!readDrawContext) { | 229 if (!readDrawContext) { |
230 failed = true; | 230 failed = true; |
231 break; | 231 break; |
232 } | 232 } |
233 | 233 |
234 readDrawContext->drawNonAARectToRect(GrClip::WideOpen(), | 234 readDrawContext->fillRectToRect(GrClip::WideOpen(), |
235 paint1, | 235 paint1, |
236 SkMatrix::I(), | 236 SkMatrix::I(), |
237 kDstRect, | 237 kDstRect, |
238 kSrcRect); | 238 kSrcRect); |
239 | 239 |
240 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead)
; | 240 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead)
; |
241 | 241 |
242 paint2.addColorFragmentProcessor(upmToPM); | 242 paint2.addColorFragmentProcessor(upmToPM); |
243 | 243 |
244 SkAutoTUnref<GrDrawContext> tempDrawContext( | 244 SkAutoTUnref<GrDrawContext> tempDrawContext( |
245 context->drawContext(tempTex->asRenderTarget
())); | 245 context->drawContext(tempTex->asRenderTarget
())); |
246 if (!tempDrawContext) { | 246 if (!tempDrawContext) { |
247 failed = true; | 247 failed = true; |
248 break; | 248 break; |
249 } | 249 } |
250 tempDrawContext->drawNonAARectToRect(GrClip::WideOpen(), | 250 tempDrawContext->fillRectToRect(GrClip::WideOpen(), |
251 paint2, | 251 paint2, |
252 SkMatrix::I(), | 252 SkMatrix::I(), |
253 kDstRect, | 253 kDstRect, |
254 kSrcRect); | 254 kSrcRect); |
255 | 255 |
256 paint3.addColorFragmentProcessor(pmToUPM2); | 256 paint3.addColorFragmentProcessor(pmToUPM2); |
257 | 257 |
258 readDrawContext.reset(context->drawContext(readTex->asRenderTarget())); | 258 readDrawContext.reset(context->drawContext(readTex->asRenderTarget())); |
259 if (!readDrawContext) { | 259 if (!readDrawContext) { |
260 failed = true; | 260 failed = true; |
261 break; | 261 break; |
262 } | 262 } |
263 | 263 |
264 readDrawContext->drawNonAARectToRect(GrClip::WideOpen(), | 264 readDrawContext->fillRectToRect(GrClip::WideOpen(), |
265 paint3, | 265 paint3, |
266 SkMatrix::I(), | 266 SkMatrix::I(), |
267 kDstRect, | 267 kDstRect, |
268 kSrcRect); | 268 kSrcRect); |
269 | 269 |
270 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead
); | 270 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead
); |
271 | 271 |
272 failed = false; | 272 failed = false; |
273 for (int y = 0; y < 256 && !failed; ++y) { | 273 for (int y = 0; y < 256 && !failed; ++y) { |
274 for (int x = 0; x <= y; ++x) { | 274 for (int x = 0; x <= y; ++x) { |
275 if (firstRead[256 * y + x] != secondRead[256 * y + x]) { | 275 if (firstRead[256 * y + x] != secondRead[256 * y + x]) { |
276 failed = true; | 276 failed = true; |
277 break; | 277 break; |
278 } | 278 } |
(...skipping 18 matching lines...) Expand all Loading... |
297 } else { | 297 } else { |
298 if (kRGBA_8888_GrPixelConfig != texture->config() && | 298 if (kRGBA_8888_GrPixelConfig != texture->config() && |
299 kBGRA_8888_GrPixelConfig != texture->config() && | 299 kBGRA_8888_GrPixelConfig != texture->config() && |
300 kNone_PMConversion != pmConversion) { | 300 kNone_PMConversion != pmConversion) { |
301 // The PM conversions assume colors are 0..255 | 301 // The PM conversions assume colors are 0..255 |
302 return nullptr; | 302 return nullptr; |
303 } | 303 } |
304 return new GrConfigConversionEffect(texture, swapRedAndBlue, pmConversio
n, matrix); | 304 return new GrConfigConversionEffect(texture, swapRedAndBlue, pmConversio
n, matrix); |
305 } | 305 } |
306 } | 306 } |
OLD | NEW |