diff options
Diffstat (limited to 'src/gpu')
| -rw-r--r-- | src/gpu/SkGpuDevice.cpp | 26 | ||||
| -rw-r--r-- | src/gpu/SkGpuDevice.h | 1 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 9b5a5a9338..0cf4a9a08b 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1264,6 +1264,32 @@ sk_sp<SkSpecialImage> SkGpuDevice::snapSpecial() { &this->surfaceProps()); } +sk_sp<SkSpecialImage> SkGpuDevice::snapBackImage(const SkIRect& subset) { + GrRenderTargetContext* rtc = this->accessRenderTargetContext(); + if (!rtc) { + return nullptr; + } + + GrContext* ctx = this->context(); + if (!rtc->asSurfaceProxy()) { + return nullptr; + } + + auto srcProxy = GrSurfaceProxy::Copy(ctx, rtc->asSurfaceProxy(), rtc->mipMapped(), subset, + rtc->asSurfaceProxy()->isBudgeted()); + if (!srcProxy) { + return nullptr; + } + + // Note, can't move srcProxy since we also refer to this in the 2nd parameter + return SkSpecialImage::MakeDeferredFromGpu(fContext.get(), + SkIRect::MakeWH(srcProxy->width(), srcProxy->height()), + kNeedNewImageUniqueID_SpecialImage, + srcProxy, + this->imageInfo().refColorSpace(), + &this->surfaceProps()); +} + void SkGpuDevice::drawDevice(SkBaseDevice* device, int left, int top, const SkPaint& paint) { SkASSERT(!paint.getImageFilter()); diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h index 6a3f22d6e7..9a1ac12e6c 100644 --- a/src/gpu/SkGpuDevice.h +++ b/src/gpu/SkGpuDevice.h @@ -117,6 +117,7 @@ public: sk_sp<SkSpecialImage> makeSpecial(const SkBitmap&) override; sk_sp<SkSpecialImage> makeSpecial(const SkImage*) override; sk_sp<SkSpecialImage> snapSpecial() override; + sk_sp<SkSpecialImage> snapBackImage(const SkIRect&) override; void flush() override; GrSemaphoresSubmitted flushAndSignalSemaphores(int numSemaphores, |
