CanvasContext::draw: flushAndSubmit when not drawing

Bug: 195081399
Test: manual + dumpsys gfxinfo

CanvasContext::draw has some conditions under which it will not draw. We
still need to flushAndSubmit to free scratch memory if there were
texture uploads this frame.

Change-Id: I60d230cd36bed310a3155e4f1ca647c99c13c4cd
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index 025be7b..2f3a509 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -482,6 +482,12 @@
 
     if (dirty.isEmpty() && Properties::skipEmptyFrames && !surfaceRequiresRedraw()) {
         mCurrentFrameInfo->addFlag(FrameInfoFlags::SkippedFrame);
+        if (auto grContext = getGrContext()) {
+            // Submit to ensure that any texture uploads complete and Skia can
+            // free its staging buffers.
+            grContext->flushAndSubmit();
+        }
+
         // Notify the callbacks, even if there's nothing to draw so they aren't waiting
         // indefinitely
         waitOnFences();