hwc: Use intermediate buffers for copybit
The earlier copybit solution involved blitting directly into
the SurfaceFlinger's framebuffer target. That solution involved
unnecessary framework changes and caused issues when the
framebuffer was being written to both by GL and copybit.
Update hwc_copybit to use our own buffers for this purpose.
We also make sure we display only the region we're interested in
so that unnecessary artifacts from previous blits do not show up
on the display. This way, we can avoid clearing the intermediate
buffers every frame.
Change-Id: I713b3fc606e0768444c621af76853ece41964da1
diff --git a/libhwcomposer/hwc_copybit.h b/libhwcomposer/hwc_copybit.h
index 015d85a..45d254a 100644
--- a/libhwcomposer/hwc_copybit.h
+++ b/libhwcomposer/hwc_copybit.h
@@ -21,8 +21,7 @@
#define HWC_COPYBIT_H
#include "hwc_utils.h"
-#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
-#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
+#define NUM_RENDER_BUFFERS 2
namespace qhwc {
@@ -40,6 +39,11 @@
int dpy, int* fd);
// resets the values
void reset();
+
+ private_handle_t * getCurrentRenderBuffer();
+
+ void setReleaseFd(int fd);
+
private:
// holds the copybit device
struct copybit_device_t *mEngine;
@@ -61,6 +65,19 @@
void getLayerResolution(const hwc_layer_1_t* layer,
unsigned int &width, unsigned int& height);
+
+ int allocRenderBuffers(int w, int h, int f);
+
+ void freeRenderBuffers();
+
+ private_handle_t* mRenderBuffer[NUM_RENDER_BUFFERS];
+
+ // Index of the current intermediate render buffer
+ int mCurRenderBufferIndex;
+
+ //These are the the release FDs of the T-2 and T-1 round
+ //We wait on the T-2 fence
+ int mRelFd[2];
};
}; //namespace qhwc