libgui: Enable -Weverything and -Werror

Enables -Weverything and -Werror, with just a few exceptions for
warnings we can't (or shouldn't need to) work around.

Cherry pick of I034abec27bf4020d84af60d7acc1939c59986dd6 plus a
couple of minor changes to CpuConsumer.cpp to make it work with a
prior change:
    Uncomment CC_LOGV on line 46
    Change C-style cast to static_cast on line 71

Change-Id: Iaec610477ea0122317b0578fb74caf2383d4cf08
This commit is contained in:
Dan Stoza 2014-11-18 10:24:03 -08:00
parent b6b81d6acd
commit 3be1c6b60a
48 changed files with 592 additions and 485 deletions

View File

@ -95,7 +95,7 @@ class BufferItemConsumer: public ConsumerBase
// setDefaultBufferFormat allows the BufferQueue to create // setDefaultBufferFormat allows the BufferQueue to create
// GraphicBuffers of a defaultFormat if no format is specified // GraphicBuffers of a defaultFormat if no format is specified
// in dequeueBuffer // in dequeueBuffer
status_t setDefaultBufferFormat(uint32_t defaultFormat); status_t setDefaultBufferFormat(PixelFormat defaultFormat);
}; };
} // namespace android } // namespace android

View File

@ -125,9 +125,8 @@ public:
// setDefaultBufferFormat allows the BufferQueue to create // setDefaultBufferFormat allows the BufferQueue to create
// GraphicBuffers of a defaultFormat if no format is specified // GraphicBuffers of a defaultFormat if no format is specified
// in dequeueBuffer. Formats are enumerated in graphics.h; the // in dequeueBuffer. The initial default is HAL_PIXEL_FORMAT_RGBA_8888.
// initial default is HAL_PIXEL_FORMAT_RGBA_8888. virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat);
virtual status_t setDefaultBufferFormat(uint32_t defaultFormat);
// setConsumerUsageBits will turn on additional usage bits for dequeueBuffer. // setConsumerUsageBits will turn on additional usage bits for dequeueBuffer.
// These are merged with the bits passed to dequeueBuffer. The values are // These are merged with the bits passed to dequeueBuffer. The values are

View File

@ -199,15 +199,15 @@ private:
// mDefaultBufferFormat can be set so it will override the buffer format // mDefaultBufferFormat can be set so it will override the buffer format
// when it isn't specified in dequeueBuffer. // when it isn't specified in dequeueBuffer.
uint32_t mDefaultBufferFormat; PixelFormat mDefaultBufferFormat;
// mDefaultWidth holds the default width of allocated buffers. It is used // mDefaultWidth holds the default width of allocated buffers. It is used
// in dequeueBuffer if a width and height of 0 are specified. // in dequeueBuffer if a width and height of 0 are specified.
int mDefaultWidth; uint32_t mDefaultWidth;
// mDefaultHeight holds the default height of allocated buffers. It is used // mDefaultHeight holds the default height of allocated buffers. It is used
// in dequeueBuffer if a width and height of 0 are specified. // in dequeueBuffer if a width and height of 0 are specified.
int mDefaultHeight; uint32_t mDefaultHeight;
// mDefaultMaxBufferCount is the default limit on the number of buffers that // 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. // will be allocated at one time. This default limit is set by the consumer.

View File

@ -73,9 +73,7 @@ public:
// updateTexImage() is called. If width and height are both zero, the // updateTexImage() is called. If width and height are both zero, the
// default values specified by setDefaultBufferSize() are used instead. // default values specified by setDefaultBufferSize() are used instead.
// //
// The pixel formats are enumerated in graphics.h, e.g. // If the format is 0, the default format will be used.
// 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 // The usage argument specifies gralloc buffer usage flags. The values
// are enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER. These // are enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER. These
@ -93,8 +91,9 @@ public:
// //
// In both cases, the producer will need to call requestBuffer to get a // In both cases, the producer will need to call requestBuffer to get a
// GraphicBuffer handle for the returned slot. // GraphicBuffer handle for the returned slot.
virtual status_t dequeueBuffer(int *outSlot, sp<Fence>* outFence, bool async, virtual status_t dequeueBuffer(int *outSlot, sp<Fence>* outFence,
uint32_t width, uint32_t height, uint32_t format, uint32_t usage); bool async, uint32_t width, uint32_t height, PixelFormat format,
uint32_t usage);
// See IGraphicBufferProducer::detachBuffer // See IGraphicBufferProducer::detachBuffer
virtual status_t detachBuffer(int slot); virtual status_t detachBuffer(int slot);
@ -171,7 +170,7 @@ public:
// See IGraphicBufferProducer::allocateBuffers // See IGraphicBufferProducer::allocateBuffers
virtual void allocateBuffers(bool async, uint32_t width, uint32_t height, virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
uint32_t format, uint32_t usage); PixelFormat format, uint32_t usage);
private: private:
// This is required by the IBinder::DeathRecipient interface // This is required by the IBinder::DeathRecipient interface

View File

@ -71,7 +71,7 @@ class CpuConsumer : public ConsumerBase
// Create a new CPU consumer. The maxLockedBuffers parameter specifies // Create a new CPU consumer. The maxLockedBuffers parameter specifies
// how many buffers can be locked for user access at the same time. // how many buffers can be locked for user access at the same time.
CpuConsumer(const sp<IGraphicBufferConsumer>& bq, CpuConsumer(const sp<IGraphicBufferConsumer>& bq,
uint32_t maxLockedBuffers, bool controlledByApp = false); size_t maxLockedBuffers, bool controlledByApp = false);
virtual ~CpuConsumer(); virtual ~CpuConsumer();
@ -86,10 +86,9 @@ class CpuConsumer : public ConsumerBase
status_t setDefaultBufferSize(uint32_t width, uint32_t height); status_t setDefaultBufferSize(uint32_t width, uint32_t height);
// setDefaultBufferFormat allows CpuConsumer's BufferQueue to create buffers // setDefaultBufferFormat allows CpuConsumer's BufferQueue to create buffers
// of a defaultFormat if no format is specified by producer. Formats are // of a defaultFormat if no format is specified by producer.
// enumerated in graphics.h; the initial default is // The initial default is PIXEL_FORMAT_RGBA_8888.
// HAL_PIXEL_FORMAT_RGBA_8888. status_t setDefaultBufferFormat(PixelFormat defaultFormat);
status_t setDefaultBufferFormat(uint32_t defaultFormat);
// Gets the next graphics buffer from the producer and locks it for CPU use, // 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 // filling out the passed-in locked buffer structure with the native pointer
@ -110,9 +109,9 @@ class CpuConsumer : public ConsumerBase
private: private:
// Maximum number of buffers that can be locked at a time // Maximum number of buffers that can be locked at a time
uint32_t mMaxLockedBuffers; size_t mMaxLockedBuffers;
status_t releaseAcquiredBufferLocked(int lockedIdx); status_t releaseAcquiredBufferLocked(size_t lockedIdx);
virtual void freeBufferLocked(int slotIndex); virtual void freeBufferLocked(int slotIndex);
@ -133,7 +132,7 @@ class CpuConsumer : public ConsumerBase
Vector<AcquiredBuffer> mAcquiredBuffers; Vector<AcquiredBuffer> mAcquiredBuffers;
// Count of currently locked buffers // Count of currently locked buffers
uint32_t mCurrentLockedBuffers; size_t mCurrentLockedBuffers;
}; };

View File

@ -150,7 +150,7 @@ public:
// //
// The frame number is an incrementing counter set to 0 at the creation of // The frame number is an incrementing counter set to 0 at the creation of
// the BufferQueue associated with this consumer. // the BufferQueue associated with this consumer.
int64_t getFrameNumber(); uint64_t getFrameNumber();
// setDefaultBufferSize is used to set the size of buffers returned by // setDefaultBufferSize is used to set the size of buffers returned by
// requestBuffers when a with and height of zero is requested. // requestBuffers when a with and height of zero is requested.
@ -197,7 +197,7 @@ public:
// These functions call the corresponding BufferQueue implementation // These functions call the corresponding BufferQueue implementation
// so the refactoring can proceed smoothly // so the refactoring can proceed smoothly
status_t setDefaultBufferFormat(uint32_t defaultFormat); status_t setDefaultBufferFormat(PixelFormat defaultFormat);
status_t setConsumerUsageBits(uint32_t usage); status_t setConsumerUsageBits(uint32_t usage);
status_t setTransformHint(uint32_t hint); status_t setTransformHint(uint32_t hint);
@ -254,7 +254,7 @@ protected:
return releaseBufferLocked(slot, graphicBuffer, mEglDisplay, eglFence); return releaseBufferLocked(slot, graphicBuffer, mEglDisplay, eglFence);
} }
static bool isExternalFormat(uint32_t format); static bool isExternalFormat(PixelFormat format);
// This releases the buffer in the slot referenced by mCurrentTexture, // This releases the buffer in the slot referenced by mCurrentTexture,
// then updates state to refer to the BufferItem, which must be a // 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. // mCurrentFrameNumber is the frame counter for the current texture.
// It gets set each time updateTexImage is called. // It gets set each time updateTexImage is called.
int64_t mCurrentFrameNumber; uint64_t mCurrentFrameNumber;
uint32_t mDefaultWidth, mDefaultHeight; uint32_t mDefaultWidth, mDefaultHeight;

View File

@ -33,8 +33,9 @@ class GraphicBufferAlloc : public BnGraphicBufferAlloc {
public: public:
GraphicBufferAlloc(); GraphicBufferAlloc();
virtual ~GraphicBufferAlloc(); virtual ~GraphicBufferAlloc();
virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h, virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width,
PixelFormat format, uint32_t usage, status_t* error); uint32_t height, PixelFormat format, uint32_t usage,
status_t* error);
}; };

View File

@ -45,10 +45,10 @@ public:
class BnGraphicBufferAlloc : public BnInterface<IGraphicBufferAlloc> class BnGraphicBufferAlloc : public BnInterface<IGraphicBufferAlloc>
{ {
public: public:
virtual status_t onTransact( uint32_t code, virtual status_t onTransact(uint32_t code,
const Parcel& data, const Parcel& data,
Parcel* reply, Parcel* reply,
uint32_t flags = 0); uint32_t flags = 0);
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -25,6 +25,7 @@
#include <utils/Timers.h> #include <utils/Timers.h>
#include <binder/IInterface.h> #include <binder/IInterface.h>
#include <ui/PixelFormat.h>
#include <ui/Rect.h> #include <ui/Rect.h>
#include <EGL/egl.h> #include <EGL/egl.h>
@ -280,11 +281,11 @@ public:
// setDefaultBufferFormat allows the BufferQueue to create // setDefaultBufferFormat allows the BufferQueue to create
// GraphicBuffers of a defaultFormat if no format is specified // GraphicBuffers of a defaultFormat if no format is specified
// in dequeueBuffer. Formats are enumerated in graphics.h; the // in dequeueBuffer.
// initial default is HAL_PIXEL_FORMAT_RGBA_8888. // The initial default is PIXEL_FORMAT_RGBA_8888.
// //
// Return of a value other than NO_ERROR means an unknown error has occurred. // Return of a value other than NO_ERROR means an unknown error has occurred.
virtual status_t setDefaultBufferFormat(uint32_t defaultFormat) = 0; virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat) = 0;
// setConsumerUsageBits will turn on additional usage bits for dequeueBuffer. // setConsumerUsageBits will turn on additional usage bits for dequeueBuffer.
// These are merged with the bits passed to dequeueBuffer. The values are // These are merged with the bits passed to dequeueBuffer. The values are

View File

@ -134,9 +134,7 @@ public:
// updateTexImage() is called. If width and height are both zero, the // updateTexImage() is called. If width and height are both zero, the
// default values specified by setDefaultBufferSize() are used instead. // default values specified by setDefaultBufferSize() are used instead.
// //
// The pixel formats are enumerated in <graphics.h>, e.g. // If the format is 0, the default format will be used.
// 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 // The usage argument specifies gralloc buffer usage flags. The values
// are enumerated in <gralloc.h>, e.g. GRALLOC_USAGE_HW_RENDER. These // are enumerated in <gralloc.h>, e.g. GRALLOC_USAGE_HW_RENDER. These
@ -167,7 +165,7 @@ public:
// All other negative values are an unknown error returned downstream // All other negative values are an unknown error returned downstream
// from the graphics allocator (typically errno). // from the graphics allocator (typically errno).
virtual status_t dequeueBuffer(int* slot, sp<Fence>* fence, bool async, virtual status_t dequeueBuffer(int* slot, sp<Fence>* fence, bool async,
uint32_t w, uint32_t h, uint32_t format, uint32_t usage) = 0; uint32_t w, uint32_t h, PixelFormat format, uint32_t usage) = 0;
// detachBuffer attempts to remove all ownership of the buffer in the given // 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 // slot from the buffer queue. If this call succeeds, the slot will be
@ -448,7 +446,7 @@ public:
// dequeueBuffer. If there are already the maximum number of buffers // dequeueBuffer. If there are already the maximum number of buffers
// allocated, this function has no effect. // allocated, this function has no effect.
virtual void allocateBuffers(bool async, uint32_t width, uint32_t height, virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
uint32_t format, uint32_t usage) = 0; PixelFormat format, uint32_t usage) = 0;
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -28,7 +28,6 @@
#include <binder/IInterface.h> #include <binder/IInterface.h>
#include <ui/FrameStats.h> #include <ui/FrameStats.h>
#include <ui/PixelFormat.h>
#include <gui/IGraphicBufferAlloc.h> #include <gui/IGraphicBufferAlloc.h>
#include <gui/ISurfaceComposerClient.h> #include <gui/ISurfaceComposerClient.h>

View File

@ -67,12 +67,12 @@ public:
int32_t getMinDelay() const; int32_t getMinDelay() const;
nsecs_t getMinDelayNs() const; nsecs_t getMinDelayNs() const;
int32_t getVersion() const; int32_t getVersion() const;
int32_t getFifoReservedEventCount() const; uint32_t getFifoReservedEventCount() const;
int32_t getFifoMaxEventCount() const; uint32_t getFifoMaxEventCount() const;
const String8& getStringType() const; const String8& getStringType() const;
const String8& getRequiredPermission() const; const String8& getRequiredPermission() const;
int32_t getMaxDelay() const; int32_t getMaxDelay() const;
int32_t getFlags() const; uint32_t getFlags() const;
bool isWakeUpSensor() const; bool isWakeUpSensor() const;
int32_t getReportingMode() const; int32_t getReportingMode() const;
@ -93,8 +93,8 @@ private:
float mPower; float mPower;
int32_t mMinDelay; int32_t mMinDelay;
int32_t mVersion; int32_t mVersion;
int32_t mFifoReservedEventCount; uint32_t mFifoReservedEventCount;
int32_t mFifoMaxEventCount; uint32_t mFifoMaxEventCount;
String8 mStringType; String8 mStringType;
String8 mRequiredPermission; String8 mRequiredPermission;
int32_t mMaxDelay; int32_t mMaxDelay;

View File

@ -160,12 +160,12 @@ protected:
virtual int connect(int api); virtual int connect(int api);
virtual int disconnect(int api); virtual int disconnect(int api);
virtual int setBufferCount(int bufferCount); virtual int setBufferCount(int bufferCount);
virtual int setBuffersDimensions(int w, int h); virtual int setBuffersDimensions(uint32_t width, uint32_t height);
virtual int setBuffersUserDimensions(int w, int h); virtual int setBuffersUserDimensions(uint32_t width, uint32_t height);
virtual int setBuffersFormat(int format); virtual int setBuffersFormat(PixelFormat format);
virtual int setScalingMode(int mode); virtual int setScalingMode(int mode);
virtual int setBuffersTransform(int transform); virtual int setBuffersTransform(uint32_t transform);
virtual int setBuffersStickyTransform(int transform); virtual int setBuffersStickyTransform(uint32_t transform);
virtual int setBuffersTimestamp(int64_t timestamp); virtual int setBuffersTimestamp(int64_t timestamp);
virtual int setCrop(Rect const* rect); virtual int setCrop(Rect const* rect);
virtual int setUsage(uint32_t reqUsage); virtual int setUsage(uint32_t reqUsage);
@ -211,7 +211,7 @@ private:
// mReqFormat is the buffer pixel format that will be requested at the next // mReqFormat is the buffer pixel format that will be requested at the next
// deuque operation. It is initialized to PIXEL_FORMAT_RGBA_8888. // deuque operation. It is initialized to PIXEL_FORMAT_RGBA_8888.
uint32_t mReqFormat; PixelFormat mReqFormat;
// mReqUsage is the set of buffer usage flags that will be requested // mReqUsage is the set of buffer usage flags that will be requested
// at the next deuque operation. It is initialized to 0. // at the next deuque operation. It is initialized to 0.
@ -240,23 +240,23 @@ private:
// from being set by the compositor. // from being set by the compositor.
uint32_t mStickyTransform; uint32_t mStickyTransform;
// mDefaultWidth is default width of the buffers, regardless of the // mDefaultWidth is default width of the buffers, regardless of the
// native_window_set_buffers_dimensions call. // native_window_set_buffers_dimensions call.
uint32_t mDefaultWidth; uint32_t mDefaultWidth;
// mDefaultHeight is default height of the buffers, regardless of the // mDefaultHeight is default height of the buffers, regardless of the
// native_window_set_buffers_dimensions call. // native_window_set_buffers_dimensions call.
uint32_t mDefaultHeight; uint32_t mDefaultHeight;
// mUserWidth, if non-zero, is an application-specified override // mUserWidth, if non-zero, is an application-specified override
// of mDefaultWidth. This is lower priority than the width set by // of mDefaultWidth. This is lower priority than the width set by
// native_window_set_buffers_dimensions. // native_window_set_buffers_dimensions.
uint32_t mUserWidth; uint32_t mUserWidth;
// mUserHeight, if non-zero, is an application-specified override // mUserHeight, if non-zero, is an application-specified override
// of mDefaultHeight. This is lower priority than the height set // of mDefaultHeight. This is lower priority than the height set
// by native_window_set_buffers_dimensions. // by native_window_set_buffers_dimensions.
uint32_t mUserHeight; uint32_t mUserHeight;
// mTransformHint is the transform probably applied to buffers of this // mTransformHint is the transform probably applied to buffers of this
// window. this is only a hint, actual transform may differ. // window. this is only a hint, actual transform may differ.

View File

@ -127,7 +127,7 @@ public:
status_t show(const sp<IBinder>& id); status_t show(const sp<IBinder>& id);
status_t setFlags(const sp<IBinder>& id, uint32_t flags, uint32_t mask); 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 setTransparentRegionHint(const sp<IBinder>& id, const Region& transparent);
status_t setLayer(const sp<IBinder>& id, int32_t layer); status_t setLayer(const sp<IBinder>& id, uint32_t layer);
status_t setAlpha(const sp<IBinder>& id, float alpha=1.0f); 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 setMatrix(const sp<IBinder>& id, float dsdx, float dtdx, float dsdy, float dtdy);
status_t setPosition(const sp<IBinder>& id, float x, float y); status_t setPosition(const sp<IBinder>& id, float x, float y);

View File

@ -57,8 +57,8 @@ public:
// release surface data from java // release surface data from java
void clear(); void clear();
status_t setLayerStack(int32_t layerStack); status_t setLayerStack(uint32_t layerStack);
status_t setLayer(int32_t layer); status_t setLayer(uint32_t layer);
status_t setPosition(float x, float y); status_t setPosition(float x, float y);
status_t setSize(uint32_t w, uint32_t h); status_t setSize(uint32_t w, uint32_t h);
status_t hide(); status_t hide();

View File

@ -1,8 +1,40 @@
# Copyright 2010 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
LOCAL_PATH := $(call my-dir) LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_CLANG := true LOCAL_CLANG := true
LOCAL_CPPFLAGS := -std=c++11 LOCAL_CPPFLAGS := -std=c++1y -Weverything -Werror
# The static constructors and destructors in this library have not been noted to
# introduce significant overheads
LOCAL_CPPFLAGS += -Wno-exit-time-destructors
LOCAL_CPPFLAGS += -Wno-global-constructors
# We only care about compiling as C++14
LOCAL_CPPFLAGS += -Wno-c++98-compat-pedantic
# We don't need to enumerate every case in a switch as long as a default case
# is present
LOCAL_CPPFLAGS += -Wno-switch-enum
# Allow calling variadic macros without a __VA_ARGS__ list
LOCAL_CPPFLAGS += -Wno-gnu-zero-variadic-macro-arguments
# Don't warn about struct padding
LOCAL_CPPFLAGS += -Wno-padded
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
IGraphicBufferConsumer.cpp \ IGraphicBufferConsumer.cpp \

View File

@ -149,12 +149,12 @@ ssize_t BitTube::sendObjects(const sp<BitTube>& tube,
ssize_t size = tube->write(vaddr, count*objSize); ssize_t size = tube->write(vaddr, count*objSize);
// should never happen because of SOCK_SEQPACKET // should never happen because of SOCK_SEQPACKET
LOG_ALWAYS_FATAL_IF((size >= 0) && (size % objSize), LOG_ALWAYS_FATAL_IF((size >= 0) && (size % static_cast<ssize_t>(objSize)),
"BitTube::sendObjects(count=%zu, size=%zu), res=%zd (partial events were sent!)", "BitTube::sendObjects(count=%zu, size=%zu), res=%zd (partial events were sent!)",
count, objSize, size); count, objSize, size);
//ALOGE_IF(size<0, "error %d sending %d events", size, count); //ALOGE_IF(size<0, "error %d sending %d events", size, count);
return size < 0 ? size : size / objSize; return size < 0 ? size : size / static_cast<ssize_t>(objSize);
} }
ssize_t BitTube::recvObjects(const sp<BitTube>& tube, ssize_t BitTube::recvObjects(const sp<BitTube>& tube,
@ -164,12 +164,12 @@ ssize_t BitTube::recvObjects(const sp<BitTube>& tube,
ssize_t size = tube->read(vaddr, count*objSize); ssize_t size = tube->read(vaddr, count*objSize);
// should never happen because of SOCK_SEQPACKET // should never happen because of SOCK_SEQPACKET
LOG_ALWAYS_FATAL_IF((size >= 0) && (size % objSize), LOG_ALWAYS_FATAL_IF((size >= 0) && (size % static_cast<ssize_t>(objSize)),
"BitTube::recvObjects(count=%zu, size=%zu), res=%zd (partial events were received!)", "BitTube::recvObjects(count=%zu, size=%zu), res=%zd (partial events were received!)",
count, objSize, size); count, objSize, size);
//ALOGE_IF(size<0, "error %d receiving %d events", size, count); //ALOGE_IF(size<0, "error %d receiving %d events", size, count);
return size < 0 ? size : size / objSize; return size < 0 ? size : size / static_cast<ssize_t>(objSize);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -16,15 +16,15 @@
//#define LOG_NDEBUG 0 //#define LOG_NDEBUG 0
#define LOG_TAG "BufferItemConsumer" #define LOG_TAG "BufferItemConsumer"
#define ATRACE_TAG ATRACE_TAG_GRAPHICS //#define ATRACE_TAG ATRACE_TAG_GRAPHICS
#include <utils/Log.h> #include <utils/Log.h>
#include <gui/BufferItemConsumer.h> #include <gui/BufferItemConsumer.h>
#define BI_LOGV(x, ...) ALOGV("[%s] " x, mName.string(), ##__VA_ARGS__) //#define BI_LOGV(x, ...) ALOGV("[%s] " x, mName.string(), ##__VA_ARGS__)
#define BI_LOGD(x, ...) ALOGD("[%s] " x, mName.string(), ##__VA_ARGS__) //#define BI_LOGD(x, ...) ALOGD("[%s] " x, mName.string(), ##__VA_ARGS__)
#define BI_LOGI(x, ...) ALOGI("[%s] " x, mName.string(), ##__VA_ARGS__) //#define BI_LOGI(x, ...) ALOGI("[%s] " x, mName.string(), ##__VA_ARGS__)
#define BI_LOGW(x, ...) ALOGW("[%s] " x, mName.string(), ##__VA_ARGS__) //#define BI_LOGW(x, ...) ALOGW("[%s] " x, mName.string(), ##__VA_ARGS__)
#define BI_LOGE(x, ...) ALOGE("[%s] " x, mName.string(), ##__VA_ARGS__) #define BI_LOGE(x, ...) ALOGE("[%s] " x, mName.string(), ##__VA_ARGS__)
namespace android { namespace android {
@ -44,8 +44,7 @@ BufferItemConsumer::BufferItemConsumer(
} }
} }
BufferItemConsumer::~BufferItemConsumer() { BufferItemConsumer::~BufferItemConsumer() {}
}
void BufferItemConsumer::setName(const String8& name) { void BufferItemConsumer::setName(const String8& name) {
Mutex::Autolock _l(mMutex); Mutex::Autolock _l(mMutex);
@ -105,7 +104,7 @@ status_t BufferItemConsumer::setDefaultBufferSize(uint32_t w, uint32_t h) {
return mConsumer->setDefaultBufferSize(w, h); return mConsumer->setDefaultBufferSize(w, h);
} }
status_t BufferItemConsumer::setDefaultBufferFormat(uint32_t defaultFormat) { status_t BufferItemConsumer::setDefaultBufferFormat(PixelFormat defaultFormat) {
Mutex::Autolock _l(mMutex); Mutex::Autolock _l(mMutex);
return mConsumer->setDefaultBufferFormat(defaultFormat); return mConsumer->setDefaultBufferFormat(defaultFormat);
} }

View File

@ -488,7 +488,7 @@ void BufferQueueConsumer::setConsumerName(const String8& name) {
mConsumerName = name; mConsumerName = name;
} }
status_t BufferQueueConsumer::setDefaultBufferFormat(uint32_t defaultFormat) { status_t BufferQueueConsumer::setDefaultBufferFormat(PixelFormat defaultFormat) {
ATRACE_CALL(); ATRACE_CALL();
BQ_LOGV("setDefaultBufferFormat: %u", defaultFormat); BQ_LOGV("setDefaultBufferFormat: %u", defaultFormat);
Mutex::Autolock lock(mCore->mMutex); Mutex::Autolock lock(mCore->mMutex);

View File

@ -250,7 +250,7 @@ status_t BufferQueueProducer::waitForFreeSlotThenRelock(const char* caller,
status_t BufferQueueProducer::dequeueBuffer(int *outSlot, status_t BufferQueueProducer::dequeueBuffer(int *outSlot,
sp<android::Fence> *outFence, bool async, sp<android::Fence> *outFence, bool async,
uint32_t width, uint32_t height, uint32_t format, uint32_t usage) { uint32_t width, uint32_t height, PixelFormat format, uint32_t usage) {
ATRACE_CALL(); ATRACE_CALL();
{ // Autolock scope { // Autolock scope
Mutex::Autolock lock(mCore->mMutex); Mutex::Autolock lock(mCore->mMutex);
@ -311,7 +311,7 @@ status_t BufferQueueProducer::dequeueBuffer(int *outSlot,
if ((buffer == NULL) || if ((buffer == NULL) ||
(static_cast<uint32_t>(buffer->width) != width) || (static_cast<uint32_t>(buffer->width) != width) ||
(static_cast<uint32_t>(buffer->height) != height) || (static_cast<uint32_t>(buffer->height) != height) ||
(static_cast<uint32_t>(buffer->format) != format) || (buffer->format != format) ||
((static_cast<uint32_t>(buffer->usage) & usage) != usage)) ((static_cast<uint32_t>(buffer->usage) & usage) != usage))
{ {
mSlots[found].mAcquireCalled = false; mSlots[found].mAcquireCalled = false;
@ -341,7 +341,7 @@ status_t BufferQueueProducer::dequeueBuffer(int *outSlot,
status_t error; status_t error;
BQ_LOGV("dequeueBuffer: allocating a new buffer for slot %d", *outSlot); BQ_LOGV("dequeueBuffer: allocating a new buffer for slot %d", *outSlot);
sp<GraphicBuffer> graphicBuffer(mCore->mAllocator->createGraphicBuffer( sp<GraphicBuffer> graphicBuffer(mCore->mAllocator->createGraphicBuffer(
width, height, format, usage, &error)); width, height, format, usage, &error));
if (graphicBuffer == NULL) { if (graphicBuffer == NULL) {
BQ_LOGE("dequeueBuffer: createGraphicBuffer failed"); BQ_LOGE("dequeueBuffer: createGraphicBuffer failed");
return error; return error;
@ -582,8 +582,8 @@ status_t BufferQueueProducer::queueBuffer(int slot,
BQ_LOGV("queueBuffer: slot=%d/%" PRIu64 " time=%" PRIu64 BQ_LOGV("queueBuffer: slot=%d/%" PRIu64 " time=%" PRIu64
" crop=[%d,%d,%d,%d] transform=%#x scale=%s", " crop=[%d,%d,%d,%d] transform=%#x scale=%s",
slot, mCore->mFrameCounter + 1, timestamp, slot, mCore->mFrameCounter + 1, timestamp,
crop.left, crop.top, crop.right, crop.bottom, crop.left, crop.top, crop.right, crop.bottom, transform,
transform, BufferItem::scalingModeName(scalingMode)); BufferItem::scalingModeName(static_cast<uint32_t>(scalingMode)));
const sp<GraphicBuffer>& graphicBuffer(mSlots[slot].mGraphicBuffer); const sp<GraphicBuffer>& graphicBuffer(mSlots[slot].mGraphicBuffer);
Rect bufferRect(graphicBuffer->getWidth(), graphicBuffer->getHeight()); Rect bufferRect(graphicBuffer->getWidth(), graphicBuffer->getHeight());
@ -603,10 +603,11 @@ status_t BufferQueueProducer::queueBuffer(int slot,
item.mAcquireCalled = mSlots[slot].mAcquireCalled; item.mAcquireCalled = mSlots[slot].mAcquireCalled;
item.mGraphicBuffer = mSlots[slot].mGraphicBuffer; item.mGraphicBuffer = mSlots[slot].mGraphicBuffer;
item.mCrop = crop; item.mCrop = crop;
item.mTransform = transform & ~NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY; item.mTransform = transform &
~static_cast<uint32_t>(NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY);
item.mTransformToDisplayInverse = item.mTransformToDisplayInverse =
bool(transform & NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY); (transform & NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY) != 0;
item.mScalingMode = scalingMode; item.mScalingMode = static_cast<uint32_t>(scalingMode);
item.mTimestamp = timestamp; item.mTimestamp = timestamp;
item.mIsAutoTimestamp = isAutoTimestamp; item.mIsAutoTimestamp = isAutoTimestamp;
item.mFrameNumber = mCore->mFrameCounter; item.mFrameNumber = mCore->mFrameCounter;
@ -647,7 +648,8 @@ status_t BufferQueueProducer::queueBuffer(int slot,
mCore->mDequeueCondition.broadcast(); mCore->mDequeueCondition.broadcast();
output->inflate(mCore->mDefaultWidth, mCore->mDefaultHeight, output->inflate(mCore->mDefaultWidth, mCore->mDefaultHeight,
mCore->mTransformHint, mCore->mQueue.size()); mCore->mTransformHint,
static_cast<uint32_t>(mCore->mQueue.size()));
ATRACE_INT(mCore->mConsumerName.string(), mCore->mQueue.size()); ATRACE_INT(mCore->mConsumerName.string(), mCore->mQueue.size());
@ -736,25 +738,25 @@ int BufferQueueProducer::query(int what, int *outValue) {
int value; int value;
switch (what) { switch (what) {
case NATIVE_WINDOW_WIDTH: case NATIVE_WINDOW_WIDTH:
value = mCore->mDefaultWidth; value = static_cast<int32_t>(mCore->mDefaultWidth);
break; break;
case NATIVE_WINDOW_HEIGHT: case NATIVE_WINDOW_HEIGHT:
value = mCore->mDefaultHeight; value = static_cast<int32_t>(mCore->mDefaultHeight);
break; break;
case NATIVE_WINDOW_FORMAT: case NATIVE_WINDOW_FORMAT:
value = mCore->mDefaultBufferFormat; value = static_cast<int32_t>(mCore->mDefaultBufferFormat);
break; break;
case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS: case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:
value = mCore->getMinUndequeuedBufferCountLocked(false); value = mCore->getMinUndequeuedBufferCountLocked(false);
break; break;
case NATIVE_WINDOW_STICKY_TRANSFORM: case NATIVE_WINDOW_STICKY_TRANSFORM:
value = static_cast<int>(mStickyTransform); value = static_cast<int32_t>(mStickyTransform);
break; break;
case NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND: case NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND:
value = (mCore->mQueue.size() > 1); value = (mCore->mQueue.size() > 1);
break; break;
case NATIVE_WINDOW_CONSUMER_USAGE_BITS: case NATIVE_WINDOW_CONSUMER_USAGE_BITS:
value = mCore->mConsumerUsageBits; value = static_cast<int32_t>(mCore->mConsumerUsageBits);
break; break;
default: default:
return BAD_VALUE; return BAD_VALUE;
@ -802,7 +804,8 @@ status_t BufferQueueProducer::connect(const sp<IProducerListener>& listener,
case NATIVE_WINDOW_API_CAMERA: case NATIVE_WINDOW_API_CAMERA:
mCore->mConnectedApi = api; mCore->mConnectedApi = api;
output->inflate(mCore->mDefaultWidth, mCore->mDefaultHeight, output->inflate(mCore->mDefaultWidth, mCore->mDefaultHeight,
mCore->mTransformHint, mCore->mQueue.size()); mCore->mTransformHint,
static_cast<uint32_t>(mCore->mQueue.size()));
// Set up a death notification so that we can disconnect // Set up a death notification so that we can disconnect
// automatically if the remote producer dies // automatically if the remote producer dies
@ -904,14 +907,14 @@ status_t BufferQueueProducer::setSidebandStream(const sp<NativeHandle>& stream)
} }
void BufferQueueProducer::allocateBuffers(bool async, uint32_t width, void BufferQueueProducer::allocateBuffers(bool async, uint32_t width,
uint32_t height, uint32_t format, uint32_t usage) { uint32_t height, PixelFormat format, uint32_t usage) {
ATRACE_CALL(); ATRACE_CALL();
while (true) { while (true) {
Vector<int> freeSlots; Vector<int> freeSlots;
size_t newBufferCount = 0; size_t newBufferCount = 0;
uint32_t allocWidth = 0; uint32_t allocWidth = 0;
uint32_t allocHeight = 0; uint32_t allocHeight = 0;
uint32_t allocFormat = 0; PixelFormat allocFormat = PIXEL_FORMAT_UNKNOWN;
uint32_t allocUsage = 0; uint32_t allocUsage = 0;
{ // Autolock scope { // Autolock scope
Mutex::Autolock lock(mCore->mMutex); Mutex::Autolock lock(mCore->mMutex);
@ -937,7 +940,8 @@ void BufferQueueProducer::allocateBuffers(bool async, uint32_t width,
currentBufferCount, maxBufferCount); currentBufferCount, maxBufferCount);
if (maxBufferCount <= currentBufferCount) if (maxBufferCount <= currentBufferCount)
return; return;
newBufferCount = maxBufferCount - currentBufferCount; newBufferCount =
static_cast<size_t>(maxBufferCount - currentBufferCount);
if (freeSlots.size() < newBufferCount) { if (freeSlots.size() < newBufferCount) {
BQ_LOGE("allocateBuffers: ran out of free slots"); BQ_LOGE("allocateBuffers: ran out of free slots");
return; return;
@ -950,7 +954,7 @@ void BufferQueueProducer::allocateBuffers(bool async, uint32_t width,
mCore->mIsAllocating = true; mCore->mIsAllocating = true;
} // Autolock scope } // Autolock scope
Vector<sp<GraphicBuffer> > buffers; Vector<sp<GraphicBuffer>> buffers;
for (size_t i = 0; i < newBufferCount; ++i) { for (size_t i = 0; i < newBufferCount; ++i) {
status_t result = NO_ERROR; status_t result = NO_ERROR;
sp<GraphicBuffer> graphicBuffer(mCore->mAllocator->createGraphicBuffer( sp<GraphicBuffer> graphicBuffer(mCore->mAllocator->createGraphicBuffer(
@ -970,7 +974,8 @@ void BufferQueueProducer::allocateBuffers(bool async, uint32_t width,
Mutex::Autolock lock(mCore->mMutex); Mutex::Autolock lock(mCore->mMutex);
uint32_t checkWidth = width > 0 ? width : mCore->mDefaultWidth; uint32_t checkWidth = width > 0 ? width : mCore->mDefaultWidth;
uint32_t checkHeight = height > 0 ? height : mCore->mDefaultHeight; uint32_t checkHeight = height > 0 ? height : mCore->mDefaultHeight;
uint32_t checkFormat = format != 0 ? format : mCore->mDefaultBufferFormat; PixelFormat checkFormat = format != 0 ?
format : mCore->mDefaultBufferFormat;
uint32_t checkUsage = usage | mCore->mConsumerUsageBits; uint32_t checkUsage = usage | mCore->mConsumerUsageBits;
if (checkWidth != allocWidth || checkHeight != allocHeight || if (checkWidth != allocWidth || checkHeight != allocHeight ||
checkFormat != allocFormat || checkUsage != allocUsage) { checkFormat != allocFormat || checkUsage != allocUsage) {

View File

@ -24,8 +24,8 @@ const char* BufferSlot::bufferStateName(BufferState state) {
case BufferSlot::QUEUED: return "QUEUED"; case BufferSlot::QUEUED: return "QUEUED";
case BufferSlot::FREE: return "FREE"; case BufferSlot::FREE: return "FREE";
case BufferSlot::ACQUIRED: return "ACQUIRED"; case BufferSlot::ACQUIRED: return "ACQUIRED";
default: return "Unknown";
} }
return "Unknown";
} }
} // namespace android } // namespace android

View File

@ -40,9 +40,9 @@
// Macros for including the ConsumerBase name in log messages // Macros for including the ConsumerBase name in log messages
#define CB_LOGV(x, ...) ALOGV("[%s] " x, mName.string(), ##__VA_ARGS__) #define CB_LOGV(x, ...) ALOGV("[%s] " x, mName.string(), ##__VA_ARGS__)
#define CB_LOGD(x, ...) ALOGD("[%s] " x, mName.string(), ##__VA_ARGS__) //#define CB_LOGD(x, ...) ALOGD("[%s] " x, mName.string(), ##__VA_ARGS__)
#define CB_LOGI(x, ...) ALOGI("[%s] " x, mName.string(), ##__VA_ARGS__) //#define CB_LOGI(x, ...) ALOGI("[%s] " x, mName.string(), ##__VA_ARGS__)
#define CB_LOGW(x, ...) ALOGW("[%s] " x, mName.string(), ##__VA_ARGS__) //#define CB_LOGW(x, ...) ALOGW("[%s] " x, mName.string(), ##__VA_ARGS__)
#define CB_LOGE(x, ...) ALOGE("[%s] " x, mName.string(), ##__VA_ARGS__) #define CB_LOGE(x, ...) ALOGE("[%s] " x, mName.string(), ##__VA_ARGS__)
namespace android { namespace android {

View File

@ -16,22 +16,22 @@
//#define LOG_NDEBUG 0 //#define LOG_NDEBUG 0
#define LOG_TAG "CpuConsumer" #define LOG_TAG "CpuConsumer"
#define ATRACE_TAG ATRACE_TAG_GRAPHICS //#define ATRACE_TAG ATRACE_TAG_GRAPHICS
#include <cutils/compiler.h> #include <cutils/compiler.h>
#include <utils/Log.h> #include <utils/Log.h>
#include <gui/CpuConsumer.h> #include <gui/CpuConsumer.h>
#define CC_LOGV(x, ...) ALOGV("[%s] " x, mName.string(), ##__VA_ARGS__) #define CC_LOGV(x, ...) ALOGV("[%s] " x, mName.string(), ##__VA_ARGS__)
#define CC_LOGD(x, ...) ALOGD("[%s] " x, mName.string(), ##__VA_ARGS__) //#define CC_LOGD(x, ...) ALOGD("[%s] " x, mName.string(), ##__VA_ARGS__)
#define CC_LOGI(x, ...) ALOGI("[%s] " x, mName.string(), ##__VA_ARGS__) //#define CC_LOGI(x, ...) ALOGI("[%s] " x, mName.string(), ##__VA_ARGS__)
#define CC_LOGW(x, ...) ALOGW("[%s] " x, mName.string(), ##__VA_ARGS__) #define CC_LOGW(x, ...) ALOGW("[%s] " x, mName.string(), ##__VA_ARGS__)
#define CC_LOGE(x, ...) ALOGE("[%s] " x, mName.string(), ##__VA_ARGS__) #define CC_LOGE(x, ...) ALOGE("[%s] " x, mName.string(), ##__VA_ARGS__)
namespace android { namespace android {
CpuConsumer::CpuConsumer(const sp<IGraphicBufferConsumer>& bq, CpuConsumer::CpuConsumer(const sp<IGraphicBufferConsumer>& bq,
uint32_t maxLockedBuffers, bool controlledByApp) : size_t maxLockedBuffers, bool controlledByApp) :
ConsumerBase(bq, controlledByApp), ConsumerBase(bq, controlledByApp),
mMaxLockedBuffers(maxLockedBuffers), mMaxLockedBuffers(maxLockedBuffers),
mCurrentLockedBuffers(0) mCurrentLockedBuffers(0)
@ -40,7 +40,7 @@ CpuConsumer::CpuConsumer(const sp<IGraphicBufferConsumer>& bq,
mAcquiredBuffers.insertAt(0, maxLockedBuffers); mAcquiredBuffers.insertAt(0, maxLockedBuffers);
mConsumer->setConsumerUsageBits(GRALLOC_USAGE_SW_READ_OFTEN); mConsumer->setConsumerUsageBits(GRALLOC_USAGE_SW_READ_OFTEN);
mConsumer->setMaxAcquiredBufferCount(maxLockedBuffers); mConsumer->setMaxAcquiredBufferCount(static_cast<int32_t>(maxLockedBuffers));
} }
CpuConsumer::~CpuConsumer() { CpuConsumer::~CpuConsumer() {
@ -61,14 +61,14 @@ status_t CpuConsumer::setDefaultBufferSize(uint32_t width, uint32_t height)
return mConsumer->setDefaultBufferSize(width, height); return mConsumer->setDefaultBufferSize(width, height);
} }
status_t CpuConsumer::setDefaultBufferFormat(uint32_t defaultFormat) status_t CpuConsumer::setDefaultBufferFormat(PixelFormat defaultFormat)
{ {
Mutex::Autolock _l(mMutex); Mutex::Autolock _l(mMutex);
return mConsumer->setDefaultBufferFormat(defaultFormat); return mConsumer->setDefaultBufferFormat(defaultFormat);
} }
static bool isPossiblyYUV(PixelFormat format) { static bool isPossiblyYUV(PixelFormat format) {
switch ((int)format) { switch (static_cast<int>(format)) {
case HAL_PIXEL_FORMAT_RGBA_8888: case HAL_PIXEL_FORMAT_RGBA_8888:
case HAL_PIXEL_FORMAT_RGBX_8888: case HAL_PIXEL_FORMAT_RGBX_8888:
case HAL_PIXEL_FORMAT_RGB_888: case HAL_PIXEL_FORMAT_RGB_888:
@ -100,7 +100,7 @@ status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) {
if (!nativeBuffer) return BAD_VALUE; if (!nativeBuffer) return BAD_VALUE;
if (mCurrentLockedBuffers == mMaxLockedBuffers) { if (mCurrentLockedBuffers == mMaxLockedBuffers) {
CC_LOGW("Max buffers have been locked (%d), cannot lock anymore.", CC_LOGW("Max buffers have been locked (%zd), cannot lock anymore.",
mMaxLockedBuffers); mMaxLockedBuffers);
return NOT_ENOUGH_DATA; return NOT_ENOUGH_DATA;
} }
@ -173,7 +173,7 @@ status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) {
} }
size_t lockedIdx = 0; size_t lockedIdx = 0;
for (; lockedIdx < mMaxLockedBuffers; lockedIdx++) { for (; lockedIdx < static_cast<size_t>(mMaxLockedBuffers); lockedIdx++) {
if (mAcquiredBuffers[lockedIdx].mSlot == if (mAcquiredBuffers[lockedIdx].mSlot ==
BufferQueue::INVALID_BUFFER_SLOT) { BufferQueue::INVALID_BUFFER_SLOT) {
break; break;
@ -193,7 +193,7 @@ status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) {
nativeBuffer->format = format; nativeBuffer->format = format;
nativeBuffer->flexFormat = flexFormat; nativeBuffer->flexFormat = flexFormat;
nativeBuffer->stride = (ycbcr.y != NULL) ? nativeBuffer->stride = (ycbcr.y != NULL) ?
ycbcr.ystride : static_cast<uint32_t>(ycbcr.ystride) :
mSlots[buf].mGraphicBuffer->getStride(); mSlots[buf].mGraphicBuffer->getStride();
nativeBuffer->crop = b.mCrop; nativeBuffer->crop = b.mCrop;
@ -204,8 +204,8 @@ status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) {
nativeBuffer->dataCb = reinterpret_cast<uint8_t*>(ycbcr.cb); nativeBuffer->dataCb = reinterpret_cast<uint8_t*>(ycbcr.cb);
nativeBuffer->dataCr = reinterpret_cast<uint8_t*>(ycbcr.cr); nativeBuffer->dataCr = reinterpret_cast<uint8_t*>(ycbcr.cr);
nativeBuffer->chromaStride = ycbcr.cstride; nativeBuffer->chromaStride = static_cast<uint32_t>(ycbcr.cstride);
nativeBuffer->chromaStep = ycbcr.chroma_step; nativeBuffer->chromaStep = static_cast<uint32_t>(ycbcr.chroma_step);
mCurrentLockedBuffers++; mCurrentLockedBuffers++;
@ -217,7 +217,7 @@ status_t CpuConsumer::unlockBuffer(const LockedBuffer &nativeBuffer) {
size_t lockedIdx = 0; size_t lockedIdx = 0;
void *bufPtr = reinterpret_cast<void *>(nativeBuffer.data); void *bufPtr = reinterpret_cast<void *>(nativeBuffer.data);
for (; lockedIdx < mMaxLockedBuffers; lockedIdx++) { for (; lockedIdx < static_cast<size_t>(mMaxLockedBuffers); lockedIdx++) {
if (bufPtr == mAcquiredBuffers[lockedIdx].mBufferPointer) break; if (bufPtr == mAcquiredBuffers[lockedIdx].mBufferPointer) break;
} }
if (lockedIdx == mMaxLockedBuffers) { if (lockedIdx == mMaxLockedBuffers) {
@ -228,13 +228,13 @@ status_t CpuConsumer::unlockBuffer(const LockedBuffer &nativeBuffer) {
return releaseAcquiredBufferLocked(lockedIdx); return releaseAcquiredBufferLocked(lockedIdx);
} }
status_t CpuConsumer::releaseAcquiredBufferLocked(int lockedIdx) { status_t CpuConsumer::releaseAcquiredBufferLocked(size_t lockedIdx) {
status_t err; status_t err;
int fd = -1; int fd = -1;
err = mAcquiredBuffers[lockedIdx].mGraphicBuffer->unlockAsync(&fd); err = mAcquiredBuffers[lockedIdx].mGraphicBuffer->unlockAsync(&fd);
if (err != OK) { if (err != OK) {
CC_LOGE("%s: Unable to unlock graphic buffer %d", __FUNCTION__, CC_LOGE("%s: Unable to unlock graphic buffer %zd", __FUNCTION__,
lockedIdx); lockedIdx);
return err; return err;
} }

View File

@ -47,18 +47,28 @@ EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint na
namespace android { namespace android {
// Macros for including the GLConsumer name in log messages // Macros for including the GLConsumer name in log messages
#define ST_LOGV(x, ...) ALOGV("[%s] " x, mName.string(), ##__VA_ARGS__) #define GLC_LOGV(x, ...) ALOGV("[%s] " x, mName.string(), ##__VA_ARGS__)
#define ST_LOGD(x, ...) ALOGD("[%s] " x, mName.string(), ##__VA_ARGS__) #define GLC_LOGD(x, ...) ALOGD("[%s] " x, mName.string(), ##__VA_ARGS__)
#define ST_LOGI(x, ...) ALOGI("[%s] " x, mName.string(), ##__VA_ARGS__) //#define GLC_LOGI(x, ...) ALOGI("[%s] " x, mName.string(), ##__VA_ARGS__)
#define ST_LOGW(x, ...) ALOGW("[%s] " x, mName.string(), ##__VA_ARGS__) #define GLC_LOGW(x, ...) ALOGW("[%s] " x, mName.string(), ##__VA_ARGS__)
#define ST_LOGE(x, ...) ALOGE("[%s] " x, mName.string(), ##__VA_ARGS__) #define GLC_LOGE(x, ...) ALOGE("[%s] " x, mName.string(), ##__VA_ARGS__)
static const struct { static const struct {
size_t width, height; uint32_t width, height;
char const* bits; char const* bits;
} kDebugData = { 15, 12, } kDebugData = { 15, 12,
"___________________________________XX_XX_______X_X_____X_X____X_XXXXXXX_X____XXXXXXXXXXX__" "_______________"
"___XX_XXX_XX_______XXXXXXX_________X___X_________X_____X__________________________________" "_______________"
"_____XX_XX_____"
"__X_X_____X_X__"
"__X_XXXXXXX_X__"
"__XXXXXXXXXXX__"
"___XX_XXX_XX___"
"____XXXXXXX____"
"_____X___X_____"
"____X_____X____"
"_______________"
"_______________"
}; };
// Transform matrices // Transform matrices
@ -135,7 +145,7 @@ GLConsumer::GLConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t tex,
mCurrentTexture(BufferQueue::INVALID_BUFFER_SLOT), mCurrentTexture(BufferQueue::INVALID_BUFFER_SLOT),
mAttached(true) mAttached(true)
{ {
ST_LOGV("GLConsumer"); GLC_LOGV("GLConsumer");
memcpy(mCurrentTransformMatrix, mtxIdentity, memcpy(mCurrentTransformMatrix, mtxIdentity,
sizeof(mCurrentTransformMatrix)); sizeof(mCurrentTransformMatrix));
@ -154,7 +164,7 @@ GLConsumer::GLConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t texTarget,
mDefaultWidth(1), mDefaultWidth(1),
mDefaultHeight(1), mDefaultHeight(1),
mFilteringEnabled(true), mFilteringEnabled(true),
mTexName(-1), mTexName(0),
mUseFenceSync(useFenceSync), mUseFenceSync(useFenceSync),
mTexTarget(texTarget), mTexTarget(texTarget),
mEglDisplay(EGL_NO_DISPLAY), mEglDisplay(EGL_NO_DISPLAY),
@ -162,7 +172,7 @@ GLConsumer::GLConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t texTarget,
mCurrentTexture(BufferQueue::INVALID_BUFFER_SLOT), mCurrentTexture(BufferQueue::INVALID_BUFFER_SLOT),
mAttached(false) mAttached(false)
{ {
ST_LOGV("GLConsumer"); GLC_LOGV("GLConsumer");
memcpy(mCurrentTransformMatrix, mtxIdentity, memcpy(mCurrentTransformMatrix, mtxIdentity,
sizeof(mCurrentTransformMatrix)); sizeof(mCurrentTransformMatrix));
@ -186,11 +196,11 @@ status_t GLConsumer::setDefaultBufferSize(uint32_t w, uint32_t h)
status_t GLConsumer::updateTexImage() { status_t GLConsumer::updateTexImage() {
ATRACE_CALL(); ATRACE_CALL();
ST_LOGV("updateTexImage"); GLC_LOGV("updateTexImage");
Mutex::Autolock lock(mMutex); Mutex::Autolock lock(mMutex);
if (mAbandoned) { if (mAbandoned) {
ST_LOGE("updateTexImage: GLConsumer is abandoned!"); GLC_LOGE("updateTexImage: GLConsumer is abandoned!");
return NO_INIT; return NO_INIT;
} }
@ -209,11 +219,11 @@ status_t GLConsumer::updateTexImage() {
if (err != NO_ERROR) { if (err != NO_ERROR) {
if (err == BufferQueue::NO_BUFFER_AVAILABLE) { if (err == BufferQueue::NO_BUFFER_AVAILABLE) {
// We always bind the texture even if we don't update its contents. // We always bind the texture even if we don't update its contents.
ST_LOGV("updateTexImage: no buffers were available"); GLC_LOGV("updateTexImage: no buffers were available");
glBindTexture(mTexTarget, mTexName); glBindTexture(mTexTarget, mTexName);
err = NO_ERROR; err = NO_ERROR;
} else { } else {
ST_LOGE("updateTexImage: acquire failed: %s (%d)", GLC_LOGE("updateTexImage: acquire failed: %s (%d)",
strerror(-err), err); strerror(-err), err);
} }
return err; return err;
@ -234,11 +244,11 @@ status_t GLConsumer::updateTexImage() {
status_t GLConsumer::releaseTexImage() { status_t GLConsumer::releaseTexImage() {
ATRACE_CALL(); ATRACE_CALL();
ST_LOGV("releaseTexImage"); GLC_LOGV("releaseTexImage");
Mutex::Autolock lock(mMutex); Mutex::Autolock lock(mMutex);
if (mAbandoned) { if (mAbandoned) {
ST_LOGE("releaseTexImage: GLConsumer is abandoned!"); GLC_LOGE("releaseTexImage: GLConsumer is abandoned!");
return NO_INIT; return NO_INIT;
} }
@ -258,13 +268,13 @@ status_t GLConsumer::releaseTexImage() {
int buf = mCurrentTexture; int buf = mCurrentTexture;
if (buf != BufferQueue::INVALID_BUFFER_SLOT) { if (buf != BufferQueue::INVALID_BUFFER_SLOT) {
ST_LOGV("releaseTexImage: (slot=%d, mAttached=%d)", buf, mAttached); GLC_LOGV("releaseTexImage: (slot=%d, mAttached=%d)", buf, mAttached);
if (mAttached) { if (mAttached) {
// Do whatever sync ops we need to do before releasing the slot. // Do whatever sync ops we need to do before releasing the slot.
err = syncForReleaseLocked(mEglDisplay); err = syncForReleaseLocked(mEglDisplay);
if (err != NO_ERROR) { if (err != NO_ERROR) {
ST_LOGE("syncForReleaseLocked failed (slot=%d), err=%d", buf, err); GLC_LOGE("syncForReleaseLocked failed (slot=%d), err=%d", buf, err);
return err; return err;
} }
} else { } else {
@ -274,7 +284,7 @@ status_t GLConsumer::releaseTexImage() {
err = releaseBufferLocked(buf, mSlots[buf].mGraphicBuffer, mEglDisplay, EGL_NO_SYNC_KHR); err = releaseBufferLocked(buf, mSlots[buf].mGraphicBuffer, mEglDisplay, EGL_NO_SYNC_KHR);
if (err < NO_ERROR) { if (err < NO_ERROR) {
ST_LOGE("releaseTexImage: failed to release buffer: %s (%d)", GLC_LOGE("releaseTexImage: failed to release buffer: %s (%d)",
strerror(-err), err); strerror(-err), err);
return err; return err;
} }
@ -293,9 +303,9 @@ status_t GLConsumer::releaseTexImage() {
if (mAttached) { if (mAttached) {
// This binds a dummy buffer (mReleasedTexImage). // This binds a dummy buffer (mReleasedTexImage).
status_t err = bindTextureImageLocked(); status_t result = bindTextureImageLocked();
if (err != NO_ERROR) { if (result != NO_ERROR) {
return err; return result;
} }
} else { } else {
// detached, don't touch the texture (and we may not even have an // detached, don't touch the texture (and we may not even have an
@ -316,14 +326,15 @@ sp<GraphicBuffer> GLConsumer::getDebugTexImageBuffer() {
GraphicBuffer::USAGE_SW_WRITE_RARELY); GraphicBuffer::USAGE_SW_WRITE_RARELY);
uint32_t* bits; uint32_t* bits;
buffer->lock(GraphicBuffer::USAGE_SW_WRITE_RARELY, reinterpret_cast<void**>(&bits)); buffer->lock(GraphicBuffer::USAGE_SW_WRITE_RARELY, reinterpret_cast<void**>(&bits));
size_t w = buffer->getStride(); uint32_t stride = buffer->getStride();
size_t h = buffer->getHeight(); uint32_t height = buffer->getHeight();
memset(bits, 0, w*h*4); memset(bits, 0, stride * height * 4);
for (size_t y=0 ; y<kDebugData.height ; y++) { for (uint32_t y = 0; y < kDebugData.height; y++) {
for (size_t x=0 ; x<kDebugData.width ; x++) { for (uint32_t x = 0; x < kDebugData.width; x++) {
bits[x] = (kDebugData.bits[y*kDebugData.width+x] == 'X') ? 0xFF000000 : 0xFFFFFFFF; bits[x] = (kDebugData.bits[y + kDebugData.width + x] == 'X') ?
0xFF000000 : 0xFFFFFFFF;
} }
bits += w; bits += stride;
} }
buffer->unlock(); buffer->unlock();
sReleasedTexImageBuffer = buffer; sReleasedTexImageBuffer = buffer;
@ -369,7 +380,7 @@ status_t GLConsumer::updateAndReleaseLocked(const BufferQueue::BufferItem& item)
int buf = item.mBuf; int buf = item.mBuf;
if (!mAttached) { if (!mAttached) {
ST_LOGE("updateAndRelease: GLConsumer is not attached to an OpenGL " GLC_LOGE("updateAndRelease: GLConsumer is not attached to an OpenGL "
"ES context"); "ES context");
releaseBufferLocked(buf, mSlots[buf].mGraphicBuffer, releaseBufferLocked(buf, mSlots[buf].mGraphicBuffer,
mEglDisplay, EGL_NO_SYNC_KHR); mEglDisplay, EGL_NO_SYNC_KHR);
@ -391,7 +402,7 @@ status_t GLConsumer::updateAndReleaseLocked(const BufferQueue::BufferItem& item)
// means the buffer was previously acquired). // means the buffer was previously acquired).
err = mEglSlots[buf].mEglImage->createIfNeeded(mEglDisplay, item.mCrop); err = mEglSlots[buf].mEglImage->createIfNeeded(mEglDisplay, item.mCrop);
if (err != NO_ERROR) { if (err != NO_ERROR) {
ST_LOGW("updateAndRelease: unable to createImage on display=%p slot=%d", GLC_LOGW("updateAndRelease: unable to createImage on display=%p slot=%d",
mEglDisplay, buf); mEglDisplay, buf);
releaseBufferLocked(buf, mSlots[buf].mGraphicBuffer, releaseBufferLocked(buf, mSlots[buf].mGraphicBuffer,
mEglDisplay, EGL_NO_SYNC_KHR); mEglDisplay, EGL_NO_SYNC_KHR);
@ -410,7 +421,7 @@ status_t GLConsumer::updateAndReleaseLocked(const BufferQueue::BufferItem& item)
return err; return err;
} }
ST_LOGV("updateAndRelease: (slot=%d buf=%p) -> (slot=%d buf=%p)", GLC_LOGV("updateAndRelease: (slot=%d buf=%p) -> (slot=%d buf=%p)",
mCurrentTexture, mCurrentTextureImage != NULL ? mCurrentTexture, mCurrentTextureImage != NULL ?
mCurrentTextureImage->graphicBufferHandle() : 0, mCurrentTextureImage->graphicBufferHandle() : 0,
buf, mSlots[buf].mGraphicBuffer->handle); buf, mSlots[buf].mGraphicBuffer->handle);
@ -421,7 +432,7 @@ status_t GLConsumer::updateAndReleaseLocked(const BufferQueue::BufferItem& item)
mCurrentTexture, mCurrentTextureImage->graphicBuffer(), mCurrentTexture, mCurrentTextureImage->graphicBuffer(),
mEglDisplay, mEglSlots[mCurrentTexture].mEglFence); mEglDisplay, mEglSlots[mCurrentTexture].mEglFence);
if (status < NO_ERROR) { if (status < NO_ERROR) {
ST_LOGE("updateAndRelease: failed to release buffer: %s (%d)", GLC_LOGE("updateAndRelease: failed to release buffer: %s (%d)",
strerror(-status), status); strerror(-status), status);
err = status; err = status;
// keep going, with error raised [?] // keep going, with error raised [?]
@ -449,22 +460,22 @@ status_t GLConsumer::bindTextureImageLocked() {
return INVALID_OPERATION; return INVALID_OPERATION;
} }
GLint error; GLenum error;
while ((error = glGetError()) != GL_NO_ERROR) { while ((error = glGetError()) != GL_NO_ERROR) {
ST_LOGW("bindTextureImage: clearing GL error: %#04x", error); GLC_LOGW("bindTextureImage: clearing GL error: %#04x", error);
} }
glBindTexture(mTexTarget, mTexName); glBindTexture(mTexTarget, mTexName);
if (mCurrentTexture == BufferQueue::INVALID_BUFFER_SLOT && if (mCurrentTexture == BufferQueue::INVALID_BUFFER_SLOT &&
mCurrentTextureImage == NULL) { mCurrentTextureImage == NULL) {
ST_LOGE("bindTextureImage: no currently-bound texture"); GLC_LOGE("bindTextureImage: no currently-bound texture");
return NO_INIT; return NO_INIT;
} }
status_t err = mCurrentTextureImage->createIfNeeded(mEglDisplay, status_t err = mCurrentTextureImage->createIfNeeded(mEglDisplay,
mCurrentCrop); mCurrentCrop);
if (err != NO_ERROR) { if (err != NO_ERROR) {
ST_LOGW("bindTextureImage: can't create image on display=%p slot=%d", GLC_LOGW("bindTextureImage: can't create image on display=%p slot=%d",
mEglDisplay, mCurrentTexture); mEglDisplay, mCurrentTexture);
return UNKNOWN_ERROR; return UNKNOWN_ERROR;
} }
@ -476,17 +487,17 @@ status_t GLConsumer::bindTextureImageLocked() {
// forcing the creation of a new image. // forcing the creation of a new image.
if ((error = glGetError()) != GL_NO_ERROR) { if ((error = glGetError()) != GL_NO_ERROR) {
glBindTexture(mTexTarget, mTexName); glBindTexture(mTexTarget, mTexName);
status_t err = mCurrentTextureImage->createIfNeeded(mEglDisplay, status_t result = mCurrentTextureImage->createIfNeeded(mEglDisplay,
mCurrentCrop, mCurrentCrop,
true); true);
if (err != NO_ERROR) { if (result != NO_ERROR) {
ST_LOGW("bindTextureImage: can't create image on display=%p slot=%d", GLC_LOGW("bindTextureImage: can't create image on display=%p slot=%d",
mEglDisplay, mCurrentTexture); mEglDisplay, mCurrentTexture);
return UNKNOWN_ERROR; return UNKNOWN_ERROR;
} }
mCurrentTextureImage->bindToTextureTarget(mTexTarget); mCurrentTextureImage->bindToTextureTarget(mTexTarget);
if ((error = glGetError()) != GL_NO_ERROR) { if ((error = glGetError()) != GL_NO_ERROR) {
ST_LOGE("bindTextureImage: error binding external image: %#04x", error); GLC_LOGE("bindTextureImage: error binding external image: %#04x", error);
return UNKNOWN_ERROR; return UNKNOWN_ERROR;
} }
} }
@ -511,12 +522,12 @@ status_t GLConsumer::checkAndUpdateEglStateLocked(bool contextCheck) {
} }
if (mEglDisplay != dpy || dpy == EGL_NO_DISPLAY) { if (mEglDisplay != dpy || dpy == EGL_NO_DISPLAY) {
ST_LOGE("checkAndUpdateEglState: invalid current EGLDisplay"); GLC_LOGE("checkAndUpdateEglState: invalid current EGLDisplay");
return INVALID_OPERATION; return INVALID_OPERATION;
} }
if (mEglContext != ctx || ctx == EGL_NO_CONTEXT) { if (mEglContext != ctx || ctx == EGL_NO_CONTEXT) {
ST_LOGE("checkAndUpdateEglState: invalid current EGLContext"); GLC_LOGE("checkAndUpdateEglState: invalid current EGLContext");
return INVALID_OPERATION; return INVALID_OPERATION;
} }
@ -531,7 +542,7 @@ void GLConsumer::setReleaseFence(const sp<Fence>& fence) {
status_t err = addReleaseFence(mCurrentTexture, status_t err = addReleaseFence(mCurrentTexture,
mCurrentTextureImage->graphicBuffer(), fence); mCurrentTextureImage->graphicBuffer(), fence);
if (err != OK) { if (err != OK) {
ST_LOGE("setReleaseFence: failed to add the fence: %s (%d)", GLC_LOGE("setReleaseFence: failed to add the fence: %s (%d)",
strerror(-err), err); strerror(-err), err);
} }
} }
@ -539,16 +550,16 @@ void GLConsumer::setReleaseFence(const sp<Fence>& fence) {
status_t GLConsumer::detachFromContext() { status_t GLConsumer::detachFromContext() {
ATRACE_CALL(); ATRACE_CALL();
ST_LOGV("detachFromContext"); GLC_LOGV("detachFromContext");
Mutex::Autolock lock(mMutex); Mutex::Autolock lock(mMutex);
if (mAbandoned) { if (mAbandoned) {
ST_LOGE("detachFromContext: abandoned GLConsumer"); GLC_LOGE("detachFromContext: abandoned GLConsumer");
return NO_INIT; return NO_INIT;
} }
if (!mAttached) { if (!mAttached) {
ST_LOGE("detachFromContext: GLConsumer is not attached to a " GLC_LOGE("detachFromContext: GLConsumer is not attached to a "
"context"); "context");
return INVALID_OPERATION; return INVALID_OPERATION;
} }
@ -557,12 +568,12 @@ status_t GLConsumer::detachFromContext() {
EGLContext ctx = eglGetCurrentContext(); EGLContext ctx = eglGetCurrentContext();
if (mEglDisplay != dpy && mEglDisplay != EGL_NO_DISPLAY) { if (mEglDisplay != dpy && mEglDisplay != EGL_NO_DISPLAY) {
ST_LOGE("detachFromContext: invalid current EGLDisplay"); GLC_LOGE("detachFromContext: invalid current EGLDisplay");
return INVALID_OPERATION; return INVALID_OPERATION;
} }
if (mEglContext != ctx && mEglContext != EGL_NO_CONTEXT) { if (mEglContext != ctx && mEglContext != EGL_NO_CONTEXT) {
ST_LOGE("detachFromContext: invalid current EGLContext"); GLC_LOGE("detachFromContext: invalid current EGLContext");
return INVALID_OPERATION; return INVALID_OPERATION;
} }
@ -584,16 +595,16 @@ status_t GLConsumer::detachFromContext() {
status_t GLConsumer::attachToContext(uint32_t tex) { status_t GLConsumer::attachToContext(uint32_t tex) {
ATRACE_CALL(); ATRACE_CALL();
ST_LOGV("attachToContext"); GLC_LOGV("attachToContext");
Mutex::Autolock lock(mMutex); Mutex::Autolock lock(mMutex);
if (mAbandoned) { if (mAbandoned) {
ST_LOGE("attachToContext: abandoned GLConsumer"); GLC_LOGE("attachToContext: abandoned GLConsumer");
return NO_INIT; return NO_INIT;
} }
if (mAttached) { if (mAttached) {
ST_LOGE("attachToContext: GLConsumer is already attached to a " GLC_LOGE("attachToContext: GLConsumer is already attached to a "
"context"); "context");
return INVALID_OPERATION; return INVALID_OPERATION;
} }
@ -602,12 +613,12 @@ status_t GLConsumer::attachToContext(uint32_t tex) {
EGLContext ctx = eglGetCurrentContext(); EGLContext ctx = eglGetCurrentContext();
if (dpy == EGL_NO_DISPLAY) { if (dpy == EGL_NO_DISPLAY) {
ST_LOGE("attachToContext: invalid current EGLDisplay"); GLC_LOGE("attachToContext: invalid current EGLDisplay");
return INVALID_OPERATION; return INVALID_OPERATION;
} }
if (ctx == EGL_NO_CONTEXT) { if (ctx == EGL_NO_CONTEXT) {
ST_LOGE("attachToContext: invalid current EGLContext"); GLC_LOGE("attachToContext: invalid current EGLContext");
return INVALID_OPERATION; return INVALID_OPERATION;
} }
@ -636,14 +647,14 @@ status_t GLConsumer::attachToContext(uint32_t tex) {
status_t GLConsumer::syncForReleaseLocked(EGLDisplay dpy) { status_t GLConsumer::syncForReleaseLocked(EGLDisplay dpy) {
ST_LOGV("syncForReleaseLocked"); GLC_LOGV("syncForReleaseLocked");
if (mCurrentTexture != BufferQueue::INVALID_BUFFER_SLOT) { if (mCurrentTexture != BufferQueue::INVALID_BUFFER_SLOT) {
if (SyncFeatures::getInstance().useNativeFenceSync()) { if (SyncFeatures::getInstance().useNativeFenceSync()) {
EGLSyncKHR sync = eglCreateSyncKHR(dpy, EGLSyncKHR sync = eglCreateSyncKHR(dpy,
EGL_SYNC_NATIVE_FENCE_ANDROID, NULL); EGL_SYNC_NATIVE_FENCE_ANDROID, NULL);
if (sync == EGL_NO_SYNC_KHR) { if (sync == EGL_NO_SYNC_KHR) {
ST_LOGE("syncForReleaseLocked: error creating EGL fence: %#x", GLC_LOGE("syncForReleaseLocked: error creating EGL fence: %#x",
eglGetError()); eglGetError());
return UNKNOWN_ERROR; return UNKNOWN_ERROR;
} }
@ -651,7 +662,7 @@ status_t GLConsumer::syncForReleaseLocked(EGLDisplay dpy) {
int fenceFd = eglDupNativeFenceFDANDROID(dpy, sync); int fenceFd = eglDupNativeFenceFDANDROID(dpy, sync);
eglDestroySyncKHR(dpy, sync); eglDestroySyncKHR(dpy, sync);
if (fenceFd == EGL_NO_NATIVE_FENCE_FD_ANDROID) { if (fenceFd == EGL_NO_NATIVE_FENCE_FD_ANDROID) {
ST_LOGE("syncForReleaseLocked: error dup'ing native fence " GLC_LOGE("syncForReleaseLocked: error dup'ing native fence "
"fd: %#x", eglGetError()); "fd: %#x", eglGetError());
return UNKNOWN_ERROR; return UNKNOWN_ERROR;
} }
@ -659,7 +670,7 @@ status_t GLConsumer::syncForReleaseLocked(EGLDisplay dpy) {
status_t err = addReleaseFenceLocked(mCurrentTexture, status_t err = addReleaseFenceLocked(mCurrentTexture,
mCurrentTextureImage->graphicBuffer(), fence); mCurrentTextureImage->graphicBuffer(), fence);
if (err != OK) { if (err != OK) {
ST_LOGE("syncForReleaseLocked: error adding release fence: " GLC_LOGE("syncForReleaseLocked: error adding release fence: "
"%s (%d)", strerror(-err), err); "%s (%d)", strerror(-err), err);
return err; return err;
} }
@ -672,11 +683,11 @@ status_t GLConsumer::syncForReleaseLocked(EGLDisplay dpy) {
// before the producer accesses it. // before the producer accesses it.
EGLint result = eglClientWaitSyncKHR(dpy, fence, 0, 1000000000); EGLint result = eglClientWaitSyncKHR(dpy, fence, 0, 1000000000);
if (result == EGL_FALSE) { if (result == EGL_FALSE) {
ST_LOGE("syncForReleaseLocked: error waiting for previous " GLC_LOGE("syncForReleaseLocked: error waiting for previous "
"fence: %#x", eglGetError()); "fence: %#x", eglGetError());
return UNKNOWN_ERROR; return UNKNOWN_ERROR;
} else if (result == EGL_TIMEOUT_EXPIRED_KHR) { } else if (result == EGL_TIMEOUT_EXPIRED_KHR) {
ST_LOGE("syncForReleaseLocked: timeout waiting for previous " GLC_LOGE("syncForReleaseLocked: timeout waiting for previous "
"fence"); "fence");
return TIMED_OUT; return TIMED_OUT;
} }
@ -687,7 +698,7 @@ status_t GLConsumer::syncForReleaseLocked(EGLDisplay dpy) {
// OpenGL ES context. // OpenGL ES context.
fence = eglCreateSyncKHR(dpy, EGL_SYNC_FENCE_KHR, NULL); fence = eglCreateSyncKHR(dpy, EGL_SYNC_FENCE_KHR, NULL);
if (fence == EGL_NO_SYNC_KHR) { if (fence == EGL_NO_SYNC_KHR) {
ST_LOGE("syncForReleaseLocked: error creating fence: %#x", GLC_LOGE("syncForReleaseLocked: error creating fence: %#x",
eglGetError()); eglGetError());
return UNKNOWN_ERROR; return UNKNOWN_ERROR;
} }
@ -699,7 +710,7 @@ status_t GLConsumer::syncForReleaseLocked(EGLDisplay dpy) {
return OK; return OK;
} }
bool GLConsumer::isExternalFormat(uint32_t format) bool GLConsumer::isExternalFormat(PixelFormat format)
{ {
switch (format) { switch (format) {
// supported YUV formats // supported YUV formats
@ -730,14 +741,14 @@ void GLConsumer::getTransformMatrix(float mtx[16]) {
void GLConsumer::setFilteringEnabled(bool enabled) { void GLConsumer::setFilteringEnabled(bool enabled) {
Mutex::Autolock lock(mMutex); Mutex::Autolock lock(mMutex);
if (mAbandoned) { if (mAbandoned) {
ST_LOGE("setFilteringEnabled: GLConsumer is abandoned!"); GLC_LOGE("setFilteringEnabled: GLConsumer is abandoned!");
return; return;
} }
bool needsRecompute = mFilteringEnabled != enabled; bool needsRecompute = mFilteringEnabled != enabled;
mFilteringEnabled = enabled; mFilteringEnabled = enabled;
if (needsRecompute && mCurrentTextureImage==NULL) { if (needsRecompute && mCurrentTextureImage==NULL) {
ST_LOGD("setFilteringEnabled called with mCurrentTextureImage == NULL"); GLC_LOGD("setFilteringEnabled called with mCurrentTextureImage == NULL");
} }
if (needsRecompute && mCurrentTextureImage != NULL) { if (needsRecompute && mCurrentTextureImage != NULL) {
@ -746,7 +757,7 @@ void GLConsumer::setFilteringEnabled(bool enabled) {
} }
void GLConsumer::computeCurrentTransformMatrixLocked() { void GLConsumer::computeCurrentTransformMatrixLocked() {
ST_LOGV("computeCurrentTransformMatrixLocked"); GLC_LOGV("computeCurrentTransformMatrixLocked");
float xform[16]; float xform[16];
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
@ -778,7 +789,7 @@ void GLConsumer::computeCurrentTransformMatrixLocked() {
NULL : mCurrentTextureImage->graphicBuffer(); NULL : mCurrentTextureImage->graphicBuffer();
if (buf == NULL) { if (buf == NULL) {
ST_LOGD("computeCurrentTransformMatrixLocked: mCurrentTextureImage is NULL"); GLC_LOGD("computeCurrentTransformMatrixLocked: mCurrentTextureImage is NULL");
} }
float mtxBeforeFlipV[16]; float mtxBeforeFlipV[16];
@ -850,13 +861,13 @@ void GLConsumer::computeCurrentTransformMatrixLocked() {
} }
nsecs_t GLConsumer::getTimestamp() { nsecs_t GLConsumer::getTimestamp() {
ST_LOGV("getTimestamp"); GLC_LOGV("getTimestamp");
Mutex::Autolock lock(mMutex); Mutex::Autolock lock(mMutex);
return mCurrentTimestamp; return mCurrentTimestamp;
} }
nsecs_t GLConsumer::getFrameNumber() { uint64_t GLConsumer::getFrameNumber() {
ST_LOGV("getFrameNumber"); GLC_LOGV("getFrameNumber");
Mutex::Autolock lock(mMutex); Mutex::Autolock lock(mMutex);
return mCurrentFrameNumber; return mCurrentFrameNumber;
} }
@ -872,30 +883,33 @@ Rect GLConsumer::getCurrentCrop() const {
Rect outCrop = mCurrentCrop; Rect outCrop = mCurrentCrop;
if (mCurrentScalingMode == NATIVE_WINDOW_SCALING_MODE_SCALE_CROP) { if (mCurrentScalingMode == NATIVE_WINDOW_SCALING_MODE_SCALE_CROP) {
int32_t newWidth = mCurrentCrop.width(); uint32_t newWidth = static_cast<uint32_t>(mCurrentCrop.width());
int32_t newHeight = mCurrentCrop.height(); uint32_t newHeight = static_cast<uint32_t>(mCurrentCrop.height());
if (newWidth * mDefaultHeight > newHeight * mDefaultWidth) { if (newWidth * mDefaultHeight > newHeight * mDefaultWidth) {
newWidth = newHeight * mDefaultWidth / mDefaultHeight; newWidth = newHeight * mDefaultWidth / mDefaultHeight;
ST_LOGV("too wide: newWidth = %d", newWidth); GLC_LOGV("too wide: newWidth = %d", newWidth);
} else if (newWidth * mDefaultHeight < newHeight * mDefaultWidth) { } else if (newWidth * mDefaultHeight < newHeight * mDefaultWidth) {
newHeight = newWidth * mDefaultHeight / mDefaultWidth; newHeight = newWidth * mDefaultHeight / mDefaultWidth;
ST_LOGV("too tall: newHeight = %d", newHeight); GLC_LOGV("too tall: newHeight = %d", newHeight);
} }
uint32_t currentWidth = static_cast<uint32_t>(mCurrentCrop.width());
uint32_t currentHeight = static_cast<uint32_t>(mCurrentCrop.height());
// The crop is too wide // The crop is too wide
if (newWidth < mCurrentCrop.width()) { if (newWidth < currentWidth) {
int32_t dw = (newWidth - mCurrentCrop.width())/2; uint32_t dw = (newWidth - currentWidth) / 2;
outCrop.left -=dw; outCrop.left -=dw;
outCrop.right += dw; outCrop.right += dw;
// The crop is too tall // The crop is too tall
} else if (newHeight < mCurrentCrop.height()) { } else if (newHeight < currentHeight) {
int32_t dh = (newHeight - mCurrentCrop.height())/2; uint32_t dh = (newHeight - currentHeight) / 2;
outCrop.top -= dh; outCrop.top -= dh;
outCrop.bottom += dh; outCrop.bottom += dh;
} }
ST_LOGV("getCurrentCrop final crop [%d,%d,%d,%d]", GLC_LOGV("getCurrentCrop final crop [%d,%d,%d,%d]",
outCrop.left, outCrop.top, outCrop.left, outCrop.top,
outCrop.right,outCrop.bottom); outCrop.right,outCrop.bottom);
} }
@ -929,12 +943,12 @@ status_t GLConsumer::doGLFenceWaitLocked() const {
EGLContext ctx = eglGetCurrentContext(); EGLContext ctx = eglGetCurrentContext();
if (mEglDisplay != dpy || mEglDisplay == EGL_NO_DISPLAY) { if (mEglDisplay != dpy || mEglDisplay == EGL_NO_DISPLAY) {
ST_LOGE("doGLFenceWait: invalid current EGLDisplay"); GLC_LOGE("doGLFenceWait: invalid current EGLDisplay");
return INVALID_OPERATION; return INVALID_OPERATION;
} }
if (mEglContext != ctx || mEglContext == EGL_NO_CONTEXT) { if (mEglContext != ctx || mEglContext == EGL_NO_CONTEXT) {
ST_LOGE("doGLFenceWait: invalid current EGLContext"); GLC_LOGE("doGLFenceWait: invalid current EGLContext");
return INVALID_OPERATION; return INVALID_OPERATION;
} }
@ -943,7 +957,7 @@ status_t GLConsumer::doGLFenceWaitLocked() const {
// Create an EGLSyncKHR from the current fence. // Create an EGLSyncKHR from the current fence.
int fenceFd = mCurrentFence->dup(); int fenceFd = mCurrentFence->dup();
if (fenceFd == -1) { if (fenceFd == -1) {
ST_LOGE("doGLFenceWait: error dup'ing fence fd: %d", errno); GLC_LOGE("doGLFenceWait: error dup'ing fence fd: %d", errno);
return -errno; return -errno;
} }
EGLint attribs[] = { EGLint attribs[] = {
@ -954,7 +968,7 @@ status_t GLConsumer::doGLFenceWaitLocked() const {
EGL_SYNC_NATIVE_FENCE_ANDROID, attribs); EGL_SYNC_NATIVE_FENCE_ANDROID, attribs);
if (sync == EGL_NO_SYNC_KHR) { if (sync == EGL_NO_SYNC_KHR) {
close(fenceFd); close(fenceFd);
ST_LOGE("doGLFenceWait: error creating EGL fence: %#x", GLC_LOGE("doGLFenceWait: error creating EGL fence: %#x",
eglGetError()); eglGetError());
return UNKNOWN_ERROR; return UNKNOWN_ERROR;
} }
@ -966,7 +980,7 @@ status_t GLConsumer::doGLFenceWaitLocked() const {
EGLint eglErr = eglGetError(); EGLint eglErr = eglGetError();
eglDestroySyncKHR(dpy, sync); eglDestroySyncKHR(dpy, sync);
if (eglErr != EGL_SUCCESS) { if (eglErr != EGL_SUCCESS) {
ST_LOGE("doGLFenceWait: error waiting for EGL fence: %#x", GLC_LOGE("doGLFenceWait: error waiting for EGL fence: %#x",
eglErr); eglErr);
return UNKNOWN_ERROR; return UNKNOWN_ERROR;
} }
@ -974,7 +988,7 @@ status_t GLConsumer::doGLFenceWaitLocked() const {
status_t err = mCurrentFence->waitForever( status_t err = mCurrentFence->waitForever(
"GLConsumer::doGLFenceWaitLocked"); "GLConsumer::doGLFenceWaitLocked");
if (err != NO_ERROR) { if (err != NO_ERROR) {
ST_LOGE("doGLFenceWait: error waiting for fence: %d", err); GLC_LOGE("doGLFenceWait: error waiting for fence: %d", err);
return err; return err;
} }
} }
@ -984,7 +998,7 @@ status_t GLConsumer::doGLFenceWaitLocked() const {
} }
void GLConsumer::freeBufferLocked(int slotIndex) { void GLConsumer::freeBufferLocked(int slotIndex) {
ST_LOGV("freeBufferLocked: slotIndex=%d", slotIndex); GLC_LOGV("freeBufferLocked: slotIndex=%d", slotIndex);
if (slotIndex == mCurrentTexture) { if (slotIndex == mCurrentTexture) {
mCurrentTexture = BufferQueue::INVALID_BUFFER_SLOT; mCurrentTexture = BufferQueue::INVALID_BUFFER_SLOT;
} }
@ -993,7 +1007,7 @@ void GLConsumer::freeBufferLocked(int slotIndex) {
} }
void GLConsumer::abandonLocked() { void GLConsumer::abandonLocked() {
ST_LOGV("abandonLocked"); GLC_LOGV("abandonLocked");
mCurrentTextureImage.clear(); mCurrentTextureImage.clear();
ConsumerBase::abandonLocked(); ConsumerBase::abandonLocked();
} }
@ -1004,7 +1018,7 @@ void GLConsumer::setName(const String8& name) {
mConsumer->setConsumerName(name); mConsumer->setConsumerName(name);
} }
status_t GLConsumer::setDefaultBufferFormat(uint32_t defaultFormat) { status_t GLConsumer::setDefaultBufferFormat(PixelFormat defaultFormat) {
Mutex::Autolock lock(mMutex); Mutex::Autolock lock(mMutex);
return mConsumer->setDefaultBufferFormat(defaultFormat); return mConsumer->setDefaultBufferFormat(defaultFormat);
} }
@ -1107,12 +1121,14 @@ status_t GLConsumer::EglImage::createIfNeeded(EGLDisplay eglDisplay,
} }
void GLConsumer::EglImage::bindToTextureTarget(uint32_t texTarget) { void GLConsumer::EglImage::bindToTextureTarget(uint32_t texTarget) {
glEGLImageTargetTexture2DOES(texTarget, (GLeglImageOES)mEglImage); glEGLImageTargetTexture2DOES(texTarget,
static_cast<GLeglImageOES>(mEglImage));
} }
EGLImageKHR GLConsumer::EglImage::createImage(EGLDisplay dpy, EGLImageKHR GLConsumer::EglImage::createImage(EGLDisplay dpy,
const sp<GraphicBuffer>& graphicBuffer, const Rect& crop) { const sp<GraphicBuffer>& graphicBuffer, const Rect& crop) {
EGLClientBuffer cbuf = (EGLClientBuffer)graphicBuffer->getNativeBuffer(); EGLClientBuffer cbuf =
static_cast<EGLClientBuffer>(graphicBuffer->getNativeBuffer());
EGLint attrs[] = { EGLint attrs[] = {
EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
EGL_IMAGE_CROP_LEFT_ANDROID, crop.left, EGL_IMAGE_CROP_LEFT_ANDROID, crop.left,

View File

@ -31,9 +31,10 @@ GraphicBufferAlloc::GraphicBufferAlloc() {
GraphicBufferAlloc::~GraphicBufferAlloc() { GraphicBufferAlloc::~GraphicBufferAlloc() {
} }
sp<GraphicBuffer> GraphicBufferAlloc::createGraphicBuffer(uint32_t w, uint32_t h, sp<GraphicBuffer> GraphicBufferAlloc::createGraphicBuffer(uint32_t width,
PixelFormat format, uint32_t usage, status_t* error) { uint32_t height, PixelFormat format, uint32_t usage, status_t* error) {
sp<GraphicBuffer> graphicBuffer(new GraphicBuffer(w, h, format, usage)); sp<GraphicBuffer> graphicBuffer(
new GraphicBuffer(width, height, format, usage));
status_t err = graphicBuffer->initCheck(); status_t err = graphicBuffer->initCheck();
*error = err; *error = err;
if (err != 0 || graphicBuffer->handle == 0) { if (err != 0 || graphicBuffer->handle == 0) {
@ -42,7 +43,7 @@ sp<GraphicBuffer> GraphicBufferAlloc::createGraphicBuffer(uint32_t w, uint32_t h
} }
ALOGE("GraphicBufferAlloc::createGraphicBuffer(w=%d, h=%d) " ALOGE("GraphicBufferAlloc::createGraphicBuffer(w=%d, h=%d) "
"failed (%s), handle=%p", "failed (%s), handle=%p",
w, h, strerror(-err), graphicBuffer->handle); width, height, strerror(-err), graphicBuffer->handle);
return 0; return 0;
} }
return graphicBuffer; return graphicBuffer;

View File

@ -40,6 +40,8 @@ public:
: BpInterface<IConsumerListener>(impl) { : BpInterface<IConsumerListener>(impl) {
} }
virtual ~BpConsumerListener();
virtual void onFrameAvailable(const BufferItem& item) { virtual void onFrameAvailable(const BufferItem& item) {
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(IConsumerListener::getInterfaceDescriptor()); data.writeInterfaceToken(IConsumerListener::getInterfaceDescriptor());
@ -60,6 +62,10 @@ public:
} }
}; };
// Out-of-line virtual method definition to trigger vtable emission in this
// translation unit (see clang warning -Wweak-vtables)
BpConsumerListener::~BpConsumerListener() {}
IMPLEMENT_META_INTERFACE(ConsumerListener, "android.gui.IConsumerListener"); IMPLEMENT_META_INTERFACE(ConsumerListener, "android.gui.IConsumerListener");
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------

View File

@ -44,6 +44,8 @@ public:
{ {
} }
virtual ~BpDisplayEventConnection();
virtual sp<BitTube> getDataChannel() const virtual sp<BitTube> getDataChannel() const
{ {
Parcel data, reply; Parcel data, reply;
@ -55,7 +57,7 @@ public:
virtual void setVsyncRate(uint32_t count) { virtual void setVsyncRate(uint32_t count) {
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(IDisplayEventConnection::getInterfaceDescriptor()); data.writeInterfaceToken(IDisplayEventConnection::getInterfaceDescriptor());
data.writeInt32(count); data.writeUint32(count);
remote()->transact(SET_VSYNC_RATE, data, &reply); remote()->transact(SET_VSYNC_RATE, data, &reply);
} }
@ -66,6 +68,10 @@ public:
} }
}; };
// Out-of-line virtual method definition to trigger vtable emission in this
// translation unit (see clang warning -Wweak-vtables)
BpDisplayEventConnection::~BpDisplayEventConnection() {}
IMPLEMENT_META_INTERFACE(DisplayEventConnection, "android.gui.DisplayEventConnection"); IMPLEMENT_META_INTERFACE(DisplayEventConnection, "android.gui.DisplayEventConnection");
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -79,17 +85,17 @@ status_t BnDisplayEventConnection::onTransact(
sp<BitTube> channel(getDataChannel()); sp<BitTube> channel(getDataChannel());
channel->writeToParcel(reply); channel->writeToParcel(reply);
return NO_ERROR; return NO_ERROR;
} break; }
case SET_VSYNC_RATE: { case SET_VSYNC_RATE: {
CHECK_INTERFACE(IDisplayEventConnection, data, reply); CHECK_INTERFACE(IDisplayEventConnection, data, reply);
setVsyncRate(data.readInt32()); setVsyncRate(data.readUint32());
return NO_ERROR; return NO_ERROR;
} break; }
case REQUEST_NEXT_VSYNC: { case REQUEST_NEXT_VSYNC: {
CHECK_INTERFACE(IDisplayEventConnection, data, reply); CHECK_INTERFACE(IDisplayEventConnection, data, reply);
requestNextVsync(); requestNextVsync();
return NO_ERROR; return NO_ERROR;
} break; }
} }
return BBinder::onTransact(code, data, reply, flags); return BBinder::onTransact(code, data, reply, flags);
} }

View File

@ -42,14 +42,17 @@ public:
{ {
} }
virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h, virtual ~BpGraphicBufferAlloc();
PixelFormat format, uint32_t usage, status_t* error) {
virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width,
uint32_t height, PixelFormat format, uint32_t usage,
status_t* error) {
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(IGraphicBufferAlloc::getInterfaceDescriptor()); data.writeInterfaceToken(IGraphicBufferAlloc::getInterfaceDescriptor());
data.writeInt32(w); data.writeUint32(width);
data.writeInt32(h); data.writeUint32(height);
data.writeInt32(format); data.writeInt32(static_cast<int32_t>(format));
data.writeInt32(usage); data.writeUint32(usage);
remote()->transact(CREATE_GRAPHIC_BUFFER, data, &reply); remote()->transact(CREATE_GRAPHIC_BUFFER, data, &reply);
sp<GraphicBuffer> graphicBuffer; sp<GraphicBuffer> graphicBuffer;
status_t result = reply.readInt32(); status_t result = reply.readInt32();
@ -65,6 +68,10 @@ public:
} }
}; };
// Out-of-line virtual method definition to trigger vtable emission in this
// translation unit (see clang warning -Wweak-vtables)
BpGraphicBufferAlloc::~BpGraphicBufferAlloc() {}
IMPLEMENT_META_INTERFACE(GraphicBufferAlloc, "android.ui.IGraphicBufferAlloc"); IMPLEMENT_META_INTERFACE(GraphicBufferAlloc, "android.ui.IGraphicBufferAlloc");
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -74,27 +81,26 @@ status_t BnGraphicBufferAlloc::onTransact(
{ {
// codes that don't require permission check // codes that don't require permission check
/* BufferReference just keeps a strong reference to a // BufferReference just keeps a strong reference to a GraphicBuffer until it
* GraphicBuffer until it is destroyed (that is, until // is destroyed (that is, until no local or remote process have a reference
* no local or remote process have a reference to it). // to it).
*/
class BufferReference : public BBinder { class BufferReference : public BBinder {
sp<GraphicBuffer> buffer; sp<GraphicBuffer> mBuffer;
public: public:
BufferReference(const sp<GraphicBuffer>& buffer) : buffer(buffer) { } BufferReference(const sp<GraphicBuffer>& buffer) : mBuffer(buffer) {}
}; };
switch(code) { switch (code) {
case CREATE_GRAPHIC_BUFFER: { case CREATE_GRAPHIC_BUFFER: {
CHECK_INTERFACE(IGraphicBufferAlloc, data, reply); CHECK_INTERFACE(IGraphicBufferAlloc, data, reply);
uint32_t w = data.readInt32(); uint32_t width = data.readUint32();
uint32_t h = data.readInt32(); uint32_t height = data.readUint32();
PixelFormat format = data.readInt32(); PixelFormat format = static_cast<PixelFormat>(data.readInt32());
uint32_t usage = data.readInt32(); uint32_t usage = data.readUint32();
status_t error; status_t error;
sp<GraphicBuffer> result = sp<GraphicBuffer> result =
createGraphicBuffer(w, h, format, usage, &error); createGraphicBuffer(width, height, format, usage, &error);
reply->writeInt32(error); reply->writeInt32(error);
if (result != 0) { if (result != 0) {
reply->write(*result); reply->write(*result);
@ -107,7 +113,7 @@ status_t BnGraphicBufferAlloc::onTransact(
reply->writeStrongBinder( new BufferReference(result) ); reply->writeStrongBinder( new BufferReference(result) );
} }
return NO_ERROR; return NO_ERROR;
} break; }
default: default:
return BBinder::onTransact(code, data, reply, flags); return BBinder::onTransact(code, data, reply, flags);
} }

View File

@ -215,6 +215,8 @@ public:
{ {
} }
virtual ~BpGraphicBufferConsumer();
virtual status_t acquireBuffer(BufferItem *buffer, nsecs_t presentWhen) { virtual status_t acquireBuffer(BufferItem *buffer, nsecs_t presentWhen) {
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
@ -261,7 +263,7 @@ public:
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
data.writeInt32(buf); data.writeInt32(buf);
data.writeInt64(frameNumber); data.writeInt64(static_cast<int64_t>(frameNumber));
data.write(*releaseFence); data.write(*releaseFence);
status_t result = remote()->transact(RELEASE_BUFFER, data, &reply); status_t result = remote()->transact(RELEASE_BUFFER, data, &reply);
if (result != NO_ERROR) { if (result != NO_ERROR) {
@ -303,15 +305,15 @@ public:
if (result != NO_ERROR) { if (result != NO_ERROR) {
return result; return result;
} }
*slotMask = reply.readInt64(); *slotMask = static_cast<uint64_t>(reply.readInt64());
return reply.readInt32(); return reply.readInt32();
} }
virtual status_t setDefaultBufferSize(uint32_t w, uint32_t h) { virtual status_t setDefaultBufferSize(uint32_t width, uint32_t height) {
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
data.writeInt32(w); data.writeUint32(width);
data.writeInt32(h); data.writeUint32(height);
status_t result = remote()->transact(SET_DEFAULT_BUFFER_SIZE, data, &reply); status_t result = remote()->transact(SET_DEFAULT_BUFFER_SIZE, data, &reply);
if (result != NO_ERROR) { if (result != NO_ERROR) {
return result; return result;
@ -358,10 +360,10 @@ public:
remote()->transact(SET_CONSUMER_NAME, data, &reply); remote()->transact(SET_CONSUMER_NAME, data, &reply);
} }
virtual status_t setDefaultBufferFormat(uint32_t defaultFormat) { virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat) {
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
data.writeInt32(defaultFormat); data.writeInt32(static_cast<int32_t>(defaultFormat));
status_t result = remote()->transact(SET_DEFAULT_BUFFER_FORMAT, data, &reply); status_t result = remote()->transact(SET_DEFAULT_BUFFER_FORMAT, data, &reply);
if (result != NO_ERROR) { if (result != NO_ERROR) {
return result; return result;
@ -372,7 +374,7 @@ public:
virtual status_t setConsumerUsageBits(uint32_t usage) { virtual status_t setConsumerUsageBits(uint32_t usage) {
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
data.writeInt32(usage); data.writeUint32(usage);
status_t result = remote()->transact(SET_CONSUMER_USAGE_BITS, data, &reply); status_t result = remote()->transact(SET_CONSUMER_USAGE_BITS, data, &reply);
if (result != NO_ERROR) { if (result != NO_ERROR) {
return result; return result;
@ -383,7 +385,7 @@ public:
virtual status_t setTransformHint(uint32_t hint) { virtual status_t setTransformHint(uint32_t hint) {
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
data.writeInt32(hint); data.writeUint32(hint);
status_t result = remote()->transact(SET_TRANSFORM_HINT, data, &reply); status_t result = remote()->transact(SET_TRANSFORM_HINT, data, &reply);
if (result != NO_ERROR) { if (result != NO_ERROR) {
return result; return result;
@ -415,6 +417,10 @@ public:
} }
}; };
// Out-of-line virtual method definition to trigger vtable emission in this
// translation unit (see clang warning -Wweak-vtables)
BpGraphicBufferConsumer::~BpGraphicBufferConsumer() {}
IMPLEMENT_META_INTERFACE(GraphicBufferConsumer, "android.gui.IGraphicBufferConsumer"); IMPLEMENT_META_INTERFACE(GraphicBufferConsumer, "android.gui.IGraphicBufferConsumer");
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -432,14 +438,14 @@ status_t BnGraphicBufferConsumer::onTransact(
if (err) return err; if (err) return err;
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case DETACH_BUFFER: { case DETACH_BUFFER: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
int slot = data.readInt32(); int slot = data.readInt32();
int result = detachBuffer(slot); int result = detachBuffer(slot);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case ATTACH_BUFFER: { case ATTACH_BUFFER: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
sp<GraphicBuffer> buffer = new GraphicBuffer(); sp<GraphicBuffer> buffer = new GraphicBuffer();
@ -449,11 +455,11 @@ status_t BnGraphicBufferConsumer::onTransact(
reply->writeInt32(slot); reply->writeInt32(slot);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case RELEASE_BUFFER: { case RELEASE_BUFFER: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
int buf = data.readInt32(); int buf = data.readInt32();
uint64_t frameNumber = data.readInt64(); uint64_t frameNumber = static_cast<uint64_t>(data.readInt64());
sp<Fence> releaseFence = new Fence(); sp<Fence> releaseFence = new Fence();
status_t err = data.read(*releaseFence); status_t err = data.read(*releaseFence);
if (err) return err; if (err) return err;
@ -461,7 +467,7 @@ status_t BnGraphicBufferConsumer::onTransact(
EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, releaseFence); EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, releaseFence);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case CONSUMER_CONNECT: { case CONSUMER_CONNECT: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
sp<IConsumerListener> consumer = IConsumerListener::asInterface( data.readStrongBinder() ); sp<IConsumerListener> consumer = IConsumerListener::asInterface( data.readStrongBinder() );
@ -469,75 +475,75 @@ status_t BnGraphicBufferConsumer::onTransact(
status_t result = consumerConnect(consumer, controlledByApp); status_t result = consumerConnect(consumer, controlledByApp);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case CONSUMER_DISCONNECT: { case CONSUMER_DISCONNECT: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
status_t result = consumerDisconnect(); status_t result = consumerDisconnect();
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case GET_RELEASED_BUFFERS: { case GET_RELEASED_BUFFERS: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
uint64_t slotMask; uint64_t slotMask;
status_t result = getReleasedBuffers(&slotMask); status_t result = getReleasedBuffers(&slotMask);
reply->writeInt64(slotMask); reply->writeInt64(static_cast<int64_t>(slotMask));
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case SET_DEFAULT_BUFFER_SIZE: { case SET_DEFAULT_BUFFER_SIZE: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
uint32_t w = data.readInt32(); uint32_t width = data.readUint32();
uint32_t h = data.readInt32(); uint32_t height = data.readUint32();
status_t result = setDefaultBufferSize(w, h); status_t result = setDefaultBufferSize(width, height);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case SET_DEFAULT_MAX_BUFFER_COUNT: { case SET_DEFAULT_MAX_BUFFER_COUNT: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
uint32_t bufferCount = data.readInt32(); int bufferCount = data.readInt32();
status_t result = setDefaultMaxBufferCount(bufferCount); status_t result = setDefaultMaxBufferCount(bufferCount);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case DISABLE_ASYNC_BUFFER: { case DISABLE_ASYNC_BUFFER: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
status_t result = disableAsyncBuffer(); status_t result = disableAsyncBuffer();
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case SET_MAX_ACQUIRED_BUFFER_COUNT: { case SET_MAX_ACQUIRED_BUFFER_COUNT: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
uint32_t maxAcquiredBuffers = data.readInt32(); int maxAcquiredBuffers = data.readInt32();
status_t result = setMaxAcquiredBufferCount(maxAcquiredBuffers); status_t result = setMaxAcquiredBufferCount(maxAcquiredBuffers);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case SET_CONSUMER_NAME: { case SET_CONSUMER_NAME: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
setConsumerName( data.readString8() ); setConsumerName( data.readString8() );
return NO_ERROR; return NO_ERROR;
} break; }
case SET_DEFAULT_BUFFER_FORMAT: { case SET_DEFAULT_BUFFER_FORMAT: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
uint32_t defaultFormat = data.readInt32(); PixelFormat defaultFormat = static_cast<PixelFormat>(data.readInt32());
status_t result = setDefaultBufferFormat(defaultFormat); status_t result = setDefaultBufferFormat(defaultFormat);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case SET_CONSUMER_USAGE_BITS: { case SET_CONSUMER_USAGE_BITS: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
uint32_t usage = data.readInt32(); uint32_t usage = data.readUint32();
status_t result = setConsumerUsageBits(usage); status_t result = setConsumerUsageBits(usage);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case SET_TRANSFORM_HINT: { case SET_TRANSFORM_HINT: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
uint32_t hint = data.readInt32(); uint32_t hint = data.readUint32();
status_t result = setTransformHint(hint); status_t result = setTransformHint(hint);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case DUMP: { case DUMP: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
String8 result = data.readString8(); String8 result = data.readString8();

View File

@ -56,6 +56,8 @@ public:
{ {
} }
virtual ~BpGraphicBufferProducer();
virtual status_t requestBuffer(int bufferIdx, sp<GraphicBuffer>* buf) { virtual status_t requestBuffer(int bufferIdx, sp<GraphicBuffer>* buf) {
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
@ -91,14 +93,15 @@ public:
} }
virtual status_t dequeueBuffer(int *buf, sp<Fence>* fence, bool async, virtual status_t dequeueBuffer(int *buf, sp<Fence>* fence, bool async,
uint32_t w, uint32_t h, uint32_t format, uint32_t usage) { uint32_t width, uint32_t height, PixelFormat format,
uint32_t usage) {
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
data.writeInt32(async); data.writeInt32(static_cast<int32_t>(async));
data.writeInt32(w); data.writeUint32(width);
data.writeInt32(h); data.writeUint32(height);
data.writeInt32(format); data.writeInt32(static_cast<int32_t>(format));
data.writeInt32(usage); data.writeUint32(usage);
status_t result = remote()->transact(DEQUEUE_BUFFER, data, &reply); status_t result = remote()->transact(DEQUEUE_BUFFER, data, &reply);
if (result != NO_ERROR) { if (result != NO_ERROR) {
return result; return result;
@ -255,14 +258,14 @@ public:
} }
virtual void allocateBuffers(bool async, uint32_t width, uint32_t height, virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
uint32_t format, uint32_t usage) { PixelFormat format, uint32_t usage) {
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
data.writeInt32(static_cast<int32_t>(async)); data.writeInt32(static_cast<int32_t>(async));
data.writeInt32(static_cast<int32_t>(width)); data.writeUint32(width);
data.writeInt32(static_cast<int32_t>(height)); data.writeUint32(height);
data.writeInt32(static_cast<int32_t>(format)); data.writeInt32(static_cast<int32_t>(format));
data.writeInt32(static_cast<int32_t>(usage)); data.writeUint32(usage);
status_t result = remote()->transact(ALLOCATE_BUFFERS, data, &reply); status_t result = remote()->transact(ALLOCATE_BUFFERS, data, &reply);
if (result != NO_ERROR) { if (result != NO_ERROR) {
ALOGE("allocateBuffers failed to transact: %d", result); ALOGE("allocateBuffers failed to transact: %d", result);
@ -270,6 +273,10 @@ public:
} }
}; };
// Out-of-line virtual method definition to trigger vtable emission in this
// translation unit (see clang warning -Wweak-vtables)
BpGraphicBufferProducer::~BpGraphicBufferProducer() {}
IMPLEMENT_META_INTERFACE(GraphicBufferProducer, "android.gui.IGraphicBufferProducer"); IMPLEMENT_META_INTERFACE(GraphicBufferProducer, "android.gui.IGraphicBufferProducer");
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -289,24 +296,25 @@ status_t BnGraphicBufferProducer::onTransact(
} }
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case SET_BUFFER_COUNT: { case SET_BUFFER_COUNT: {
CHECK_INTERFACE(IGraphicBufferProducer, data, reply); CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
int bufferCount = data.readInt32(); int bufferCount = data.readInt32();
int result = setBufferCount(bufferCount); int result = setBufferCount(bufferCount);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case DEQUEUE_BUFFER: { case DEQUEUE_BUFFER: {
CHECK_INTERFACE(IGraphicBufferProducer, data, reply); CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
bool async = data.readInt32(); bool async = static_cast<bool>(data.readInt32());
uint32_t w = data.readInt32(); uint32_t width = data.readUint32();
uint32_t h = data.readInt32(); uint32_t height = data.readUint32();
uint32_t format = data.readInt32(); PixelFormat format = static_cast<PixelFormat>(data.readInt32());
uint32_t usage = data.readInt32(); uint32_t usage = data.readUint32();
int buf; int buf;
sp<Fence> fence; sp<Fence> fence;
int result = dequeueBuffer(&buf, &fence, async, w, h, format, usage); int result = dequeueBuffer(&buf, &fence, async, width, height,
format, usage);
reply->writeInt32(buf); reply->writeInt32(buf);
reply->writeInt32(fence != NULL); reply->writeInt32(fence != NULL);
if (fence != NULL) { if (fence != NULL) {
@ -314,14 +322,14 @@ status_t BnGraphicBufferProducer::onTransact(
} }
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case DETACH_BUFFER: { case DETACH_BUFFER: {
CHECK_INTERFACE(IGraphicBufferProducer, data, reply); CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
int slot = data.readInt32(); int slot = data.readInt32();
int result = detachBuffer(slot); int result = detachBuffer(slot);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case DETACH_NEXT_BUFFER: { case DETACH_NEXT_BUFFER: {
CHECK_INTERFACE(IGraphicBufferProducer, data, reply); CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
sp<GraphicBuffer> buffer; sp<GraphicBuffer> buffer;
@ -339,7 +347,7 @@ status_t BnGraphicBufferProducer::onTransact(
} }
} }
return NO_ERROR; return NO_ERROR;
} break; }
case ATTACH_BUFFER: { case ATTACH_BUFFER: {
CHECK_INTERFACE(IGraphicBufferProducer, data, reply); CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
sp<GraphicBuffer> buffer = new GraphicBuffer(); sp<GraphicBuffer> buffer = new GraphicBuffer();
@ -349,7 +357,7 @@ status_t BnGraphicBufferProducer::onTransact(
reply->writeInt32(slot); reply->writeInt32(slot);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case QUEUE_BUFFER: { case QUEUE_BUFFER: {
CHECK_INTERFACE(IGraphicBufferProducer, data, reply); CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
int buf = data.readInt32(); int buf = data.readInt32();
@ -360,7 +368,7 @@ status_t BnGraphicBufferProducer::onTransact(
status_t result = queueBuffer(buf, input, output); status_t result = queueBuffer(buf, input, output);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case CANCEL_BUFFER: { case CANCEL_BUFFER: {
CHECK_INTERFACE(IGraphicBufferProducer, data, reply); CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
int buf = data.readInt32(); int buf = data.readInt32();
@ -368,7 +376,7 @@ status_t BnGraphicBufferProducer::onTransact(
data.read(*fence.get()); data.read(*fence.get());
cancelBuffer(buf, fence); cancelBuffer(buf, fence);
return NO_ERROR; return NO_ERROR;
} break; }
case QUERY: { case QUERY: {
CHECK_INTERFACE(IGraphicBufferProducer, data, reply); CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
int value; int value;
@ -377,7 +385,7 @@ status_t BnGraphicBufferProducer::onTransact(
reply->writeInt32(value); reply->writeInt32(value);
reply->writeInt32(res); reply->writeInt32(res);
return NO_ERROR; return NO_ERROR;
} break; }
case CONNECT: { case CONNECT: {
CHECK_INTERFACE(IGraphicBufferProducer, data, reply); CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
sp<IProducerListener> listener; sp<IProducerListener> listener;
@ -392,14 +400,14 @@ status_t BnGraphicBufferProducer::onTransact(
status_t res = connect(listener, api, producerControlledByApp, output); status_t res = connect(listener, api, producerControlledByApp, output);
reply->writeInt32(res); reply->writeInt32(res);
return NO_ERROR; return NO_ERROR;
} break; }
case DISCONNECT: { case DISCONNECT: {
CHECK_INTERFACE(IGraphicBufferProducer, data, reply); CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
int api = data.readInt32(); int api = data.readInt32();
status_t res = disconnect(api); status_t res = disconnect(api);
reply->writeInt32(res); reply->writeInt32(res);
return NO_ERROR; return NO_ERROR;
} break; }
case SET_SIDEBAND_STREAM: { case SET_SIDEBAND_STREAM: {
CHECK_INTERFACE(IGraphicBufferProducer, data, reply); CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
sp<NativeHandle> stream; sp<NativeHandle> stream;
@ -409,14 +417,14 @@ status_t BnGraphicBufferProducer::onTransact(
status_t result = setSidebandStream(stream); status_t result = setSidebandStream(stream);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case ALLOCATE_BUFFERS: case ALLOCATE_BUFFERS:
CHECK_INTERFACE(IGraphicBufferProducer, data, reply); CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
bool async = static_cast<bool>(data.readInt32()); bool async = static_cast<bool>(data.readInt32());
uint32_t width = static_cast<uint32_t>(data.readInt32()); uint32_t width = data.readUint32();
uint32_t height = static_cast<uint32_t>(data.readInt32()); uint32_t height = data.readUint32();
uint32_t format = static_cast<uint32_t>(data.readInt32()); PixelFormat format = static_cast<PixelFormat>(data.readInt32());
uint32_t usage = static_cast<uint32_t>(data.readInt32()); uint32_t usage = data.readUint32();
allocateBuffers(async, width, height, format, usage); allocateBuffers(async, width, height, format, usage);
return NO_ERROR; return NO_ERROR;
} }

View File

@ -30,6 +30,8 @@ public:
BpProducerListener(const sp<IBinder>& impl) BpProducerListener(const sp<IBinder>& impl)
: BpInterface<IProducerListener>(impl) {} : BpInterface<IProducerListener>(impl) {}
virtual ~BpProducerListener();
virtual void onBufferReleased() { virtual void onBufferReleased() {
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(IProducerListener::getInterfaceDescriptor()); data.writeInterfaceToken(IProducerListener::getInterfaceDescriptor());
@ -37,6 +39,10 @@ public:
} }
}; };
// Out-of-line virtual method definition to trigger vtable emission in this
// translation unit (see clang warning -Wweak-vtables)
BpProducerListener::~BpProducerListener() {}
IMPLEMENT_META_INTERFACE(ProducerListener, "android.gui.IProducerListener") IMPLEMENT_META_INTERFACE(ProducerListener, "android.gui.IProducerListener")
status_t BnProducerListener::onTransact(uint32_t code, const Parcel& data, status_t BnProducerListener::onTransact(uint32_t code, const Parcel& data,

View File

@ -45,6 +45,8 @@ public:
{ {
} }
virtual ~BpSensorEventConnection();
virtual sp<BitTube> getSensorChannel() const virtual sp<BitTube> getSensorChannel() const
{ {
Parcel data, reply; Parcel data, reply;
@ -85,6 +87,10 @@ public:
} }
}; };
// Out-of-line virtual method definition to trigger vtable emission in this
// translation unit (see clang warning -Wweak-vtables)
BpSensorEventConnection::~BpSensorEventConnection() {}
IMPLEMENT_META_INTERFACE(SensorEventConnection, "android.gui.SensorEventConnection"); IMPLEMENT_META_INTERFACE(SensorEventConnection, "android.gui.SensorEventConnection");
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -98,7 +104,7 @@ status_t BnSensorEventConnection::onTransact(
sp<BitTube> channel(getSensorChannel()); sp<BitTube> channel(getSensorChannel());
channel->writeToParcel(reply); channel->writeToParcel(reply);
return NO_ERROR; return NO_ERROR;
} break; }
case ENABLE_DISABLE: { case ENABLE_DISABLE: {
CHECK_INTERFACE(ISensorEventConnection, data, reply); CHECK_INTERFACE(ISensorEventConnection, data, reply);
int handle = data.readInt32(); int handle = data.readInt32();
@ -110,21 +116,21 @@ status_t BnSensorEventConnection::onTransact(
maxBatchReportLatencyNs, reservedFlags); maxBatchReportLatencyNs, reservedFlags);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case SET_EVENT_RATE: { case SET_EVENT_RATE: {
CHECK_INTERFACE(ISensorEventConnection, data, reply); CHECK_INTERFACE(ISensorEventConnection, data, reply);
int handle = data.readInt32(); int handle = data.readInt32();
int ns = data.readInt64(); nsecs_t ns = data.readInt64();
status_t result = setEventRate(handle, ns); status_t result = setEventRate(handle, ns);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case FLUSH_SENSOR: { case FLUSH_SENSOR: {
CHECK_INTERFACE(ISensorEventConnection, data, reply); CHECK_INTERFACE(ISensorEventConnection, data, reply);
status_t result = flush(); status_t result = flush();
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
} }
return BBinder::onTransact(code, data, reply, flags); return BBinder::onTransact(code, data, reply, flags);
} }

View File

@ -45,6 +45,8 @@ public:
{ {
} }
virtual ~BpSensorServer();
virtual Vector<Sensor> getSensorList() virtual Vector<Sensor> getSensorList()
{ {
Parcel data, reply; Parcel data, reply;
@ -52,7 +54,7 @@ public:
remote()->transact(GET_SENSOR_LIST, data, &reply); remote()->transact(GET_SENSOR_LIST, data, &reply);
Sensor s; Sensor s;
Vector<Sensor> v; Vector<Sensor> v;
int32_t n = reply.readInt32(); uint32_t n = reply.readUint32();
v.setCapacity(n); v.setCapacity(n);
while (n--) { while (n--) {
reply.read(s); reply.read(s);
@ -70,6 +72,10 @@ public:
} }
}; };
// Out-of-line virtual method definition to trigger vtable emission in this
// translation unit (see clang warning -Wweak-vtables)
BpSensorServer::~BpSensorServer() {}
IMPLEMENT_META_INTERFACE(SensorServer, "android.gui.SensorServer"); IMPLEMENT_META_INTERFACE(SensorServer, "android.gui.SensorServer");
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -82,18 +88,18 @@ status_t BnSensorServer::onTransact(
CHECK_INTERFACE(ISensorServer, data, reply); CHECK_INTERFACE(ISensorServer, data, reply);
Vector<Sensor> v(getSensorList()); Vector<Sensor> v(getSensorList());
size_t n = v.size(); size_t n = v.size();
reply->writeInt32(n); reply->writeUint32(static_cast<uint32_t>(n));
for (size_t i=0 ; i<n ; i++) { for (size_t i = 0; i < n; i++) {
reply->write(v[i]); reply->write(v[i]);
} }
return NO_ERROR; return NO_ERROR;
} break; }
case CREATE_SENSOR_EVENT_CONNECTION: { case CREATE_SENSOR_EVENT_CONNECTION: {
CHECK_INTERFACE(ISensorServer, data, reply); CHECK_INTERFACE(ISensorServer, data, reply);
sp<ISensorEventConnection> connection(createSensorEventConnection()); sp<ISensorEventConnection> connection(createSensorEventConnection());
reply->writeStrongBinder(IInterface::asBinder(connection)); reply->writeStrongBinder(IInterface::asBinder(connection));
return NO_ERROR; return NO_ERROR;
} break; }
} }
return BBinder::onTransact(code, data, reply, flags); return BBinder::onTransact(code, data, reply, flags);
} }

View File

@ -51,6 +51,8 @@ public:
{ {
} }
virtual ~BpSurfaceComposer();
virtual sp<ISurfaceComposerClient> createConnection() virtual sp<ISurfaceComposerClient> createConnection()
{ {
Parcel data, reply; Parcel data, reply;
@ -74,23 +76,18 @@ public:
{ {
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
{
Vector<ComposerState>::const_iterator b(state.begin()); data.writeUint32(static_cast<uint32_t>(state.size()));
Vector<ComposerState>::const_iterator e(state.end()); for (const auto& s : state) {
data.writeInt32(state.size()); s.write(data);
for ( ; b != e ; ++b ) {
b->write(data);
}
} }
{
Vector<DisplayState>::const_iterator b(displays.begin()); data.writeUint32(static_cast<uint32_t>(displays.size()));
Vector<DisplayState>::const_iterator e(displays.end()); for (const auto& d : displays) {
data.writeInt32(displays.size()); d.write(data);
for ( ; b != e ; ++b ) {
b->write(data);
}
} }
data.writeInt32(flags);
data.writeUint32(flags);
remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply); remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
} }
@ -113,10 +110,10 @@ public:
data.writeStrongBinder(display); data.writeStrongBinder(display);
data.writeStrongBinder(IInterface::asBinder(producer)); data.writeStrongBinder(IInterface::asBinder(producer));
data.write(sourceCrop); data.write(sourceCrop);
data.writeInt32(reqWidth); data.writeUint32(reqWidth);
data.writeInt32(reqHeight); data.writeUint32(reqHeight);
data.writeInt32(minLayerZ); data.writeUint32(minLayerZ);
data.writeInt32(maxLayerZ); data.writeUint32(maxLayerZ);
data.writeInt32(static_cast<int32_t>(useIdentityTransform)); data.writeInt32(static_cast<int32_t>(useIdentityTransform));
data.writeInt32(static_cast<int32_t>(rotation)); data.writeInt32(static_cast<int32_t>(rotation));
remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply); remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
@ -224,7 +221,7 @@ public:
remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply); remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
status_t result = reply.readInt32(); status_t result = reply.readInt32();
if (result == NO_ERROR) { if (result == NO_ERROR) {
size_t numConfigs = static_cast<size_t>(reply.readInt32()); size_t numConfigs = reply.readUint32();
configs->clear(); configs->clear();
configs->resize(numConfigs); configs->resize(numConfigs);
for (size_t c = 0; c < numConfigs; ++c) { for (size_t c = 0; c < numConfigs; ++c) {
@ -287,6 +284,10 @@ public:
} }
}; };
// Out-of-line virtual method definition to trigger vtable emission in this
// translation unit (see clang warning -Wweak-vtables)
BpSurfaceComposer::~BpSurfaceComposer() {}
IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer"); IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -309,34 +310,37 @@ status_t BnSurfaceComposer::onTransact(
} }
case SET_TRANSACTION_STATE: { case SET_TRANSACTION_STATE: {
CHECK_INTERFACE(ISurfaceComposer, data, reply); CHECK_INTERFACE(ISurfaceComposer, data, reply);
size_t count = data.readInt32();
size_t count = data.readUint32();
if (count > data.dataSize()) { if (count > data.dataSize()) {
return BAD_VALUE; return BAD_VALUE;
} }
ComposerState s; ComposerState s;
Vector<ComposerState> state; Vector<ComposerState> state;
state.setCapacity(count); state.setCapacity(count);
for (size_t i=0 ; i<count ; i++) { for (size_t i = 0; i < count; i++) {
if (s.read(data) == BAD_VALUE) { if (s.read(data) == BAD_VALUE) {
return BAD_VALUE; return BAD_VALUE;
} }
state.add(s); state.add(s);
} }
count = data.readInt32();
count = data.readUint32();
if (count > data.dataSize()) { if (count > data.dataSize()) {
return BAD_VALUE; return BAD_VALUE;
} }
DisplayState d; DisplayState d;
Vector<DisplayState> displays; Vector<DisplayState> displays;
displays.setCapacity(count); displays.setCapacity(count);
for (size_t i=0 ; i<count ; i++) { for (size_t i = 0; i < count; i++) {
if (d.read(data) == BAD_VALUE) { if (d.read(data) == BAD_VALUE) {
return BAD_VALUE; return BAD_VALUE;
} }
displays.add(d); displays.add(d);
} }
uint32_t flags = data.readInt32();
setTransactionState(state, displays, flags); uint32_t stateFlags = data.readUint32();
setTransactionState(state, displays, stateFlags);
return NO_ERROR; return NO_ERROR;
} }
case BOOT_FINISHED: { case BOOT_FINISHED: {
@ -351,12 +355,12 @@ status_t BnSurfaceComposer::onTransact(
interface_cast<IGraphicBufferProducer>(data.readStrongBinder()); interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
Rect sourceCrop; Rect sourceCrop;
data.read(sourceCrop); data.read(sourceCrop);
uint32_t reqWidth = data.readInt32(); uint32_t reqWidth = data.readUint32();
uint32_t reqHeight = data.readInt32(); uint32_t reqHeight = data.readUint32();
uint32_t minLayerZ = data.readInt32(); uint32_t minLayerZ = data.readUint32();
uint32_t maxLayerZ = data.readInt32(); uint32_t maxLayerZ = data.readUint32();
bool useIdentityTransform = static_cast<bool>(data.readInt32()); bool useIdentityTransform = static_cast<bool>(data.readInt32());
uint32_t rotation = data.readInt32(); int32_t rotation = data.readInt32();
status_t res = captureScreen(display, producer, status_t res = captureScreen(display, producer,
sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ, sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ,
@ -407,7 +411,7 @@ status_t BnSurfaceComposer::onTransact(
status_t result = getDisplayConfigs(display, &configs); status_t result = getDisplayConfigs(display, &configs);
reply->writeInt32(result); reply->writeInt32(result);
if (result == NO_ERROR) { if (result == NO_ERROR) {
reply->writeInt32(static_cast<int32_t>(configs.size())); reply->writeUint32(static_cast<uint32_t>(configs.size()));
for (size_t c = 0; c < configs.size(); ++c) { for (size_t c = 0; c < configs.size(); ++c) {
memcpy(reply->writeInplace(sizeof(DisplayInfo)), memcpy(reply->writeInplace(sizeof(DisplayInfo)),
&configs[c], sizeof(DisplayInfo)); &configs[c], sizeof(DisplayInfo));
@ -467,8 +471,6 @@ status_t BnSurfaceComposer::onTransact(
return BBinder::onTransact(code, data, reply, flags); return BBinder::onTransact(code, data, reply, flags);
} }
} }
// should be unreachable
return NO_ERROR;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -51,17 +51,19 @@ public:
: BpInterface<ISurfaceComposerClient>(impl) { : BpInterface<ISurfaceComposerClient>(impl) {
} }
virtual status_t createSurface(const String8& name, uint32_t w, virtual ~BpSurfaceComposerClient();
uint32_t h, PixelFormat format, uint32_t flags,
virtual status_t createSurface(const String8& name, uint32_t width,
uint32_t height, PixelFormat format, uint32_t flags,
sp<IBinder>* handle, sp<IBinder>* handle,
sp<IGraphicBufferProducer>* gbp) { sp<IGraphicBufferProducer>* gbp) {
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(ISurfaceComposerClient::getInterfaceDescriptor()); data.writeInterfaceToken(ISurfaceComposerClient::getInterfaceDescriptor());
data.writeString8(name); data.writeString8(name);
data.writeInt32(w); data.writeUint32(width);
data.writeInt32(h); data.writeUint32(height);
data.writeInt32(format); data.writeInt32(static_cast<int32_t>(format));
data.writeInt32(flags); data.writeUint32(flags);
remote()->transact(CREATE_SURFACE, data, &reply); remote()->transact(CREATE_SURFACE, data, &reply);
*handle = reply.readStrongBinder(); *handle = reply.readStrongBinder();
*gbp = interface_cast<IGraphicBufferProducer>(reply.readStrongBinder()); *gbp = interface_cast<IGraphicBufferProducer>(reply.readStrongBinder());
@ -94,6 +96,10 @@ public:
} }
}; };
// Out-of-line virtual method definition to trigger vtable emission in this
// translation unit (see clang warning -Wweak-vtables)
BpSurfaceComposerClient::~BpSurfaceComposerClient() {}
IMPLEMENT_META_INTERFACE(SurfaceComposerClient, "android.ui.ISurfaceComposerClient"); IMPLEMENT_META_INTERFACE(SurfaceComposerClient, "android.ui.ISurfaceComposerClient");
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -105,31 +111,31 @@ status_t BnSurfaceComposerClient::onTransact(
case CREATE_SURFACE: { case CREATE_SURFACE: {
CHECK_INTERFACE(ISurfaceComposerClient, data, reply); CHECK_INTERFACE(ISurfaceComposerClient, data, reply);
String8 name = data.readString8(); String8 name = data.readString8();
uint32_t w = data.readInt32(); uint32_t width = data.readUint32();
uint32_t h = data.readInt32(); uint32_t height = data.readUint32();
PixelFormat format = data.readInt32(); PixelFormat format = static_cast<PixelFormat>(data.readInt32());
uint32_t flags = data.readInt32(); uint32_t createFlags = data.readUint32();
sp<IBinder> handle; sp<IBinder> handle;
sp<IGraphicBufferProducer> gbp; sp<IGraphicBufferProducer> gbp;
status_t result = createSurface(name, w, h, format, flags, status_t result = createSurface(name, width, height, format,
&handle, &gbp); createFlags, &handle, &gbp);
reply->writeStrongBinder(handle); reply->writeStrongBinder(handle);
reply->writeStrongBinder(IInterface::asBinder(gbp)); reply->writeStrongBinder(IInterface::asBinder(gbp));
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case DESTROY_SURFACE: { case DESTROY_SURFACE: {
CHECK_INTERFACE(ISurfaceComposerClient, data, reply); CHECK_INTERFACE(ISurfaceComposerClient, data, reply);
reply->writeInt32(destroySurface( data.readStrongBinder() ) ); reply->writeInt32(destroySurface( data.readStrongBinder() ) );
return NO_ERROR; return NO_ERROR;
} break; }
case CLEAR_LAYER_FRAME_STATS: { case CLEAR_LAYER_FRAME_STATS: {
CHECK_INTERFACE(ISurfaceComposerClient, data, reply); CHECK_INTERFACE(ISurfaceComposerClient, data, reply);
sp<IBinder> handle = data.readStrongBinder(); sp<IBinder> handle = data.readStrongBinder();
status_t result = clearLayerFrameStats(handle); status_t result = clearLayerFrameStats(handle);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
case GET_LAYER_FRAME_STATS: { case GET_LAYER_FRAME_STATS: {
CHECK_INTERFACE(ISurfaceComposerClient, data, reply); CHECK_INTERFACE(ISurfaceComposerClient, data, reply);
sp<IBinder> handle = data.readStrongBinder(); sp<IBinder> handle = data.readStrongBinder();
@ -138,7 +144,7 @@ status_t BnSurfaceComposerClient::onTransact(
reply->write(stats); reply->write(stats);
reply->writeInt32(result); reply->writeInt32(result);
return NO_ERROR; return NO_ERROR;
} break; }
default: default:
return BBinder::onTransact(code, data, reply, flags); return BBinder::onTransact(code, data, reply, flags);
} }

View File

@ -25,16 +25,16 @@ namespace android {
status_t layer_state_t::write(Parcel& output) const status_t layer_state_t::write(Parcel& output) const
{ {
output.writeStrongBinder(surface); output.writeStrongBinder(surface);
output.writeInt32(what); output.writeUint32(what);
output.writeFloat(x); output.writeFloat(x);
output.writeFloat(y); output.writeFloat(y);
output.writeInt32(z); output.writeUint32(z);
output.writeInt32(w); output.writeUint32(w);
output.writeInt32(h); output.writeUint32(h);
output.writeInt32(layerStack); output.writeUint32(layerStack);
output.writeFloat(alpha); output.writeFloat(alpha);
output.writeInt32(flags); output.writeUint32(flags);
output.writeInt32(mask); output.writeUint32(mask);
*reinterpret_cast<layer_state_t::matrix22_t *>( *reinterpret_cast<layer_state_t::matrix22_t *>(
output.writeInplace(sizeof(layer_state_t::matrix22_t))) = matrix; output.writeInplace(sizeof(layer_state_t::matrix22_t))) = matrix;
output.write(crop); output.write(crop);
@ -45,16 +45,16 @@ status_t layer_state_t::write(Parcel& output) const
status_t layer_state_t::read(const Parcel& input) status_t layer_state_t::read(const Parcel& input)
{ {
surface = input.readStrongBinder(); surface = input.readStrongBinder();
what = input.readInt32(); what = input.readUint32();
x = input.readFloat(); x = input.readFloat();
y = input.readFloat(); y = input.readFloat();
z = input.readInt32(); z = input.readUint32();
w = input.readInt32(); w = input.readUint32();
h = input.readInt32(); h = input.readUint32();
layerStack = input.readInt32(); layerStack = input.readUint32();
alpha = input.readFloat(); alpha = input.readFloat();
flags = input.readInt32(); flags = static_cast<uint8_t>(input.readUint32());
mask = input.readInt32(); mask = static_cast<uint8_t>(input.readUint32());
const void* matrix_data = input.readInplace(sizeof(layer_state_t::matrix22_t)); const void* matrix_data = input.readInplace(sizeof(layer_state_t::matrix22_t));
if (matrix_data) { if (matrix_data) {
matrix = *reinterpret_cast<layer_state_t::matrix22_t const *>(matrix_data); matrix = *reinterpret_cast<layer_state_t::matrix22_t const *>(matrix_data);
@ -80,26 +80,26 @@ status_t ComposerState::read(const Parcel& input) {
status_t DisplayState::write(Parcel& output) const { status_t DisplayState::write(Parcel& output) const {
output.writeStrongBinder(token); output.writeStrongBinder(token);
output.writeStrongBinder(IInterface::asBinder(surface)); output.writeStrongBinder(IInterface::asBinder(surface));
output.writeInt32(what); output.writeUint32(what);
output.writeInt32(layerStack); output.writeUint32(layerStack);
output.writeInt32(orientation); output.writeUint32(orientation);
output.write(viewport); output.write(viewport);
output.write(frame); output.write(frame);
output.writeInt32(width); output.writeUint32(width);
output.writeInt32(height); output.writeUint32(height);
return NO_ERROR; return NO_ERROR;
} }
status_t DisplayState::read(const Parcel& input) { status_t DisplayState::read(const Parcel& input) {
token = input.readStrongBinder(); token = input.readStrongBinder();
surface = interface_cast<IGraphicBufferProducer>(input.readStrongBinder()); surface = interface_cast<IGraphicBufferProducer>(input.readStrongBinder());
what = input.readInt32(); what = input.readUint32();
layerStack = input.readInt32(); layerStack = input.readUint32();
orientation = input.readInt32(); orientation = input.readUint32();
input.read(viewport); input.read(viewport);
input.read(frame); input.read(frame);
width = input.readInt32(); width = input.readUint32();
height = input.readInt32(); height = input.readUint32();
return NO_ERROR; return NO_ERROR;
} }

View File

@ -72,7 +72,7 @@ Sensor::Sensor(struct sensor_t const* hwSensor, int halVersion)
static_cast<int64_t>(hwSensor->maxDelay)); static_cast<int64_t>(hwSensor->maxDelay));
mMaxDelay = INT_MAX; mMaxDelay = INT_MAX;
} else { } else {
mMaxDelay = (int32_t) hwSensor->maxDelay; mMaxDelay = static_cast<int32_t>(hwSensor->maxDelay);
} }
} else { } else {
// For older hals set maxDelay to 0. // For older hals set maxDelay to 0.
@ -221,7 +221,7 @@ Sensor::Sensor(struct sensor_t const* hwSensor, int halVersion)
} }
if (halVersion >= SENSORS_DEVICE_API_VERSION_1_3) { if (halVersion >= SENSORS_DEVICE_API_VERSION_1_3) {
mFlags = (int32_t) hwSensor->flags; mFlags = static_cast<uint32_t>(hwSensor->flags);
} else { } else {
// This is an OEM defined sensor on an older HAL. Use minDelay to determine the // This is an OEM defined sensor on an older HAL. Use minDelay to determine the
// reporting mode of the sensor. // reporting mode of the sensor.
@ -302,11 +302,11 @@ int32_t Sensor::getVersion() const {
return mVersion; return mVersion;
} }
int32_t Sensor::getFifoReservedEventCount() const { uint32_t Sensor::getFifoReservedEventCount() const {
return mFifoReservedEventCount; return mFifoReservedEventCount;
} }
int32_t Sensor::getFifoMaxEventCount() const { uint32_t Sensor::getFifoMaxEventCount() const {
return mFifoMaxEventCount; return mFifoMaxEventCount;
} }
@ -322,7 +322,7 @@ int32_t Sensor::getMaxDelay() const {
return mMaxDelay; return mMaxDelay;
} }
int32_t Sensor::getFlags() const { uint32_t Sensor::getFlags() const {
return mFlags; return mFlags;
} }
@ -414,7 +414,7 @@ status_t Sensor::unflatten(void const* buffer, size_t size) {
void Sensor::flattenString8(void*& buffer, size_t& size, void Sensor::flattenString8(void*& buffer, size_t& size,
const String8& string8) { const String8& string8) {
uint32_t len = string8.length(); uint32_t len = static_cast<uint32_t>(string8.length());
FlattenableUtils::write(buffer, size, len); FlattenableUtils::write(buffer, size, len);
memcpy(static_cast<char*>(buffer), string8.string(), len); memcpy(static_cast<char*>(buffer), string8.string(), len);
FlattenableUtils::advance(buffer, size, FlattenableUtils::align<4>(len)); FlattenableUtils::advance(buffer, size, FlattenableUtils::align<4>(len));

View File

@ -16,6 +16,7 @@
#define LOG_TAG "Sensors" #define LOG_TAG "Sensors"
#include <algorithm>
#include <stdint.h> #include <stdint.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
@ -31,6 +32,8 @@
#include <android/sensor.h> #include <android/sensor.h>
using std::min;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
namespace android { namespace android {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -68,14 +71,14 @@ ssize_t SensorEventQueue::read(ASensorEvent* events, size_t numEvents) {
if (err < 0) { if (err < 0) {
return err; return err;
} }
mAvailable = err; mAvailable = static_cast<size_t>(err);
mConsumed = 0; mConsumed = 0;
} }
size_t count = numEvents < mAvailable ? numEvents : mAvailable; size_t count = min(numEvents, mAvailable);
memcpy(events, mRecBuffer + mConsumed, count*sizeof(ASensorEvent)); memcpy(events, mRecBuffer + mConsumed, count * sizeof(ASensorEvent));
mAvailable -= count; mAvailable -= count;
mConsumed += count; mConsumed += count;
return count; return static_cast<ssize_t>(count);
} }
sp<Looper> SensorEventQueue::getLooper() const sp<Looper> SensorEventQueue::getLooper() const

View File

@ -90,7 +90,8 @@ status_t SensorManager::assertStateLocked() const {
mSensors = mSensorServer->getSensorList(); mSensors = mSensorServer->getSensorList();
size_t count = mSensors.size(); size_t count = mSensors.size();
mSensorList = (Sensor const**)malloc(count * sizeof(Sensor*)); mSensorList =
static_cast<Sensor const**>(malloc(count * sizeof(Sensor*)));
for (size_t i=0 ; i<count ; i++) { for (size_t i=0 ; i<count ; i++) {
mSensorList[i] = mSensors.array() + i; mSensorList[i] = mSensors.array() + i;
} }
@ -106,10 +107,10 @@ ssize_t SensorManager::getSensorList(Sensor const* const** list) const
Mutex::Autolock _l(mLock); Mutex::Autolock _l(mLock);
status_t err = assertStateLocked(); status_t err = assertStateLocked();
if (err < 0) { if (err < 0) {
return ssize_t(err); return static_cast<ssize_t>(err);
} }
*list = mSensorList; *list = mSensorList;
return mSensors.size(); return static_cast<ssize_t>(mSensors.size());
} }
Sensor const* SensorManager::getDefaultSensor(int type) Sensor const* SensorManager::getDefaultSensor(int type)

View File

@ -141,7 +141,7 @@ void StreamSplitter::onFrameAvailable(const BufferItem& /* item */) {
IGraphicBufferProducer::QueueBufferInput queueInput( IGraphicBufferProducer::QueueBufferInput queueInput(
bufferItem.mTimestamp, bufferItem.mIsAutoTimestamp, bufferItem.mTimestamp, bufferItem.mIsAutoTimestamp,
bufferItem.mCrop, bufferItem.mScalingMode, bufferItem.mCrop, static_cast<int32_t>(bufferItem.mScalingMode),
bufferItem.mTransform, bufferItem.mIsDroppable, bufferItem.mTransform, bufferItem.mIsDroppable,
bufferItem.mFence); bufferItem.mFence);

View File

@ -193,17 +193,17 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer, int* fenceFd) {
ATRACE_CALL(); ATRACE_CALL();
ALOGV("Surface::dequeueBuffer"); ALOGV("Surface::dequeueBuffer");
int reqW; uint32_t reqWidth;
int reqH; uint32_t reqHeight;
bool swapIntervalZero; bool swapIntervalZero;
uint32_t reqFormat; PixelFormat reqFormat;
uint32_t reqUsage; uint32_t reqUsage;
{ {
Mutex::Autolock lock(mMutex); Mutex::Autolock lock(mMutex);
reqW = mReqWidth ? mReqWidth : mUserWidth; reqWidth = mReqWidth ? mReqWidth : mUserWidth;
reqH = mReqHeight ? mReqHeight : mUserHeight; reqHeight = mReqHeight ? mReqHeight : mUserHeight;
swapIntervalZero = mSwapIntervalZero; swapIntervalZero = mSwapIntervalZero;
reqFormat = mReqFormat; reqFormat = mReqFormat;
@ -213,12 +213,12 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer, int* fenceFd) {
int buf = -1; int buf = -1;
sp<Fence> fence; sp<Fence> fence;
status_t result = mGraphicBufferProducer->dequeueBuffer(&buf, &fence, swapIntervalZero, status_t result = mGraphicBufferProducer->dequeueBuffer(&buf, &fence, swapIntervalZero,
reqW, reqH, reqFormat, reqUsage); reqWidth, reqHeight, reqFormat, reqUsage);
if (result < 0) { if (result < 0) {
ALOGV("dequeueBuffer: IGraphicBufferProducer::dequeueBuffer(%d, %d, %d, %d, %d)" ALOGV("dequeueBuffer: IGraphicBufferProducer::dequeueBuffer(%d, %d, %d, %d, %d)"
"failed: %d", swapIntervalZero, reqW, reqH, reqFormat, reqUsage, "failed: %d", swapIntervalZero, reqWidth, reqHeight, reqFormat,
result); reqUsage, result);
return result; return result;
} }
@ -346,7 +346,7 @@ int Surface::query(int what, int* value) const {
switch (what) { switch (what) {
case NATIVE_WINDOW_FORMAT: case NATIVE_WINDOW_FORMAT:
if (mReqFormat) { if (mReqFormat) {
*value = mReqFormat; *value = static_cast<int>(mReqFormat);
return NO_ERROR; return NO_ERROR;
} }
break; break;
@ -364,13 +364,15 @@ int Surface::query(int what, int* value) const {
*value = NATIVE_WINDOW_SURFACE; *value = NATIVE_WINDOW_SURFACE;
return NO_ERROR; return NO_ERROR;
case NATIVE_WINDOW_DEFAULT_WIDTH: case NATIVE_WINDOW_DEFAULT_WIDTH:
*value = mUserWidth ? mUserWidth : mDefaultWidth; *value = static_cast<int>(
mUserWidth ? mUserWidth : mDefaultWidth);
return NO_ERROR; return NO_ERROR;
case NATIVE_WINDOW_DEFAULT_HEIGHT: case NATIVE_WINDOW_DEFAULT_HEIGHT:
*value = mUserHeight ? mUserHeight : mDefaultHeight; *value = static_cast<int>(
mUserHeight ? mUserHeight : mDefaultHeight);
return NO_ERROR; return NO_ERROR;
case NATIVE_WINDOW_TRANSFORM_HINT: case NATIVE_WINDOW_TRANSFORM_HINT:
*value = mTransformHint; *value = static_cast<int>(mTransformHint);
return NO_ERROR; return NO_ERROR;
case NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND: { case NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND: {
status_t err = NO_ERROR; status_t err = NO_ERROR;
@ -466,7 +468,7 @@ int Surface::dispatchDisconnect(va_list args) {
int Surface::dispatchSetUsage(va_list args) { int Surface::dispatchSetUsage(va_list args) {
int usage = va_arg(args, int); int usage = va_arg(args, int);
return setUsage(usage); return setUsage(static_cast<uint32_t>(usage));
} }
int Surface::dispatchSetCrop(va_list args) { int Surface::dispatchSetCrop(va_list args) {
@ -476,49 +478,49 @@ int Surface::dispatchSetCrop(va_list args) {
int Surface::dispatchSetBufferCount(va_list args) { int Surface::dispatchSetBufferCount(va_list args) {
size_t bufferCount = va_arg(args, size_t); size_t bufferCount = va_arg(args, size_t);
return setBufferCount(bufferCount); return setBufferCount(static_cast<int32_t>(bufferCount));
} }
int Surface::dispatchSetBuffersGeometry(va_list args) { int Surface::dispatchSetBuffersGeometry(va_list args) {
int w = va_arg(args, int); uint32_t width = va_arg(args, uint32_t);
int h = va_arg(args, int); uint32_t height = va_arg(args, uint32_t);
int f = va_arg(args, int); PixelFormat format = va_arg(args, PixelFormat);
int err = setBuffersDimensions(w, h); int err = setBuffersDimensions(width, height);
if (err != 0) { if (err != 0) {
return err; return err;
} }
return setBuffersFormat(f); return setBuffersFormat(format);
} }
int Surface::dispatchSetBuffersDimensions(va_list args) { int Surface::dispatchSetBuffersDimensions(va_list args) {
int w = va_arg(args, int); uint32_t width = va_arg(args, uint32_t);
int h = va_arg(args, int); uint32_t height = va_arg(args, uint32_t);
return setBuffersDimensions(w, h); return setBuffersDimensions(width, height);
} }
int Surface::dispatchSetBuffersUserDimensions(va_list args) { int Surface::dispatchSetBuffersUserDimensions(va_list args) {
int w = va_arg(args, int); uint32_t width = va_arg(args, uint32_t);
int h = va_arg(args, int); uint32_t height = va_arg(args, uint32_t);
return setBuffersUserDimensions(w, h); return setBuffersUserDimensions(width, height);
} }
int Surface::dispatchSetBuffersFormat(va_list args) { int Surface::dispatchSetBuffersFormat(va_list args) {
int f = va_arg(args, int); PixelFormat format = va_arg(args, PixelFormat);
return setBuffersFormat(f); return setBuffersFormat(format);
} }
int Surface::dispatchSetScalingMode(va_list args) { int Surface::dispatchSetScalingMode(va_list args) {
int m = va_arg(args, int); int mode = va_arg(args, int);
return setScalingMode(m); return setScalingMode(mode);
} }
int Surface::dispatchSetBuffersTransform(va_list args) { int Surface::dispatchSetBuffersTransform(va_list args) {
int transform = va_arg(args, int); uint32_t transform = va_arg(args, uint32_t);
return setBuffersTransform(transform); return setBuffersTransform(transform);
} }
int Surface::dispatchSetBuffersStickyTransform(va_list args) { int Surface::dispatchSetBuffersStickyTransform(va_list args) {
int transform = va_arg(args, int); uint32_t transform = va_arg(args, uint32_t);
return setBuffersStickyTransform(transform); return setBuffersStickyTransform(transform);
} }
@ -638,47 +640,38 @@ int Surface::setBufferCount(int bufferCount)
return err; return err;
} }
int Surface::setBuffersDimensions(int w, int h) int Surface::setBuffersDimensions(uint32_t width, uint32_t height)
{ {
ATRACE_CALL(); ATRACE_CALL();
ALOGV("Surface::setBuffersDimensions"); ALOGV("Surface::setBuffersDimensions");
if (w<0 || h<0) if ((width && !height) || (!width && height))
return BAD_VALUE;
if ((w && !h) || (!w && h))
return BAD_VALUE; return BAD_VALUE;
Mutex::Autolock lock(mMutex); Mutex::Autolock lock(mMutex);
mReqWidth = w; mReqWidth = width;
mReqHeight = h; mReqHeight = height;
return NO_ERROR; return NO_ERROR;
} }
int Surface::setBuffersUserDimensions(int w, int h) int Surface::setBuffersUserDimensions(uint32_t width, uint32_t height)
{ {
ATRACE_CALL(); ATRACE_CALL();
ALOGV("Surface::setBuffersUserDimensions"); ALOGV("Surface::setBuffersUserDimensions");
if (w<0 || h<0) if ((width && !height) || (!width && height))
return BAD_VALUE;
if ((w && !h) || (!w && h))
return BAD_VALUE; return BAD_VALUE;
Mutex::Autolock lock(mMutex); Mutex::Autolock lock(mMutex);
mUserWidth = w; mUserWidth = width;
mUserHeight = h; mUserHeight = height;
return NO_ERROR; return NO_ERROR;
} }
int Surface::setBuffersFormat(int format) int Surface::setBuffersFormat(PixelFormat format)
{ {
ALOGV("Surface::setBuffersFormat"); ALOGV("Surface::setBuffersFormat");
if (format<0)
return BAD_VALUE;
Mutex::Autolock lock(mMutex); Mutex::Autolock lock(mMutex);
mReqFormat = format; mReqFormat = format;
return NO_ERROR; return NO_ERROR;
@ -704,7 +697,7 @@ int Surface::setScalingMode(int mode)
return NO_ERROR; return NO_ERROR;
} }
int Surface::setBuffersTransform(int transform) int Surface::setBuffersTransform(uint32_t transform)
{ {
ATRACE_CALL(); ATRACE_CALL();
ALOGV("Surface::setBuffersTransform"); ALOGV("Surface::setBuffersTransform");
@ -713,7 +706,7 @@ int Surface::setBuffersTransform(int transform)
return NO_ERROR; return NO_ERROR;
} }
int Surface::setBuffersStickyTransform(int transform) int Surface::setBuffersStickyTransform(uint32_t transform)
{ {
ATRACE_CALL(); ATRACE_CALL();
ALOGV("Surface::setBuffersStickyTransform"); ALOGV("Surface::setBuffersStickyTransform");
@ -747,30 +740,34 @@ static status_t copyBlt(
// src and dst with, height and format must be identical. no verification // src and dst with, height and format must be identical. no verification
// is done here. // is done here.
status_t err; status_t err;
uint8_t const * src_bits = NULL; uint8_t* src_bits = NULL;
err = src->lock(GRALLOC_USAGE_SW_READ_OFTEN, reg.bounds(), (void**)&src_bits); err = src->lock(GRALLOC_USAGE_SW_READ_OFTEN, reg.bounds(),
reinterpret_cast<void**>(&src_bits));
ALOGE_IF(err, "error locking src buffer %s", strerror(-err)); ALOGE_IF(err, "error locking src buffer %s", strerror(-err));
uint8_t* dst_bits = NULL; uint8_t* dst_bits = NULL;
err = dst->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, reg.bounds(), (void**)&dst_bits); err = dst->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, reg.bounds(),
reinterpret_cast<void**>(&dst_bits));
ALOGE_IF(err, "error locking dst buffer %s", strerror(-err)); ALOGE_IF(err, "error locking dst buffer %s", strerror(-err));
Region::const_iterator head(reg.begin()); Region::const_iterator head(reg.begin());
Region::const_iterator tail(reg.end()); Region::const_iterator tail(reg.end());
if (head != tail && src_bits && dst_bits) { if (head != tail && src_bits && dst_bits) {
const size_t bpp = bytesPerPixel(src->format); const size_t bpp = bytesPerPixel(src->format);
const size_t dbpr = dst->stride * bpp; const size_t dbpr = static_cast<uint32_t>(dst->stride) * bpp;
const size_t sbpr = src->stride * bpp; const size_t sbpr = static_cast<uint32_t>(src->stride) * bpp;
while (head != tail) { while (head != tail) {
const Rect& r(*head++); const Rect& r(*head++);
ssize_t h = r.height(); int32_t h = r.height();
if (h <= 0) continue; if (h <= 0) continue;
size_t size = r.width() * bpp; size_t size = static_cast<uint32_t>(r.width()) * bpp;
uint8_t const * s = src_bits + (r.left + src->stride * r.top) * bpp; uint8_t const * s = src_bits +
uint8_t * d = dst_bits + (r.left + dst->stride * r.top) * bpp; static_cast<uint32_t>(r.left + src->stride * r.top) * bpp;
uint8_t * d = dst_bits +
static_cast<uint32_t>(r.left + dst->stride * r.top) * bpp;
if (dbpr==sbpr && size==sbpr) { if (dbpr==sbpr && size==sbpr) {
size *= h; size *= static_cast<size_t>(h);
h = 1; h = 1;
} }
do { do {

View File

@ -143,7 +143,7 @@ public:
status_t setSize(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id, status_t setSize(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
uint32_t w, uint32_t h); uint32_t w, uint32_t h);
status_t setLayer(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id, status_t setLayer(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
int32_t z); uint32_t z);
status_t setFlags(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id, status_t setFlags(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
uint32_t flags, uint32_t mask); uint32_t flags, uint32_t mask);
status_t setTransparentRegionHint( status_t setTransparentRegionHint(
@ -293,7 +293,7 @@ status_t Composer::setSize(const sp<SurfaceComposerClient>& client,
} }
status_t Composer::setLayer(const sp<SurfaceComposerClient>& client, status_t Composer::setLayer(const sp<SurfaceComposerClient>& client,
const sp<IBinder>& id, int32_t z) { const sp<IBinder>& id, uint32_t z) {
Mutex::Autolock _l(mLock); Mutex::Autolock _l(mLock);
layer_state_t* s = getLayerStateLocked(client, id); layer_state_t* s = getLayerStateLocked(client, id);
if (!s) if (!s)
@ -395,7 +395,7 @@ DisplayState& Composer::getDisplayStateLocked(const sp<IBinder>& token) {
s.what = 0; s.what = 0;
index = mDisplayStates.add(s); index = mDisplayStates.add(s);
} }
return mDisplayStates.editItemAt(index); return mDisplayStates.editItemAt(static_cast<size_t>(index));
} }
void Composer::setDisplaySurface(const sp<IBinder>& token, void Composer::setDisplaySurface(const sp<IBinder>& token,
@ -571,7 +571,7 @@ status_t SurfaceComposerClient::setSize(const sp<IBinder>& id, uint32_t w, uint3
return getComposer().setSize(this, id, w, h); return getComposer().setSize(this, id, w, h);
} }
status_t SurfaceComposerClient::setLayer(const sp<IBinder>& id, int32_t z) { status_t SurfaceComposerClient::setLayer(const sp<IBinder>& id, uint32_t z) {
return getComposer().setLayer(this, id, z); return getComposer().setLayer(this, id, z);
} }
@ -657,7 +657,7 @@ status_t SurfaceComposerClient::getDisplayInfo(const sp<IBinder>& display,
return NAME_NOT_FOUND; return NAME_NOT_FOUND;
} }
*info = configs[activeId]; *info = configs[static_cast<size_t>(activeId)];
return NO_ERROR; return NO_ERROR;
} }

View File

@ -89,12 +89,12 @@ bool SurfaceControl::isSameSurface(
return lhs->mHandle == rhs->mHandle; return lhs->mHandle == rhs->mHandle;
} }
status_t SurfaceControl::setLayerStack(int32_t layerStack) { status_t SurfaceControl::setLayerStack(uint32_t layerStack) {
status_t err = validate(); status_t err = validate();
if (err < 0) return err; if (err < 0) return err;
return mClient->setLayerStack(mHandle, layerStack); return mClient->setLayerStack(mHandle, layerStack);
} }
status_t SurfaceControl::setLayer(int32_t layer) { status_t SurfaceControl::setLayer(uint32_t layer) {
status_t err = validate(); status_t err = validate();
if (err < 0) return err; if (err < 0) return err;
return mClient->setLayer(mHandle, layer); return mClient->setLayer(mHandle, layer);

View File

@ -16,7 +16,6 @@
#define LOG_TAG "GLConsumer" #define LOG_TAG "GLConsumer"
#define GL_GLEXT_PROTOTYPES
#define EGL_EGLEXT_PROTOTYPES #define EGL_EGLEXT_PROTOTYPES
#include <EGL/egl.h> #include <EGL/egl.h>

View File

@ -284,7 +284,7 @@ status_t VirtualDisplaySurface::setBufferCount(int bufferCount) {
} }
status_t VirtualDisplaySurface::dequeueBuffer(Source source, status_t VirtualDisplaySurface::dequeueBuffer(Source source,
uint32_t format, uint32_t usage, int* sslot, sp<Fence>* fence) { PixelFormat format, uint32_t usage, int* sslot, sp<Fence>* fence) {
LOG_FATAL_IF(mDisplayId < 0, "mDisplayId=%d but should not be < 0.", mDisplayId); LOG_FATAL_IF(mDisplayId < 0, "mDisplayId=%d but should not be < 0.", mDisplayId);
// Don't let a slow consumer block us // Don't let a slow consumer block us
bool async = (source == SOURCE_SINK); bool async = (source == SOURCE_SINK);
@ -329,7 +329,7 @@ status_t VirtualDisplaySurface::dequeueBuffer(Source source,
} }
status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp<Fence>* fence, bool async, status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp<Fence>* fence, bool async,
uint32_t w, uint32_t h, uint32_t format, uint32_t usage) { uint32_t w, uint32_t h, PixelFormat format, uint32_t usage) {
if (mDisplayId < 0) if (mDisplayId < 0)
return mSource[SOURCE_SINK]->dequeueBuffer(pslot, fence, async, w, h, format, usage); return mSource[SOURCE_SINK]->dequeueBuffer(pslot, fence, async, w, h, format, usage);
@ -364,7 +364,7 @@ status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp<Fence>* fence, bool
usage |= GRALLOC_USAGE_HW_COMPOSER; usage |= GRALLOC_USAGE_HW_COMPOSER;
const sp<GraphicBuffer>& buf = mProducerBuffers[mOutputProducerSlot]; const sp<GraphicBuffer>& buf = mProducerBuffers[mOutputProducerSlot];
if ((usage & ~buf->getUsage()) != 0 || if ((usage & ~buf->getUsage()) != 0 ||
(format != 0 && format != (uint32_t)buf->getPixelFormat()) || (format != 0 && format != buf->getPixelFormat()) ||
(w != 0 && w != mSinkBufferWidth) || (w != 0 && w != mSinkBufferWidth) ||
(h != 0 && h != mSinkBufferHeight)) { (h != 0 && h != mSinkBufferHeight)) {
VDS_LOGV("dequeueBuffer: dequeueing new output buffer: " VDS_LOGV("dequeueBuffer: dequeueing new output buffer: "
@ -517,7 +517,7 @@ status_t VirtualDisplaySurface::setSidebandStream(const sp<NativeHandle>& /*stre
} }
void VirtualDisplaySurface::allocateBuffers(bool /* async */, void VirtualDisplaySurface::allocateBuffers(bool /* async */,
uint32_t /* width */, uint32_t /* height */, uint32_t /* format */, uint32_t /* width */, uint32_t /* height */, PixelFormat /* format */,
uint32_t /* usage */) { uint32_t /* usage */) {
// TODO: Should we actually allocate buffers for a virtual display? // TODO: Should we actually allocate buffers for a virtual display?
} }

View File

@ -100,7 +100,7 @@ private:
virtual status_t requestBuffer(int pslot, sp<GraphicBuffer>* outBuf); virtual status_t requestBuffer(int pslot, sp<GraphicBuffer>* outBuf);
virtual status_t setBufferCount(int bufferCount); virtual status_t setBufferCount(int bufferCount);
virtual status_t dequeueBuffer(int* pslot, sp<Fence>* fence, bool async, virtual status_t dequeueBuffer(int* pslot, sp<Fence>* fence, bool async,
uint32_t w, uint32_t h, uint32_t format, uint32_t usage); uint32_t w, uint32_t h, PixelFormat format, uint32_t usage);
virtual status_t detachBuffer(int slot); virtual status_t detachBuffer(int slot);
virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer, virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer,
sp<Fence>* outFence); sp<Fence>* outFence);
@ -114,13 +114,13 @@ private:
virtual status_t disconnect(int api); virtual status_t disconnect(int api);
virtual status_t setSidebandStream(const sp<NativeHandle>& stream); virtual status_t setSidebandStream(const sp<NativeHandle>& stream);
virtual void allocateBuffers(bool async, uint32_t width, uint32_t height, virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
uint32_t format, uint32_t usage); PixelFormat format, uint32_t usage);
// //
// Utility methods // Utility methods
// //
static Source fbSourceForCompositionType(CompositionType type); static Source fbSourceForCompositionType(CompositionType type);
status_t dequeueBuffer(Source source, uint32_t format, uint32_t usage, status_t dequeueBuffer(Source source, PixelFormat format, uint32_t usage,
int* sslot, sp<Fence>* fence); int* sslot, sp<Fence>* fence);
void updateQueueBufferOutput(const QueueBufferOutput& qbo); void updateQueueBufferOutput(const QueueBufferOutput& qbo);
void resetPerFrameState(); void resetPerFrameState();

View File

@ -61,7 +61,7 @@ status_t MonitoredProducer::setBufferCount(int bufferCount) {
} }
status_t MonitoredProducer::dequeueBuffer(int* slot, sp<Fence>* fence, status_t MonitoredProducer::dequeueBuffer(int* slot, sp<Fence>* fence,
bool async, uint32_t w, uint32_t h, uint32_t format, uint32_t usage) { bool async, uint32_t w, uint32_t h, PixelFormat format, uint32_t usage) {
return mProducer->dequeueBuffer(slot, fence, async, w, h, format, usage); return mProducer->dequeueBuffer(slot, fence, async, w, h, format, usage);
} }
@ -106,7 +106,7 @@ status_t MonitoredProducer::setSidebandStream(const sp<NativeHandle>& stream) {
} }
void MonitoredProducer::allocateBuffers(bool async, uint32_t width, void MonitoredProducer::allocateBuffers(bool async, uint32_t width,
uint32_t height, uint32_t format, uint32_t usage) { uint32_t height, PixelFormat format, uint32_t usage) {
mProducer->allocateBuffers(async, width, height, format, usage); mProducer->allocateBuffers(async, width, height, format, usage);
} }

View File

@ -37,7 +37,7 @@ public:
virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf); virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf);
virtual status_t setBufferCount(int bufferCount); virtual status_t setBufferCount(int bufferCount);
virtual status_t dequeueBuffer(int* slot, sp<Fence>* fence, bool async, virtual status_t dequeueBuffer(int* slot, sp<Fence>* fence, bool async,
uint32_t w, uint32_t h, uint32_t format, uint32_t usage); uint32_t w, uint32_t h, PixelFormat format, uint32_t usage);
virtual status_t detachBuffer(int slot); virtual status_t detachBuffer(int slot);
virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer, virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer,
sp<Fence>* outFence); sp<Fence>* outFence);
@ -52,7 +52,7 @@ public:
virtual status_t disconnect(int api); virtual status_t disconnect(int api);
virtual status_t setSidebandStream(const sp<NativeHandle>& stream); virtual status_t setSidebandStream(const sp<NativeHandle>& stream);
virtual void allocateBuffers(bool async, uint32_t width, uint32_t height, virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
uint32_t format, uint32_t usage); PixelFormat format, uint32_t usage);
virtual IBinder* onAsBinder(); virtual IBinder* onAsBinder();
private: private: