Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3715677d authored by Stan Iliev's avatar Stan Iliev
Browse files

Fix nine patch scaling

Fix nine patch scaling for assets that don't match the DPI.
Sometimes nine patches were scaled up with divs bigger than
width/height. This is fixing incorrect SearchView control draw
for 213dpi material theme in ThemeHostTest.

Test: Ran CtsGraphicsTestCases, CtsUiRenderingTestCases tests
Change-Id: Ifb8037e8ece97b802e723f911d9b74ccd8fe5400
parent 9cc5b4f0
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -130,8 +130,10 @@ static void scaleNinePatchChunk(android::Res_png_9patch* chunk, float scale,
    chunk->paddingRight = int(chunk->paddingRight * scale + 0.5f);
    chunk->paddingBottom = int(chunk->paddingBottom * scale + 0.5f);

    scaleDivRange(chunk->getXDivs(), chunk->numXDivs, scale, scaledWidth);
    scaleDivRange(chunk->getYDivs(), chunk->numYDivs, scale, scaledHeight);
    // The max value for the divRange is one pixel less than the actual max to ensure that the size
    // of the last div is not zero. A div of size 0 is considered invalid input and will not render.
    scaleDivRange(chunk->getXDivs(), chunk->numXDivs, scale, scaledWidth - 1);
    scaleDivRange(chunk->getYDivs(), chunk->numYDivs, scale, scaledHeight - 1);
}

class ScaleCheckingAllocator : public SkBitmap::HeapAllocator {