diff options
author | Mike Reed <reed@google.com> | 2018-11-21 13:13:29 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-11-21 13:13:37 +0000 |
commit | 1e28e5d79e895e502afddecda2eb66a73a453d38 (patch) | |
tree | 6924704f0f181c1fd1edc39ff4168ce2c75f9211 /src/image | |
parent | 302809f47e629a6a63d4db0225c30b875d6bbef3 (diff) | |
download | skqp-1e28e5d79e895e502afddecda2eb66a73a453d38.tar.gz |
Revert "add rect-parameter to makeImageSnapshot"
This reverts commit e195d1c22e4f40dd3c2fa06303291aff5158c30c.
Reason for revert: broke android subclass (illegal)
Original change's description:
> add rect-parameter to makeImageSnapshot
>
> Bug: skia:
> Change-Id: I56044fb1f21b959993d69fc587f95e3dbf30c371
> Reviewed-on: https://skia-review.googlesource.com/c/171905
> Commit-Queue: Mike Reed <reed@google.com>
> Auto-Submit: Mike Reed <reed@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
TBR=djsollen@google.com,egdaniel@google.com,jvanverth@google.com,bsalomon@google.com,reed@google.com
Change-Id: Ied294732b332192e251a845a5cb6349a670c25b0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/c/172301
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src/image')
-rw-r--r-- | src/image/SkSurface.cpp | 16 | ||||
-rw-r--r-- | src/image/SkSurface_Base.h | 5 | ||||
-rw-r--r-- | src/image/SkSurface_Gpu.cpp | 14 | ||||
-rw-r--r-- | src/image/SkSurface_Gpu.h | 2 | ||||
-rw-r--r-- | src/image/SkSurface_Raster.cpp | 13 |
5 files changed, 10 insertions, 40 deletions
diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp index e4a1986630..1a3eb4312e 100644 --- a/src/image/SkSurface.cpp +++ b/src/image/SkSurface.cpp @@ -167,20 +167,6 @@ sk_sp<SkImage> SkSurface::makeImageSnapshot() { return asSB(this)->refCachedImage(); } -sk_sp<SkImage> SkSurface::makeImageSnapshot(const SkIRect& srcBounds) { - const SkIRect surfBounds = { 0, 0, fWidth, fHeight }; - SkIRect bounds = srcBounds; - if (!bounds.intersect(surfBounds)) { - return nullptr; - } - SkASSERT(!bounds.isEmpty()); - if (bounds == surfBounds) { - return this->makeImageSnapshot(); - } else { - return asSB(this)->onNewImageSnapshot(&bounds); - } -} - sk_sp<SkSurface> SkSurface::makeSurface(const SkImageInfo& info) { return asSB(this)->onNewSurface(info); } @@ -279,7 +265,7 @@ protected: sk_sp<SkSurface> onNewSurface(const SkImageInfo& info) override { return MakeNull(info.width(), info.height()); } - sk_sp<SkImage> onNewImageSnapshot(const SkIRect* subsetOrNull) override { return nullptr; } + sk_sp<SkImage> onNewImageSnapshot() override { return nullptr; } void onWritePixels(const SkPixmap&, int x, int y) override {} void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) override {} void onCopyOnWrite(ContentChangeMode) override {} diff --git a/src/image/SkSurface_Base.h b/src/image/SkSurface_Base.h index ef09331d40..67d330f9bb 100644 --- a/src/image/SkSurface_Base.h +++ b/src/image/SkSurface_Base.h @@ -37,11 +37,8 @@ public: * This needs to be able to outlive the surface itself (if need be), and * must faithfully represent the current contents, even if the surface * is changed after this called (e.g. it is drawn to via its canvas). - * - * If a subset is specified, the the impl must make a copy, rather than try to wait - * on copy-on-write. */ - virtual sk_sp<SkImage> onNewImageSnapshot(const SkIRect* subset = nullptr) = 0; + virtual sk_sp<SkImage> onNewImageSnapshot() = 0; virtual void onWritePixels(const SkPixmap&, int x, int y) = 0; diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index 41f36a8724..af0b564515 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -83,7 +83,7 @@ sk_sp<SkSurface> SkSurface_Gpu::onNewSurface(const SkImageInfo& info) { origin, &this->props()); } -sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot(const SkIRect* subset) { +sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot() { GrRenderTargetContext* rtc = fDevice->accessRenderTargetContext(); if (!rtc) { return nullptr; @@ -98,14 +98,10 @@ sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot(const SkIRect* subset) { SkBudgeted budgeted = rtc->asSurfaceProxy()->isBudgeted(); sk_sp<GrTextureProxy> srcProxy = rtc->asTextureProxyRef(); - - if (subset) { - srcProxy = GrSurfaceProxy::Copy(ctx, rtc->asSurfaceProxy(), rtc->mipMapped(), *subset, - budgeted); - } else if (!srcProxy || rtc->priv().refsWrappedObjects()) { - // If the original render target is a buffer originally created by the client, then we don't - // want to ever retarget the SkSurface at another buffer we create. Force a copy now to avoid - // copy-on-write. + // If the original render target is a buffer originally created by the client, then we don't + // want to ever retarget the SkSurface at another buffer we create. Force a copy now to avoid + // copy-on-write. + if (!srcProxy || rtc->priv().refsWrappedObjects()) { SkASSERT(rtc->origin() == rtc->asSurfaceProxy()->origin()); srcProxy = GrSurfaceProxy::Copy(ctx, rtc->asSurfaceProxy(), rtc->mipMapped(), budgeted); diff --git a/src/image/SkSurface_Gpu.h b/src/image/SkSurface_Gpu.h index d5fea6dcbd..97fe5e5d5a 100644 --- a/src/image/SkSurface_Gpu.h +++ b/src/image/SkSurface_Gpu.h @@ -28,7 +28,7 @@ public: SkCanvas* onNewCanvas() override; sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override; - sk_sp<SkImage> onNewImageSnapshot(const SkIRect* subset) override; + sk_sp<SkImage> onNewImageSnapshot() override; void onWritePixels(const SkPixmap&, int x, int y) override; void onCopyOnWrite(ContentChangeMode) override; void onDiscard() override; diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp index 5a4fcd2915..19078239d4 100644 --- a/src/image/SkSurface_Raster.cpp +++ b/src/image/SkSurface_Raster.cpp @@ -21,7 +21,7 @@ public: SkCanvas* onNewCanvas() override; sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override; - sk_sp<SkImage> onNewImageSnapshot(const SkIRect* subset) override; + sk_sp<SkImage> onNewImageSnapshot() override; void onWritePixels(const SkPixmap&, int x, int y) override; void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) override; void onCopyOnWrite(ContentChangeMode) override; @@ -98,16 +98,7 @@ void SkSurface_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, canvas->drawBitmap(fBitmap, x, y, paint); } -sk_sp<SkImage> SkSurface_Raster::onNewImageSnapshot(const SkIRect* subset) { - if (subset) { - SkASSERT(SkIRect::MakeWH(fBitmap.width(), fBitmap.height()).contains(*subset)); - SkBitmap dst; - dst.allocPixels(fBitmap.info().makeWH(subset->width(), subset->height())); - SkAssertResult(fBitmap.readPixels(dst.pixmap(), subset->left(), subset->top())); - dst.setImmutable(); // key, so MakeFromBitmap doesn't make a copy of the buffer - return SkImage::MakeFromBitmap(dst); - } - +sk_sp<SkImage> SkSurface_Raster::onNewImageSnapshot() { SkCopyPixelsMode cpm = kIfMutable_SkCopyPixelsMode; if (fWeOwnThePixels) { // SkImage_raster requires these pixels are immutable for its full lifetime. |