| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 GrPaint paint2; | 216 GrPaint paint2; |
| 217 GrPaint paint3; | 217 GrPaint paint3; |
| 218 SkAutoTUnref<GrFragmentProcessor> pmToUPM1(new GrConfigConversionEffect( | 218 SkAutoTUnref<GrFragmentProcessor> pmToUPM1(new GrConfigConversionEffect( |
| 219 dataTex, false, *pmToUPMRule, SkMatrix::I())); | 219 dataTex, false, *pmToUPMRule, SkMatrix::I())); |
| 220 SkAutoTUnref<GrFragmentProcessor> upmToPM(new GrConfigConversionEffect( | 220 SkAutoTUnref<GrFragmentProcessor> upmToPM(new GrConfigConversionEffect( |
| 221 readTex, false, *upmToPMRule, SkMatrix::I())); | 221 readTex, false, *upmToPMRule, SkMatrix::I())); |
| 222 SkAutoTUnref<GrFragmentProcessor> pmToUPM2(new GrConfigConversionEffect( | 222 SkAutoTUnref<GrFragmentProcessor> pmToUPM2(new GrConfigConversionEffect( |
| 223 tempTex, false, *pmToUPMRule, SkMatrix::I())); | 223 tempTex, false, *pmToUPMRule, SkMatrix::I())); |
| 224 | 224 |
| 225 paint1.addColorFragmentProcessor(pmToUPM1); | 225 paint1.addColorFragmentProcessor(pmToUPM1); |
| 226 paint1.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
| 226 | 227 |
| 227 | 228 |
| 228 SkAutoTUnref<GrDrawContext> readDrawContext( | 229 SkAutoTUnref<GrDrawContext> readDrawContext( |
| 229 context->drawContext(readTex->asRenderTarget
())); | 230 context->drawContext(readTex->asRenderTarget
())); |
| 230 if (!readDrawContext) { | 231 if (!readDrawContext) { |
| 231 failed = true; | 232 failed = true; |
| 232 break; | 233 break; |
| 233 } | 234 } |
| 234 | 235 |
| 235 readDrawContext->fillRectToRect(GrClip::WideOpen(), | 236 readDrawContext->fillRectToRect(GrClip::WideOpen(), |
| 236 paint1, | 237 paint1, |
| 237 SkMatrix::I(), | 238 SkMatrix::I(), |
| 238 kDstRect, | 239 kDstRect, |
| 239 kSrcRect); | 240 kSrcRect); |
| 240 | 241 |
| 241 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead)
; | 242 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead)
; |
| 242 | 243 |
| 243 paint2.addColorFragmentProcessor(upmToPM); | 244 paint2.addColorFragmentProcessor(upmToPM); |
| 245 paint2.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
| 244 | 246 |
| 245 SkAutoTUnref<GrDrawContext> tempDrawContext( | 247 SkAutoTUnref<GrDrawContext> tempDrawContext( |
| 246 context->drawContext(tempTex->asRenderTarget
())); | 248 context->drawContext(tempTex->asRenderTarget
())); |
| 247 if (!tempDrawContext) { | 249 if (!tempDrawContext) { |
| 248 failed = true; | 250 failed = true; |
| 249 break; | 251 break; |
| 250 } | 252 } |
| 251 tempDrawContext->fillRectToRect(GrClip::WideOpen(), | 253 tempDrawContext->fillRectToRect(GrClip::WideOpen(), |
| 252 paint2, | 254 paint2, |
| 253 SkMatrix::I(), | 255 SkMatrix::I(), |
| 254 kDstRect, | 256 kDstRect, |
| 255 kSrcRect); | 257 kSrcRect); |
| 256 | 258 |
| 257 paint3.addColorFragmentProcessor(pmToUPM2); | 259 paint3.addColorFragmentProcessor(pmToUPM2); |
| 260 paint3.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
| 258 | 261 |
| 259 readDrawContext.reset(context->drawContext(readTex->asRenderTarget())); | 262 readDrawContext.reset(context->drawContext(readTex->asRenderTarget())); |
| 260 if (!readDrawContext) { | 263 if (!readDrawContext) { |
| 261 failed = true; | 264 failed = true; |
| 262 break; | 265 break; |
| 263 } | 266 } |
| 264 | 267 |
| 265 readDrawContext->fillRectToRect(GrClip::WideOpen(), | 268 readDrawContext->fillRectToRect(GrClip::WideOpen(), |
| 266 paint3, | 269 paint3, |
| 267 SkMatrix::I(), | 270 SkMatrix::I(), |
| (...skipping 30 matching lines...) Expand all Loading... |
| 298 } else { | 301 } else { |
| 299 if (kRGBA_8888_GrPixelConfig != texture->config() && | 302 if (kRGBA_8888_GrPixelConfig != texture->config() && |
| 300 kBGRA_8888_GrPixelConfig != texture->config() && | 303 kBGRA_8888_GrPixelConfig != texture->config() && |
| 301 kNone_PMConversion != pmConversion) { | 304 kNone_PMConversion != pmConversion) { |
| 302 // The PM conversions assume colors are 0..255 | 305 // The PM conversions assume colors are 0..255 |
| 303 return nullptr; | 306 return nullptr; |
| 304 } | 307 } |
| 305 return new GrConfigConversionEffect(texture, swapRedAndBlue, pmConversio
n, matrix); | 308 return new GrConfigConversionEffect(texture, swapRedAndBlue, pmConversio
n, matrix); |
| 306 } | 309 } |
| 307 } | 310 } |
| OLD | NEW |