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

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

Issue 2215323003: Start using RenderTargetProxy (omnibus) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update Created 4 years, 1 month 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
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | src/gpu/GrBlurUtils.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "SkArithmeticModePriv.h" 9 #include "SkArithmeticModePriv.h"
10 10
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "SkColorPriv.h" 12 #include "SkColorPriv.h"
13 #include "SkReadBuffer.h" 13 #include "SkReadBuffer.h"
14 #include "SkSpecialImage.h" 14 #include "SkSpecialImage.h"
15 #include "SkSpecialSurface.h" 15 #include "SkSpecialSurface.h"
16 #include "SkWriteBuffer.h" 16 #include "SkWriteBuffer.h"
17 #include "SkXfermode.h" 17 #include "SkXfermode.h"
18 #if SK_SUPPORT_GPU 18 #if SK_SUPPORT_GPU
19 #include "GrContext.h" 19 #include "GrContext.h"
20 #include "GrRenderTargetContext.h" 20 #include "GrRenderTargetContext.h"
21 #include "GrTextureProxy.h"
21 #include "effects/GrConstColorProcessor.h" 22 #include "effects/GrConstColorProcessor.h"
22 #include "effects/GrTextureDomain.h" 23 #include "effects/GrTextureDomain.h"
23 #include "effects/GrSimpleTextureEffect.h" 24 #include "effects/GrSimpleTextureEffect.h"
24 #include "SkArithmeticMode_gpu.h" 25 #include "SkArithmeticMode_gpu.h"
25 #include "SkGr.h" 26 #include "SkGr.h"
26 #include "SkGrPriv.h" 27 #include "SkGrPriv.h"
27 #endif 28 #endif
28 29
29 class SkXfermodeImageFilter_Base : public SkImageFilter { 30 class SkXfermodeImageFilter_Base : public SkImageFilter {
30 public: 31 public:
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 GrPaint paint; 247 GrPaint paint;
247 sk_sp<GrFragmentProcessor> bgFP; 248 sk_sp<GrFragmentProcessor> bgFP;
248 249
249 if (backgroundTex) { 250 if (backgroundTex) {
250 SkMatrix backgroundMatrix; 251 SkMatrix backgroundMatrix;
251 backgroundMatrix.setIDiv(backgroundTex->width(), backgroundTex->height() ); 252 backgroundMatrix.setIDiv(backgroundTex->width(), backgroundTex->height() );
252 backgroundMatrix.preTranslate(-SkIntToScalar(backgroundOffset.fX), 253 backgroundMatrix.preTranslate(-SkIntToScalar(backgroundOffset.fX),
253 -SkIntToScalar(backgroundOffset.fY)); 254 -SkIntToScalar(backgroundOffset.fY));
254 bgFP = GrTextureDomainEffect::Make( 255 bgFP = GrTextureDomainEffect::Make(
255 backgroundTex.get(), nullptr, backgroundMatrix, 256 backgroundTex.get(), nullptr, backgroundMatrix,
256 GrTextureDomain::MakeTexelDomain(backgroundTex.get() , 257 GrTextureDomain::MakeTexelDomain(backgroundTex->widt h(),
258 backgroundTex->heig ht(),
257 background->subset( )), 259 background->subset( )),
258 GrTextureDomain::kDecal_Mode, 260 GrTextureDomain::kDecal_Mode,
259 GrTextureParams::kNone_FilterMode); 261 GrTextureParams::kNone_FilterMode);
260 } else { 262 } else {
261 bgFP = GrConstColorProcessor::Make(GrColor4f::TransparentBlack(), 263 bgFP = GrConstColorProcessor::Make(GrColor4f::TransparentBlack(),
262 GrConstColorProcessor::kIgnore_InputM ode); 264 GrConstColorProcessor::kIgnore_InputM ode);
263 } 265 }
264 266
265 if (foregroundTex) { 267 if (foregroundTex) {
266 SkMatrix foregroundMatrix; 268 SkMatrix foregroundMatrix;
267 foregroundMatrix.setIDiv(foregroundTex->width(), foregroundTex->height() ); 269 foregroundMatrix.setIDiv(foregroundTex->width(), foregroundTex->height() );
268 foregroundMatrix.preTranslate(-SkIntToScalar(foregroundOffset.fX), 270 foregroundMatrix.preTranslate(-SkIntToScalar(foregroundOffset.fX),
269 -SkIntToScalar(foregroundOffset.fY)); 271 -SkIntToScalar(foregroundOffset.fY));
270 272
271 sk_sp<GrFragmentProcessor> foregroundFP; 273 sk_sp<GrFragmentProcessor> foregroundFP;
272 274
273 foregroundFP = GrTextureDomainEffect::Make( 275 foregroundFP = GrTextureDomainEffect::Make(
274 foregroundTex.get(), nullptr, foregroundMatrix, 276 foregroundTex.get(), nullptr, foregroundMatrix,
275 GrTextureDomain::MakeTexelDomain(foregroundTex.get() , 277 GrTextureDomain::MakeTexelDomain(foregroundTex->widt h(),
278 foregroundTex->heig ht(),
276 foreground->subset( )), 279 foreground->subset( )),
277 GrTextureDomain::kDecal_Mode, 280 GrTextureDomain::kDecal_Mode,
278 GrTextureParams::kNone_FilterMode); 281 GrTextureParams::kNone_FilterMode);
279 282
280 paint.addColorFragmentProcessor(std::move(foregroundFP)); 283 paint.addColorFragmentProcessor(std::move(foregroundFP));
281 284
282 sk_sp<GrFragmentProcessor> xferFP = this->makeFGFrag(bgFP); 285 sk_sp<GrFragmentProcessor> xferFP = this->makeFGFrag(bgFP);
283 286
284 // A null 'xferFP' here means kSrc_Mode was used in which case we can ju st proceed 287 // A null 'xferFP' here means kSrc_Mode was used in which case we can ju st proceed
285 if (xferFP) { 288 if (xferFP) {
286 paint.addColorFragmentProcessor(std::move(xferFP)); 289 paint.addColorFragmentProcessor(std::move(xferFP));
287 } 290 }
288 } else { 291 } else {
289 paint.addColorFragmentProcessor(std::move(bgFP)); 292 paint.addColorFragmentProcessor(std::move(bgFP));
290 } 293 }
291 294
292 paint.setPorterDuffXPFactory(SkBlendMode::kSrc); 295 paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
293 296
294 sk_sp<GrRenderTargetContext> renderTargetContext(context->makeRenderTargetCo ntext( 297 sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRender TargetContext(
295 SkBackingFit::kApprox, bounds.width(), bounds.height(), 298 SkBackingFit::kApprox, bounds.width(), bounds.height(),
296 GrRenderableConfigForColorSpace(outputProperties.colorSpace()), 299 GrRenderableConfigForColorSpace(outputProperties.colorSpace()),
297 sk_ref_sp(outputProperties.colorSpace()))); 300 sk_ref_sp(outputProperties.colorSpace())));
298 if (!renderTargetContext) { 301 if (!renderTargetContext) {
299 return nullptr; 302 return nullptr;
300 } 303 }
301 paint.setGammaCorrect(renderTargetContext->isGammaCorrect()); 304 paint.setGammaCorrect(renderTargetContext->isGammaCorrect());
302 305
303 SkMatrix matrix; 306 SkMatrix matrix;
304 matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top ())); 307 matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top ()));
305 renderTargetContext->drawRect(GrNoClip(), paint, matrix, SkRect::Make(bounds )); 308 renderTargetContext->drawRect(GrNoClip(), paint, matrix, SkRect::Make(bounds ));
306 309
307 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.he ight()), 310 return SkSpecialImage::MakeDeferredFromGpu(SkIRect::MakeWH(bounds.width(), b ounds.height()),
308 kNeedNewImageUniqueID_SpecialImage, 311 kNeedNewImageUniqueID_SpecialImag e,
309 renderTargetContext->asTexture(), 312 renderTargetContext->asDeferredTe xture(),
310 sk_ref_sp(renderTargetContext->getColorSp ace())); 313 sk_ref_sp(renderTargetContext->ge tColorSpace()));
311 } 314 }
312 315
313 sk_sp<GrFragmentProcessor> 316 sk_sp<GrFragmentProcessor>
314 SkXfermodeImageFilter_Base::makeFGFrag(sk_sp<GrFragmentProcessor> bgFP) const { 317 SkXfermodeImageFilter_Base::makeFGFrag(sk_sp<GrFragmentProcessor> bgFP) const {
315 // A null fMode is interpreted to mean kSrcOver_Mode (to match raster). 318 // A null fMode is interpreted to mean kSrcOver_Mode (to match raster).
316 SkXfermode* xfer = SkXfermode::Peek(fMode); 319 SkXfermode* xfer = SkXfermode::Peek(fMode);
317 sk_sp<SkXfermode> srcover; 320 sk_sp<SkXfermode> srcover;
318 if (!xfer) { 321 if (!xfer) {
319 // It would be awesome to use SkXfermode::Create here but it knows bette r 322 // It would be awesome to use SkXfermode::Create here but it knows bette r
320 // than us and won't return a kSrcOver_Mode SkXfermode. That means we 323 // than us and won't return a kSrcOver_Mode SkXfermode. That means we
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 528
526 //////////////////////////////////////////////////////////////////////////////// /////////////////// 529 //////////////////////////////////////////////////////////////////////////////// ///////////////////
527 530
528 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermodeImageFilter) 531 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermodeImageFilter)
529 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkXfermodeImageFilter_Base) 532 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkXfermodeImageFilter_Base)
530 // manually register the legacy serialized name "SkXfermodeImageFilter" 533 // manually register the legacy serialized name "SkXfermodeImageFilter"
531 SkFlattenable::Register("SkXfermodeImageFilter", SkXfermodeImageFilter_Base: :CreateProc, 534 SkFlattenable::Register("SkXfermodeImageFilter", SkXfermodeImageFilter_Base: :CreateProc,
532 SkFlattenable::kSkImageFilter_Type); 535 SkFlattenable::kSkImageFilter_Type);
533 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticImageFilter) 536 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticImageFilter)
534 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 537 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | src/gpu/GrBlurUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698