From 5ab804aff406ac41bb46df021c76540abda4297c Mon Sep 17 00:00:00 2001 From: Yotam Hacohen Date: Mon, 2 May 2022 20:35:23 +0000 Subject: [PATCH] Remove the return value of setDeviceCoordinateSystem In https://skia-review.googlesource.com/c/skia/+/527505 we removed the 'invert' call from 'SetDeviceCoordinateSystem', removing the only place where the function might return 'false'. This patch changes the return value from bool to void, as it is obsolete. Change-Id: I0262f82d2cf339879ea716bdb5f16ca26d453cb9 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/536097 Reviewed-by: Michael Ludwig Commit-Queue: Michael Ludwig --- src/core/SkCanvas.cpp | 21 ++++++--------------- src/core/SkDevice.cpp | 3 +-- src/core/SkDevice.h | 15 ++++++--------- 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index d6cf83c32d..9c54314a2a 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -1114,21 +1114,12 @@ void SkCanvas::internalSaveLayer(const SaveLayerRec& rec, SaveLayerStrategy stra // The setDeviceCoordinateSystem applies the prior device's global transform since // 'newLayerMapping' only defines the transforms between the two devices and it must be updated // to the global coordinate system. - if (!newDevice->setDeviceCoordinateSystem( - priorDevice->deviceToGlobal() * SkM44(newLayerMapping.layerToDevice()), - SkM44(newLayerMapping.deviceToLayer()) * priorDevice->globalToDevice(), - SkM44(newLayerMapping.layerMatrix()), - layerBounds.left(), - layerBounds.top())) { - // If we made it this far and the coordinate system is invalid, we most likely had a valid - // mapping until being combined with the previous device-to-global matrix, at which point - // it overflowed or floating point rounding caused it to no longer be invertible. There's - // not much we can do but clean up the layer and mark the clip as empty. This tends to come - // up in fuzzer-generated inputs, so this policy is not unreasonable and helps avoids UB. - newDevice = nullptr; - abortLayer(); - return; - } + newDevice->setDeviceCoordinateSystem( + priorDevice->deviceToGlobal() * SkM44(newLayerMapping.layerToDevice()), + SkM44(newLayerMapping.deviceToLayer()) * priorDevice->globalToDevice(), + SkM44(newLayerMapping.layerMatrix()), + layerBounds.left(), + layerBounds.top()); if (initBackdrop) { SkPaint backdropPaint; diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp index d2d31210c7..32a87fd68d 100644 --- a/src/core/SkDevice.cpp +++ b/src/core/SkDevice.cpp @@ -45,7 +45,7 @@ SkBaseDevice::SkBaseDevice(const SkImageInfo& info, const SkSurfaceProps& surfac fGlobalToDevice.setIdentity(); } -bool SkBaseDevice::setDeviceCoordinateSystem(const SkM44& deviceToGlobal, +void SkBaseDevice::setDeviceCoordinateSystem(const SkM44& deviceToGlobal, const SkM44& globalToDevice, const SkM44& localToDevice, int bufferOriginX, @@ -64,7 +64,6 @@ bool SkBaseDevice::setDeviceCoordinateSystem(const SkM44& deviceToGlobal, } fLocalToDevice33 = fLocalToDevice.asM33(); fLocalToDeviceDirty = true; - return true; } void SkBaseDevice::setGlobalCTM(const SkM44& ctm) { diff --git a/src/core/SkDevice.h b/src/core/SkDevice.h index ae9cffd607..a1d115a152 100644 --- a/src/core/SkDevice.h +++ b/src/core/SkDevice.h @@ -464,18 +464,15 @@ private: // is anchored in the device space. The final device-to-global matrix stored by the SkDevice // will include a pre-translation by T(deviceOriginX, deviceOriginY), and the final // local-to-device matrix will have a post-translation of T(-deviceOriginX, -deviceOriginY). - // - // Returns false if the final device coordinate space is invalid, in which case the canvas - // should discard the device - bool SK_WARN_UNUSED_RESULT setDeviceCoordinateSystem(const SkM44& deviceToGlobal, - const SkM44& globalToDevice, - const SkM44& localToDevice, - int bufferOriginX, - int bufferOriginY); + void setDeviceCoordinateSystem(const SkM44& deviceToGlobal, + const SkM44& globalToDevice, + const SkM44& localToDevice, + int bufferOriginX, + int bufferOriginY); // Convenience to configure the device to be axis-aligned with the root canvas, but with a // unique origin. void setOrigin(const SkM44& globalCTM, int x, int y) { - SkAssertResult(this->setDeviceCoordinateSystem(SkM44(), SkM44(), globalCTM, x, y)); + this->setDeviceCoordinateSystem(SkM44(), SkM44(), globalCTM, x, y); } virtual SkImageFilterCache* getImageFilterCache() { return nullptr; }