diff options
Diffstat (limited to 'include/gui')
-rw-r--r-- | include/gui/BufferItem.h | 1 | ||||
-rw-r--r-- | include/gui/BufferItemConsumer.h | 2 | ||||
-rw-r--r-- | include/gui/BufferQueue.h | 2 | ||||
-rw-r--r-- | include/gui/BufferQueueConsumer.h | 5 | ||||
-rw-r--r-- | include/gui/BufferQueueCore.h | 6 | ||||
-rw-r--r-- | include/gui/BufferQueueProducer.h | 27 | ||||
-rw-r--r-- | include/gui/ConsumerBase.h | 4 | ||||
-rw-r--r-- | include/gui/CpuConsumer.h | 15 | ||||
-rw-r--r-- | include/gui/GLConsumer.h | 8 | ||||
-rw-r--r-- | include/gui/GraphicBufferAlloc.h | 5 | ||||
-rw-r--r-- | include/gui/IConsumerListener.h | 19 | ||||
-rw-r--r-- | include/gui/IGraphicBufferAlloc.h | 8 | ||||
-rw-r--r-- | include/gui/IGraphicBufferConsumer.h | 7 | ||||
-rw-r--r-- | include/gui/IGraphicBufferProducer.h | 8 | ||||
-rw-r--r-- | include/gui/ISurfaceComposer.h | 1 | ||||
-rw-r--r-- | include/gui/Sensor.h | 10 | ||||
-rw-r--r-- | include/gui/StreamSplitter.h | 2 | ||||
-rw-r--r-- | include/gui/Surface.h | 40 | ||||
-rw-r--r-- | include/gui/SurfaceComposerClient.h | 2 | ||||
-rw-r--r-- | include/gui/SurfaceControl.h | 4 |
20 files changed, 106 insertions, 70 deletions
diff --git a/include/gui/BufferItem.h b/include/gui/BufferItem.h index 5effd10..01b6ff4 100644 --- a/include/gui/BufferItem.h +++ b/include/gui/BufferItem.h @@ -44,6 +44,7 @@ class BufferItem : public Flattenable<BufferItem> { // The default value of mBuf, used to indicate this doesn't correspond to a slot. enum { INVALID_BUFFER_SLOT = -1 }; BufferItem(); + ~BufferItem(); operator IGraphicBufferConsumer::BufferItem() const; static const char* scalingModeName(uint32_t scalingMode); diff --git a/include/gui/BufferItemConsumer.h b/include/gui/BufferItemConsumer.h index 869b470..5494ff1 100644 --- a/include/gui/BufferItemConsumer.h +++ b/include/gui/BufferItemConsumer.h @@ -95,7 +95,7 @@ class BufferItemConsumer: public ConsumerBase // setDefaultBufferFormat allows the BufferQueue to create // GraphicBuffers of a defaultFormat if no format is specified // in dequeueBuffer - status_t setDefaultBufferFormat(PixelFormat defaultFormat); + status_t setDefaultBufferFormat(uint32_t defaultFormat); }; } // namespace android diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h index 3297b10..1188837 100644 --- a/include/gui/BufferQueue.h +++ b/include/gui/BufferQueue.h @@ -62,7 +62,7 @@ public: public: ProxyConsumerListener(const wp<ConsumerListener>& consumerListener); virtual ~ProxyConsumerListener(); - virtual void onFrameAvailable(); + virtual void onFrameAvailable(const android::BufferItem& item); virtual void onBuffersReleased(); virtual void onSidebandStreamChanged(); private: diff --git a/include/gui/BufferQueueConsumer.h b/include/gui/BufferQueueConsumer.h index 898c451..1912ed0 100644 --- a/include/gui/BufferQueueConsumer.h +++ b/include/gui/BufferQueueConsumer.h @@ -125,8 +125,9 @@ public: // setDefaultBufferFormat allows the BufferQueue to create // GraphicBuffers of a defaultFormat if no format is specified - // in dequeueBuffer. The initial default is HAL_PIXEL_FORMAT_RGBA_8888. - virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat); + // in dequeueBuffer. Formats are enumerated in graphics.h; the + // initial default is HAL_PIXEL_FORMAT_RGBA_8888. + virtual status_t setDefaultBufferFormat(uint32_t defaultFormat); // setConsumerUsageBits will turn on additional usage bits for dequeueBuffer. // These are merged with the bits passed to dequeueBuffer. The values are diff --git a/include/gui/BufferQueueCore.h b/include/gui/BufferQueueCore.h index b23cb08..1d975c0 100644 --- a/include/gui/BufferQueueCore.h +++ b/include/gui/BufferQueueCore.h @@ -199,15 +199,15 @@ private: // mDefaultBufferFormat can be set so it will override the buffer format // when it isn't specified in dequeueBuffer. - PixelFormat mDefaultBufferFormat; + uint32_t mDefaultBufferFormat; // mDefaultWidth holds the default width of allocated buffers. It is used // in dequeueBuffer if a width and height of 0 are specified. - uint32_t mDefaultWidth; + int mDefaultWidth; // mDefaultHeight holds the default height of allocated buffers. It is used // in dequeueBuffer if a width and height of 0 are specified. - uint32_t mDefaultHeight; + int mDefaultHeight; // mDefaultMaxBufferCount is the default limit on the number of buffers that // will be allocated at one time. This default limit is set by the consumer. diff --git a/include/gui/BufferQueueProducer.h b/include/gui/BufferQueueProducer.h index 34c32dc..ed1056a 100644 --- a/include/gui/BufferQueueProducer.h +++ b/include/gui/BufferQueueProducer.h @@ -73,7 +73,9 @@ public: // updateTexImage() is called. If width and height are both zero, the // default values specified by setDefaultBufferSize() are used instead. // - // If the format is 0, the default format will be used. + // The pixel formats are enumerated in graphics.h, e.g. + // HAL_PIXEL_FORMAT_RGBA_8888. If the format is 0, the default format + // will be used. // // The usage argument specifies gralloc buffer usage flags. The values // are enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER. These @@ -91,9 +93,8 @@ public: // // In both cases, the producer will need to call requestBuffer to get a // GraphicBuffer handle for the returned slot. - virtual status_t dequeueBuffer(int *outSlot, sp<Fence>* outFence, - bool async, uint32_t width, uint32_t height, PixelFormat format, - uint32_t usage); + virtual status_t dequeueBuffer(int *outSlot, sp<Fence>* outFence, bool async, + uint32_t width, uint32_t height, uint32_t format, uint32_t usage); // See IGraphicBufferProducer::detachBuffer virtual status_t detachBuffer(int slot); @@ -170,7 +171,7 @@ public: // See IGraphicBufferProducer::allocateBuffers virtual void allocateBuffers(bool async, uint32_t width, uint32_t height, - PixelFormat format, uint32_t usage); + uint32_t format, uint32_t usage); private: // This is required by the IBinder::DeathRecipient interface @@ -196,6 +197,22 @@ private: uint32_t mStickyTransform; + // This saves the fence from the last queueBuffer, such that the + // next queueBuffer call can throttle buffer production. The prior + // queueBuffer's fence is not nessessarily available elsewhere, + // since the previous buffer might have already been acquired. + sp<Fence> mLastQueueBufferFence; + + // Take-a-ticket system for ensuring that onFrame* callbacks are called in + // the order that frames are queued. While the BufferQueue lock + // (mCore->mMutex) is held, a ticket is retained by the producer. After + // dropping the BufferQueue lock, the producer must wait on the condition + // variable until the current callback ticket matches its retained ticket. + Mutex mCallbackMutex; + int mNextCallbackTicket; // Protected by mCore->mMutex + int mCurrentCallbackTicket; // Protected by mCallbackMutex + Condition mCallbackCondition; + }; // class BufferQueueProducer } // namespace android diff --git a/include/gui/ConsumerBase.h b/include/gui/ConsumerBase.h index 100bb26..f7ab5ac 100644 --- a/include/gui/ConsumerBase.h +++ b/include/gui/ConsumerBase.h @@ -46,7 +46,7 @@ public: // // This is called without any lock held and can be called concurrently // by multiple threads. - virtual void onFrameAvailable() = 0; + virtual void onFrameAvailable(const BufferItem& item) = 0; }; virtual ~ConsumerBase(); @@ -106,7 +106,7 @@ protected: // the ConsumerBase implementation must be called from the derived class. // The ConsumerBase version of onSidebandStreamChanged does nothing and can // be overriden by derived classes if they want the notification. - virtual void onFrameAvailable(); + virtual void onFrameAvailable(const BufferItem& item); virtual void onBuffersReleased(); virtual void onSidebandStreamChanged(); diff --git a/include/gui/CpuConsumer.h b/include/gui/CpuConsumer.h index 3414ede..6f4c2ec 100644 --- a/include/gui/CpuConsumer.h +++ b/include/gui/CpuConsumer.h @@ -67,7 +67,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<IGraphicBufferConsumer>& bq, - size_t maxLockedBuffers, bool controlledByApp = false); + uint32_t maxLockedBuffers, bool controlledByApp = false); virtual ~CpuConsumer(); @@ -82,9 +82,10 @@ class CpuConsumer : public ConsumerBase status_t setDefaultBufferSize(uint32_t width, uint32_t height); // setDefaultBufferFormat allows CpuConsumer's BufferQueue to create buffers - // of a defaultFormat if no format is specified by producer. - // The initial default is PIXEL_FORMAT_RGBA_8888. - status_t setDefaultBufferFormat(PixelFormat defaultFormat); + // of a defaultFormat if no format is specified by producer. Formats are + // enumerated in graphics.h; the initial default is + // HAL_PIXEL_FORMAT_RGBA_8888. + status_t setDefaultBufferFormat(uint32_t defaultFormat); // Gets the next graphics buffer from the producer and locks it for CPU use, // filling out the passed-in locked buffer structure with the native pointer @@ -105,9 +106,9 @@ class CpuConsumer : public ConsumerBase private: // Maximum number of buffers that can be locked at a time - size_t mMaxLockedBuffers; + uint32_t mMaxLockedBuffers; - status_t releaseAcquiredBufferLocked(size_t lockedIdx); + status_t releaseAcquiredBufferLocked(int lockedIdx); virtual void freeBufferLocked(int slotIndex); @@ -128,7 +129,7 @@ class CpuConsumer : public ConsumerBase Vector<AcquiredBuffer> mAcquiredBuffers; // Count of currently locked buffers - size_t mCurrentLockedBuffers; + uint32_t mCurrentLockedBuffers; }; diff --git a/include/gui/GLConsumer.h b/include/gui/GLConsumer.h index 053d1ed..f91fe46 100644 --- a/include/gui/GLConsumer.h +++ b/include/gui/GLConsumer.h @@ -150,7 +150,7 @@ public: // // The frame number is an incrementing counter set to 0 at the creation of // the BufferQueue associated with this consumer. - uint64_t getFrameNumber(); + int64_t getFrameNumber(); // setDefaultBufferSize is used to set the size of buffers returned by // requestBuffers when a with and height of zero is requested. @@ -197,7 +197,7 @@ public: // These functions call the corresponding BufferQueue implementation // so the refactoring can proceed smoothly - status_t setDefaultBufferFormat(PixelFormat defaultFormat); + status_t setDefaultBufferFormat(uint32_t defaultFormat); status_t setConsumerUsageBits(uint32_t usage); status_t setTransformHint(uint32_t hint); @@ -254,7 +254,7 @@ protected: return releaseBufferLocked(slot, graphicBuffer, mEglDisplay, eglFence); } - static bool isExternalFormat(PixelFormat format); + static bool isExternalFormat(uint32_t format); // This releases the buffer in the slot referenced by mCurrentTexture, // then updates state to refer to the BufferItem, which must be a @@ -391,7 +391,7 @@ private: // mCurrentFrameNumber is the frame counter for the current texture. // It gets set each time updateTexImage is called. - uint64_t mCurrentFrameNumber; + int64_t mCurrentFrameNumber; uint32_t mDefaultWidth, mDefaultHeight; diff --git a/include/gui/GraphicBufferAlloc.h b/include/gui/GraphicBufferAlloc.h index 69fe51e..b08750c 100644 --- a/include/gui/GraphicBufferAlloc.h +++ b/include/gui/GraphicBufferAlloc.h @@ -33,9 +33,8 @@ class GraphicBufferAlloc : public BnGraphicBufferAlloc { public: GraphicBufferAlloc(); virtual ~GraphicBufferAlloc(); - virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width, - uint32_t height, PixelFormat format, uint32_t usage, - status_t* error); + virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h, + PixelFormat format, uint32_t usage, status_t* error); }; diff --git a/include/gui/IConsumerListener.h b/include/gui/IConsumerListener.h index 260099e..3f39799 100644 --- a/include/gui/IConsumerListener.h +++ b/include/gui/IConsumerListener.h @@ -28,6 +28,8 @@ namespace android { // ---------------------------------------------------------------------------- +class BufferItem; + // ConsumerListener is the interface through which the BufferQueue notifies // the consumer of events that the consumer may wish to react to. Because // the consumer will generally have a mutex that is locked during calls from @@ -43,11 +45,24 @@ public: // frame becomes available for consumption. This means that frames that // are queued while in asynchronous mode only trigger the callback if no // previous frames are pending. Frames queued while in synchronous mode - // always trigger the callback. + // always trigger the callback. The item passed to the callback will contain + // all of the information about the queued frame except for its + // GraphicBuffer pointer, which will always be null. + // + // This is called without any lock held and can be called concurrently + // by multiple threads. + virtual void onFrameAvailable(const BufferItem& item) = 0; /* Asynchronous */ + + // onFrameReplaced is called from queueBuffer if the frame being queued is + // replacing an existing slot in the queue. Any call to queueBuffer that + // doesn't call onFrameAvailable will call this callback instead. The item + // passed to the callback will contain all of the information about the + // queued frame except for its GraphicBuffer pointer, which will always be + // null. // // This is called without any lock held and can be called concurrently // by multiple threads. - virtual void onFrameAvailable() = 0; /* Asynchronous */ + virtual void onFrameReplaced(const BufferItem& /* item */) {} /* Asynchronous */ // onBuffersReleased is called to notify the buffer consumer that the // BufferQueue has released its references to one or more GraphicBuffers diff --git a/include/gui/IGraphicBufferAlloc.h b/include/gui/IGraphicBufferAlloc.h index f3c46ec..cee41d9 100644 --- a/include/gui/IGraphicBufferAlloc.h +++ b/include/gui/IGraphicBufferAlloc.h @@ -45,10 +45,10 @@ public: class BnGraphicBufferAlloc : public BnInterface<IGraphicBufferAlloc> { public: - virtual status_t onTransact(uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); + virtual status_t onTransact( uint32_t code, + const Parcel& data, + Parcel* reply, + uint32_t flags = 0); }; // ---------------------------------------------------------------------------- diff --git a/include/gui/IGraphicBufferConsumer.h b/include/gui/IGraphicBufferConsumer.h index 9ac23c2..15f51fe 100644 --- a/include/gui/IGraphicBufferConsumer.h +++ b/include/gui/IGraphicBufferConsumer.h @@ -25,7 +25,6 @@ #include <utils/Timers.h> #include <binder/IInterface.h> -#include <ui/PixelFormat.h> #include <ui/Rect.h> #include <EGL/egl.h> @@ -281,11 +280,11 @@ public: // setDefaultBufferFormat allows the BufferQueue to create // GraphicBuffers of a defaultFormat if no format is specified - // in dequeueBuffer. - // The initial default is PIXEL_FORMAT_RGBA_8888. + // in dequeueBuffer. Formats are enumerated in graphics.h; the + // initial default is HAL_PIXEL_FORMAT_RGBA_8888. // // Return of a value other than NO_ERROR means an unknown error has occurred. - virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat) = 0; + virtual status_t setDefaultBufferFormat(uint32_t defaultFormat) = 0; // setConsumerUsageBits will turn on additional usage bits for dequeueBuffer. // These are merged with the bits passed to dequeueBuffer. The values are diff --git a/include/gui/IGraphicBufferProducer.h b/include/gui/IGraphicBufferProducer.h index 4d3cd9a..4e9e810 100644 --- a/include/gui/IGraphicBufferProducer.h +++ b/include/gui/IGraphicBufferProducer.h @@ -134,7 +134,9 @@ public: // updateTexImage() is called. If width and height are both zero, the // default values specified by setDefaultBufferSize() are used instead. // - // If the format is 0, the default format will be used. + // The pixel formats are enumerated in <graphics.h>, e.g. + // HAL_PIXEL_FORMAT_RGBA_8888. If the format is 0, the default format + // will be used. // // The usage argument specifies gralloc buffer usage flags. The values // are enumerated in <gralloc.h>, e.g. GRALLOC_USAGE_HW_RENDER. These @@ -165,7 +167,7 @@ public: // All other negative values are an unknown error returned downstream // from the graphics allocator (typically errno). virtual status_t dequeueBuffer(int* slot, sp<Fence>* fence, bool async, - uint32_t w, uint32_t h, PixelFormat format, uint32_t usage) = 0; + uint32_t w, uint32_t h, uint32_t format, uint32_t usage) = 0; // detachBuffer attempts to remove all ownership of the buffer in the given // slot from the buffer queue. If this call succeeds, the slot will be @@ -446,7 +448,7 @@ public: // dequeueBuffer. If there are already the maximum number of buffers // allocated, this function has no effect. virtual void allocateBuffers(bool async, uint32_t width, uint32_t height, - PixelFormat format, uint32_t usage) = 0; + uint32_t format, uint32_t usage) = 0; }; // ---------------------------------------------------------------------------- diff --git a/include/gui/ISurfaceComposer.h b/include/gui/ISurfaceComposer.h index 8c3d49e..f04a848 100644 --- a/include/gui/ISurfaceComposer.h +++ b/include/gui/ISurfaceComposer.h @@ -28,6 +28,7 @@ #include <binder/IInterface.h> #include <ui/FrameStats.h> +#include <ui/PixelFormat.h> #include <gui/IGraphicBufferAlloc.h> #include <gui/ISurfaceComposerClient.h> diff --git a/include/gui/Sensor.h b/include/gui/Sensor.h index 27a215e..59b4d4d 100644 --- a/include/gui/Sensor.h +++ b/include/gui/Sensor.h @@ -67,12 +67,12 @@ public: int32_t getMinDelay() const; nsecs_t getMinDelayNs() const; int32_t getVersion() const; - uint32_t getFifoReservedEventCount() const; - uint32_t getFifoMaxEventCount() const; + int32_t getFifoReservedEventCount() const; + int32_t getFifoMaxEventCount() const; const String8& getStringType() const; const String8& getRequiredPermission() const; int32_t getMaxDelay() const; - uint32_t getFlags() const; + int32_t getFlags() const; bool isWakeUpSensor() const; int32_t getReportingMode() const; @@ -93,8 +93,8 @@ private: float mPower; int32_t mMinDelay; int32_t mVersion; - uint32_t mFifoReservedEventCount; - uint32_t mFifoMaxEventCount; + int32_t mFifoReservedEventCount; + int32_t mFifoMaxEventCount; String8 mStringType; String8 mRequiredPermission; int32_t mMaxDelay; diff --git a/include/gui/StreamSplitter.h b/include/gui/StreamSplitter.h index f927953..8f47eb4 100644 --- a/include/gui/StreamSplitter.h +++ b/include/gui/StreamSplitter.h @@ -74,7 +74,7 @@ private: // can block if there are too many outstanding buffers. If it blocks, it // will resume when onBufferReleasedByOutput releases a buffer back to the // input. - virtual void onFrameAvailable(); + virtual void onFrameAvailable(const BufferItem& item); // From IConsumerListener // We don't care about released buffers because we detach each buffer as diff --git a/include/gui/Surface.h b/include/gui/Surface.h index 98f4f4f..f2cf018 100644 --- a/include/gui/Surface.h +++ b/include/gui/Surface.h @@ -160,12 +160,12 @@ protected: virtual int connect(int api); virtual int disconnect(int api); virtual int setBufferCount(int bufferCount); - virtual int setBuffersDimensions(uint32_t width, uint32_t height); - virtual int setBuffersUserDimensions(uint32_t width, uint32_t height); - virtual int setBuffersFormat(PixelFormat format); + virtual int setBuffersDimensions(int w, int h); + virtual int setBuffersUserDimensions(int w, int h); + virtual int setBuffersFormat(int format); virtual int setScalingMode(int mode); - virtual int setBuffersTransform(uint32_t transform); - virtual int setBuffersStickyTransform(uint32_t transform); + virtual int setBuffersTransform(int transform); + virtual int setBuffersStickyTransform(int transform); virtual int setBuffersTimestamp(int64_t timestamp); virtual int setCrop(Rect const* rect); virtual int setUsage(uint32_t reqUsage); @@ -211,7 +211,7 @@ private: // mReqFormat is the buffer pixel format that will be requested at the next // deuque operation. It is initialized to PIXEL_FORMAT_RGBA_8888. - PixelFormat mReqFormat; + uint32_t mReqFormat; // mReqUsage is the set of buffer usage flags that will be requested // at the next deuque operation. It is initialized to 0. @@ -240,23 +240,23 @@ private: // from being set by the compositor. uint32_t mStickyTransform; - // mDefaultWidth is default width of the buffers, regardless of the - // native_window_set_buffers_dimensions call. - uint32_t mDefaultWidth; + // mDefaultWidth is default width of the buffers, regardless of the + // native_window_set_buffers_dimensions call. + uint32_t mDefaultWidth; - // mDefaultHeight is default height of the buffers, regardless of the - // native_window_set_buffers_dimensions call. - uint32_t mDefaultHeight; + // mDefaultHeight is default height of the buffers, regardless of the + // native_window_set_buffers_dimensions call. + uint32_t mDefaultHeight; - // mUserWidth, if non-zero, is an application-specified override - // of mDefaultWidth. This is lower priority than the width set by - // native_window_set_buffers_dimensions. - uint32_t mUserWidth; + // mUserWidth, if non-zero, is an application-specified override + // of mDefaultWidth. This is lower priority than the width set by + // native_window_set_buffers_dimensions. + uint32_t mUserWidth; - // mUserHeight, if non-zero, is an application-specified override - // of mDefaultHeight. This is lower priority than the height set - // by native_window_set_buffers_dimensions. - uint32_t mUserHeight; + // mUserHeight, if non-zero, is an application-specified override + // of mDefaultHeight. This is lower priority than the height set + // by native_window_set_buffers_dimensions. + uint32_t mUserHeight; // mTransformHint is the transform probably applied to buffers of this // window. this is only a hint, actual transform may differ. diff --git a/include/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h index 37d953e..4cbfc09 100644 --- a/include/gui/SurfaceComposerClient.h +++ b/include/gui/SurfaceComposerClient.h @@ -127,7 +127,7 @@ public: status_t show(const sp<IBinder>& id); status_t setFlags(const sp<IBinder>& id, uint32_t flags, uint32_t mask); status_t setTransparentRegionHint(const sp<IBinder>& id, const Region& transparent); - status_t setLayer(const sp<IBinder>& id, uint32_t layer); + status_t setLayer(const sp<IBinder>& id, int32_t layer); status_t setAlpha(const sp<IBinder>& id, float alpha=1.0f); status_t setMatrix(const sp<IBinder>& id, float dsdx, float dtdx, float dsdy, float dtdy); status_t setPosition(const sp<IBinder>& id, float x, float y); diff --git a/include/gui/SurfaceControl.h b/include/gui/SurfaceControl.h index 9f62f7c..84fb9f9 100644 --- a/include/gui/SurfaceControl.h +++ b/include/gui/SurfaceControl.h @@ -57,8 +57,8 @@ public: // release surface data from java void clear(); - status_t setLayerStack(uint32_t layerStack); - status_t setLayer(uint32_t layer); + status_t setLayerStack(int32_t layerStack); + status_t setLayer(int32_t layer); status_t setPosition(float x, float y); status_t setSize(uint32_t w, uint32_t h); status_t hide(); |