Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db89edc9 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

All consumers now take an IGraphicBufferConsumer instead of a BufferQueue

this means they only have access to the consumer end of
the interface. we had a lot of code that assumed consumers
where holding a BufferQueue (i.e.: both ends), so most of
this change is untangling in fix that

Bug: 9265647
Change-Id: Ic2e2596ee14c7535f51bf26d9a897a0fc036d22c
parent 687821c0
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -87,8 +87,6 @@ class BufferItemConsumer: public ConsumerBase
    status_t releaseBuffer(const BufferItem &item,
            const sp<Fence>& releaseFence = Fence::NO_FENCE);

    sp<IGraphicBufferProducer> getProducerInterface() const { return getBufferQueue(); }

    // setDefaultBufferSize is used to set the size of buffers returned by
    // requestBuffers when a with and height of zero is requested.
    status_t setDefaultBufferSize(uint32_t w, uint32_t h);
+3 −4
Original line number Diff line number Diff line
@@ -78,10 +78,6 @@ public:
    BufferQueue(const sp<IGraphicBufferAlloc>& allocator = NULL);
    virtual ~BufferQueue();

    // dump our state in a String
    virtual void dump(String8& result) const;
    virtual void dump(String8& result, const char* prefix) const;

    /*
     * IGraphicBufferProducer interface
     */
@@ -302,6 +298,9 @@ public:
    // NATIVE_WINDOW_TRANSFORM_ROT_90.  The default is 0 (no transform).
    virtual status_t setTransformHint(uint32_t hint);

    // dump our state in a String
    virtual void dump(String8& result, const char* prefix) const;


private:
    // freeBufferLocked frees the GraphicBuffer and sync resources for the
+5 −10
Original line number Diff line number Diff line
@@ -66,10 +66,6 @@ public:
    // log messages.
    void setName(const String8& name);

    // getBufferQueue returns the BufferQueue object to which this
    // ConsumerBase is connected.
    sp<BufferQueue> getBufferQueue() const;

    // dump writes the current state to a string. Child classes should add
    // their state to the dump by overriding the dumpLocked method, which is
    // called by these methods after locking the mutex.
@@ -85,12 +81,11 @@ private:
    void operator=(const ConsumerBase&);

protected:

    // ConsumerBase constructs a new ConsumerBase object to consume image
    // buffers from the given BufferQueue.
    // buffers from the given IGraphicBufferConsumer.
    // The controlledByApp flag indicates that this consumer is under the application's
    // control.
    ConsumerBase(const sp<BufferQueue> &bufferQueue, bool controlledByApp = false);
    ConsumerBase(const sp<IGraphicBufferConsumer>& consumer, bool controlledByApp = false);

    // onLastStrongRef gets called by RefBase just before the dtor of the most
    // derived class.  It is used to clean up the buffers so that ConsumerBase
@@ -104,7 +99,7 @@ protected:
    // from the derived class.
    virtual void onLastStrongRef(const void* id);

    // Implementation of the BufferQueue::ConsumerListener interface.  These
    // Implementation of the IConsumerListener interface.  These
    // calls are used to notify the ConsumerBase of asynchronous events in the
    // BufferQueue.  These methods should not need to be overridden by derived
    // classes, but if they are overridden the ConsumerBase implementation
@@ -155,7 +150,7 @@ protected:
    // initialization that must take place the first time a buffer is assigned
    // to a slot.  If it is overridden the derived class's implementation must
    // call ConsumerBase::acquireBufferLocked.
    virtual status_t acquireBufferLocked(BufferQueue::BufferItem *item,
    virtual status_t acquireBufferLocked(IGraphicBufferConsumer::BufferItem *item,
        nsecs_t presentWhen);

    // releaseBufferLocked relinquishes control over a buffer, returning that
@@ -226,7 +221,7 @@ protected:

    // The ConsumerBase has-a BufferQueue and is responsible for creating this object
    // if none is supplied
    sp<BufferQueue> mBufferQueue;
    sp<IGraphicBufferConsumer> mConsumer;

    // mMutex is the mutex used to prevent concurrent access to the member
    // variables of ConsumerBase objects. It must be locked whenever the
+1 −3
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ class CpuConsumer : public ConsumerBase

    // Create a new CPU consumer. The maxLockedBuffers parameter specifies
    // how many buffers can be locked for user access at the same time.
    CpuConsumer(const sp<BufferQueue>& bq,
    CpuConsumer(const sp<IGraphicBufferConsumer>& bq,
            uint32_t maxLockedBuffers, bool controlledByApp = false);

    virtual ~CpuConsumer();
@@ -104,8 +104,6 @@ class CpuConsumer : public ConsumerBase
    // lockNextBuffer.
    status_t unlockBuffer(const LockedBuffer &nativeBuffer);

    sp<IGraphicBufferProducer> getProducerInterface() const { return getBufferQueue(); }

  private:
    // Maximum number of buffers that can be locked at a time
    uint32_t mMaxLockedBuffers;
+1 −11
Original line number Diff line number Diff line
@@ -32,10 +32,6 @@
#include <utils/Vector.h>
#include <utils/threads.h>

#define ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID "mSurfaceTexture"
#define ANDROID_GRAPHICS_FRAMEAVAILABLELISTENER_JNI_ID \
                                         "mFrameAvailableListener"

namespace android {
// ----------------------------------------------------------------------------

@@ -85,7 +81,7 @@ public:
    // purely to allow a GLConsumer to be transferred from one consumer
    // context to another. If such a transfer is not needed there is no
    // requirement that either of these methods be called.
    GLConsumer(const sp<BufferQueue>& bq,
    GLConsumer(const sp<IGraphicBufferConsumer>& bq,
            GLuint tex, GLenum texTarget = GL_TEXTURE_EXTERNAL_OES,
            bool useFenceSync = true, bool isControlledByApp = false);

@@ -194,12 +190,6 @@ public:
    status_t setConsumerUsageBits(uint32_t usage);
    status_t setTransformHint(uint32_t hint);

    // getBufferQueue returns the BufferQueue object to which this
    // GLConsumer is connected.
    sp<BufferQueue> getBufferQueue() const {
        return mBufferQueue;
    }

    // detachFromContext detaches the GLConsumer from the calling thread's
    // current OpenGL ES context.  This context must be the same as the context
    // that was current for previous calls to updateTexImage.
Loading