aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-prod (mdb) <android-build-team-robot@google.com>2018-10-04 14:30:39 +0000
committerandroid-build-prod (mdb) <android-build-team-robot@google.com>2018-10-04 14:30:39 +0000
commitaa8e6d25cbf54cfc4d26db7f489052fa0159a54a (patch)
treec838531d14eada016fb9e44a48b518ad2ff90843
parent8d4f34449419eef424271d5b1298689992431108 (diff)
parent8b38e8b084dea39af9c48ba7a85c057eed7ed2a7 (diff)
downloaddevice_generic_goldfish-opengl-aa8e6d25cbf54cfc4d26db7f489052fa0159a54a.tar.gz
device_generic_goldfish-opengl-aa8e6d25cbf54cfc4d26db7f489052fa0159a54a.tar.bz2
device_generic_goldfish-opengl-aa8e6d25cbf54cfc4d26db7f489052fa0159a54a.zip
Snap for 5048791 from 8b38e8b084dea39af9c48ba7a85c057eed7ed2a7 to emu-3.0-release
Change-Id: I26ac60505874a59a796325335fa2caa3aaf41ebd
-rw-r--r--shared/OpenglCodecCommon/gralloc_cb.h15
-rw-r--r--shared/OpenglCodecCommon/qemu_pipe.h4
-rw-r--r--system/egl/egl.cpp20
-rw-r--r--system/gralloc/gralloc.cpp19
4 files changed, 47 insertions, 11 deletions
diff --git a/shared/OpenglCodecCommon/gralloc_cb.h b/shared/OpenglCodecCommon/gralloc_cb.h
index 04a70404..f874c12f 100644
--- a/shared/OpenglCodecCommon/gralloc_cb.h
+++ b/shared/OpenglCodecCommon/gralloc_cb.h
@@ -22,6 +22,7 @@
#include <cutils/native_handle.h>
#include "goldfish_dma.h"
+#include "qemu_pipe.h"
#define BUFFER_HANDLE_MAGIC ((int)0xabfabfab)
#define CB_HANDLE_NUM_INTS(nfds) (int)((sizeof(cb_handle_t) - (nfds)*sizeof(int)) / sizeof(int))
@@ -64,7 +65,7 @@ struct cb_handle_t : public native_handle {
emuFrameworkFormat(p_emuFrameworkFormat)
{
goldfish_dma.fd = -1;
- dmafd = -1;
+ refcount_pipe_fd = QEMU_PIPE_INVALID_HANDLE;
version = sizeof(native_handle);
numFds = 0;
numInts = CB_HANDLE_NUM_INTS(numFds);
@@ -82,11 +83,15 @@ struct cb_handle_t : public native_handle {
numInts = CB_HANDLE_NUM_INTS(numFds);
}
- void setDmaFd(int fd) {
- if (fd >= 0) {
+ bool hasRefcountPipe() {
+ return qemu_pipe_valid(refcount_pipe_fd);
+ }
+
+ void setRefcountPipeFd(QEMU_PIPE_HANDLE fd) {
+ if (qemu_pipe_valid(fd)) {
numFds++;
}
- dmafd = fd;
+ refcount_pipe_fd = fd;
numInts = CB_HANDLE_NUM_INTS(numFds);
}
@@ -103,7 +108,7 @@ struct cb_handle_t : public native_handle {
// file-descriptors
int fd; // ashmem fd (-1 of ashmem region did not allocated, i.e. no SW access needed)
- int dmafd; // goldfish dma fd.
+ QEMU_PIPE_HANDLE refcount_pipe_fd; // goldfish pipe service for gralloc refcounting fd.
// ints
int magic; // magic number in order to validate a pointer to be a cb_handle_t
diff --git a/shared/OpenglCodecCommon/qemu_pipe.h b/shared/OpenglCodecCommon/qemu_pipe.h
index 4b1aaf22..62de57f4 100644
--- a/shared/OpenglCodecCommon/qemu_pipe.h
+++ b/shared/OpenglCodecCommon/qemu_pipe.h
@@ -22,6 +22,8 @@
typedef void* QEMU_PIPE_HANDLE;
+#define QEMU_PIPE_INVALID_HANDLE NULL
+
QEMU_PIPE_HANDLE qemu_pipe_open(const char* pipeName);
void qemu_pipe_close(QEMU_PIPE_HANDLE pipe);
@@ -37,6 +39,8 @@ void qemu_pipe_print_error(QEMU_PIPE_HANDLE pipe);
typedef int QEMU_PIPE_HANDLE;
+#define QEMU_PIPE_INVALID_HANDLE (-1)
+
#include <cutils/log.h>
#include <sys/cdefs.h>
#include <unistd.h>
diff --git a/system/egl/egl.cpp b/system/egl/egl.cpp
index 5b645c0b..23fb8cc8 100644
--- a/system/egl/egl.cpp
+++ b/system/egl/egl.cpp
@@ -29,6 +29,7 @@
#include "ClientAPIExts.h"
#include "EGLImage.h"
#include "ProcessPipe.h"
+#include "qemu_pipe.h"
#include "GLEncoder.h"
#ifdef WITH_GLES2
@@ -405,6 +406,7 @@ EGLBoolean egl_window_surface_t::init()
DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
rcSurface = rcEnc->rcCreateWindowSurface(rcEnc, (uintptr_t)config,
getWidth(), getHeight());
+
if (!rcSurface) {
ALOGE("rcCreateWindowSurface returned 0");
return EGL_FALSE;
@@ -433,6 +435,7 @@ egl_window_surface_t::~egl_window_surface_t() {
if (rcSurface && rcEnc) {
rcEnc->rcDestroyWindowSurface(rcEnc, rcSurface);
}
+
if (buffer) {
nativeWindow->cancelBuffer_DEPRECATED(nativeWindow, buffer);
}
@@ -599,12 +602,13 @@ private:
EGLBoolean init(GLenum format);
uint32_t rcColorBuffer;
+ QEMU_PIPE_HANDLE refcountPipeFd;
};
egl_pbuffer_surface_t::egl_pbuffer_surface_t(EGLDisplay dpy, EGLConfig config,
EGLint surfType, int32_t w, int32_t h)
: egl_surface_t(dpy, config, surfType),
- rcColorBuffer(0)
+ rcColorBuffer(0), refcountPipeFd(QEMU_PIPE_INVALID_HANDLE)
{
setWidth(w);
setHeight(h);
@@ -614,7 +618,13 @@ egl_pbuffer_surface_t::~egl_pbuffer_surface_t()
{
DEFINE_HOST_CONNECTION;
if (rcEnc) {
- if (rcColorBuffer) rcEnc->rcCloseColorBuffer(rcEnc, rcColorBuffer);
+ if (rcColorBuffer){
+ if(qemu_pipe_valid(refcountPipeFd)) {
+ qemu_pipe_close(refcountPipeFd);
+ } else {
+ rcEnc->rcCloseColorBuffer(rcEnc, rcColorBuffer);
+ }
+ }
if (rcSurface) rcEnc->rcDestroyWindowSurface(rcEnc, rcSurface);
}
}
@@ -665,6 +675,12 @@ EGLBoolean egl_pbuffer_surface_t::init(GLenum pixelFormat)
if (!rcColorBuffer) {
ALOGE("rcCreateColorBuffer returned 0");
return EGL_FALSE;
+ } else {
+ refcountPipeFd = qemu_pipe_open("refcount");
+ //Send color buffer handle in case RefCountPipe feature is turned on.
+ if (qemu_pipe_valid(refcountPipeFd)) {
+ qemu_pipe_write(refcountPipeFd, &rcColorBuffer, 4);
+ }
}
rcEnc->rcSetWindowColorBuffer(rcEnc, rcSurface, rcColorBuffer);
diff --git a/system/gralloc/gralloc.cpp b/system/gralloc/gralloc.cpp
index e3bf5d6f..48b40792 100644
--- a/system/gralloc/gralloc.cpp
+++ b/system/gralloc/gralloc.cpp
@@ -34,6 +34,8 @@
#include "ProcessPipe.h"
#include "ThreadInfo.h"
#include "glUtils.h"
+#include "qemu_pipe.h"
+
#include <cutils/log.h>
#include <cutils/properties.h>
@@ -744,7 +746,6 @@ static int gralloc_alloc(alloc_device_t* dev,
} else {
cb->hostHandle = rcEnc->rcCreateColorBuffer(rcEnc, w, h, allocFormat);
}
- D("Created host ColorBuffer 0x%x\n", cb->hostHandle);
}
if (!cb->hostHandle) {
@@ -753,6 +754,13 @@ static int gralloc_alloc(alloc_device_t* dev,
delete cb;
ALOGD("%s: failed to create host cb! -EIO", __FUNCTION__);
return -EIO;
+ } else {
+ QEMU_PIPE_HANDLE refcountPipeFd = qemu_pipe_open("refcount");
+ if(qemu_pipe_valid(refcountPipeFd)) {
+ cb->setRefcountPipeFd(refcountPipeFd);
+ qemu_pipe_write(refcountPipeFd, &cb->hostHandle, 4);
+ }
+ D("Created host ColorBuffer 0x%x\n", cb->hostHandle);
}
if (isHidlGralloc) { *getOpenCountPtr(cb) = 0; }
@@ -798,7 +806,7 @@ static int gralloc_free(alloc_device_t* dev,
D("%s: for buf %p ptr %p size %d\n",
__FUNCTION__, handle, cb->ashmemBase, cb->ashmemSize);
- if (cb->hostHandle) {
+ if (cb->hostHandle && !cb->hasRefcountPipe()) {
int32_t openCount = 1;
int32_t* openCountPtr = &openCount;
@@ -828,6 +836,9 @@ static int gralloc_free(alloc_device_t* dev,
close(cb->fd);
}
+ if(qemu_pipe_valid(cb->refcount_pipe_fd)) {
+ qemu_pipe_close(cb->refcount_pipe_fd);
+ }
D("%s: done", __FUNCTION__);
// remove it from the allocated list
gralloc_device_t *grdev = (gralloc_device_t *)dev;
@@ -988,7 +999,7 @@ static int gralloc_register_buffer(gralloc_module_t const* module,
D("gralloc_register_buffer(%p) w %d h %d format 0x%x framworkFormat 0x%x",
handle, cb->width, cb->height, cb->format, cb->frameworkFormat);
- if (cb->hostHandle != 0) {
+ if (cb->hostHandle != 0 && !cb->hasRefcountPipe()) {
DEFINE_AND_VALIDATE_HOST_CONNECTION;
D("Opening host ColorBuffer 0x%x\n", cb->hostHandle);
rcEnc->rcOpenColorBuffer2(rcEnc, cb->hostHandle);
@@ -1044,7 +1055,7 @@ static int gralloc_unregister_buffer(gralloc_module_t const* module,
}
- if (cb->hostHandle) {
+ if (cb->hostHandle && !cb->hasRefcountPipe()) {
D("Closing host ColorBuffer 0x%x\n", cb->hostHandle);
DEFINE_AND_VALIDATE_HOST_CONNECTION;
rcEnc->rcCloseColorBuffer(rcEnc, cb->hostHandle);