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

Side by Side Diff: src/effects/SkXfermodeImageFilter.cpp

Issue 2359443003: Fix some GPU image filter code to preserve precision and color space (Closed)
Patch Set: Created 4 years, 3 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 2013 The Android Open Source Project 2 * Copyright 2013 The Android Open Source Project
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 "SkXfermodeImageFilter.h" 8 #include "SkXfermodeImageFilter.h"
9 9
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkColorPriv.h" 11 #include "SkColorPriv.h"
12 #include "SkReadBuffer.h" 12 #include "SkReadBuffer.h"
13 #include "SkSpecialImage.h" 13 #include "SkSpecialImage.h"
14 #include "SkSpecialSurface.h" 14 #include "SkSpecialSurface.h"
15 #include "SkWriteBuffer.h" 15 #include "SkWriteBuffer.h"
16 #include "SkXfermode.h" 16 #include "SkXfermode.h"
17 #if SK_SUPPORT_GPU 17 #if SK_SUPPORT_GPU
18 #include "GrContext.h" 18 #include "GrContext.h"
19 #include "GrDrawContext.h" 19 #include "GrDrawContext.h"
20 #include "effects/GrConstColorProcessor.h" 20 #include "effects/GrConstColorProcessor.h"
21 #include "effects/GrTextureDomain.h" 21 #include "effects/GrTextureDomain.h"
22 #include "effects/GrSimpleTextureEffect.h" 22 #include "effects/GrSimpleTextureEffect.h"
23 #include "SkGr.h" 23 #include "SkGr.h"
24 #include "SkGrPriv.h"
24 #endif 25 #endif
25 26
26 /////////////////////////////////////////////////////////////////////////////// 27 ///////////////////////////////////////////////////////////////////////////////
27 28
28 sk_sp<SkImageFilter> SkXfermodeImageFilter::Make(sk_sp<SkXfermode> mode, 29 sk_sp<SkImageFilter> SkXfermodeImageFilter::Make(sk_sp<SkXfermode> mode,
29 sk_sp<SkImageFilter> background , 30 sk_sp<SkImageFilter> background ,
30 sk_sp<SkImageFilter> foreground , 31 sk_sp<SkImageFilter> foreground ,
31 const CropRect* cropRect) { 32 const CropRect* cropRect) {
32 sk_sp<SkImageFilter> inputs[2] = { std::move(background), std::move(foregrou nd) }; 33 sk_sp<SkImageFilter> inputs[2] = { std::move(background), std::move(foregrou nd) };
33 return sk_sp<SkImageFilter>(new SkXfermodeImageFilter(mode, inputs, cropRect )); 34 return sk_sp<SkImageFilter>(new SkXfermodeImageFilter(mode, inputs, cropRect ));
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // A null 'xferFP' here means kSrc_Mode was used in which case we can ju st proceed 234 // A null 'xferFP' here means kSrc_Mode was used in which case we can ju st proceed
234 if (xferFP) { 235 if (xferFP) {
235 paint.addColorFragmentProcessor(std::move(xferFP)); 236 paint.addColorFragmentProcessor(std::move(xferFP));
236 } 237 }
237 } else { 238 } else {
238 paint.addColorFragmentProcessor(std::move(bgFP)); 239 paint.addColorFragmentProcessor(std::move(bgFP));
239 } 240 }
240 241
241 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); 242 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
242 243
243 sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kApp rox, 244 sk_sp<GrDrawContext> drawContext(
244 bounds.width(), bo unds.height(), 245 context->makeDrawContext(SkBackingFit::kApprox, bounds.width(), bounds.h eight(),
245 kSkia8888_GrPixelC onfig, 246 GrRenderableConfigForColorSpace(source->getColo rSpace()),
246 sk_ref_sp(source-> getColorSpace()))); 247 sk_ref_sp(source->getColorSpace())));
247 if (!drawContext) { 248 if (!drawContext) {
248 return nullptr; 249 return nullptr;
249 } 250 }
250 paint.setAllowSRGBInputs(drawContext->isGammaCorrect()); 251 paint.setAllowSRGBInputs(drawContext->isGammaCorrect());
251 252
252 SkMatrix matrix; 253 SkMatrix matrix;
253 matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top ())); 254 matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top ()));
254 drawContext->drawRect(GrNoClip(), paint, matrix, SkRect::Make(bounds)); 255 drawContext->drawRect(GrNoClip(), paint, matrix, SkRect::Make(bounds));
255 256
256 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.he ight()), 257 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.he ight()),
257 kNeedNewImageUniqueID_SpecialImage, 258 kNeedNewImageUniqueID_SpecialImage,
258 drawContext->asTexture(), 259 drawContext->asTexture(),
259 sk_ref_sp(drawContext->getColorSpace())); 260 sk_ref_sp(drawContext->getColorSpace()));
260 } 261 }
261 262
262 #endif 263 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698