Permalink
Browse files

Merge changes Ia732806b,Ibd397fb3 into ics

* changes:
  Hold a reference to the allocated buffers in GraphicBufferAlloc
  opengl: remove unused adreno flag from the makefile
  • Loading branch information...
2 parents 72c57da + f7519f3 commit 48ba49d343f4b9faab092983c07c5557e22ec612 @Kali- Kali- committed with Gerrit Code Review Jan 14, 2012
@@ -38,6 +38,14 @@ class IGraphicBufferAlloc : public IInterface
*/
virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
PixelFormat format, uint32_t usage, status_t* error) = 0;
+
+#ifdef QCOM_HARDWARE
+ /* Free all but one of the GraphicBuffer objects that the server is
+ * currently referencing. If bufIndex is not a valid index of the buffers
+ * the server is referencing, then all buffers are freed.
+ */
+ virtual void freeAllGraphicBuffersExcept(int bufIndex) = 0;
+#endif
};
// ----------------------------------------------------------------------------
@@ -32,6 +32,9 @@ namespace android {
enum {
CREATE_GRAPHIC_BUFFER = IBinder::FIRST_CALL_TRANSACTION,
+#ifdef QCOM_HARDWARE
+ FREE_ALL_GRAPHIC_BUFFERS_EXCEPT,
+#endif
};
class BpGraphicBufferAlloc : public BpInterface<IGraphicBufferAlloc>
@@ -63,6 +66,16 @@ class BpGraphicBufferAlloc : public BpInterface<IGraphicBufferAlloc>
*error = result;
return graphicBuffer;
}
+
+#ifdef QCOM_HARDWARE
+ virtual void freeAllGraphicBuffersExcept(int bufIdx) {
+ Parcel data, reply;
+ data.writeInterfaceToken(
+ IGraphicBufferAlloc::getInterfaceDescriptor());
+ data.writeInt32(bufIdx);
+ remote()->transact(FREE_ALL_GRAPHIC_BUFFERS_EXCEPT, data, &reply);
+ }
+#endif
};
IMPLEMENT_META_INTERFACE(GraphicBufferAlloc, "android.ui.IGraphicBufferAlloc");
@@ -108,6 +121,14 @@ status_t BnGraphicBufferAlloc::onTransact(
}
return NO_ERROR;
} break;
+#ifdef QCOM_HARDWARE
+ case FREE_ALL_GRAPHIC_BUFFERS_EXCEPT: {
+ CHECK_INTERFACE(IGraphicBufferAlloc, data, reply);
+ int bufIdx = data.readInt32();
+ freeAllGraphicBuffersExcept(bufIdx);
+ return NO_ERROR;
+ } break;
+#endif
default:
return BBinder::onTransact(code, data, reply, flags);
}
@@ -1104,6 +1104,9 @@ void SurfaceTexture::freeAllBuffersLocked() {
for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
freeBufferLocked(i);
}
+#ifdef QCOM_HARDWARE
+ mGraphicBufferAlloc->freeAllGraphicBuffersExcept(-1);
+#endif
}
void SurfaceTexture::freeAllBuffersExceptHeadLocked() {
@@ -1120,6 +1123,9 @@ void SurfaceTexture::freeAllBuffersExceptHeadLocked() {
freeBufferLocked(i);
}
}
+#ifdef QCOM_HARDWARE
+ mGraphicBufferAlloc->freeAllGraphicBuffersExcept(head);
+#endif
}
status_t SurfaceTexture::drainQueueLocked() {
@@ -39,10 +39,6 @@ LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
LOCAL_CFLAGS += -fvisibility=hidden
LOCAL_CFLAGS += -DEGL_TRACE=1
-ifeq ($(TARGET_BOARD_PLATFORM),msm7k)
-LOCAL_CFLAGS += -DADRENO130=1
-endif
-
ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER
endif
@@ -2724,9 +2724,25 @@ sp<GraphicBuffer> GraphicBufferAlloc::createGraphicBuffer(uint32_t w, uint32_t h
w, h, strerror(-err), graphicBuffer->handle);
return 0;
}
+#ifdef QCOM_HARDWARE
+ Mutex::Autolock _l(mLock);
+ mBuffers.add(graphicBuffer);
+#endif
return graphicBuffer;
}
+#ifdef QCOM_HARDWARE
+void GraphicBufferAlloc::freeAllGraphicBuffersExcept(int bufIdx) {
+ Mutex::Autolock _l(mLock);
+ if (0 <= bufIdx && bufIdx < mBuffers.size()) {
+ sp<GraphicBuffer> b(mBuffers[bufIdx]);
+ mBuffers.clear();
+ mBuffers.add(b);
+ } else {
+ mBuffers.clear();
+ }
+}
+#endif
// ---------------------------------------------------------------------------
GraphicPlane::GraphicPlane()
@@ -97,6 +97,12 @@ class GraphicBufferAlloc : public BnGraphicBufferAlloc
virtual ~GraphicBufferAlloc();
virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
PixelFormat format, uint32_t usage, status_t* error);
+#ifdef QCOM_HARDWARE
+ virtual void freeAllGraphicBuffersExcept(int bufIdx);
+private:
+ Vector<sp<GraphicBuffer> > mBuffers;
+ Mutex mLock;
+#endif
};
// ---------------------------------------------------------------------------

0 comments on commit 48ba49d

Please sign in to comment.