From 7af5b2c65387c08b59cdcff700a7321f85912d0e Mon Sep 17 00:00:00 2001 From: John Reck Date: Wed, 5 Dec 2018 13:36:20 -0800 Subject: [PATCH] Fix skp on 32-bit %d strikes again... Test: dumped skp on 32bit app Change-Id: Ica4d9e3939d0e726beb80fbf45a938b004b5eb5d --- libs/hwui/RenderNode.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp index 4a639102192fa..00ce28ad196fd 100644 --- a/libs/hwui/RenderNode.cpp +++ b/libs/hwui/RenderNode.cpp @@ -454,6 +454,9 @@ const SkPath* RenderNode::getClippedOutline(const SkRect& clipRect) const { using StringBuffer = FatVector; template +// TODO:__printflike(2, 3) +// Doesn't work because the warning doesn't understand string_view and doesn't like that +// it's not a C-style variadic function. static void format(StringBuffer& buffer, const std::string_view& format, T... args) { buffer.resize(buffer.capacity()); while (1) { @@ -468,19 +471,20 @@ static void format(StringBuffer& buffer, const std::string_view& format, T... ar buffer.resize(needed + 1); return; } - buffer.resize(buffer.size() * 2); + // If we're doing a heap alloc anyway might as well give it some slop + buffer.resize(needed + 100); } } void RenderNode::markDrawStart(SkCanvas& canvas) { StringBuffer buffer; - format(buffer, "RenderNode(id=%d, name='%s')", uniqueId(), getName()); + format(buffer, "RenderNode(id=%" PRId64 ", name='%s')", uniqueId(), getName()); canvas.drawAnnotation(SkRect::MakeWH(getWidth(), getHeight()), buffer.data(), nullptr); } void RenderNode::markDrawEnd(SkCanvas& canvas) { StringBuffer buffer; - format(buffer, "/RenderNode(id=%d, name='%s')", uniqueId(), getName()); + format(buffer, "/RenderNode(id=%" PRId64 ", name='%s')", uniqueId(), getName()); canvas.drawAnnotation(SkRect::MakeWH(getWidth(), getHeight()), buffer.data(), nullptr); }