class SharedBufferBase
{
public:
- SharedBufferBase(SharedClient* sharedClient, int surface, int num);
+ SharedBufferBase(SharedClient* sharedClient, int surface, int num,
+ int32_t identity);
~SharedBufferBase();
uint32_t getIdentity();
status_t getStatus() const;
SharedClient* const mSharedClient;
SharedBufferStack* const mSharedStack;
const int mNumBuffers;
+ const int mIdentity;
friend struct Update;
friend struct QueueUpdate;
SharedClient& client( *mSharedClient );
const nsecs_t TIMEOUT = s2ns(1);
Mutex::Autolock _l(client.lock);
- while ((condition()==false) && (stack.status == NO_ERROR)) {
+ while ((condition()==false) &&
+ (stack.identity == mIdentity) &&
+ (stack.status == NO_ERROR))
+ {
status_t err = client.cv.waitRelative(client.lock, TIMEOUT);
// handle errors and timeouts
LOGE("waitForCondition(%s) timed out (identity=%d), "
"but condition is true! We recovered but it "
"shouldn't happen." , T::name(),
- mSharedStack->identity);
+ stack.identity);
break;
} else {
LOGW("waitForCondition(%s) timed out "
"(identity=%d, status=%d). "
"CPU may be pegged. trying again.", T::name(),
- mSharedStack->identity, mSharedStack->status);
+ stack.identity, stack.status);
}
} else {
LOGE("waitForCondition(%s) error (%s) ",
}
}
}
- return stack.status;
+ return (stack.identity != mIdentity) ? status_t(BAD_INDEX) : stack.status;
}
class SharedBufferClient : public SharedBufferBase
{
public:
- SharedBufferClient(SharedClient* sharedClient, int surface, int num);
-
+ SharedBufferClient(SharedClient* sharedClient, int surface, int num,
+ int32_t identity);
+
ssize_t dequeue();
status_t undoDequeue(int buf);
void Layer::reloadTexture(const Region& dirty)
{
Mutex::Autolock _l(mLock);
- sp<GraphicBuffer> buffer(getFrontBuffer());
+ sp<GraphicBuffer> buffer(getFrontBufferLocked());
if (LIKELY((mFlags & DisplayHardware::DIRECT_TEXTURE) &&
(buffer->usage & GRALLOC_USAGE_HW_TEXTURE))) {
int index = mFrontBufferIndex;
}
}
} else {
- for (int i=0 ; i<NUM_BUFFERS ; i++)
+ for (size_t i=0 ; i<NUM_BUFFERS ; i++)
mTextures[i].image = EGL_NO_IMAGE_KHR;
GGLSurface t;
inline PixelFormat pixelFormat() const { return mFormat; }
private:
- inline sp<GraphicBuffer> getFrontBuffer() {
+ inline sp<GraphicBuffer> getFrontBufferLocked() {
return mBuffers[mFrontBufferIndex];
}
} else {
GLuint tw = 1 << (31 - clz(w));
GLuint th = 1 << (31 - clz(h));
- if (tw < w) tw <<= 1;
- if (th < h) th <<= 1;
+ if (tw < GLuint(w)) tw <<= 1;
+ if (th < GLuint(h)) th <<= 1;
glTexImage2D(GL_TEXTURE_2D, 0, mReadFormat, tw, th, 0,
mReadFormat, mReadType, NULL);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h,
// ----------------------------------------------------------------------------
SharedBufferBase::SharedBufferBase(SharedClient* sharedClient,
- int surface, int num)
+ int surface, int num, int32_t identity)
: mSharedClient(sharedClient),
mSharedStack(sharedClient->surfaces + surface),
- mNumBuffers(num)
+ mNumBuffers(num), mIdentity(identity)
{
}
// ============================================================================
SharedBufferClient::SharedBufferClient(SharedClient* sharedClient,
- int surface, int num)
- : SharedBufferBase(sharedClient, surface, num), tail(0)
+ int surface, int num, int32_t identity)
+ : SharedBufferBase(sharedClient, surface, num, identity), tail(0)
{
tail = computeTail();
}
SharedBufferServer::SharedBufferServer(SharedClient* sharedClient,
int surface, int num, int32_t identity)
- : SharedBufferBase(sharedClient, surface, num)
+ : SharedBufferBase(sharedClient, surface, num, identity)
{
mSharedStack->init(identity);
mSharedStack->head = num-1;
mWidth(surface->mWidth), mHeight(surface->mHeight)
{
mSharedBufferClient = new SharedBufferClient(
- mClient->mControl, mToken, 2);
+ mClient->mControl, mToken, 2, mIdentity);
init();
}
mClient = SurfaceComposerClient::clientForConnection(clientBinder);
mSharedBufferClient = new SharedBufferClient(
- mClient->mControl, mToken, 2);
+ mClient->mControl, mToken, 2, mIdentity);
}
init();