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

Side by Side Diff: src/core/SkImageFilter.cpp

Issue 1892493002: Remove asFragmentProcessor gpu-specific ImageFilter code path (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove unused parameters 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
« no previous file with comments | « include/core/SkImageFilter.h ('k') | no next file » | 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 2012 The Android Open Source Project 2 * Copyright 2012 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 "SkImageFilter.h" 8 #include "SkImageFilter.h"
9 #include "SkImageFilterCacheKey.h" 9 #include "SkImageFilterCacheKey.h"
10 10
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 } 386 }
387 387
388 // This is the only valid call to the old filterImage path 388 // This is the only valid call to the old filterImage path
389 if (!this->filterImageDeprecated(src->internal_getProxy(), srcBM, ctx, &resu ltBM, offset)) { 389 if (!this->filterImageDeprecated(src->internal_getProxy(), srcBM, ctx, &resu ltBM, offset)) {
390 return nullptr; 390 return nullptr;
391 } 391 }
392 392
393 return SkSpecialImage::internal_fromBM(src->internal_getProxy(), resultBM, & src->props()); 393 return SkSpecialImage::internal_fromBM(src->internal_getProxy(), resultBM, & src->props());
394 } 394 }
395 395
396 bool SkImageFilter::canFilterImageGPU() const {
397 return this->asFragmentProcessor(nullptr, nullptr, SkMatrix::I(), SkIRect()) ;
398 }
399
400 bool SkImageFilter::filterImageGPUDeprecated(Proxy* proxy, const SkBitmap& src, const Context& ctx,
401 SkBitmap* result, SkIPoint* offset) const {
402 #if SK_SUPPORT_GPU
403 SkBitmap input = src;
404 SkASSERT(fInputCount == 1);
405 SkIPoint srcOffset = SkIPoint::Make(0, 0);
406 if (!this->filterInputGPUDeprecated(0, proxy, src, ctx, &input, &srcOffset)) {
407 return false;
408 }
409 GrTexture* srcTexture = input.getTexture();
410 SkIRect bounds;
411 if (!this->applyCropRectDeprecated(ctx, proxy, input, &srcOffset, &bounds, & input)) {
412 return false;
413 }
414 GrContext* context = srcTexture->getContext();
415
416 GrSurfaceDesc desc;
417 desc.fFlags = kRenderTarget_GrSurfaceFlag;
418 desc.fWidth = bounds.width();
419 desc.fHeight = bounds.height();
420 desc.fConfig = kRGBA_8888_GrPixelConfig;
421
422 SkAutoTUnref<GrTexture> dst(context->textureProvider()->createApproxTexture( desc));
423 if (!dst) {
424 return false;
425 }
426
427 GrFragmentProcessor* fp;
428 offset->fX = bounds.left();
429 offset->fY = bounds.top();
430 bounds.offset(-srcOffset);
431 SkMatrix matrix(ctx.ctm());
432 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to p()));
433 GrPaint paint;
434 // SRGBTODO: Don't handle sRGB here, in anticipation of this code path being deleted.
435 if (this->asFragmentProcessor(&fp, srcTexture, matrix, bounds)) {
436 SkASSERT(fp);
437 paint.addColorFragmentProcessor(fp)->unref();
438 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
439
440 SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(dst->asRend erTarget()));
441 if (drawContext) {
442 SkRect srcRect = SkRect::Make(bounds);
443 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
444 GrClip clip(dstRect);
445 drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, src Rect);
446
447 GrWrapTextureInBitmap(dst, bounds.width(), bounds.height(), false, r esult);
448 return true;
449 }
450 }
451 #endif
452 return false;
453 }
454
455 #if SK_SUPPORT_GPU 396 #if SK_SUPPORT_GPU
456 sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context, 397 sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context,
457 sk_sp<GrFragmentProcessor> fp, 398 sk_sp<GrFragmentProcessor> fp,
458 const SkIRect& bounds, 399 const SkIRect& bounds,
459 SkImageFilter::Proxy* proxy) { 400 SkImageFilter::Proxy* proxy) {
460 GrPaint paint; 401 GrPaint paint;
461 paint.addColorFragmentProcessor(fp.get()); 402 paint.addColorFragmentProcessor(fp.get());
462 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); 403 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
463 404
464 GrSurfaceDesc desc; 405 GrSurfaceDesc desc;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 return src; 554 return src;
614 } 555 }
615 556
616 557
617 SkImageFilter::Context SkImageFilter::mapContext(const Context& ctx) const { 558 SkImageFilter::Context SkImageFilter::mapContext(const Context& ctx) const {
618 SkIRect clipBounds = this->onFilterNodeBounds(ctx.clipBounds(), ctx.ctm(), 559 SkIRect clipBounds = this->onFilterNodeBounds(ctx.clipBounds(), ctx.ctm(),
619 MapDirection::kReverse_MapDire ction); 560 MapDirection::kReverse_MapDire ction);
620 return Context(ctx.ctm(), clipBounds, ctx.cache()); 561 return Context(ctx.ctm(), clipBounds, ctx.cache());
621 } 562 }
622 563
623 bool SkImageFilter::asFragmentProcessor(GrFragmentProcessor**, GrTexture*,
624 const SkMatrix&, const SkIRect&) const {
625 return false;
626 }
627
628 sk_sp<SkImageFilter> SkImageFilter::MakeMatrixFilter(const SkMatrix& matrix, 564 sk_sp<SkImageFilter> SkImageFilter::MakeMatrixFilter(const SkMatrix& matrix,
629 SkFilterQuality filterQuali ty, 565 SkFilterQuality filterQuali ty,
630 sk_sp<SkImageFilter> input) { 566 sk_sp<SkImageFilter> input) {
631 return SkMatrixImageFilter::Make(matrix, filterQuality, std::move(input)); 567 return SkMatrixImageFilter::Make(matrix, filterQuality, std::move(input));
632 } 568 }
633 569
634 sk_sp<SkImageFilter> SkImageFilter::makeWithLocalMatrix(const SkMatrix& matrix) const { 570 sk_sp<SkImageFilter> SkImageFilter::makeWithLocalMatrix(const SkMatrix& matrix) const {
635 // SkLocalMatrixImageFilter takes SkImage* in its factory, but logically tha t parameter 571 // SkLocalMatrixImageFilter takes SkImage* in its factory, but logically tha t parameter
636 // is *always* treated as a const ptr. Hence the const-cast here. 572 // is *always* treated as a const ptr. Hence the const-cast here.
637 // 573 //
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 dev = SkBitmapDevice::Create(cinfo.fInfo, surfaceProps); 803 dev = SkBitmapDevice::Create(cinfo.fInfo, surfaceProps);
868 } 804 }
869 return dev; 805 return dev;
870 } 806 }
871 807
872 bool SkImageFilter::DeviceProxy::filterImage(const SkImageFilter* filter, const SkBitmap& src, 808 bool SkImageFilter::DeviceProxy::filterImage(const SkImageFilter* filter, const SkBitmap& src,
873 const SkImageFilter::Context& ctx, 809 const SkImageFilter::Context& ctx,
874 SkBitmap* result, SkIPoint* offset) { 810 SkBitmap* result, SkIPoint* offset) {
875 return fDevice->filterImage(filter, src, ctx, result, offset); 811 return fDevice->filterImage(filter, src, ctx, result, offset);
876 } 812 }
OLDNEW
« no previous file with comments | « include/core/SkImageFilter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698