Refactor hal to remove cpuConsumer from drivers
This CL should minimize build breaks due to
BufferQueue changes in the future.
Change-Id: I565a6eae5cc25603741fef32f2cfcb31a32eb757
diff --git a/driver/rsdAllocation.cpp b/driver/rsdAllocation.cpp
index 1d34f08..19b080f 100644
--- a/driver/rsdAllocation.cpp
+++ b/driver/rsdAllocation.cpp
@@ -617,35 +617,6 @@
}
#ifndef RS_COMPATIBILITY_LIB
-void DrvAllocation::NewBufferListener::onFrameAvailable() {
- intptr_t ip = (intptr_t)alloc;
- rsc->sendMessageToClient(NULL, RS_MESSAGE_TO_CLIENT_NEW_BUFFER, ip, 0, true);
-}
-#endif
-
-void* rsdAllocationGetSurface(const Context *rsc, const Allocation *alloc) {
-#ifndef RS_COMPATIBILITY_LIB
- DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- // Configure CpuConsumer to be in asynchronous mode
- sp<BufferQueue> bq = new BufferQueue();
- drv->cpuConsumer = new CpuConsumer(bq, 2, false);
- sp<IGraphicBufferProducer> bp = bq;
- bp->incStrong(NULL);
-
- drv->mBufferListener = new DrvAllocation::NewBufferListener();
- drv->mBufferListener->rsc = rsc;
- drv->mBufferListener->alloc = alloc;
-
- drv->cpuConsumer->setFrameAvailableListener(drv->mBufferListener);
-
- return bp.get();
-#else
- return NULL;
-#endif
-}
-
-#ifndef RS_COMPATIBILITY_LIB
static bool IoGetBuffer(const Context *rsc, Allocation *alloc, ANativeWindow *nw) {
DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
@@ -780,33 +751,9 @@
void rsdAllocationIoReceive(const Context *rsc, Allocation *alloc) {
#ifndef RS_COMPATIBILITY_LIB
DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv;
-
- if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_SCRIPT) {
- CpuConsumer::LockedBuffer lb;
- status_t ret = drv->cpuConsumer->lockNextBuffer(&lb);
- if (ret == OK) {
- if (drv->lb.data != NULL) {
- drv->cpuConsumer->unlockBuffer(drv->lb);
- }
- drv->lb = lb;
- alloc->mHal.drvState.lod[0].mallocPtr = drv->lb.data;
- alloc->mHal.drvState.lod[0].stride = drv->lb.stride *
- alloc->mHal.state.elementSizeBytes;
-
- if (alloc->mHal.state.yuv) {
- DeriveYUVLayout(alloc->mHal.state.yuv, &alloc->mHal.drvState);
- }
- } else if (ret == BAD_VALUE) {
- // No new frame, don't do anything
- } else {
- rsc->setError(RS_ERROR_DRIVER, "Error receiving IO input buffer.");
- }
-
- } else {
+ if (!(alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_SCRIPT)) {
drv->surfaceTexture->updateTexImage();
}
-
-
#endif
}
@@ -1200,3 +1147,10 @@
}
}
}
+
+uint32_t rsdAllocationGrallocBits(const android::renderscript::Context *rsc,
+ android::renderscript::Allocation *alloc)
+{
+ return 0;
+}
+
diff --git a/driver/rsdAllocation.h b/driver/rsdAllocation.h
index 35999d3..ff47f03 100644
--- a/driver/rsdAllocation.h
+++ b/driver/rsdAllocation.h
@@ -29,7 +29,6 @@
#endif
#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
-#include "gui/CpuConsumer.h"
#include "gui/GLConsumer.h"
#endif
@@ -51,16 +50,6 @@
uint32_t renderTargetID;
#ifndef RS_COMPATIBILITY_LIB
- class NewBufferListener : public android::ConsumerBase::FrameAvailableListener {
- public:
- const android::renderscript::Context *rsc;
- const android::renderscript::Allocation *alloc;
-
- virtual void onFrameAvailable();
- };
- android::sp<NewBufferListener> mBufferListener;
-
-
GLenum glTarget;
GLenum glType;
GLenum glFormat;
@@ -79,11 +68,6 @@
RsdFrameBufferObj * readBackFBO;
ANativeWindow *wnd;
ANativeWindowBuffer *wndBuffer;
-
-#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
- android::sp< android::CpuConsumer > cpuConsumer;
- android::CpuConsumer::LockedBuffer lb;
-#endif
};
#ifndef RS_COMPATIBILITY_LIB
@@ -92,6 +76,8 @@
#endif
+uint32_t rsdAllocationGrallocBits(const android::renderscript::Context *rsc,
+ android::renderscript::Allocation *alloc);
bool rsdAllocationInit(const android::renderscript::Context *rsc,
android::renderscript::Allocation *alloc,
bool forceZero);
@@ -106,8 +92,6 @@
RsAllocationUsageType src);
void rsdAllocationMarkDirty(const android::renderscript::Context *rsc,
const android::renderscript::Allocation *alloc);
-void* rsdAllocationGetSurface(const android::renderscript::Context *rsc,
- const android::renderscript::Allocation *alloc);
void rsdAllocationSetSurface(const android::renderscript::Context *rsc,
android::renderscript::Allocation *alloc, ANativeWindow *nw);
void rsdAllocationIoSend(const android::renderscript::Context *rsc,
diff --git a/driver/rsdCore.cpp b/driver/rsdCore.cpp
index 4aad52a..2b473c4 100644
--- a/driver/rsdCore.cpp
+++ b/driver/rsdCore.cpp
@@ -89,10 +89,10 @@
{
rsdAllocationInit,
rsdAllocationDestroy,
+ rsdAllocationGrallocBits,
rsdAllocationResize,
rsdAllocationSyncAll,
rsdAllocationMarkDirty,
- NATIVE_FUNC(rsdAllocationGetSurface),
NATIVE_FUNC(rsdAllocationSetSurface),
NATIVE_FUNC(rsdAllocationIoSend),
NATIVE_FUNC(rsdAllocationIoReceive),
diff --git a/driver/rsdRuntimeStubs.cpp b/driver/rsdRuntimeStubs.cpp
index cb3a5b4..ac80ba3 100644
--- a/driver/rsdRuntimeStubs.cpp
+++ b/driver/rsdRuntimeStubs.cpp
@@ -141,13 +141,13 @@
#ifndef RS_COMPATIBILITY_LIB
static void SC_AllocationIoSend(Allocation *alloc) {
Context *rsc = RsdCpuReference::getTlsContext();
- rsdAllocationIoSend(rsc, alloc);
+ rsrAllocationIoSend(rsc, alloc);
}
static void SC_AllocationIoReceive(Allocation *alloc) {
Context *rsc = RsdCpuReference::getTlsContext();
- rsdAllocationIoReceive(rsc, alloc);
+ rsrAllocationIoReceive(rsc, alloc);
}
diff --git a/driver/runtime/rs_structs.h b/driver/runtime/rs_structs.h
index 6db4279..204717c 100644
--- a/driver/runtime/rs_structs.h
+++ b/driver/runtime/rs_structs.h
@@ -39,8 +39,8 @@
bool hasReferences;
void * usrPtr;
int32_t surfaceTextureID;
- void * wndSurface;
- void * surfaceTexture;
+ void * nativeBuffer;
+ int64_t timestamp;
} state;
struct DrvState {