Skip to content

Commit

Permalink
Merge changes Ia732806b,Ibd397fb3 into ics
Browse files Browse the repository at this point in the history
* changes:
  Hold a reference to the allocated buffers in GraphicBufferAlloc
  opengl: remove unused adreno flag from the makefile
  • Loading branch information
Kali- authored and Gerrit Code Review committed Jan 14, 2012
2 parents 72c57da + f7519f3 commit 48ba49d
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 4 deletions.
8 changes: 8 additions & 0 deletions include/surfaceflinger/IGraphicBufferAlloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

// ----------------------------------------------------------------------------
Expand Down
21 changes: 21 additions & 0 deletions libs/gui/IGraphicBufferAlloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 6 additions & 0 deletions libs/gui/SurfaceTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -1120,6 +1123,9 @@ void SurfaceTexture::freeAllBuffersExceptHeadLocked() {
freeBufferLocked(i);
}
}
#ifdef QCOM_HARDWARE
mGraphicBufferAlloc->freeAllGraphicBuffersExcept(head);
#endif
}

status_t SurfaceTexture::drainQueueLocked() {
Expand Down
4 changes: 0 additions & 4 deletions opengl/libs/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions services/surfaceflinger/SurfaceFlinger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions services/surfaceflinger/SurfaceFlinger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

// ---------------------------------------------------------------------------
Expand Down

0 comments on commit 48ba49d

Please sign in to comment.