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

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

Issue 1874763002: Force upload to VRAM in filterImage (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to ToT 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 | « no previous file | 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698