diff options
author | robertphillips <robertphillips@google.com> | 2016-04-20 11:48:36 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-20 11:48:36 -0700 |
commit | 3e302275b324172c845627cbd00cee8a06571baf (patch) | |
tree | 51b7ab49a3e044145d8818051ad019432a820654 /src | |
parent | 9ca06c4b00bfb9bb1a7f352efd264185e5a95fbc (diff) |
Begin removing deprecated (and now, unused) ImageFilter code paths
This CL focuses on removing the Proxy objects but takes some other stuff with it.
BUG=skia:4965
TBR=reed@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1896383003
Review URL: https://codereview.chromium.org/1896383003
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkCanvas.cpp | 3 | ||||
-rw-r--r-- | src/core/SkDevice.cpp | 4 | ||||
-rw-r--r-- | src/core/SkImageFilter.cpp | 100 | ||||
-rw-r--r-- | src/core/SkSpecialImage.cpp | 92 | ||||
-rw-r--r-- | src/core/SkSpecialImage.h | 31 | ||||
-rw-r--r-- | src/core/SkSpecialSurface.cpp | 52 | ||||
-rw-r--r-- | src/core/SkSpecialSurface.h | 20 | ||||
-rw-r--r-- | src/effects/SkAlphaThresholdFilter.cpp | 5 | ||||
-rw-r--r-- | src/effects/SkBlurImageFilter.cpp | 6 | ||||
-rw-r--r-- | src/effects/SkDisplacementMapEffect.cpp | 6 | ||||
-rw-r--r-- | src/effects/SkImageSource.cpp | 3 | ||||
-rw-r--r-- | src/effects/SkLightingImageFilter.cpp | 10 | ||||
-rw-r--r-- | src/effects/SkMagnifierImageFilter.cpp | 5 | ||||
-rw-r--r-- | src/effects/SkMatrixConvolutionImageFilter.cpp | 5 | ||||
-rw-r--r-- | src/effects/SkMorphologyImageFilter.cpp | 6 | ||||
-rw-r--r-- | src/effects/SkXfermodeImageFilter.cpp | 3 | ||||
-rw-r--r-- | src/gpu/GrLayerHoister.cpp | 4 |
17 files changed, 90 insertions, 265 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index b07b4316b9..3732a35b54 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -1408,7 +1408,6 @@ void SkCanvas::internalDrawDevice(SkBaseDevice* srcDev, int x, int y, SkImageFilter* filter = paint->getImageFilter(); SkIPoint pos = { x - iter.getX(), y - iter.getY() }; if (filter) { - SkImageFilter::DeviceProxy proxy(dstDev); SkIPoint offset = SkIPoint::Make(0, 0); const SkBitmap& srcBM = srcDev->accessBitmap(false); SkMatrix matrix = *iter.fMatrix; @@ -1417,7 +1416,7 @@ void SkCanvas::internalDrawDevice(SkBaseDevice* srcDev, int x, int y, SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache()); SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); - sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(&proxy, srcBM, + sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(srcBM, &dstDev->surfaceProps())); if (!srcImg) { continue; // something disastrous happened diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp index d4bbc27ed6..24118f4662 100644 --- a/src/core/SkDevice.cpp +++ b/src/core/SkDevice.cpp @@ -409,7 +409,6 @@ void SkBaseDevice::drawSpriteWithFilter(const SkDraw& draw, const SkBitmap& bitm SkImageFilter* filter = paint.getImageFilter(); SkASSERT(filter); - SkImageFilter::DeviceProxy proxy(this); SkIPoint offset = SkIPoint::Make(0, 0); SkMatrix matrix = *draw.fMatrix; matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); @@ -417,8 +416,7 @@ void SkBaseDevice::drawSpriteWithFilter(const SkDraw& draw, const SkBitmap& bitm SkAutoTUnref<SkImageFilter::Cache> cache(this->getImageFilterCache()); SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); - sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(&proxy, bitmap, - &this->surfaceProps())); + sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(bitmap, &this->surfaceProps())); if (!srcImg) { return; // something disastrous happened } diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp index b71b79a57b..18fafd9cff 100644 --- a/src/core/SkImageFilter.cpp +++ b/src/core/SkImageFilter.cpp @@ -229,7 +229,7 @@ sk_sp<SkSpecialImage> SkImageFilter::filterImage(SkSpecialImage* src, const Cont // Keep the result on the GPU - this is still required for some // image filters that don't support GPU in all cases GrContext* context = src->getContext(); - result = result->makeTextureImage(src->internal_getProxy(), context); + result = result->makeTextureImage(context); } #endif @@ -242,54 +242,6 @@ sk_sp<SkSpecialImage> SkImageFilter::filterImage(SkSpecialImage* src, const Cont return result; } -bool SkImageFilter::filterImageDeprecated(Proxy* proxy, const SkBitmap& src, - const Context& context, - SkBitmap* result, SkIPoint* offset) const { - SkASSERT(result); - SkASSERT(offset); - uint32_t srcGenID = fUsesSrcInput ? src.getGenerationID() : 0; - Cache::Key key(fUniqueID, context.ctm(), context.clipBounds(), - srcGenID, SkIRect::MakeWH(0, 0)); - if (context.cache()) { - if (context.cache()->get(key, result, offset)) { - return true; - } - } - if (this->onFilterImageDeprecated(proxy, src, context, result, offset)) { - if (context.cache()) { - context.cache()->set(key, *result, *offset); - SkAutoMutexAcquire mutex(fMutex); - fCacheKeys.push_back(key); - } - return true; - } - return false; -} - -bool SkImageFilter::filterInputDeprecated(int index, Proxy* proxy, const SkBitmap& src, - const Context& ctx, - SkBitmap* result, SkIPoint* offset) const { - SkImageFilter* input = this->getInput(index); - if (!input) { - return true; - } - - // SRGBTODO: Don't handle sRGB here, in anticipation of this code path being deleted. - sk_sp<SkSpecialImage> specialSrc(SkSpecialImage::internal_fromBM(proxy, src, nullptr)); - if (!specialSrc) { - return false; - } - - sk_sp<SkSpecialImage> tmp(input->onFilterImage(specialSrc.get(), - this->mapContext(ctx), - offset)); - if (!tmp) { - return false; - } - - return tmp->internal_getBM(result); -} - SkIRect SkImageFilter::filterBounds(const SkIRect& src, const SkMatrix& ctm, MapDirection direction) const { if (kReverse_MapDirection == direction) { @@ -333,38 +285,10 @@ bool SkImageFilter::canComputeFastBounds() const { return true; } -bool SkImageFilter::onFilterImageDeprecated(Proxy*, const SkBitmap&, const Context&, - SkBitmap*, SkIPoint*) const { - // Only classes that now use the new SkSpecialImage-based path will not have - // onFilterImageDeprecated methods. For those classes we should never be - // calling this method. - SkASSERT(0); - return false; -} - -// SkImageFilter-derived classes that do not yet have their own onFilterImage -// implementation convert back to calling the deprecated filterImage method -sk_sp<SkSpecialImage> SkImageFilter::onFilterImage(SkSpecialImage* src, const Context& ctx, - SkIPoint* offset) const { - SkBitmap srcBM, resultBM; - - if (!src->internal_getBM(&srcBM)) { - return nullptr; - } - - // This is the only valid call to the old filterImage path - if (!this->filterImageDeprecated(src->internal_getProxy(), srcBM, ctx, &resultBM, offset)) { - return nullptr; - } - - return SkSpecialImage::internal_fromBM(src->internal_getProxy(), resultBM, &src->props()); -} - #if SK_SUPPORT_GPU sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context, sk_sp<GrFragmentProcessor> fp, - const SkIRect& bounds, - SkImageFilter::Proxy* proxy) { + const SkIRect& bounds) { GrPaint paint; paint.addColorFragmentProcessor(fp.get()); paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); @@ -390,8 +314,7 @@ sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context, GrClip clip(dstRect); drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect); - return SkSpecialImage::MakeFromGpu(proxy, - SkIRect::MakeWH(bounds.width(), bounds.height()), + return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.height()), kNeedNewImageUniqueID_SpecialImage, dst.get()); @@ -680,20 +603,3 @@ void SkImageFilter::PurgeCache() { Cache::Get()->purge(); } -/////////////////////////////////////////////////////////////////////////////////////////////////// - -SkBaseDevice* SkImageFilter::DeviceProxy::createDevice(int w, int h, TileUsage usage) { - SkBaseDevice::CreateInfo cinfo(SkImageInfo::MakeN32Premul(w, h), - kPossible_TileUsage == usage ? SkBaseDevice::kPossible_TileUsage - : SkBaseDevice::kNever_TileUsage, - kUnknown_SkPixelGeometry, - false, /* preserveLCDText */ - true /*forImageFilter*/); - SkBaseDevice* dev = fDevice->onCreateDevice(cinfo, nullptr); - if (nullptr == dev) { - const SkSurfaceProps surfaceProps(fDevice->fSurfaceProps.flags(), - kUnknown_SkPixelGeometry); - dev = SkBitmapDevice::Create(cinfo.fInfo, surfaceProps); - } - return dev; -} diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp index f7bbf9ecaa..bbc7635b66 100644 --- a/src/core/SkSpecialImage.cpp +++ b/src/core/SkSpecialImage.cpp @@ -21,11 +21,10 @@ /////////////////////////////////////////////////////////////////////////////// class SkSpecialImage_Base : public SkSpecialImage { public: - SkSpecialImage_Base(SkImageFilter::Proxy* proxy, const SkIRect& subset, uint32_t uniqueID, - const SkSurfaceProps* props) - : INHERITED(proxy, subset, uniqueID, props) { + SkSpecialImage_Base(const SkIRect& subset, uint32_t uniqueID, const SkSurfaceProps* props) + : INHERITED(subset, uniqueID, props) { } - virtual ~SkSpecialImage_Base() { } + ~SkSpecialImage_Base() override { } virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const = 0; @@ -55,18 +54,15 @@ static inline const SkSpecialImage_Base* as_SIB(const SkSpecialImage* image) { return static_cast<const SkSpecialImage_Base*>(image); } -SkSpecialImage::SkSpecialImage(SkImageFilter::Proxy* proxy, - const SkIRect& subset, +SkSpecialImage::SkSpecialImage(const SkIRect& subset, uint32_t uniqueID, const SkSurfaceProps* props) : fProps(SkSurfacePropsCopyOrDefault(props)) , fSubset(subset) - , fUniqueID(kNeedNewImageUniqueID_SpecialImage == uniqueID ? SkNextID::ImageID() : uniqueID) - , fProxy(proxy) { + , fUniqueID(kNeedNewImageUniqueID_SpecialImage == uniqueID ? SkNextID::ImageID() : uniqueID) { } -sk_sp<SkSpecialImage> SkSpecialImage::makeTextureImage(SkImageFilter::Proxy* proxy, - GrContext* context) { +sk_sp<SkSpecialImage> SkSpecialImage::makeTextureImage(GrContext* context) { #if SK_SUPPORT_GPU if (!context) { return nullptr; @@ -81,7 +77,7 @@ sk_sp<SkSpecialImage> SkSpecialImage::makeTextureImage(SkImageFilter::Proxy* pro } if (bmp.empty()) { - return SkSpecialImage::MakeFromRaster(proxy, SkIRect::MakeEmpty(), bmp, &this->props()); + return SkSpecialImage::MakeFromRaster(SkIRect::MakeEmpty(), bmp, &this->props()); } SkAutoTUnref<GrTexture> resultTex( @@ -92,8 +88,7 @@ sk_sp<SkSpecialImage> SkSpecialImage::makeTextureImage(SkImageFilter::Proxy* pro SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType; - return SkSpecialImage::MakeFromGpu(proxy, - SkIRect::MakeWH(resultTex->width(), resultTex->height()), + return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(resultTex->width(), resultTex->height()), this->uniqueID(), resultTex, &this->props(), at); #else @@ -154,19 +149,17 @@ sk_sp<SkImage> SkSpecialImage::makeTightSubset(const SkIRect& subset) const { #include "SkGrPixelRef.h" #endif -sk_sp<SkSpecialImage> SkSpecialImage::internal_fromBM(SkImageFilter::Proxy* proxy, - const SkBitmap& src, +sk_sp<SkSpecialImage> SkSpecialImage::internal_fromBM(const SkBitmap& src, const SkSurfaceProps* props) { // Need to test offset case! (see skbug.com/4967) if (src.getTexture()) { - return SkSpecialImage::MakeFromGpu(proxy, - src.bounds(), + return SkSpecialImage::MakeFromGpu(src.bounds(), src.getGenerationID(), src.getTexture(), props); } - return SkSpecialImage::MakeFromRaster(proxy, src.bounds(), src, props); + return SkSpecialImage::MakeFromRaster(src.bounds(), src, props); } bool SkSpecialImage::internal_getBM(SkBitmap* result) { @@ -176,10 +169,6 @@ bool SkSpecialImage::internal_getBM(SkBitmap* result) { return ib->getBitmapDeprecated(result); } -SkImageFilter::Proxy* SkSpecialImage::internal_getProxy() const { - return fProxy; -} - /////////////////////////////////////////////////////////////////////////////// #include "SkImage.h" #if SK_SUPPORT_GPU @@ -189,11 +178,10 @@ SkImageFilter::Proxy* SkSpecialImage::internal_getProxy() const { class SkSpecialImage_Image : public SkSpecialImage_Base { public: - SkSpecialImage_Image(SkImageFilter::Proxy* proxy, - const SkIRect& subset, + SkSpecialImage_Image(const SkIRect& subset, sk_sp<SkImage> image, const SkSurfaceProps* props) - : INHERITED(proxy, subset, image->uniqueID(), props) + : INHERITED(subset, image->uniqueID(), props) , fImage(image) { } @@ -262,10 +250,10 @@ public: GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info, *texture->getContext()->caps()); desc.fFlags = kRenderTarget_GrSurfaceFlag; - return SkSpecialSurface::MakeRenderTarget(this->proxy(), texture->getContext(), desc); + return SkSpecialSurface::MakeRenderTarget(texture->getContext(), desc); } #endif - return SkSpecialSurface::MakeRaster(this->proxy(), info, nullptr); + return SkSpecialSurface::MakeRaster(info, nullptr); } sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override { @@ -274,8 +262,7 @@ public: return nullptr; } - return SkSpecialImage::MakeFromImage(this->internal_getProxy(), - SkIRect::MakeWH(subset.width(), subset.height()), + return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(subset.width(), subset.height()), subsetImg, &this->props()); } @@ -314,13 +301,12 @@ static bool rect_fits(const SkIRect& rect, int width, int height) { } #endif -sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(SkImageFilter::Proxy* proxy, - const SkIRect& subset, +sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(const SkIRect& subset, sk_sp<SkImage> image, const SkSurfaceProps* props) { SkASSERT(rect_fits(subset, image->width(), image->height())); - return sk_make_sp<SkSpecialImage_Image>(proxy, subset, image, props); + return sk_make_sp<SkSpecialImage_Image>(subset, image, props); } /////////////////////////////////////////////////////////////////////////////// @@ -330,9 +316,8 @@ sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(SkImageFilter::Proxy* proxy, class SkSpecialImage_Raster : public SkSpecialImage_Base { public: - SkSpecialImage_Raster(SkImageFilter::Proxy* proxy, const SkIRect& subset, const SkBitmap& bm, - const SkSurfaceProps* props) - : INHERITED(proxy, subset, bm.getGenerationID(), props) + SkSpecialImage_Raster(const SkIRect& subset, const SkBitmap& bm, const SkSurfaceProps* props) + : INHERITED(subset, bm.getGenerationID(), props) , fBitmap(bm) { if (bm.pixelRef() && bm.pixelRef()->isPreLocked()) { // we only preemptively lock if there is no chance of triggering something expensive @@ -341,13 +326,12 @@ public: } } - SkSpecialImage_Raster(SkImageFilter::Proxy* proxy, - const SkIRect& subset, + SkSpecialImage_Raster(const SkIRect& subset, const SkPixmap& pixmap, RasterReleaseProc releaseProc, ReleaseContext context, const SkSurfaceProps* props) - : INHERITED(proxy, subset, kNeedNewImageUniqueID_SpecialImage, props) { + : INHERITED(subset, kNeedNewImageUniqueID_SpecialImage, props) { fBitmap.installPixels(pixmap.info(), pixmap.writable_addr(), pixmap.rowBytes(), pixmap.ctable(), releaseProc, context); @@ -388,7 +372,7 @@ public: } sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const override { - return SkSpecialSurface::MakeRaster(this->proxy(), info, nullptr); + return SkSpecialSurface::MakeRaster(info, nullptr); } sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override { @@ -398,8 +382,7 @@ public: return nullptr; } - return SkSpecialImage::MakeFromRaster(this->internal_getProxy(), - SkIRect::MakeWH(subset.width(), subset.height()), + return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(subset.width(), subset.height()), subsetBM, &this->props()); } @@ -424,18 +407,16 @@ private: typedef SkSpecialImage_Base INHERITED; }; -sk_sp<SkSpecialImage> SkSpecialImage::MakeFromRaster(SkImageFilter::Proxy* proxy, - const SkIRect& subset, +sk_sp<SkSpecialImage> SkSpecialImage::MakeFromRaster(const SkIRect& subset, const SkBitmap& bm, const SkSurfaceProps* props) { SkASSERT(nullptr == bm.getTexture()); SkASSERT(rect_fits(subset, bm.width(), bm.height())); - return sk_make_sp<SkSpecialImage_Raster>(proxy, subset, bm, props); + return sk_make_sp<SkSpecialImage_Raster>(subset, bm, props); } -sk_sp<SkSpecialImage> SkSpecialImage::MakeFromPixmap(SkImageFilter::Proxy* proxy, - const SkIRect& subset, +sk_sp<SkSpecialImage> SkSpecialImage::MakeFromPixmap(const SkIRect& subset, const SkPixmap& src, RasterReleaseProc releaseProc, ReleaseContext context, @@ -444,7 +425,7 @@ sk_sp<SkSpecialImage> SkSpecialImage::MakeFromPixmap(SkImageFilter::Proxy* proxy return nullptr; } - return sk_make_sp<SkSpecialImage_Raster>(proxy, subset, src, releaseProc, context, props); + return sk_make_sp<SkSpecialImage_Raster>(subset, src, releaseProc, context, props); } @@ -455,10 +436,10 @@ sk_sp<SkSpecialImage> SkSpecialImage::MakeFromPixmap(SkImageFilter::Proxy* proxy class SkSpecialImage_Gpu : public SkSpecialImage_Base { public: - SkSpecialImage_Gpu(SkImageFilter::Proxy* proxy, const SkIRect& subset, + SkSpecialImage_Gpu(const SkIRect& subset, uint32_t uniqueID, GrTexture* tex, SkAlphaType at, const SkSurfaceProps* props) - : INHERITED(proxy, subset, uniqueID, props) + : INHERITED(subset, uniqueID, props) , fTexture(SkRef(tex)) , fAlphaType(at) , fAddedRasterVersionToCache(false) { @@ -543,12 +524,11 @@ public: GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info, *fTexture->getContext()->caps()); desc.fFlags = kRenderTarget_GrSurfaceFlag; - return SkSpecialSurface::MakeRenderTarget(this->proxy(), fTexture->getContext(), desc); + return SkSpecialSurface::MakeRenderTarget(fTexture->getContext(), desc); } sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override { - return SkSpecialImage::MakeFromGpu(this->internal_getProxy(), - subset, + return SkSpecialImage::MakeFromGpu(subset, this->uniqueID(), fTexture, &this->props(), @@ -592,20 +572,18 @@ private: typedef SkSpecialImage_Base INHERITED; }; -sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(SkImageFilter::Proxy* proxy, - const SkIRect& subset, +sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(const SkIRect& subset, uint32_t uniqueID, GrTexture* tex, const SkSurfaceProps* props, SkAlphaType at) { SkASSERT(rect_fits(subset, tex->width(), tex->height())); - return sk_make_sp<SkSpecialImage_Gpu>(proxy, subset, uniqueID, tex, at, props); + return sk_make_sp<SkSpecialImage_Gpu>(subset, uniqueID, tex, at, props); } #else -sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(SkImageFilter::Proxy* proxy, - const SkIRect& subset, +sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(const SkIRect& subset, uint32_t uniqueID, GrTexture* tex, const SkSurfaceProps* props, diff --git a/src/core/SkSpecialImage.h b/src/core/SkSpecialImage.h index 2aa5bc6854..aec344348c 100644 --- a/src/core/SkSpecialImage.h +++ b/src/core/SkSpecialImage.h @@ -63,29 +63,25 @@ public: * transformation is required, the returned image may be the same as this special image. * If this special image is from a different GrContext, this will fail. */ - sk_sp<SkSpecialImage> makeTextureImage(SkImageFilter::Proxy*, GrContext*); + sk_sp<SkSpecialImage> makeTextureImage(GrContext*); /** * Draw this SpecialImage into the canvas. */ void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const; - static sk_sp<SkSpecialImage> MakeFromImage(SkImageFilter::Proxy*, - const SkIRect& subset, + static sk_sp<SkSpecialImage> MakeFromImage(const SkIRect& subset, sk_sp<SkImage>, const SkSurfaceProps* = nullptr); - static sk_sp<SkSpecialImage> MakeFromRaster(SkImageFilter::Proxy*, - const SkIRect& subset, + static sk_sp<SkSpecialImage> MakeFromRaster(const SkIRect& subset, const SkBitmap&, const SkSurfaceProps* = nullptr); - static sk_sp<SkSpecialImage> MakeFromGpu(SkImageFilter::Proxy*, - const SkIRect& subset, + static sk_sp<SkSpecialImage> MakeFromGpu(const SkIRect& subset, uint32_t uniqueID, GrTexture*, const SkSurfaceProps* = nullptr, SkAlphaType at = kPremul_SkAlphaType); - static sk_sp<SkSpecialImage> MakeFromPixmap(SkImageFilter::Proxy*, - const SkIRect& subset, + static sk_sp<SkSpecialImage> MakeFromPixmap(const SkIRect& subset, const SkPixmap&, RasterReleaseProc, ReleaseContext, @@ -117,9 +113,7 @@ public: // These three internal methods will go away (see skbug.com/4965) bool internal_getBM(SkBitmap* result); - static sk_sp<SkSpecialImage> internal_fromBM(SkImageFilter::Proxy*, const SkBitmap&, - const SkSurfaceProps*); - SkImageFilter::Proxy* internal_getProxy() const; + static sk_sp<SkSpecialImage> internal_fromBM(const SkBitmap&, const SkSurfaceProps*); // TODO: hide this when GrLayerHoister uses SkSpecialImages more fully (see skbug.com/5063) /** @@ -148,24 +142,13 @@ public: bool getROPixels(SkBitmap*) const; protected: - SkSpecialImage(SkImageFilter::Proxy*, const SkIRect& subset, uint32_t uniqueID, - const SkSurfaceProps*); - - // The following 2 are for testing and shouldn't be used. - friend class TestingSpecialImageAccess; - friend class TestingSpecialSurfaceAccess; - - // TODO: remove this ASAP (see skbug.com/4965) - SkImageFilter::Proxy* proxy() const { return fProxy; } + SkSpecialImage(const SkIRect& subset, uint32_t uniqueID, const SkSurfaceProps*); private: const SkSurfaceProps fProps; const SkIRect fSubset; const uint32_t fUniqueID; - // TODO: remove this ASAP (see skbug.com/4965) - SkImageFilter::Proxy* fProxy; - typedef SkRefCnt INHERITED; }; diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp index eecdaecd61..2e2d8cc54a 100644 --- a/src/core/SkSpecialSurface.cpp +++ b/src/core/SkSpecialSurface.cpp @@ -13,9 +13,8 @@ /////////////////////////////////////////////////////////////////////////////// class SkSpecialSurface_Base : public SkSpecialSurface { public: - SkSpecialSurface_Base(SkImageFilter::Proxy* proxy, - const SkIRect& subset, const SkSurfaceProps* props) - : INHERITED(proxy, subset, props) + SkSpecialSurface_Base(const SkIRect& subset, const SkSurfaceProps* props) + : INHERITED(subset, props) , fCanvas(nullptr) { } @@ -41,12 +40,10 @@ static SkSpecialSurface_Base* as_SB(SkSpecialSurface* surface) { return static_cast<SkSpecialSurface_Base*>(surface); } -SkSpecialSurface::SkSpecialSurface(SkImageFilter::Proxy* proxy, - const SkIRect& subset, +SkSpecialSurface::SkSpecialSurface(const SkIRect& subset, const SkSurfaceProps* props) : fProps(SkSurfacePropsCopyOrDefault(props).flags(), kUnknown_SkPixelGeometry) - , fSubset(subset) - , fProxy(proxy) { + , fSubset(subset) { SkASSERT(fSubset.width() > 0); SkASSERT(fSubset.height() > 0); } @@ -66,11 +63,10 @@ sk_sp<SkSpecialImage> SkSpecialSurface::makeImageSnapshot() { class SkSpecialSurface_Raster : public SkSpecialSurface_Base { public: - SkSpecialSurface_Raster(SkImageFilter::Proxy* proxy, - SkPixelRef* pr, + SkSpecialSurface_Raster(SkPixelRef* pr, const SkIRect& subset, const SkSurfaceProps* props) - : INHERITED(proxy, subset, props) { + : INHERITED(subset, props) { const SkImageInfo& info = pr->info(); fBitmap.setInfo(info, info.minRowBytes()); @@ -83,8 +79,7 @@ public: ~SkSpecialSurface_Raster() override { } sk_sp<SkSpecialImage> onMakeImageSnapshot() override { - return SkSpecialImage::MakeFromRaster(this->proxy(), this->subset(), fBitmap, - &this->props()); + return SkSpecialImage::MakeFromRaster(this->subset(), fBitmap, &this->props()); } private: @@ -93,14 +88,12 @@ private: typedef SkSpecialSurface_Base INHERITED; }; -sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromBitmap(SkImageFilter::Proxy* proxy, - const SkIRect& subset, SkBitmap& bm, +sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromBitmap(const SkIRect& subset, SkBitmap& bm, const SkSurfaceProps* props) { - return sk_make_sp<SkSpecialSurface_Raster>(proxy, bm.pixelRef(), subset, props); + return sk_make_sp<SkSpecialSurface_Raster>(bm.pixelRef(), subset, props); } -sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRaster(SkImageFilter::Proxy* proxy, - const SkImageInfo& info, +sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRaster(const SkImageInfo& info, const SkSurfaceProps* props) { SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewZeroed(info, 0, nullptr)); if (nullptr == pr.get()) { @@ -109,7 +102,7 @@ sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRaster(SkImageFilter::Proxy* proxy const SkIRect subset = SkIRect::MakeWH(pr->info().width(), pr->info().height()); - return sk_make_sp<SkSpecialSurface_Raster>(proxy, pr, subset, props); + return sk_make_sp<SkSpecialSurface_Raster>(pr, subset, props); } #if SK_SUPPORT_GPU @@ -119,11 +112,10 @@ sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRaster(SkImageFilter::Proxy* proxy class SkSpecialSurface_Gpu : public SkSpecialSurface_Base { public: - SkSpecialSurface_Gpu(SkImageFilter::Proxy* proxy, - GrTexture* texture, + SkSpecialSurface_Gpu(GrTexture* texture, const SkIRect& subset, const SkSurfaceProps* props) - : INHERITED(proxy, subset, props) + : INHERITED(subset, props) , fTexture(SkRef(texture)) { SkASSERT(fTexture->asRenderTarget()); @@ -141,7 +133,7 @@ public: ~SkSpecialSurface_Gpu() override { } sk_sp<SkSpecialImage> onMakeImageSnapshot() override { - return SkSpecialImage::MakeFromGpu(this->proxy(), this->subset(), + return SkSpecialImage::MakeFromGpu(this->subset(), kNeedNewImageUniqueID_SpecialImage, fTexture, &this->props()); } @@ -152,19 +144,17 @@ private: typedef SkSpecialSurface_Base INHERITED; }; -sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromTexture(SkImageFilter::Proxy* proxy, - const SkIRect& subset, +sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromTexture(const SkIRect& subset, GrTexture* texture, const SkSurfaceProps* props) { if (!texture->asRenderTarget()) { return nullptr; } - return sk_make_sp<SkSpecialSurface_Gpu>(proxy, texture, subset, props); + return sk_make_sp<SkSpecialSurface_Gpu>(texture, subset, props); } -sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(SkImageFilter::Proxy* proxy, - GrContext* context, +sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrContext* context, const GrSurfaceDesc& desc, const SkSurfaceProps* props) { if (!context || !SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag)) { @@ -178,20 +168,18 @@ sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(SkImageFilter::Proxy* const SkIRect subset = SkIRect::MakeWH(desc.fWidth, desc.fHeight); - return sk_make_sp<SkSpecialSurface_Gpu>(proxy, temp, subset, props); + return sk_make_sp<SkSpecialSurface_Gpu>(temp, subset, props); } #else -sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromTexture(SkImageFilter::Proxy* proxy, - const SkIRect& subset, +sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromTexture(const SkIRect& subset, GrTexture*, const SkSurfaceProps*) { return nullptr; } -sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(SkImageFilter::Proxy* proxy, - GrContext* context, +sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrContext* context, const GrSurfaceDesc& desc, const SkSurfaceProps* props) { return nullptr; diff --git a/src/core/SkSpecialSurface.h b/src/core/SkSpecialSurface.h index d24ee74569..6ed8a77da5 100644 --- a/src/core/SkSpecialSurface.h +++ b/src/core/SkSpecialSurface.h @@ -53,23 +53,20 @@ public: /** * Use an existing (renderTarget-capable) GrTexture as the backing store. */ - static sk_sp<SkSpecialSurface> MakeFromTexture(SkImageFilter::Proxy* proxy, - const SkIRect& subset, GrTexture*, + static sk_sp<SkSpecialSurface> MakeFromTexture(const SkIRect& subset, GrTexture*, const SkSurfaceProps* = nullptr); /** * Allocate a new GPU-backed SkSpecialSurface. If the requested surface cannot * be created, nullptr will be returned. */ - static sk_sp<SkSpecialSurface> MakeRenderTarget(SkImageFilter::Proxy* proxy, - GrContext*, const GrSurfaceDesc&, + static sk_sp<SkSpecialSurface> MakeRenderTarget(GrContext*, const GrSurfaceDesc&, const SkSurfaceProps* = nullptr); /** * Use and existing SkBitmap as the backing store. */ - static sk_sp<SkSpecialSurface> MakeFromBitmap(SkImageFilter::Proxy* proxy, - const SkIRect& subset, SkBitmap& bm, + static sk_sp<SkSpecialSurface> MakeFromBitmap(const SkIRect& subset, SkBitmap& bm, const SkSurfaceProps* = nullptr); /** @@ -79,27 +76,20 @@ public: * If the requested surface cannot be created, or the request is not a * supported configuration, nullptr will be returned. */ - static sk_sp<SkSpecialSurface> MakeRaster(SkImageFilter::Proxy* proxy, - const SkImageInfo&, + static sk_sp<SkSpecialSurface> MakeRaster(const SkImageInfo&, const SkSurfaceProps* = nullptr); protected: - SkSpecialSurface(SkImageFilter::Proxy*, const SkIRect& subset, const SkSurfaceProps*); + SkSpecialSurface(const SkIRect& subset, const SkSurfaceProps*); // For testing only friend class TestingSpecialSurfaceAccess; const SkIRect& subset() const { return fSubset; } - // TODO: remove this ASAP (see skbug.com/4965) - SkImageFilter::Proxy* proxy() const { return fProxy; } - private: const SkSurfaceProps fProps; const SkIRect fSubset; - // TODO: remove this ASAP (see skbug.com/4965) - SkImageFilter::Proxy* fProxy; - typedef SkRefCnt INHERITED; }; diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp index 0d16ec685e..bf2a3fda1c 100644 --- a/src/effects/SkAlphaThresholdFilter.cpp +++ b/src/effects/SkAlphaThresholdFilter.cpp @@ -187,7 +187,7 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(SkSpecialImage* return nullptr; } - return DrawWithFP(context, std::move(fp), bounds, source->internal_getProxy()); + return DrawWithFP(context, std::move(fp), bounds); } #endif @@ -262,8 +262,7 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(SkSpecialImage* offset->fX = bounds.left(); offset->fY = bounds.top(); - return SkSpecialImage::MakeFromRaster(source->internal_getProxy(), - SkIRect::MakeWH(bounds.width(), bounds.height()), + return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds.height()), dst); } diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp index 3ed88f1534..d233c04ea7 100644 --- a/src/effects/SkBlurImageFilter.cpp +++ b/src/effects/SkBlurImageFilter.cpp @@ -133,8 +133,7 @@ sk_sp<SkSpecialImage> SkBlurImageFilter::onFilterImage(SkSpecialImage* source, return nullptr; } - return SkSpecialImage::MakeFromGpu(source->internal_getProxy(), - SkIRect::MakeWH(dstBounds.width(), dstBounds.height()), + return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(dstBounds.width(), dstBounds.height()), kNeedNewImageUniqueID_SpecialImage, tex, &source->props()); } @@ -225,8 +224,7 @@ sk_sp<SkSpecialImage> SkBlurImageFilter::onFilterImage(SkSpecialImage* source, SkOpts::box_blur_xy(t, h, dstBoundsT, d, kernelSizeY3, highOffsetY, highOffsetY, h, w); } - return SkSpecialImage::MakeFromRaster(source->internal_getProxy(), - SkIRect::MakeWH(dstBounds.width(), + return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(dstBounds.width(), dstBounds.height()), dst, &source->props()); } diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp index b715f6a4f3..c52b958746 100644 --- a/src/effects/SkDisplacementMapEffect.cpp +++ b/src/effects/SkDisplacementMapEffect.cpp @@ -355,8 +355,7 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou offset->fX = bounds.left(); offset->fY = bounds.top(); - return SkSpecialImage::MakeFromGpu(source->internal_getProxy(), - SkIRect::MakeWH(bounds.width(), bounds.height()), + return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.height()), kNeedNewImageUniqueID_SpecialImage, dst); } @@ -393,8 +392,7 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou offset->fX = bounds.left(); offset->fY = bounds.top(); - return SkSpecialImage::MakeFromRaster(source->internal_getProxy(), - SkIRect::MakeWH(bounds.width(), bounds.height()), + return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds.height()), dst); } diff --git a/src/effects/SkImageSource.cpp b/src/effects/SkImageSource.cpp index e00bced4c4..f3fc05491e 100644 --- a/src/effects/SkImageSource.cpp +++ b/src/effects/SkImageSource.cpp @@ -86,8 +86,7 @@ sk_sp<SkSpecialImage> SkImageSource::onFilterImage(SkSpecialImage* source, const if (fSrcRect == bounds && dstRect == bounds) { // No regions cropped out or resized; return entire image. offset->fX = offset->fY = 0; - return SkSpecialImage::MakeFromImage(source->internal_getProxy(), - SkIRect::MakeWH(fImage->width(), fImage->height()), + return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(fImage->width(), fImage->height()), fImage, &source->props()); } diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index b37fc28b2a..7f0e3eab4b 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -460,8 +460,7 @@ sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU(SkSpecialIma this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottomRight, kBottomRight_BoundaryMode, pSrcBounds, offsetBounds); - return SkSpecialImage::MakeFromGpu(source->internal_getProxy(), - SkIRect::MakeWH(offsetBounds.width(), offsetBounds.height()), + return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(offsetBounds.width(), offsetBounds.height()), kNeedNewImageUniqueID_SpecialImage, dst.get()); } @@ -1326,8 +1325,7 @@ sk_sp<SkSpecialImage> SkDiffuseLightingImageFilter::onFilterImage(SkSpecialImage break; } - return SkSpecialImage::MakeFromRaster(source->internal_getProxy(), - SkIRect::MakeWH(bounds.width(), bounds.height()), + return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds.height()), dst); } @@ -1493,9 +1491,7 @@ sk_sp<SkSpecialImage> SkSpecularLightingImageFilter::onFilterImage(SkSpecialImag break; } - return SkSpecialImage::MakeFromRaster(source->internal_getProxy(), - SkIRect::MakeWH(bounds.width(), bounds.height()), - dst); + return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds.height()), dst); } #ifndef SK_IGNORE_TO_STRING diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp index 9ab18a7582..517e31d250 100644 --- a/src/effects/SkMagnifierImageFilter.cpp +++ b/src/effects/SkMagnifierImageFilter.cpp @@ -337,7 +337,7 @@ sk_sp<SkSpecialImage> SkMagnifierImageFilter::onFilterImage(SkSpecialImage* sour return nullptr; } - return DrawWithFP(context, std::move(fp), bounds, source->internal_getProxy()); + return DrawWithFP(context, std::move(fp), bounds); } #endif @@ -408,8 +408,7 @@ sk_sp<SkSpecialImage> SkMagnifierImageFilter::onFilterImage(SkSpecialImage* sour offset->fX = bounds.left(); offset->fY = bounds.top(); - return SkSpecialImage::MakeFromRaster(source->internal_getProxy(), - SkIRect::MakeWH(bounds.width(), bounds.height()), + return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds.height()), dst); } diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp index 51e3b6faa7..f5d9a3f7d2 100644 --- a/src/effects/SkMatrixConvolutionImageFilter.cpp +++ b/src/effects/SkMatrixConvolutionImageFilter.cpp @@ -329,7 +329,7 @@ sk_sp<SkSpecialImage> SkMatrixConvolutionImageFilter::onFilterImage(SkSpecialIma return nullptr; } - return DrawWithFP(context, std::move(fp), bounds, source->internal_getProxy()); + return DrawWithFP(context, std::move(fp), bounds); } #endif @@ -381,8 +381,7 @@ sk_sp<SkSpecialImage> SkMatrixConvolutionImageFilter::onFilterImage(SkSpecialIma this->filterInteriorPixels(inputBM, &dst, interior, bounds); this->filterBorderPixels(inputBM, &dst, right, bounds); this->filterBorderPixels(inputBM, &dst, bottom, bounds); - return SkSpecialImage::MakeFromRaster(source->internal_getProxy(), - SkIRect::MakeWH(bounds.width(), bounds.height()), + return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds.height()), dst); } diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp index 1f22a6e194..d5a048c6ce 100644 --- a/src/effects/SkMorphologyImageFilter.cpp +++ b/src/effects/SkMorphologyImageFilter.cpp @@ -533,8 +533,7 @@ static sk_sp<SkSpecialImage> apply_morphology(GrContext* context, srcTexture.reset(scratch); } - return SkSpecialImage::MakeFromGpu(input->internal_getProxy(), - SkIRect::MakeWH(rect.width(), rect.height()), + return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(rect.width(), rect.height()), kNeedNewImageUniqueID_SpecialImage, srcTexture, &input->props()); } @@ -644,7 +643,6 @@ sk_sp<SkSpecialImage> SkMorphologyImageFilter::onFilterImage(SkSpecialImage* sou offset->fX = bounds.left(); offset->fY = bounds.top(); - return SkSpecialImage::MakeFromRaster(source->internal_getProxy(), - SkIRect::MakeWH(bounds.width(), bounds.height()), + return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(bounds.width(), bounds.height()), dst, &source->props()); } diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp index af58a644ee..25a750eefb 100644 --- a/src/effects/SkXfermodeImageFilter.cpp +++ b/src/effects/SkXfermodeImageFilter.cpp @@ -257,8 +257,7 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter::filterImageGPU(SkSpecialImage* sour matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top())); drawContext->drawRect(GrClip::WideOpen(), paint, matrix, SkRect::Make(bounds)); - return SkSpecialImage::MakeFromGpu(source->internal_getProxy(), - SkIRect::MakeWH(bounds.width(), bounds.height()), + return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.height()), kNeedNewImageUniqueID_SpecialImage, dst.get()); } diff --git a/src/gpu/GrLayerHoister.cpp b/src/gpu/GrLayerHoister.cpp index 9a2be0be60..38aff8c2f3 100644 --- a/src/gpu/GrLayerHoister.cpp +++ b/src/gpu/GrLayerHoister.cpp @@ -300,11 +300,9 @@ void GrLayerHoister::FilterLayer(GrContext* context, SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kDefaultCacheSize)); SkImageFilter::Context filterContext(totMat, clipBounds, cache); - SkImageFilter::DeviceProxy proxy(device); - // TODO: should the layer hoister store stand alone layers as SkSpecialImages internally? const SkIRect subset = SkIRect::MakeWH(layer->texture()->width(), layer->texture()->height()); - sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromGpu(&proxy, subset, + sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromGpu(subset, kNeedNewImageUniqueID_SpecialImage, layer->texture(), &device->surfaceProps())); |