From 66365e40f39e081672e50f5cbab83316b2246481 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Mon, 8 Apr 2019 16:58:04 -0700 Subject: Transaction::setGeometry: Handle invalid src rect correctly If no source rect (INVALID_RECT) is passed in we use no crop and a scaling factor of 1. Bug: 123720507 Test: android.wm.cts.SurfaceControlTest Change-Id: I92a7f951c32fb10071a7fac17bc338b433d521fd --- libs/gui/SurfaceComposerClient.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libs/gui/SurfaceComposerClient.cpp') diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 0e6170278f..e9bcf268f1 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -1147,8 +1147,12 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setGeome int x = dst.left; int y = dst.top; - float xScale = dst.getWidth() / static_cast(source.getWidth()); - float yScale = dst.getHeight() / static_cast(source.getHeight()); + + float sourceWidth = source.getWidth(); + float sourceHeight = source.getHeight(); + + float xScale = sourceWidth < 0 ? 1.0f : dst.getWidth() / sourceWidth; + float yScale = sourceHeight < 0 ? 1.0f : dst.getHeight() / sourceHeight; float matrix[4] = {1, 0, 0, 1}; switch (transform) { -- cgit v1.2.3-59-g8ed1b