SF: fix BufferTX counter for null buffers

Don't increment the BufferTX counter is the transaction includes
a buffer change but that buffer is null.

Test: Open  https://jsfiddle.net/8q7nuwh9/show in Chrome and scroll up down
Bug: 192352790
Change-Id: Ia0a27ff32fb20f20a1ac671f2b4fdb3ae22a8aea
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index e65c721..2d99fc1 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -562,6 +562,10 @@
     return (what & layer_state_t::eBufferChanged) || (what & layer_state_t::eCachedBufferChanged);
 }
 
+bool layer_state_t::hasValidBuffer() const {
+    return buffer || cachedBuffer.isValid();
+}
+
 status_t layer_state_t::matrix22_t::write(Parcel& output) const {
     SAFE_PARCEL(output.writeFloat, dsdx);
     SAFE_PARCEL(output.writeFloat, dtdx);
diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h
index 8ac1e5d..465e34c 100644
--- a/libs/gui/include/gui/LayerState.h
+++ b/libs/gui/include/gui/LayerState.h
@@ -126,6 +126,7 @@
     status_t write(Parcel& output) const;
     status_t read(const Parcel& input);
     bool hasBufferChanges() const;
+    bool hasValidBuffer() const;
 
     struct matrix22_t {
         float dsdx{0};