OLD | NEW |
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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 } | 288 } |
289 | 289 |
290 bool SkImageFilter::filterInputDeprecated(int index, Proxy* proxy, const SkBitma
p& src, | 290 bool SkImageFilter::filterInputDeprecated(int index, Proxy* proxy, const SkBitma
p& src, |
291 const Context& ctx, | 291 const Context& ctx, |
292 SkBitmap* result, SkIPoint* offset) co
nst { | 292 SkBitmap* result, SkIPoint* offset) co
nst { |
293 SkImageFilter* input = this->getInput(index); | 293 SkImageFilter* input = this->getInput(index); |
294 if (!input) { | 294 if (!input) { |
295 return true; | 295 return true; |
296 } | 296 } |
297 | 297 |
298 sk_sp<SkSpecialImage> specialSrc(SkSpecialImage::internal_fromBM(proxy, src)
); | 298 // SRGBTODO: Don't handle sRGB here, in anticipation of this code path being
deleted. |
| 299 sk_sp<SkSpecialImage> specialSrc(SkSpecialImage::internal_fromBM(proxy, src,
nullptr)); |
299 if (!specialSrc) { | 300 if (!specialSrc) { |
300 return false; | 301 return false; |
301 } | 302 } |
302 | 303 |
303 sk_sp<SkSpecialImage> tmp(input->onFilterImage(specialSrc.get(), | 304 sk_sp<SkSpecialImage> tmp(input->onFilterImage(specialSrc.get(), |
304 this->mapContext(ctx), | 305 this->mapContext(ctx), |
305 offset)); | 306 offset)); |
306 if (!tmp) { | 307 if (!tmp) { |
307 return false; | 308 return false; |
308 } | 309 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 | 371 |
371 if (!src->internal_getBM(&srcBM)) { | 372 if (!src->internal_getBM(&srcBM)) { |
372 return nullptr; | 373 return nullptr; |
373 } | 374 } |
374 | 375 |
375 // This is the only valid call to the old filterImage path | 376 // This is the only valid call to the old filterImage path |
376 if (!this->filterImageDeprecated(src->internal_getProxy(), srcBM, ctx, &resu
ltBM, offset)) { | 377 if (!this->filterImageDeprecated(src->internal_getProxy(), srcBM, ctx, &resu
ltBM, offset)) { |
377 return nullptr; | 378 return nullptr; |
378 } | 379 } |
379 | 380 |
380 return SkSpecialImage::internal_fromBM(src->internal_getProxy(), resultBM); | 381 return SkSpecialImage::internal_fromBM(src->internal_getProxy(), resultBM, &
src->props()); |
381 } | 382 } |
382 | 383 |
383 bool SkImageFilter::canFilterImageGPU() const { | 384 bool SkImageFilter::canFilterImageGPU() const { |
384 return this->asFragmentProcessor(nullptr, nullptr, SkMatrix::I(), SkIRect())
; | 385 return this->asFragmentProcessor(nullptr, nullptr, SkMatrix::I(), SkIRect())
; |
385 } | 386 } |
386 | 387 |
387 bool SkImageFilter::filterImageGPUDeprecated(Proxy* proxy, const SkBitmap& src,
const Context& ctx, | 388 bool SkImageFilter::filterImageGPUDeprecated(Proxy* proxy, const SkBitmap& src,
const Context& ctx, |
388 SkBitmap* result, SkIPoint* offset)
const { | 389 SkBitmap* result, SkIPoint* offset)
const { |
389 #if SK_SUPPORT_GPU | 390 #if SK_SUPPORT_GPU |
390 SkBitmap input = src; | 391 SkBitmap input = src; |
(...skipping 20 matching lines...) Expand all Loading... |
411 return false; | 412 return false; |
412 } | 413 } |
413 | 414 |
414 GrFragmentProcessor* fp; | 415 GrFragmentProcessor* fp; |
415 offset->fX = bounds.left(); | 416 offset->fX = bounds.left(); |
416 offset->fY = bounds.top(); | 417 offset->fY = bounds.top(); |
417 bounds.offset(-srcOffset); | 418 bounds.offset(-srcOffset); |
418 SkMatrix matrix(ctx.ctm()); | 419 SkMatrix matrix(ctx.ctm()); |
419 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to
p())); | 420 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to
p())); |
420 GrPaint paint; | 421 GrPaint paint; |
| 422 // SRGBTODO: Don't handle sRGB here, in anticipation of this code path being
deleted. |
421 if (this->asFragmentProcessor(&fp, srcTexture, matrix, bounds)) { | 423 if (this->asFragmentProcessor(&fp, srcTexture, matrix, bounds)) { |
422 SkASSERT(fp); | 424 SkASSERT(fp); |
423 paint.addColorFragmentProcessor(fp)->unref(); | 425 paint.addColorFragmentProcessor(fp)->unref(); |
424 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 426 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
425 | 427 |
426 SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(dst->asRend
erTarget())); | 428 SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(dst->asRend
erTarget())); |
427 if (drawContext) { | 429 if (drawContext) { |
428 SkRect srcRect = SkRect::Make(bounds); | 430 SkRect srcRect = SkRect::Make(bounds); |
429 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); | 431 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); |
430 GrClip clip(dstRect); | 432 GrClip clip(dstRect); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 #if SK_SUPPORT_GPU | 615 #if SK_SUPPORT_GPU |
614 | 616 |
615 bool SkImageFilter::filterInputGPUDeprecated(int index, SkImageFilter::Proxy* pr
oxy, | 617 bool SkImageFilter::filterInputGPUDeprecated(int index, SkImageFilter::Proxy* pr
oxy, |
616 const SkBitmap& src, const Context&
ctx, | 618 const SkBitmap& src, const Context&
ctx, |
617 SkBitmap* result, SkIPoint* offset)
const { | 619 SkBitmap* result, SkIPoint* offset)
const { |
618 SkImageFilter* input = this->getInput(index); | 620 SkImageFilter* input = this->getInput(index); |
619 if (!input) { | 621 if (!input) { |
620 return true; | 622 return true; |
621 } | 623 } |
622 | 624 |
623 sk_sp<SkSpecialImage> specialSrc(SkSpecialImage::internal_fromBM(proxy, src)
); | 625 // SRGBTODO: Don't handle sRGB here, in anticipation of this code path being
deleted. |
| 626 sk_sp<SkSpecialImage> specialSrc(SkSpecialImage::internal_fromBM(proxy, src,
nullptr)); |
624 if (!specialSrc) { | 627 if (!specialSrc) { |
625 return false; | 628 return false; |
626 } | 629 } |
627 | 630 |
628 sk_sp<SkSpecialImage> tmp(input->onFilterImage(specialSrc.get(), | 631 sk_sp<SkSpecialImage> tmp(input->onFilterImage(specialSrc.get(), |
629 this->mapContext(ctx), | 632 this->mapContext(ctx), |
630 offset)); | 633 offset)); |
631 if (!tmp) { | 634 if (!tmp) { |
632 return false; | 635 return false; |
633 } | 636 } |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 dev = SkBitmapDevice::Create(cinfo.fInfo, surfaceProps); | 824 dev = SkBitmapDevice::Create(cinfo.fInfo, surfaceProps); |
822 } | 825 } |
823 return dev; | 826 return dev; |
824 } | 827 } |
825 | 828 |
826 bool SkImageFilter::DeviceProxy::filterImage(const SkImageFilter* filter, const
SkBitmap& src, | 829 bool SkImageFilter::DeviceProxy::filterImage(const SkImageFilter* filter, const
SkBitmap& src, |
827 const SkImageFilter::Context& ctx, | 830 const SkImageFilter::Context& ctx, |
828 SkBitmap* result, SkIPoint* offset) { | 831 SkBitmap* result, SkIPoint* offset) { |
829 return fDevice->filterImage(filter, src, ctx, result, offset); | 832 return fDevice->filterImage(filter, src, ctx, result, offset); |
830 } | 833 } |
OLD | NEW |