The gralloc register_buffer() function, which calls rcOpenColorBuffer,
must actually increment the reference count before returning.
Otherwise the buffer allocator may release its reference before the
client has obtained one, and the buffer will be freed prematurely.
Since rcOpenColorBuffer was just sending a message to the host without
waiting for it to be received/processed, this guarantee was not met.
Adding a return value makes the call synchronous.
Bug:
12988668
Change-Id: I8b2399cfb0f600f99b3387f630343291b59bc9a6
if (cb->hostHandle != 0) {
DEFINE_AND_VALIDATE_HOST_CONNECTION;
D("Opening host ColorBuffer 0x%x\n", cb->hostHandle);
- rcEnc->rcOpenColorBuffer(rcEnc, cb->hostHandle);
+ rcEnc->rcOpenColorBuffer2(rcEnc, cb->hostHandle);
}
//
ptr = getProc("rcColorBufferCacheFlush", userData); set_rcColorBufferCacheFlush((rcColorBufferCacheFlush_client_proc_t)ptr);
ptr = getProc("rcReadColorBuffer", userData); set_rcReadColorBuffer((rcReadColorBuffer_client_proc_t)ptr);
ptr = getProc("rcUpdateColorBuffer", userData); set_rcUpdateColorBuffer((rcUpdateColorBuffer_client_proc_t)ptr);
+ ptr = getProc("rcOpenColorBuffer2", userData); set_rcOpenColorBuffer2((rcOpenColorBuffer2_client_proc_t)ptr);
return 0;
}
rcColorBufferCacheFlush_client_proc_t rcColorBufferCacheFlush;
rcReadColorBuffer_client_proc_t rcReadColorBuffer;
rcUpdateColorBuffer_client_proc_t rcUpdateColorBuffer;
+ rcOpenColorBuffer2_client_proc_t rcOpenColorBuffer2;
//Accessors
virtual rcGetRendererVersion_client_proc_t set_rcGetRendererVersion(rcGetRendererVersion_client_proc_t f) { rcGetRendererVersion_client_proc_t retval = rcGetRendererVersion; rcGetRendererVersion = f; return retval;}
virtual rcGetEGLVersion_client_proc_t set_rcGetEGLVersion(rcGetEGLVersion_client_proc_t f) { rcGetEGLVersion_client_proc_t retval = rcGetEGLVersion; rcGetEGLVersion = f; return retval;}
virtual rcColorBufferCacheFlush_client_proc_t set_rcColorBufferCacheFlush(rcColorBufferCacheFlush_client_proc_t f) { rcColorBufferCacheFlush_client_proc_t retval = rcColorBufferCacheFlush; rcColorBufferCacheFlush = f; return retval;}
virtual rcReadColorBuffer_client_proc_t set_rcReadColorBuffer(rcReadColorBuffer_client_proc_t f) { rcReadColorBuffer_client_proc_t retval = rcReadColorBuffer; rcReadColorBuffer = f; return retval;}
virtual rcUpdateColorBuffer_client_proc_t set_rcUpdateColorBuffer(rcUpdateColorBuffer_client_proc_t f) { rcUpdateColorBuffer_client_proc_t retval = rcUpdateColorBuffer; rcUpdateColorBuffer = f; return retval;}
+ virtual rcOpenColorBuffer2_client_proc_t set_rcOpenColorBuffer2(rcOpenColorBuffer2_client_proc_t f) { rcOpenColorBuffer2_client_proc_t retval = rcOpenColorBuffer2; rcOpenColorBuffer2 = f; return retval;}
virtual ~renderControl_client_context_t() {}
typedef renderControl_client_context_t *CONTEXT_ACCESSOR_TYPE(void);
typedef EGLint (renderControl_APIENTRY *rcColorBufferCacheFlush_client_proc_t) (void * ctx, uint32_t, EGLint, int);
typedef void (renderControl_APIENTRY *rcReadColorBuffer_client_proc_t) (void * ctx, uint32_t, GLint, GLint, GLint, GLint, GLenum, GLenum, void*);
typedef int (renderControl_APIENTRY *rcUpdateColorBuffer_client_proc_t) (void * ctx, uint32_t, GLint, GLint, GLint, GLint, GLenum, GLenum, void*);
+typedef int (renderControl_APIENTRY *rcOpenColorBuffer2_client_proc_t) (void * ctx, uint32_t);
#endif
return retval;
}
+int rcOpenColorBuffer2_enc(void *self , uint32_t colorbuffer)
+{
+
+ renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+ IOStream *stream = ctx->m_stream;
+
+ unsigned char *ptr;
+ const size_t packetSize = 8 + 4;
+ ptr = stream->alloc(packetSize);
+ int tmp = OP_rcOpenColorBuffer2;memcpy(ptr, &tmp, 4); ptr += 4;
+ memcpy(ptr, &packetSize, 4); ptr += 4;
+
+ memcpy(ptr, &colorbuffer, 4); ptr += 4;
+
+ int retval;
+ stream->readback(&retval, 4);
+ return retval;
+}
+
renderControl_encoder_context_t::renderControl_encoder_context_t(IOStream *stream)
{
m_stream = stream;
set_rcColorBufferCacheFlush(rcColorBufferCacheFlush_enc);
set_rcReadColorBuffer(rcReadColorBuffer_enc);
set_rcUpdateColorBuffer(rcUpdateColorBuffer_enc);
+ set_rcOpenColorBuffer2(rcOpenColorBuffer2_enc);
}
EGLint rcColorBufferCacheFlush_enc(void *self , uint32_t colorbuffer, EGLint postCount, int forRead);
void rcReadColorBuffer_enc(void *self , uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels);
int rcUpdateColorBuffer_enc(void *self , uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels);
+ int rcOpenColorBuffer2_enc(void *self , uint32_t colorbuffer);
};
#endif
\ No newline at end of file
EGLint rcColorBufferCacheFlush(uint32_t colorbuffer, EGLint postCount, int forRead);
void rcReadColorBuffer(uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels);
int rcUpdateColorBuffer(uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels);
+ int rcOpenColorBuffer2(uint32_t colorbuffer);
};
#endif
return ctx->rcUpdateColorBuffer(ctx, colorbuffer, x, y, width, height, format, type, pixels);
}
+int rcOpenColorBuffer2(uint32_t colorbuffer)
+{
+ GET_CONTEXT;
+ return ctx->rcOpenColorBuffer2(ctx, colorbuffer);
+}
+
{"rcColorBufferCacheFlush", (void*)rcColorBufferCacheFlush},
{"rcReadColorBuffer", (void*)rcReadColorBuffer},
{"rcUpdateColorBuffer", (void*)rcUpdateColorBuffer},
+ {"rcOpenColorBuffer2", (void*)rcOpenColorBuffer2},
};
static int renderControl_num_funcs = sizeof(renderControl_funcs_by_name) / sizeof(struct _renderControl_funcs_by_name);
#define OP_rcColorBufferCacheFlush 10022
#define OP_rcReadColorBuffer 10023
#define OP_rcUpdateColorBuffer 10024
-#define OP_last 10025
+#define OP_rcOpenColorBuffer2 10025
+#define OP_last 10026
#endif