Avoid clearing transaction flags too early

Transaction flags were cleared in commitTransactions  before
checking if we needed to run the composite stage. This caused
us to miss some updates. In addition, display  color matrix is only
updated if the colorMatrixChanged is set so, if we miss an update
device would be in an invalid state until the next update.

Fixes: 300194609
Test: presubmit
Change-Id: Ie397d4c37af6b54ff8d59e1151ddee24811e2d13
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index cbea312..9c3c935 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -728,8 +728,10 @@
             compositionengine::CompositionRefreshArgs& refreshArgs, bool cursorOnly);
     void moveSnapshotsFromCompositionArgs(compositionengine::CompositionRefreshArgs& refreshArgs,
                                           const std::vector<std::pair<Layer*, LayerFE*>>& layers);
+    // Return true if we must composite this frame
     bool updateLayerSnapshotsLegacy(VsyncId vsyncId, nsecs_t frameTimeNs, bool transactionsFlushed,
                                     bool& out) REQUIRES(kMainThreadContext);
+    // Return true if we must composite this frame
     bool updateLayerSnapshots(VsyncId vsyncId, nsecs_t frameTimeNs, bool transactionsFlushed,
                               bool& out) REQUIRES(kMainThreadContext);
     void updateLayerHistory(nsecs_t now);