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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 const SkIRect srcSubset = fUsesSrcInput ? src->subset() : SkIRect::MakeWH(0,
0); | 244 const SkIRect srcSubset = fUsesSrcInput ? src->subset() : SkIRect::MakeWH(0,
0); |
245 Cache::Key key(fUniqueID, context.ctm(), context.clipBounds(), srcGenID, src
Subset); | 245 Cache::Key key(fUniqueID, context.ctm(), context.clipBounds(), srcGenID, src
Subset); |
246 if (context.cache()) { | 246 if (context.cache()) { |
247 SkSpecialImage* result = context.cache()->get(key, offset); | 247 SkSpecialImage* result = context.cache()->get(key, offset); |
248 if (result) { | 248 if (result) { |
249 return sk_sp<SkSpecialImage>(SkRef(result)); | 249 return sk_sp<SkSpecialImage>(SkRef(result)); |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 sk_sp<SkSpecialImage> result(this->onFilterImage(src, context, offset)); | 253 sk_sp<SkSpecialImage> result(this->onFilterImage(src, context, offset)); |
| 254 |
| 255 #if SK_SUPPORT_GPU |
| 256 if (src->isTextureBacked() && result && !result->isTextureBacked()) { |
| 257 // Keep the result on the GPU - this is still required for some |
| 258 // image filters that don't support GPU in all cases |
| 259 GrContext* context = src->getContext(); |
| 260 result = result->makeTextureImage(src->internal_getProxy(), context); |
| 261 } |
| 262 #endif |
| 263 |
254 if (result && context.cache()) { | 264 if (result && context.cache()) { |
255 context.cache()->set(key, result.get(), *offset); | 265 context.cache()->set(key, result.get(), *offset); |
256 SkAutoMutexAcquire mutex(fMutex); | 266 SkAutoMutexAcquire mutex(fMutex); |
257 fCacheKeys.push_back(key); | 267 fCacheKeys.push_back(key); |
258 } | 268 } |
259 | 269 |
260 return result; | 270 return result; |
261 } | 271 } |
262 | 272 |
263 bool SkImageFilter::filterImageDeprecated(Proxy* proxy, const SkBitmap& src, | 273 bool SkImageFilter::filterImageDeprecated(Proxy* proxy, const SkBitmap& src, |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 SkSpecialImage* src, | 605 SkSpecialImage* src, |
596 const Context& ctx, | 606 const Context& ctx, |
597 SkIPoint* offset) const { | 607 SkIPoint* offset) const { |
598 SkImageFilter* input = this->getInput(index); | 608 SkImageFilter* input = this->getInput(index); |
599 if (!input) { | 609 if (!input) { |
600 return sk_sp<SkSpecialImage>(SkRef(src)); | 610 return sk_sp<SkSpecialImage>(SkRef(src)); |
601 } | 611 } |
602 | 612 |
603 sk_sp<SkSpecialImage> result(input->filterImage(src, this->mapContext(ctx),
offset)); | 613 sk_sp<SkSpecialImage> result(input->filterImage(src, this->mapContext(ctx),
offset)); |
604 | 614 |
605 #if SK_SUPPORT_GPU | 615 SkASSERT(!result || src->isTextureBacked() == result->isTextureBacked()); |
606 if (src->isTextureBacked() && result && !result->isTextureBacked()) { | |
607 // Keep the result on the GPU - this is still required for some | |
608 // image filters that don't support GPU in all cases | |
609 GrContext* context = src->getContext(); | |
610 return result->makeTextureImage(src->internal_getProxy(), context); | |
611 } | |
612 #endif | |
613 | 616 |
614 return result; | 617 return result; |
615 } | 618 } |
616 | 619 |
617 #if SK_SUPPORT_GPU | 620 #if SK_SUPPORT_GPU |
618 | 621 |
619 bool SkImageFilter::filterInputGPUDeprecated(int index, SkImageFilter::Proxy* pr
oxy, | 622 bool SkImageFilter::filterInputGPUDeprecated(int index, SkImageFilter::Proxy* pr
oxy, |
620 const SkBitmap& src, const Context&
ctx, | 623 const SkBitmap& src, const Context&
ctx, |
621 SkBitmap* result, SkIPoint* offset)
const { | 624 SkBitmap* result, SkIPoint* offset)
const { |
622 SkImageFilter* input = this->getInput(index); | 625 SkImageFilter* input = this->getInput(index); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 dev = SkBitmapDevice::Create(cinfo.fInfo, surfaceProps); | 829 dev = SkBitmapDevice::Create(cinfo.fInfo, surfaceProps); |
827 } | 830 } |
828 return dev; | 831 return dev; |
829 } | 832 } |
830 | 833 |
831 bool SkImageFilter::DeviceProxy::filterImage(const SkImageFilter* filter, const
SkBitmap& src, | 834 bool SkImageFilter::DeviceProxy::filterImage(const SkImageFilter* filter, const
SkBitmap& src, |
832 const SkImageFilter::Context& ctx, | 835 const SkImageFilter::Context& ctx, |
833 SkBitmap* result, SkIPoint* offset) { | 836 SkBitmap* result, SkIPoint* offset) { |
834 return fDevice->filterImage(filter, src, ctx, result, offset); | 837 return fDevice->filterImage(filter, src, ctx, result, offset); |
835 } | 838 } |
OLD | NEW |