diff options
author | Mike Reed <reed@google.com> | 2018-05-29 15:41:27 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-29 20:42:17 +0000 |
commit | f2c736400f03f8fe7fe356962c979f23df4d5f6b (patch) | |
tree | 809d21837d0701569cccd0e21f23e2ac5574007a /src/image | |
parent | 4f078f7cfac6580dce6e213c022708922739ac6d (diff) |
support image-subsets in serialization
A follow-on API change *could* be to extend the SerialProcs to pass subset information
up to the client, in case they want to handle the subsetting step themselves.
Bug: skia:7983
Change-Id: I36d3f1ce439886384495485c3be3c591d611a135
Reviewed-on: https://skia-review.googlesource.com/130543
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src/image')
-rw-r--r-- | src/image/SkImage.cpp | 5 | ||||
-rw-r--r-- | src/image/SkImage_Base.h | 4 | ||||
-rw-r--r-- | src/image/SkImage_Lazy.cpp | 4 |
3 files changed, 13 insertions, 0 deletions
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp index 72285bd698..cc4419a904 100644 --- a/src/image/SkImage.cpp +++ b/src/image/SkImage.cpp @@ -411,6 +411,11 @@ void SkImage_unpinAsTexture(const SkImage* image, GrContext* ctx) { as_IB(image)->onUnpinAsTexture(ctx); } +SkIRect SkImage_getSubset(const SkImage* image) { + SkASSERT(image); + return as_IB(image)->onGetSubset(); +} + /////////////////////////////////////////////////////////////////////////////////////////////////// sk_sp<SkImage> SkImageMakeRasterCopyAndAssignColorSpace(const SkImage* src, diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h index 2049fb3561..0d54a39471 100644 --- a/src/image/SkImage_Base.h +++ b/src/image/SkImage_Base.h @@ -38,6 +38,10 @@ public: virtual SkColorType onColorType() const = 0; virtual SkAlphaType onAlphaType() const = 0; + virtual SkIRect onGetSubset() const { + return { 0, 0, this->width(), this->height() }; + } + virtual bool onPeekPixels(SkPixmap*) const { return false; } virtual const SkBitmap* onPeekBitmap() const { return nullptr; } diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp index 82d573d708..7914f58d3c 100644 --- a/src/image/SkImage_Lazy.cpp +++ b/src/image/SkImage_Lazy.cpp @@ -77,6 +77,10 @@ public: return fInfo.alphaType(); } + SkIRect onGetSubset() const override { + return SkIRect::MakeXYWH(fOrigin.fX, fOrigin.fY, fInfo.width(), fInfo.height()); + } + bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY, CachingHint) const override; #if SK_SUPPORT_GPU |