Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(932)

Side by Side Diff: src/gpu/effects/GrConfigConversionEffect.cpp

Issue 1918003003: Bring sk_sp to GrDrawContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 dataTex, GrSwizzle::RGBA(), *pmToUPMRule, SkMatrix::I())); 218 dataTex, GrSwizzle::RGBA(), *pmToUPMRule, SkMatrix::I()));
219 SkAutoTUnref<GrFragmentProcessor> upmToPM(new GrConfigConversionEffect( 219 SkAutoTUnref<GrFragmentProcessor> upmToPM(new GrConfigConversionEffect(
220 readTex, GrSwizzle::RGBA(), *upmToPMRule, SkMatrix::I())); 220 readTex, GrSwizzle::RGBA(), *upmToPMRule, SkMatrix::I()));
221 SkAutoTUnref<GrFragmentProcessor> pmToUPM2(new GrConfigConversionEffect( 221 SkAutoTUnref<GrFragmentProcessor> pmToUPM2(new GrConfigConversionEffect(
222 tempTex, GrSwizzle::RGBA(), *pmToUPMRule, SkMatrix::I())); 222 tempTex, GrSwizzle::RGBA(), *pmToUPMRule, SkMatrix::I()));
223 223
224 paint1.addColorFragmentProcessor(pmToUPM1); 224 paint1.addColorFragmentProcessor(pmToUPM1);
225 paint1.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); 225 paint1.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
226 226
227 227
228 SkAutoTUnref<GrDrawContext> readDrawContext( 228 sk_sp<GrDrawContext> readDrawContext(
229 context->drawContext(readTex->asRenderTarget ())); 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(GrClip::WideOpen(),
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 SkAutoTUnref<GrDrawContext> tempDrawContext( 246 sk_sp<GrDrawContext> tempDrawContext(
247 context->drawContext(tempTex->asRenderTarget ())); 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(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 paint3.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); 259 paint3.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
260 260
261 readDrawContext.reset(context->drawContext(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(GrClip::WideOpen(),
268 paint3, 268 paint3,
269 SkMatrix::I(), 269 SkMatrix::I(),
270 kDstRect, 270 kDstRect,
271 kSrcRect); 271 kSrcRect);
(...skipping 29 matching lines...) Expand all
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698