Merge damage region when dropping an app buffer

When we decide to drop a buffer from a buffer queue, make sure to merge
the damage region from the dropped buffer into the current damage
region. Otherwise we'll pass the wrong damage region to hardware
composer and get broken rendering.

Bug: 136158117
Test: Wrote a new test in Transaction_test.cpp to repro the problem and
confirm the fix works.

Change-Id: Icdc61e1be3297450f2869c496dad1453fb6dca6d
diff --git a/services/surfaceflinger/BufferLayerConsumer.h b/services/surfaceflinger/BufferLayerConsumer.h
index e3f6100..901556a 100644
--- a/services/surfaceflinger/BufferLayerConsumer.h
+++ b/services/surfaceflinger/BufferLayerConsumer.h
@@ -140,6 +140,9 @@
     // must be called from SF main thread
     const Region& getSurfaceDamage() const;
 
+    // Merge the given damage region into the current damage region value.
+    void mergeSurfaceDamage(const Region& damage);
+
     // getCurrentApi retrieves the API which queues the current buffer.
     int getCurrentApi() const;