diff --git a/include/core/SkDrawable.h b/include/core/SkDrawable.h index 48cca6df18..3210ef779e 100644 --- a/include/core/SkDrawable.h +++ b/include/core/SkDrawable.h @@ -74,12 +74,13 @@ public: /** * Snaps off a GpuDrawHandler to represent the state of the SkDrawable at the time the snap is * called. This is used for executing GPU backend specific draws intermixed with normal Skia GPU - * draws. The GPU API, which will be used for the draw, as well as the full matrix are passed in - * as inputs. + * draws. The GPU API, which will be used for the draw, as well as the full matrix and device + * clip bounds are passed in as inputs. */ std::unique_ptr snapGpuDrawHandler(GrBackendApi backendApi, - const SkMatrix& matrix) { - return this->onSnapGpuDrawHandler(backendApi, matrix); + const SkMatrix& matrix, + const SkIRect& clipBounds) { + return this->onSnapGpuDrawHandler(backendApi, matrix, clipBounds); } SkPicture* newPictureSnapshot(); @@ -131,6 +132,12 @@ protected: virtual SkRect onGetBounds() = 0; virtual void onDraw(SkCanvas*) = 0; + virtual std::unique_ptr onSnapGpuDrawHandler(GrBackendApi, const SkMatrix&, + const SkIRect& /*clipBounds*/) { + return nullptr; + } + + // TODO: Delete this once Android gets updated to take the clipBounds version above. virtual std::unique_ptr onSnapGpuDrawHandler(GrBackendApi, const SkMatrix&) { return nullptr; } diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 1ca23df757..e82edbedd3 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1709,7 +1709,7 @@ void SkGpuDevice::drawDrawable(SkDrawable* drawable, const SkMatrix* matrix, SkC const SkMatrix& ctm = canvas->getTotalMatrix(); const SkMatrix& combinedMatrix = matrix ? SkMatrix::Concat(ctm, *matrix) : ctm; std::unique_ptr gpuDraw = - drawable->snapGpuDrawHandler(api, combinedMatrix); + drawable->snapGpuDrawHandler(api, combinedMatrix, canvas->getDeviceClipBounds()); if (gpuDraw) { fRenderTargetContext->drawDrawable(std::move(gpuDraw), drawable->getBounds()); return; diff --git a/tests/VkDrawableTest.cpp b/tests/VkDrawableTest.cpp index 8bb1251284..0ff94aa454 100644 --- a/tests/VkDrawableTest.cpp +++ b/tests/VkDrawableTest.cpp @@ -87,7 +87,8 @@ public: }; std::unique_ptr onSnapGpuDrawHandler(GrBackendApi backendApi, - const SkMatrix& matrix) override { + const SkMatrix& matrix, + const SkIRect& clipBounds) override { if (backendApi != GrBackendApi::kVulkan) { return nullptr; }