diff options
author | 2016-04-17 14:31:22 -0700 | |
---|---|---|
committer | 2016-04-17 14:31:22 -0700 | |
commit | cb232e8b1b9f2d7831ad90815df5934ecafab1d4 (patch) | |
tree | 61581521bdc335326fc9de5bd9d90262612c419e /include/core | |
parent | 225db4441e0cb887d52c906e8bb39df506304b3e (diff) |
Revert of Remove deprecated paths from image filter infrastructure. (patchset #2 id:20001 of https://codereview.chromium.org/1888243003/ )
Reason for revert:
Surprisingly (appallingly?), Chrome calls canFilterImageGPU
Original issue's description:
> Remove deprecated paths from image filter infrastructure.
>
> Now that there are no filterImageGPUDeprecated() implementations,
> we can being to rip out the deprecated infrastructure.
>
> BUG=skia:
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1888243003
>
> Committed: https://skia.googlesource.com/skia/+/6fb3cd7209849e665635ac17ef4eef4ad63e7f61
TBR=reed@google.com,senorblanco@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/1893993002
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkDevice.h | 22 | ||||
-rw-r--r-- | include/core/SkImageFilter.h | 51 |
2 files changed, 73 insertions, 0 deletions
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h index 2377b57dfb..c15aeccf82 100644 --- a/include/core/SkDevice.h +++ b/include/core/SkDevice.h @@ -280,6 +280,28 @@ protected: */ virtual const SkBitmap& onAccessBitmap() = 0; + /** + * Override and return true for filters that the device can handle + * intrinsically. Doing so means that SkCanvas will pass-through this + * filter to drawSprite and drawDevice (and potentially filterImage). + * Returning false means the SkCanvas will have apply the filter itself, + * and just pass the resulting image to the device. + */ + virtual bool canHandleImageFilter(const SkImageFilter*) { return false; } + + /** + * Related (but not required) to canHandleImageFilter, this method returns + * true if the device could apply the filter to the src bitmap and return + * the result (and updates offset as needed). + * If the device does not recognize or support this filter, + * it just returns false and leaves result and offset unchanged. + */ + virtual bool filterImage(const SkImageFilter*, const SkBitmap&, + const SkImageFilter::Context&, + SkBitmap* /*result*/, SkIPoint* /*offset*/) { + return false; + } + protected: virtual sk_sp<SkSurface> makeSurface(const SkImageInfo&, const SkSurfaceProps&); virtual bool onPeekPixels(SkPixmap*) { return false; } diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h index 554f9f8335..dcd25bf91b 100644 --- a/include/core/SkImageFilter.h +++ b/include/core/SkImageFilter.h @@ -116,6 +116,12 @@ public: virtual SkBaseDevice* createDevice(int width, int height, TileUsage usage = kNever_TileUsage) = 0; + + // Returns true if the proxy handled the filter itself. If this returns + // false then the filter's code will be called. + virtual bool filterImage(const SkImageFilter*, const SkBitmap& src, + const SkImageFilter::Context&, + SkBitmap* result, SkIPoint* offset) = 0; }; class DeviceProxy : public Proxy { @@ -125,6 +131,11 @@ public: SkBaseDevice* createDevice(int width, int height, TileUsage usage = kNever_TileUsage) override; + // Returns true if the proxy handled the filter itself. If this returns + // false then the filter's code will be called. + bool filterImage(const SkImageFilter*, const SkBitmap& src, const SkImageFilter::Context&, + SkBitmap* result, SkIPoint* offset) override; + private: SkBaseDevice* fDevice; }; @@ -164,6 +175,31 @@ public: SkIRect filterBounds(const SkIRect& src, const SkMatrix& ctm, MapDirection = kReverse_MapDirection) const; + /** + * Returns true if the filter can be processed on the GPU. This is most + * often used for multi-pass effects, where intermediate results must be + * rendered to textures. For single-pass effects, use asFragmentProcessor(). + * The default implementation returns asFragmentProcessor(NULL, NULL, SkMatrix::I(), + * SkIRect()). + */ + virtual bool canFilterImageGPU() const { return false; } + + /** + * Process this image filter on the GPU. This is most often used for + * multi-pass effects, where intermediate results must be rendered to + * textures. For single-pass effects, use asFragmentProcessor(). src is the + * source image for processing, as a texture-backed bitmap. result is + * the destination bitmap, which should contain a texture-backed pixelref + * on success. offset is the amount to translate the resulting image + * relative to the src when it is drawn. The default implementation does + * single-pass processing using asFragmentProcessor(). + */ + virtual bool filterImageGPUDeprecated(Proxy*, const SkBitmap&, const Context&, + SkBitmap*, SkIPoint*) const { + SkASSERT(false); + return false; + } + #if SK_SUPPORT_GPU static sk_sp<SkSpecialImage> DrawWithFP(GrContext* context, sk_sp<GrFragmentProcessor> fp, @@ -262,6 +298,18 @@ public: const Context&, SkIPoint* offset) const; +#if SK_SUPPORT_GPU + // Helper function which invokes GPU filter processing on the + // input at the specified "index". If the input is null, it leaves + // "result" and "offset" untouched, and returns true. If the input + // has a GPU implementation, it will be invoked directly. + // Otherwise, the filter will be processed in software and + // uploaded to the GPU. + bool filterInputGPUDeprecated(int index, SkImageFilter::Proxy* proxy, + const SkBitmap& src, const Context&, + SkBitmap* result, SkIPoint* offset) const; +#endif + SK_TO_STRING_PUREVIRT() SK_DEFINE_FLATTENABLE_TYPE(SkImageFilter) @@ -392,6 +440,9 @@ protected: * which are not capable of processing a smaller source bitmap into a * larger destination. */ + bool applyCropRectDeprecated(const Context&, Proxy* proxy, const SkBitmap& src, + SkIPoint* srcOffset, SkIRect* bounds, SkBitmap* result) const; + sk_sp<SkSpecialImage> applyCropRect(const Context&, SkSpecialImage* src, SkIPoint* srcOffset, SkIRect* bounds) const; |