summaryrefslogtreecommitdiffstats
path: root/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h
diff options
context:
space:
mode:
authorJesse Hall <jessehall@google.com>2013-03-15 12:32:10 -0700
committerJesse Hall <jessehall@google.com>2013-03-18 14:21:45 -0700
commit80e0a397a4712666661ecc629a64ec26e7f6aac3 (patch)
treef0171cbaeff47237eeab83e2095b76818f04caca /services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h
parent99c7dbb24994df2f3e175f7b25dd2c9dd92a72f0 (diff)
downloadframeworks_native-80e0a397a4712666661ecc629a64ec26e7f6aac3.zip
frameworks_native-80e0a397a4712666661ecc629a64ec26e7f6aac3.tar.gz
frameworks_native-80e0a397a4712666661ecc629a64ec26e7f6aac3.tar.bz2
Add BufferQueueInterposer and use it for virtual displays
BufferQueueInterposer allows a client to tap into a IGraphicBufferProducer-based buffer queue, and modify buffers as they pass from producer to consumer. VirtualDisplaySurface uses this to layer HWC composition on top of GLES composition before passing the buffer to the virtual display consumer. Bug: 8384764 Change-Id: I61ae54f3d90de6a35f4f02bb5e64e7cc88e1cb83
Diffstat (limited to 'services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h')
-rw-r--r--services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h31
1 files changed, 29 insertions, 2 deletions
diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h
index db886ed..66f8580 100644
--- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h
+++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h
@@ -17,7 +17,7 @@
#ifndef ANDROID_SF_VIRTUAL_DISPLAY_SURFACE_H
#define ANDROID_SF_VIRTUAL_DISPLAY_SURFACE_H
-#include <utils/String8.h>
+#include "BufferQueueInterposer.h"
#include "DisplaySurface.h"
// ---------------------------------------------------------------------------
@@ -26,6 +26,28 @@ namespace android {
class HWComposer;
+/* This DisplaySurface implementation uses a BufferQueueInterposer to pass
+ * partially- or fully-composited buffers from the OpenGL ES driver to
+ * HWComposer to use as the output buffer for virtual displays. Allowing HWC
+ * to compose into the same buffer that contains GLES results saves bandwidth
+ * compared to having two separate BufferQueues for frames with at least some
+ * GLES composition.
+ *
+ * The alternative would be to have two complete BufferQueues, one from GLES
+ * to HWC and one from HWC to the virtual display sink (e.g. video encoder).
+ * For GLES-only frames, the same bandwidth saving could be achieved if buffers
+ * could be acquired from the GLES->HWC queue and inserted into the HWC->sink
+ * queue. That would be complicated and doesn't help the mixed GLES+HWC case.
+ *
+ * On frames with no GLES composition, the VirtualDisplaySurface dequeues a
+ * buffer directly from the sink IGraphicBufferProducer and passes it to HWC,
+ * bypassing the GLES driver. This is only guaranteed to work if
+ * eglSwapBuffers doesn't immediately dequeue a buffer for the next frame,
+ * since we can't rely on being able to dequeue more than one buffer at a time.
+ *
+ * TODO(jessehall): Add a libgui test that ensures that EGL/GLES do lazy
+ * dequeBuffers; we've wanted to require that for other reasons anyway.
+ */
class VirtualDisplaySurface : public DisplaySurface {
public:
VirtualDisplaySurface(HWComposer& hwc, int disp,
@@ -45,8 +67,13 @@ private:
// immutable after construction
HWComposer& mHwc;
int mDisplayId;
- sp<IGraphicBufferProducer> mSink;
+ sp<BufferQueueInterposer> mSource;
String8 mName;
+
+ // mutable, must be synchronized with mMutex
+ Mutex mMutex;
+ sp<GraphicBuffer> mAcquiredBuffer;
+ sp<Fence> mReleaseFence;
};
// ---------------------------------------------------------------------------