| 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 paint1.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 225 paint1.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
| 226 | 226 |
| 227 | 227 |
| 228 sk_sp<GrDrawContext> readDrawContext( | 228 sk_sp<GrDrawContext> readDrawContext( |
| 229 context->drawContext(sk_ref_sp(readTex->asRe
nderTarget()))); | 229 context->drawContext(sk_ref_sp(readTex->asRe
nderTarget()))); |
| 230 if (!readDrawContext) { | 230 if (!readDrawContext) { |
| 231 failed = true; | 231 failed = true; |
| 232 break; | 232 break; |
| 233 } | 233 } |
| 234 | 234 |
| 235 readDrawContext->fillRectToRect(GrClip::WideOpen(), | 235 readDrawContext->fillRectToRect(GrNoClip(), |
| 236 paint1, | 236 paint1, |
| 237 SkMatrix::I(), | 237 SkMatrix::I(), |
| 238 kDstRect, | 238 kDstRect, |
| 239 kSrcRect); | 239 kSrcRect); |
| 240 | 240 |
| 241 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead)
; | 241 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead)
; |
| 242 | 242 |
| 243 paint2.addColorFragmentProcessor(upmToPM); | 243 paint2.addColorFragmentProcessor(upmToPM); |
| 244 paint2.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 244 paint2.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
| 245 | 245 |
| 246 sk_sp<GrDrawContext> tempDrawContext( | 246 sk_sp<GrDrawContext> tempDrawContext( |
| 247 context->drawContext(sk_ref_sp(tempTex->asRe
nderTarget()))); | 247 context->drawContext(sk_ref_sp(tempTex->asRe
nderTarget()))); |
| 248 if (!tempDrawContext) { | 248 if (!tempDrawContext) { |
| 249 failed = true; | 249 failed = true; |
| 250 break; | 250 break; |
| 251 } | 251 } |
| 252 tempDrawContext->fillRectToRect(GrClip::WideOpen(), | 252 tempDrawContext->fillRectToRect(GrNoClip(), |
| 253 paint2, | 253 paint2, |
| 254 SkMatrix::I(), | 254 SkMatrix::I(), |
| 255 kDstRect, | 255 kDstRect, |
| 256 kSrcRect); | 256 kSrcRect); |
| 257 | 257 |
| 258 paint3.addColorFragmentProcessor(pmToUPM2); | 258 paint3.addColorFragmentProcessor(pmToUPM2); |
| 259 paint3.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 259 paint3.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
| 260 | 260 |
| 261 readDrawContext = context->drawContext(sk_ref_sp(readTex->asRenderTarget
())); | 261 readDrawContext = context->drawContext(sk_ref_sp(readTex->asRenderTarget
())); |
| 262 if (!readDrawContext) { | 262 if (!readDrawContext) { |
| 263 failed = true; | 263 failed = true; |
| 264 break; | 264 break; |
| 265 } | 265 } |
| 266 | 266 |
| 267 readDrawContext->fillRectToRect(GrClip::WideOpen(), | 267 readDrawContext->fillRectToRect(GrNoClip(), |
| 268 paint3, | 268 paint3, |
| 269 SkMatrix::I(), | 269 SkMatrix::I(), |
| 270 kDstRect, | 270 kDstRect, |
| 271 kSrcRect); | 271 kSrcRect); |
| 272 | 272 |
| 273 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead
); | 273 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead
); |
| 274 | 274 |
| 275 failed = false; | 275 failed = false; |
| 276 for (int y = 0; y < 256 && !failed; ++y) { | 276 for (int y = 0; y < 256 && !failed; ++y) { |
| 277 for (int x = 0; x <= y; ++x) { | 277 for (int x = 0; x <= y; ++x) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 301 } else { | 301 } else { |
| 302 if (kRGBA_8888_GrPixelConfig != texture->config() && | 302 if (kRGBA_8888_GrPixelConfig != texture->config() && |
| 303 kBGRA_8888_GrPixelConfig != texture->config() && | 303 kBGRA_8888_GrPixelConfig != texture->config() && |
| 304 kNone_PMConversion != pmConversion) { | 304 kNone_PMConversion != pmConversion) { |
| 305 // The PM conversions assume colors are 0..255 | 305 // The PM conversions assume colors are 0..255 |
| 306 return nullptr; | 306 return nullptr; |
| 307 } | 307 } |
| 308 return new GrConfigConversionEffect(texture, swizzle, pmConversion, matr
ix); | 308 return new GrConfigConversionEffect(texture, swizzle, pmConversion, matr
ix); |
| 309 } | 309 } |
| 310 } | 310 } |
| OLD | NEW |