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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 SkAutoTUnref<GrFragmentProcessor> pmToUPM1(new GrConfigConversionEffect( | 219 SkAutoTUnref<GrFragmentProcessor> pmToUPM1(new GrConfigConversionEffect( |
220 paint1.getProcessorDataManager(), dataTex, false, *pmToUPMRule,
SkMatrix::I())); | 220 paint1.getProcessorDataManager(), dataTex, false, *pmToUPMRule,
SkMatrix::I())); |
221 SkAutoTUnref<GrFragmentProcessor> upmToPM(new GrConfigConversionEffect( | 221 SkAutoTUnref<GrFragmentProcessor> upmToPM(new GrConfigConversionEffect( |
222 paint2.getProcessorDataManager(), readTex, false, *upmToPMRule,
SkMatrix::I())); | 222 paint2.getProcessorDataManager(), readTex, false, *upmToPMRule,
SkMatrix::I())); |
223 SkAutoTUnref<GrFragmentProcessor> pmToUPM2(new GrConfigConversionEffect( | 223 SkAutoTUnref<GrFragmentProcessor> pmToUPM2(new GrConfigConversionEffect( |
224 paint3.getProcessorDataManager(), tempTex, false, *pmToUPMRule,
SkMatrix::I())); | 224 paint3.getProcessorDataManager(), tempTex, false, *pmToUPMRule,
SkMatrix::I())); |
225 | 225 |
226 paint1.addColorFragmentProcessor(pmToUPM1); | 226 paint1.addColorFragmentProcessor(pmToUPM1); |
227 | 227 |
228 | 228 |
229 GrDrawContext* readDrawContext = context->drawContext(); | 229 SkAutoTUnref<GrDrawContext> readDrawContext(context->drawContext()); |
230 if (!readDrawContext) { | 230 if (!readDrawContext) { |
231 failed = true; | 231 failed = true; |
232 break; | 232 break; |
233 } | 233 } |
234 | 234 |
235 readDrawContext->drawNonAARectToRect(readTex->asRenderTarget(), | 235 readDrawContext->drawNonAARectToRect(readTex->asRenderTarget(), |
236 GrClip::WideOpen(), | 236 GrClip::WideOpen(), |
237 paint1, | 237 paint1, |
238 SkMatrix::I(), | 238 SkMatrix::I(), |
239 kDstRect, | 239 kDstRect, |
240 kSrcRect); | 240 kSrcRect); |
241 | 241 |
242 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead)
; | 242 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead)
; |
243 | 243 |
244 paint2.addColorFragmentProcessor(upmToPM); | 244 paint2.addColorFragmentProcessor(upmToPM); |
245 | 245 |
246 GrDrawContext* tempDrawContext = context->drawContext(); | 246 SkAutoTUnref<GrDrawContext> tempDrawContext(context->drawContext()); |
247 if (!tempDrawContext) { | 247 if (!tempDrawContext) { |
248 failed = true; | 248 failed = true; |
249 break; | 249 break; |
250 } | 250 } |
251 tempDrawContext->drawNonAARectToRect(tempTex->asRenderTarget(), | 251 tempDrawContext->drawNonAARectToRect(tempTex->asRenderTarget(), |
252 GrClip::WideOpen(), | 252 GrClip::WideOpen(), |
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 | 259 |
260 readDrawContext = context->drawContext(); | 260 readDrawContext.reset(context->drawContext()); |
261 if (!readDrawContext) { | 261 if (!readDrawContext) { |
262 failed = true; | 262 failed = true; |
263 break; | 263 break; |
264 } | 264 } |
265 | 265 |
266 readDrawContext->drawNonAARectToRect(readTex->asRenderTarget(), | 266 readDrawContext->drawNonAARectToRect(readTex->asRenderTarget(), |
267 GrClip::WideOpen(), | 267 GrClip::WideOpen(), |
268 paint3, | 268 paint3, |
269 SkMatrix::I(), | 269 SkMatrix::I(), |
270 kDstRect, | 270 kDstRect, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(procDataManager, texture, swapRedAnd
Blue, pmConversion, | 308 return new GrConfigConversionEffect(procDataManager, texture, swapRedAnd
Blue, pmConversion, |
309 matrix); | 309 matrix); |
310 } | 310 } |
311 } | 311 } |
OLD | NEW |