Add dataSpace to buffer queues; remove old format enums.
- Wire up new dataSpace parameter through buffer queue stack - Update tests to include the parameter - Switch eglApi to using dataSpace to indicate sRGB gamma/linear difference - Remove RAW_SENSOR in favor of RAW16 - Remove use of sRGB format enums - Add default dataspace to buffer queue core - Add query for default dataspace Change-Id: I070bd2e7c56506055c419004c29e2e3feac725df
This commit is contained in:
parent
123edd9f81
commit
5b75a513e4
|
@ -78,6 +78,11 @@ class BufferItem : public Flattenable<BufferItem> {
|
||||||
// automatically when the buffer was queued.
|
// automatically when the buffer was queued.
|
||||||
bool mIsAutoTimestamp;
|
bool mIsAutoTimestamp;
|
||||||
|
|
||||||
|
// mDataSpace is the current dataSpace value for this buffer slot. This gets
|
||||||
|
// set by queueBuffer each time this slot is queued. The meaning of the
|
||||||
|
// dataSpace is format-dependent.
|
||||||
|
android_dataspace mDataSpace;
|
||||||
|
|
||||||
// mFrameNumber is the number of the queued frame for this slot.
|
// mFrameNumber is the number of the queued frame for this slot.
|
||||||
uint64_t mFrameNumber;
|
uint64_t mFrameNumber;
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,13 @@ class BufferItemConsumer: public ConsumerBase
|
||||||
// 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(PixelFormat defaultFormat);
|
status_t setDefaultBufferFormat(PixelFormat defaultFormat);
|
||||||
|
|
||||||
|
// setDefaultBufferDataSpace allows the BufferQueue to create
|
||||||
|
// GraphicBuffers of a defaultDataSpace if no data space is specified
|
||||||
|
// in queueBuffer.
|
||||||
|
// The initial default is HAL_DATASPACE_UNKNOWN
|
||||||
|
status_t setDefaultBufferDataSpace(android_dataspace defaultDataSpace);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace android
|
} // namespace android
|
||||||
|
|
|
@ -128,6 +128,13 @@ public:
|
||||||
// in dequeueBuffer. The initial default is HAL_PIXEL_FORMAT_RGBA_8888.
|
// in dequeueBuffer. The initial default is HAL_PIXEL_FORMAT_RGBA_8888.
|
||||||
virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat);
|
virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat);
|
||||||
|
|
||||||
|
// setDefaultBufferDataSpace allows the BufferQueue to create
|
||||||
|
// GraphicBuffers of a defaultDataSpace if no data space is specified
|
||||||
|
// in queueBuffer.
|
||||||
|
// The initial default is HAL_DATASPACE_UNKNOWN
|
||||||
|
virtual status_t setDefaultBufferDataSpace(
|
||||||
|
android_dataspace defaultDataSpace);
|
||||||
|
|
||||||
// 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
|
||||||
// enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER; the default is 0.
|
// enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER; the default is 0.
|
||||||
|
|
|
@ -209,6 +209,11 @@ private:
|
||||||
// in dequeueBuffer if a width and height of 0 are specified.
|
// in dequeueBuffer if a width and height of 0 are specified.
|
||||||
uint32_t mDefaultHeight;
|
uint32_t mDefaultHeight;
|
||||||
|
|
||||||
|
// mDefaultBufferDataSpace holds the default dataSpace of queued buffers.
|
||||||
|
// It is used in queueBuffer if a dataspace of 0 (HAL_DATASPACE_UNKNOWN)
|
||||||
|
// is specified.
|
||||||
|
android_dataspace mDefaultBufferDataSpace;
|
||||||
|
|
||||||
// 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.
|
||||||
// The limit (as opposed to the default limit) may be overriden by the
|
// The limit (as opposed to the default limit) may be overriden by the
|
||||||
|
|
|
@ -53,6 +53,7 @@ class CpuConsumer : public ConsumerBase
|
||||||
uint32_t transform;
|
uint32_t transform;
|
||||||
uint32_t scalingMode;
|
uint32_t scalingMode;
|
||||||
int64_t timestamp;
|
int64_t timestamp;
|
||||||
|
android_dataspace dataSpace;
|
||||||
uint64_t frameNumber;
|
uint64_t frameNumber;
|
||||||
// this is the same as format, except for formats that are compatible with
|
// this is the same as format, except for formats that are compatible with
|
||||||
// a flexible format (e.g. HAL_PIXEL_FORMAT_YCbCr_420_888). In the latter
|
// a flexible format (e.g. HAL_PIXEL_FORMAT_YCbCr_420_888). In the latter
|
||||||
|
@ -90,6 +91,12 @@ class CpuConsumer : public ConsumerBase
|
||||||
// The initial default is PIXEL_FORMAT_RGBA_8888.
|
// The initial default is PIXEL_FORMAT_RGBA_8888.
|
||||||
status_t setDefaultBufferFormat(PixelFormat defaultFormat);
|
status_t setDefaultBufferFormat(PixelFormat defaultFormat);
|
||||||
|
|
||||||
|
// setDefaultBufferDataSpace allows the BufferQueue to create
|
||||||
|
// GraphicBuffers of a defaultDataSpace if no data space is specified
|
||||||
|
// in queueBuffer.
|
||||||
|
// The initial default is HAL_DATASPACE_UNKNOWN
|
||||||
|
status_t setDefaultBufferDataSpace(android_dataspace defaultDataSpace);
|
||||||
|
|
||||||
// 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
|
||||||
// and metadata. Returns BAD_VALUE if no new buffer is available, and
|
// and metadata. Returns BAD_VALUE if no new buffer is available, and
|
||||||
|
|
|
@ -198,6 +198,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(PixelFormat defaultFormat);
|
status_t setDefaultBufferFormat(PixelFormat defaultFormat);
|
||||||
|
status_t setDefaultBufferDataSpace(android_dataspace defaultDataSpace);
|
||||||
status_t setConsumerUsageBits(uint32_t usage);
|
status_t setConsumerUsageBits(uint32_t usage);
|
||||||
status_t setTransformHint(uint32_t hint);
|
status_t setTransformHint(uint32_t hint);
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,10 @@ public:
|
||||||
// automatically when the buffer was queued.
|
// automatically when the buffer was queued.
|
||||||
bool mIsAutoTimestamp;
|
bool mIsAutoTimestamp;
|
||||||
|
|
||||||
|
// mDataSpace is the current dataSpace for this buffer slot. This gets
|
||||||
|
// set by queueBuffer each time this slot is queued.
|
||||||
|
android_dataspace mDataSpace;
|
||||||
|
|
||||||
// mFrameNumber is the number of the queued frame for this slot.
|
// mFrameNumber is the number of the queued frame for this slot.
|
||||||
uint64_t mFrameNumber;
|
uint64_t mFrameNumber;
|
||||||
|
|
||||||
|
@ -287,6 +291,14 @@ public:
|
||||||
// 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(PixelFormat defaultFormat) = 0;
|
virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat) = 0;
|
||||||
|
|
||||||
|
// setDefaultBufferDataSpace is a request to the producer to provide buffers
|
||||||
|
// of the indicated dataSpace. The producer may ignore this request.
|
||||||
|
// The initial default is HAL_DATASPACE_UNKNOWN.
|
||||||
|
//
|
||||||
|
// Return of a value other than NO_ERROR means an unknown error has occurred.
|
||||||
|
virtual status_t setDefaultBufferDataSpace(
|
||||||
|
android_dataspace defaultDataSpace) = 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
|
||||||
// enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER; the default is 0.
|
// enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER; the default is 0.
|
||||||
|
|
|
@ -265,6 +265,7 @@ public:
|
||||||
inline QueueBufferInput(const Parcel& parcel);
|
inline QueueBufferInput(const Parcel& parcel);
|
||||||
// timestamp - a monotonically increasing value in nanoseconds
|
// timestamp - a monotonically increasing value in nanoseconds
|
||||||
// isAutoTimestamp - if the timestamp was synthesized at queue time
|
// isAutoTimestamp - if the timestamp was synthesized at queue time
|
||||||
|
// dataSpace - description of the contents, interpretation depends on format
|
||||||
// crop - a crop rectangle that's used as a hint to the consumer
|
// crop - a crop rectangle that's used as a hint to the consumer
|
||||||
// scalingMode - a set of flags from NATIVE_WINDOW_SCALING_* in <window.h>
|
// scalingMode - a set of flags from NATIVE_WINDOW_SCALING_* in <window.h>
|
||||||
// transform - a set of flags from NATIVE_WINDOW_TRANSFORM_* in <window.h>
|
// transform - a set of flags from NATIVE_WINDOW_TRANSFORM_* in <window.h>
|
||||||
|
@ -274,17 +275,21 @@ public:
|
||||||
// sticky - the sticky transform set in Surface (only used by the LEGACY
|
// sticky - the sticky transform set in Surface (only used by the LEGACY
|
||||||
// camera mode).
|
// camera mode).
|
||||||
inline QueueBufferInput(int64_t timestamp, bool isAutoTimestamp,
|
inline QueueBufferInput(int64_t timestamp, bool isAutoTimestamp,
|
||||||
const Rect& crop, int scalingMode, uint32_t transform, bool async,
|
android_dataspace dataSpace, const Rect& crop, int scalingMode,
|
||||||
const sp<Fence>& fence, uint32_t sticky = 0)
|
uint32_t transform, bool async, const sp<Fence>& fence,
|
||||||
: timestamp(timestamp), isAutoTimestamp(isAutoTimestamp), crop(crop),
|
uint32_t sticky = 0)
|
||||||
scalingMode(scalingMode), transform(transform), stickyTransform(sticky),
|
: timestamp(timestamp), isAutoTimestamp(isAutoTimestamp),
|
||||||
async(async), fence(fence) { }
|
dataSpace(dataSpace), crop(crop), scalingMode(scalingMode),
|
||||||
|
transform(transform), stickyTransform(sticky),
|
||||||
|
async(async), fence(fence) { }
|
||||||
inline void deflate(int64_t* outTimestamp, bool* outIsAutoTimestamp,
|
inline void deflate(int64_t* outTimestamp, bool* outIsAutoTimestamp,
|
||||||
Rect* outCrop, int* outScalingMode, uint32_t* outTransform,
|
android_dataspace* outDataSpace,
|
||||||
bool* outAsync, sp<Fence>* outFence,
|
Rect* outCrop, int* outScalingMode,
|
||||||
|
uint32_t* outTransform, bool* outAsync, sp<Fence>* outFence,
|
||||||
uint32_t* outStickyTransform = NULL) const {
|
uint32_t* outStickyTransform = NULL) const {
|
||||||
*outTimestamp = timestamp;
|
*outTimestamp = timestamp;
|
||||||
*outIsAutoTimestamp = bool(isAutoTimestamp);
|
*outIsAutoTimestamp = bool(isAutoTimestamp);
|
||||||
|
*outDataSpace = dataSpace;
|
||||||
*outCrop = crop;
|
*outCrop = crop;
|
||||||
*outScalingMode = scalingMode;
|
*outScalingMode = scalingMode;
|
||||||
*outTransform = transform;
|
*outTransform = transform;
|
||||||
|
@ -304,6 +309,7 @@ public:
|
||||||
private:
|
private:
|
||||||
int64_t timestamp;
|
int64_t timestamp;
|
||||||
int isAutoTimestamp;
|
int isAutoTimestamp;
|
||||||
|
android_dataspace dataSpace;
|
||||||
Rect crop;
|
Rect crop;
|
||||||
int scalingMode;
|
int scalingMode;
|
||||||
uint32_t transform;
|
uint32_t transform;
|
||||||
|
|
|
@ -146,6 +146,7 @@ private:
|
||||||
int dispatchLock(va_list args);
|
int dispatchLock(va_list args);
|
||||||
int dispatchUnlockAndPost(va_list args);
|
int dispatchUnlockAndPost(va_list args);
|
||||||
int dispatchSetSidebandStream(va_list args);
|
int dispatchSetSidebandStream(va_list args);
|
||||||
|
int dispatchSetBuffersDataSpace(va_list args);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int dequeueBuffer(ANativeWindowBuffer** buffer, int* fenceFd);
|
virtual int dequeueBuffer(ANativeWindowBuffer** buffer, int* fenceFd);
|
||||||
|
@ -167,6 +168,7 @@ protected:
|
||||||
virtual int setBuffersTransform(uint32_t transform);
|
virtual int setBuffersTransform(uint32_t transform);
|
||||||
virtual int setBuffersStickyTransform(uint32_t transform);
|
virtual int setBuffersStickyTransform(uint32_t transform);
|
||||||
virtual int setBuffersTimestamp(int64_t timestamp);
|
virtual int setBuffersTimestamp(int64_t timestamp);
|
||||||
|
virtual int setBuffersDataSpace(android_dataspace dataSpace);
|
||||||
virtual int setCrop(Rect const* rect);
|
virtual int setCrop(Rect const* rect);
|
||||||
virtual int setUsage(uint32_t reqUsage);
|
virtual int setUsage(uint32_t reqUsage);
|
||||||
|
|
||||||
|
@ -222,6 +224,11 @@ private:
|
||||||
// a timestamp is auto-generated when queueBuffer is called.
|
// a timestamp is auto-generated when queueBuffer is called.
|
||||||
int64_t mTimestamp;
|
int64_t mTimestamp;
|
||||||
|
|
||||||
|
// mDataSpace is the buffer dataSpace that will be used for the next buffer
|
||||||
|
// queue operation. It defaults to HAL_DATASPACE_UNKNOWN, which
|
||||||
|
// means that the buffer contains some type of color data.
|
||||||
|
android_dataspace mDataSpace;
|
||||||
|
|
||||||
// mCrop is the crop rectangle that will be used for the next buffer
|
// mCrop is the crop rectangle that will be used for the next buffer
|
||||||
// that gets queued. It is set by calling setCrop.
|
// that gets queued. It is set by calling setCrop.
|
||||||
Rect mCrop;
|
Rect mCrop;
|
||||||
|
|
|
@ -60,8 +60,6 @@ enum {
|
||||||
PIXEL_FORMAT_BGRA_8888 = HAL_PIXEL_FORMAT_BGRA_8888, // 4x8-bit BGRA
|
PIXEL_FORMAT_BGRA_8888 = HAL_PIXEL_FORMAT_BGRA_8888, // 4x8-bit BGRA
|
||||||
PIXEL_FORMAT_RGBA_5551 = 6, // 16-bit ARGB
|
PIXEL_FORMAT_RGBA_5551 = 6, // 16-bit ARGB
|
||||||
PIXEL_FORMAT_RGBA_4444 = 7, // 16-bit ARGB
|
PIXEL_FORMAT_RGBA_4444 = 7, // 16-bit ARGB
|
||||||
PIXEL_FORMAT_sRGB_A_8888 = HAL_PIXEL_FORMAT_sRGB_A_8888, // 4x8-bit sRGB + A
|
|
||||||
PIXEL_FORMAT_sRGB_X_8888 = HAL_PIXEL_FORMAT_sRGB_X_8888, // 4x8-bit sRGB, no A
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int32_t PixelFormat;
|
typedef int32_t PixelFormat;
|
||||||
|
|
|
@ -28,6 +28,7 @@ BufferItem::BufferItem() :
|
||||||
mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
|
mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
|
||||||
mTimestamp(0),
|
mTimestamp(0),
|
||||||
mIsAutoTimestamp(false),
|
mIsAutoTimestamp(false),
|
||||||
|
mDataSpace(HAL_DATASPACE_UNKNOWN),
|
||||||
mFrameNumber(0),
|
mFrameNumber(0),
|
||||||
mSlot(INVALID_BUFFER_SLOT),
|
mSlot(INVALID_BUFFER_SLOT),
|
||||||
mIsDroppable(false),
|
mIsDroppable(false),
|
||||||
|
@ -47,6 +48,7 @@ BufferItem::operator IGraphicBufferConsumer::BufferItem() const {
|
||||||
bufferItem.mScalingMode = mScalingMode;
|
bufferItem.mScalingMode = mScalingMode;
|
||||||
bufferItem.mTimestamp = mTimestamp;
|
bufferItem.mTimestamp = mTimestamp;
|
||||||
bufferItem.mIsAutoTimestamp = mIsAutoTimestamp;
|
bufferItem.mIsAutoTimestamp = mIsAutoTimestamp;
|
||||||
|
bufferItem.mDataSpace = mDataSpace;
|
||||||
bufferItem.mFrameNumber = mFrameNumber;
|
bufferItem.mFrameNumber = mFrameNumber;
|
||||||
bufferItem.mBuf = mSlot;
|
bufferItem.mBuf = mSlot;
|
||||||
bufferItem.mIsDroppable = mIsDroppable;
|
bufferItem.mIsDroppable = mIsDroppable;
|
||||||
|
@ -61,6 +63,7 @@ size_t BufferItem::getPodSize() const {
|
||||||
sizeof(mScalingMode) +
|
sizeof(mScalingMode) +
|
||||||
sizeof(mTimestamp) +
|
sizeof(mTimestamp) +
|
||||||
sizeof(mIsAutoTimestamp) +
|
sizeof(mIsAutoTimestamp) +
|
||||||
|
sizeof(mDataSpace) +
|
||||||
sizeof(mFrameNumber) +
|
sizeof(mFrameNumber) +
|
||||||
sizeof(mSlot) +
|
sizeof(mSlot) +
|
||||||
sizeof(mIsDroppable) +
|
sizeof(mIsDroppable) +
|
||||||
|
@ -131,6 +134,7 @@ status_t BufferItem::flatten(
|
||||||
FlattenableUtils::write(buffer, size, mScalingMode);
|
FlattenableUtils::write(buffer, size, mScalingMode);
|
||||||
FlattenableUtils::write(buffer, size, mTimestamp);
|
FlattenableUtils::write(buffer, size, mTimestamp);
|
||||||
FlattenableUtils::write(buffer, size, mIsAutoTimestamp);
|
FlattenableUtils::write(buffer, size, mIsAutoTimestamp);
|
||||||
|
FlattenableUtils::write(buffer, size, mDataSpace);
|
||||||
FlattenableUtils::write(buffer, size, mFrameNumber);
|
FlattenableUtils::write(buffer, size, mFrameNumber);
|
||||||
FlattenableUtils::write(buffer, size, mSlot);
|
FlattenableUtils::write(buffer, size, mSlot);
|
||||||
FlattenableUtils::write(buffer, size, mIsDroppable);
|
FlattenableUtils::write(buffer, size, mIsDroppable);
|
||||||
|
@ -173,6 +177,7 @@ status_t BufferItem::unflatten(
|
||||||
FlattenableUtils::read(buffer, size, mScalingMode);
|
FlattenableUtils::read(buffer, size, mScalingMode);
|
||||||
FlattenableUtils::read(buffer, size, mTimestamp);
|
FlattenableUtils::read(buffer, size, mTimestamp);
|
||||||
FlattenableUtils::read(buffer, size, mIsAutoTimestamp);
|
FlattenableUtils::read(buffer, size, mIsAutoTimestamp);
|
||||||
|
FlattenableUtils::read(buffer, size, mDataSpace);
|
||||||
FlattenableUtils::read(buffer, size, mFrameNumber);
|
FlattenableUtils::read(buffer, size, mFrameNumber);
|
||||||
FlattenableUtils::read(buffer, size, mSlot);
|
FlattenableUtils::read(buffer, size, mSlot);
|
||||||
FlattenableUtils::read(buffer, size, mIsDroppable);
|
FlattenableUtils::read(buffer, size, mIsDroppable);
|
||||||
|
|
|
@ -109,4 +109,10 @@ status_t BufferItemConsumer::setDefaultBufferFormat(PixelFormat defaultFormat) {
|
||||||
return mConsumer->setDefaultBufferFormat(defaultFormat);
|
return mConsumer->setDefaultBufferFormat(defaultFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status_t BufferItemConsumer::setDefaultBufferDataSpace(
|
||||||
|
android_dataspace defaultDataSpace) {
|
||||||
|
Mutex::Autolock _l(mMutex);
|
||||||
|
return mConsumer->setDefaultBufferDataSpace(defaultDataSpace);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace android
|
} // namespace android
|
||||||
|
|
|
@ -496,6 +496,15 @@ status_t BufferQueueConsumer::setDefaultBufferFormat(PixelFormat defaultFormat)
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status_t BufferQueueConsumer::setDefaultBufferDataSpace(
|
||||||
|
android_dataspace defaultDataSpace) {
|
||||||
|
ATRACE_CALL();
|
||||||
|
BQ_LOGV("setDefaultBufferDataSpace: %u", defaultDataSpace);
|
||||||
|
Mutex::Autolock lock(mCore->mMutex);
|
||||||
|
mCore->mDefaultBufferDataSpace = defaultDataSpace;
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
status_t BufferQueueConsumer::setConsumerUsageBits(uint32_t usage) {
|
status_t BufferQueueConsumer::setConsumerUsageBits(uint32_t usage) {
|
||||||
ATRACE_CALL();
|
ATRACE_CALL();
|
||||||
BQ_LOGV("setConsumerUsageBits: %#x", usage);
|
BQ_LOGV("setConsumerUsageBits: %#x", usage);
|
||||||
|
|
|
@ -60,6 +60,7 @@ BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) :
|
||||||
mDefaultBufferFormat(PIXEL_FORMAT_RGBA_8888),
|
mDefaultBufferFormat(PIXEL_FORMAT_RGBA_8888),
|
||||||
mDefaultWidth(1),
|
mDefaultWidth(1),
|
||||||
mDefaultHeight(1),
|
mDefaultHeight(1),
|
||||||
|
mDefaultBufferDataSpace(HAL_DATASPACE_UNKNOWN),
|
||||||
mDefaultMaxBufferCount(2),
|
mDefaultMaxBufferCount(2),
|
||||||
mMaxAcquiredBufferCount(1),
|
mMaxAcquiredBufferCount(1),
|
||||||
mBufferHasBeenQueued(false),
|
mBufferHasBeenQueued(false),
|
||||||
|
|
|
@ -516,14 +516,15 @@ status_t BufferQueueProducer::queueBuffer(int slot,
|
||||||
|
|
||||||
int64_t timestamp;
|
int64_t timestamp;
|
||||||
bool isAutoTimestamp;
|
bool isAutoTimestamp;
|
||||||
|
android_dataspace dataSpace;
|
||||||
Rect crop;
|
Rect crop;
|
||||||
int scalingMode;
|
int scalingMode;
|
||||||
uint32_t transform;
|
uint32_t transform;
|
||||||
uint32_t stickyTransform;
|
uint32_t stickyTransform;
|
||||||
bool async;
|
bool async;
|
||||||
sp<Fence> fence;
|
sp<Fence> fence;
|
||||||
input.deflate(×tamp, &isAutoTimestamp, &crop, &scalingMode, &transform,
|
input.deflate(×tamp, &isAutoTimestamp, &dataSpace, &crop, &scalingMode,
|
||||||
&async, &fence, &stickyTransform);
|
&transform, &async, &fence, &stickyTransform);
|
||||||
|
|
||||||
if (fence == NULL) {
|
if (fence == NULL) {
|
||||||
BQ_LOGE("queueBuffer: fence is NULL");
|
BQ_LOGE("queueBuffer: fence is NULL");
|
||||||
|
@ -579,9 +580,9 @@ status_t BufferQueueProducer::queueBuffer(int slot,
|
||||||
return BAD_VALUE;
|
return BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BQ_LOGV("queueBuffer: slot=%d/%" PRIu64 " time=%" PRIu64
|
BQ_LOGV("queueBuffer: slot=%d/%" PRIu64 " time=%" PRIu64 " dataSpace=%d"
|
||||||
" 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, dataSpace,
|
||||||
crop.left, crop.top, crop.right, crop.bottom, transform,
|
crop.left, crop.top, crop.right, crop.bottom, transform,
|
||||||
BufferItem::scalingModeName(static_cast<uint32_t>(scalingMode)));
|
BufferItem::scalingModeName(static_cast<uint32_t>(scalingMode)));
|
||||||
|
|
||||||
|
@ -595,6 +596,11 @@ status_t BufferQueueProducer::queueBuffer(int slot,
|
||||||
return BAD_VALUE;
|
return BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Override UNKNOWN dataspace with consumer default
|
||||||
|
if (dataSpace == HAL_DATASPACE_UNKNOWN) {
|
||||||
|
dataSpace = mCore->mDefaultBufferDataSpace;
|
||||||
|
}
|
||||||
|
|
||||||
mSlots[slot].mFence = fence;
|
mSlots[slot].mFence = fence;
|
||||||
mSlots[slot].mBufferState = BufferSlot::QUEUED;
|
mSlots[slot].mBufferState = BufferSlot::QUEUED;
|
||||||
++mCore->mFrameCounter;
|
++mCore->mFrameCounter;
|
||||||
|
@ -610,6 +616,7 @@ status_t BufferQueueProducer::queueBuffer(int slot,
|
||||||
item.mScalingMode = static_cast<uint32_t>(scalingMode);
|
item.mScalingMode = static_cast<uint32_t>(scalingMode);
|
||||||
item.mTimestamp = timestamp;
|
item.mTimestamp = timestamp;
|
||||||
item.mIsAutoTimestamp = isAutoTimestamp;
|
item.mIsAutoTimestamp = isAutoTimestamp;
|
||||||
|
item.mDataSpace = dataSpace;
|
||||||
item.mFrameNumber = mCore->mFrameCounter;
|
item.mFrameNumber = mCore->mFrameCounter;
|
||||||
item.mSlot = slot;
|
item.mSlot = slot;
|
||||||
item.mFence = fence;
|
item.mFence = fence;
|
||||||
|
@ -758,6 +765,9 @@ int BufferQueueProducer::query(int what, int *outValue) {
|
||||||
case NATIVE_WINDOW_CONSUMER_USAGE_BITS:
|
case NATIVE_WINDOW_CONSUMER_USAGE_BITS:
|
||||||
value = static_cast<int32_t>(mCore->mConsumerUsageBits);
|
value = static_cast<int32_t>(mCore->mConsumerUsageBits);
|
||||||
break;
|
break;
|
||||||
|
case NATIVE_WINDOW_DEFAULT_DATASPACE:
|
||||||
|
value = static_cast<int32_t>(mCore->mDefaultBufferDataSpace);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return BAD_VALUE;
|
return BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,13 @@ status_t CpuConsumer::setDefaultBufferFormat(PixelFormat defaultFormat)
|
||||||
return mConsumer->setDefaultBufferFormat(defaultFormat);
|
return mConsumer->setDefaultBufferFormat(defaultFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status_t CpuConsumer::setDefaultBufferDataSpace(
|
||||||
|
android_dataspace defaultDataSpace)
|
||||||
|
{
|
||||||
|
Mutex::Autolock _l(mMutex);
|
||||||
|
return mConsumer->setDefaultBufferDataSpace(defaultDataSpace);
|
||||||
|
}
|
||||||
|
|
||||||
static bool isPossiblyYUV(PixelFormat format) {
|
static bool isPossiblyYUV(PixelFormat format) {
|
||||||
switch (static_cast<int>(format)) {
|
switch (static_cast<int>(format)) {
|
||||||
case HAL_PIXEL_FORMAT_RGBA_8888:
|
case HAL_PIXEL_FORMAT_RGBA_8888:
|
||||||
|
@ -74,11 +81,9 @@ static bool isPossiblyYUV(PixelFormat format) {
|
||||||
case HAL_PIXEL_FORMAT_RGB_888:
|
case HAL_PIXEL_FORMAT_RGB_888:
|
||||||
case HAL_PIXEL_FORMAT_RGB_565:
|
case HAL_PIXEL_FORMAT_RGB_565:
|
||||||
case HAL_PIXEL_FORMAT_BGRA_8888:
|
case HAL_PIXEL_FORMAT_BGRA_8888:
|
||||||
case HAL_PIXEL_FORMAT_sRGB_A_8888:
|
|
||||||
case HAL_PIXEL_FORMAT_sRGB_X_8888:
|
|
||||||
case HAL_PIXEL_FORMAT_Y8:
|
case HAL_PIXEL_FORMAT_Y8:
|
||||||
case HAL_PIXEL_FORMAT_Y16:
|
case HAL_PIXEL_FORMAT_Y16:
|
||||||
case HAL_PIXEL_FORMAT_RAW16: // same as HAL_PIXEL_FORMAT_RAW_SENSOR
|
case HAL_PIXEL_FORMAT_RAW16:
|
||||||
case HAL_PIXEL_FORMAT_RAW10:
|
case HAL_PIXEL_FORMAT_RAW10:
|
||||||
case HAL_PIXEL_FORMAT_RAW_OPAQUE:
|
case HAL_PIXEL_FORMAT_RAW_OPAQUE:
|
||||||
case HAL_PIXEL_FORMAT_BLOB:
|
case HAL_PIXEL_FORMAT_BLOB:
|
||||||
|
@ -200,6 +205,7 @@ status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) {
|
||||||
nativeBuffer->transform = b.mTransform;
|
nativeBuffer->transform = b.mTransform;
|
||||||
nativeBuffer->scalingMode = b.mScalingMode;
|
nativeBuffer->scalingMode = b.mScalingMode;
|
||||||
nativeBuffer->timestamp = b.mTimestamp;
|
nativeBuffer->timestamp = b.mTimestamp;
|
||||||
|
nativeBuffer->dataSpace = b.mDataSpace;
|
||||||
nativeBuffer->frameNumber = b.mFrameNumber;
|
nativeBuffer->frameNumber = b.mFrameNumber;
|
||||||
|
|
||||||
nativeBuffer->dataCb = reinterpret_cast<uint8_t*>(ycbcr.cb);
|
nativeBuffer->dataCb = reinterpret_cast<uint8_t*>(ycbcr.cb);
|
||||||
|
|
|
@ -1023,6 +1023,12 @@ status_t GLConsumer::setDefaultBufferFormat(PixelFormat defaultFormat) {
|
||||||
return mConsumer->setDefaultBufferFormat(defaultFormat);
|
return mConsumer->setDefaultBufferFormat(defaultFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status_t GLConsumer::setDefaultBufferDataSpace(
|
||||||
|
android_dataspace defaultDataSpace) {
|
||||||
|
Mutex::Autolock lock(mMutex);
|
||||||
|
return mConsumer->setDefaultBufferDataSpace(defaultDataSpace);
|
||||||
|
}
|
||||||
|
|
||||||
status_t GLConsumer::setConsumerUsageBits(uint32_t usage) {
|
status_t GLConsumer::setConsumerUsageBits(uint32_t usage) {
|
||||||
Mutex::Autolock lock(mMutex);
|
Mutex::Autolock lock(mMutex);
|
||||||
usage |= DEFAULT_USAGE_FLAGS;
|
usage |= DEFAULT_USAGE_FLAGS;
|
||||||
|
|
|
@ -39,6 +39,7 @@ IGraphicBufferConsumer::BufferItem::BufferItem() :
|
||||||
mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
|
mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
|
||||||
mTimestamp(0),
|
mTimestamp(0),
|
||||||
mIsAutoTimestamp(false),
|
mIsAutoTimestamp(false),
|
||||||
|
mDataSpace(HAL_DATASPACE_UNKNOWN),
|
||||||
mFrameNumber(0),
|
mFrameNumber(0),
|
||||||
mBuf(INVALID_BUFFER_SLOT),
|
mBuf(INVALID_BUFFER_SLOT),
|
||||||
mIsDroppable(false),
|
mIsDroppable(false),
|
||||||
|
@ -53,6 +54,7 @@ size_t IGraphicBufferConsumer::BufferItem::getPodSize() const {
|
||||||
sizeof(mScalingMode) +
|
sizeof(mScalingMode) +
|
||||||
sizeof(mTimestamp) +
|
sizeof(mTimestamp) +
|
||||||
sizeof(mIsAutoTimestamp) +
|
sizeof(mIsAutoTimestamp) +
|
||||||
|
sizeof(mDataSpace) +
|
||||||
sizeof(mFrameNumber) +
|
sizeof(mFrameNumber) +
|
||||||
sizeof(mBuf) +
|
sizeof(mBuf) +
|
||||||
sizeof(mIsDroppable) +
|
sizeof(mIsDroppable) +
|
||||||
|
@ -133,6 +135,7 @@ status_t IGraphicBufferConsumer::BufferItem::flatten(
|
||||||
FlattenableUtils::write(buffer, size, mScalingMode);
|
FlattenableUtils::write(buffer, size, mScalingMode);
|
||||||
FlattenableUtils::write(buffer, size, mTimestamp);
|
FlattenableUtils::write(buffer, size, mTimestamp);
|
||||||
writeBoolAsInt(buffer, size, mIsAutoTimestamp);
|
writeBoolAsInt(buffer, size, mIsAutoTimestamp);
|
||||||
|
FlattenableUtils::write(buffer, size, mDataSpace);
|
||||||
FlattenableUtils::write(buffer, size, mFrameNumber);
|
FlattenableUtils::write(buffer, size, mFrameNumber);
|
||||||
FlattenableUtils::write(buffer, size, mBuf);
|
FlattenableUtils::write(buffer, size, mBuf);
|
||||||
writeBoolAsInt(buffer, size, mIsDroppable);
|
writeBoolAsInt(buffer, size, mIsDroppable);
|
||||||
|
@ -175,6 +178,7 @@ status_t IGraphicBufferConsumer::BufferItem::unflatten(
|
||||||
FlattenableUtils::read(buffer, size, mScalingMode);
|
FlattenableUtils::read(buffer, size, mScalingMode);
|
||||||
FlattenableUtils::read(buffer, size, mTimestamp);
|
FlattenableUtils::read(buffer, size, mTimestamp);
|
||||||
mIsAutoTimestamp = readBoolFromInt(buffer, size);
|
mIsAutoTimestamp = readBoolFromInt(buffer, size);
|
||||||
|
FlattenableUtils::read(buffer, size, mDataSpace);
|
||||||
FlattenableUtils::read(buffer, size, mFrameNumber);
|
FlattenableUtils::read(buffer, size, mFrameNumber);
|
||||||
FlattenableUtils::read(buffer, size, mBuf);
|
FlattenableUtils::read(buffer, size, mBuf);
|
||||||
mIsDroppable = readBoolFromInt(buffer, size);
|
mIsDroppable = readBoolFromInt(buffer, size);
|
||||||
|
@ -200,6 +204,7 @@ enum {
|
||||||
SET_MAX_ACQUIRED_BUFFER_COUNT,
|
SET_MAX_ACQUIRED_BUFFER_COUNT,
|
||||||
SET_CONSUMER_NAME,
|
SET_CONSUMER_NAME,
|
||||||
SET_DEFAULT_BUFFER_FORMAT,
|
SET_DEFAULT_BUFFER_FORMAT,
|
||||||
|
SET_DEFAULT_BUFFER_DATA_SPACE,
|
||||||
SET_CONSUMER_USAGE_BITS,
|
SET_CONSUMER_USAGE_BITS,
|
||||||
SET_TRANSFORM_HINT,
|
SET_TRANSFORM_HINT,
|
||||||
GET_SIDEBAND_STREAM,
|
GET_SIDEBAND_STREAM,
|
||||||
|
@ -371,6 +376,19 @@ public:
|
||||||
return reply.readInt32();
|
return reply.readInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual status_t setDefaultBufferDataSpace(
|
||||||
|
android_dataspace defaultDataSpace) {
|
||||||
|
Parcel data, reply;
|
||||||
|
data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
|
||||||
|
data.writeInt32(static_cast<int32_t>(defaultDataSpace));
|
||||||
|
status_t result = remote()->transact(SET_DEFAULT_BUFFER_DATA_SPACE,
|
||||||
|
data, &reply);
|
||||||
|
if (result != NO_ERROR) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return reply.readInt32();
|
||||||
|
}
|
||||||
|
|
||||||
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());
|
||||||
|
@ -530,6 +548,14 @@ status_t BnGraphicBufferConsumer::onTransact(
|
||||||
reply->writeInt32(result);
|
reply->writeInt32(result);
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
case SET_DEFAULT_BUFFER_DATA_SPACE: {
|
||||||
|
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
|
||||||
|
android_dataspace defaultDataSpace =
|
||||||
|
static_cast<android_dataspace>(data.readInt32());
|
||||||
|
status_t result = setDefaultBufferDataSpace(defaultDataSpace);
|
||||||
|
reply->writeInt32(result);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
case SET_CONSUMER_USAGE_BITS: {
|
case SET_CONSUMER_USAGE_BITS: {
|
||||||
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
|
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
|
||||||
uint32_t usage = data.readUint32();
|
uint32_t usage = data.readUint32();
|
||||||
|
|
|
@ -440,6 +440,7 @@ IGraphicBufferProducer::QueueBufferInput::QueueBufferInput(const Parcel& parcel)
|
||||||
size_t IGraphicBufferProducer::QueueBufferInput::getFlattenedSize() const {
|
size_t IGraphicBufferProducer::QueueBufferInput::getFlattenedSize() const {
|
||||||
return sizeof(timestamp)
|
return sizeof(timestamp)
|
||||||
+ sizeof(isAutoTimestamp)
|
+ sizeof(isAutoTimestamp)
|
||||||
|
+ sizeof(dataSpace)
|
||||||
+ sizeof(crop)
|
+ sizeof(crop)
|
||||||
+ sizeof(scalingMode)
|
+ sizeof(scalingMode)
|
||||||
+ sizeof(transform)
|
+ sizeof(transform)
|
||||||
|
@ -460,6 +461,7 @@ status_t IGraphicBufferProducer::QueueBufferInput::flatten(
|
||||||
}
|
}
|
||||||
FlattenableUtils::write(buffer, size, timestamp);
|
FlattenableUtils::write(buffer, size, timestamp);
|
||||||
FlattenableUtils::write(buffer, size, isAutoTimestamp);
|
FlattenableUtils::write(buffer, size, isAutoTimestamp);
|
||||||
|
FlattenableUtils::write(buffer, size, dataSpace);
|
||||||
FlattenableUtils::write(buffer, size, crop);
|
FlattenableUtils::write(buffer, size, crop);
|
||||||
FlattenableUtils::write(buffer, size, scalingMode);
|
FlattenableUtils::write(buffer, size, scalingMode);
|
||||||
FlattenableUtils::write(buffer, size, transform);
|
FlattenableUtils::write(buffer, size, transform);
|
||||||
|
@ -474,6 +476,7 @@ status_t IGraphicBufferProducer::QueueBufferInput::unflatten(
|
||||||
size_t minNeeded =
|
size_t minNeeded =
|
||||||
sizeof(timestamp)
|
sizeof(timestamp)
|
||||||
+ sizeof(isAutoTimestamp)
|
+ sizeof(isAutoTimestamp)
|
||||||
|
+ sizeof(dataSpace)
|
||||||
+ sizeof(crop)
|
+ sizeof(crop)
|
||||||
+ sizeof(scalingMode)
|
+ sizeof(scalingMode)
|
||||||
+ sizeof(transform)
|
+ sizeof(transform)
|
||||||
|
@ -486,6 +489,7 @@ status_t IGraphicBufferProducer::QueueBufferInput::unflatten(
|
||||||
|
|
||||||
FlattenableUtils::read(buffer, size, timestamp);
|
FlattenableUtils::read(buffer, size, timestamp);
|
||||||
FlattenableUtils::read(buffer, size, isAutoTimestamp);
|
FlattenableUtils::read(buffer, size, isAutoTimestamp);
|
||||||
|
FlattenableUtils::read(buffer, size, dataSpace);
|
||||||
FlattenableUtils::read(buffer, size, crop);
|
FlattenableUtils::read(buffer, size, crop);
|
||||||
FlattenableUtils::read(buffer, size, scalingMode);
|
FlattenableUtils::read(buffer, size, scalingMode);
|
||||||
FlattenableUtils::read(buffer, size, transform);
|
FlattenableUtils::read(buffer, size, transform);
|
||||||
|
|
|
@ -141,7 +141,8 @@ void StreamSplitter::onFrameAvailable(const BufferItem& /* item */) {
|
||||||
|
|
||||||
IGraphicBufferProducer::QueueBufferInput queueInput(
|
IGraphicBufferProducer::QueueBufferInput queueInput(
|
||||||
bufferItem.mTimestamp, bufferItem.mIsAutoTimestamp,
|
bufferItem.mTimestamp, bufferItem.mIsAutoTimestamp,
|
||||||
bufferItem.mCrop, static_cast<int32_t>(bufferItem.mScalingMode),
|
bufferItem.mDataSpace, bufferItem.mCrop,
|
||||||
|
static_cast<int32_t>(bufferItem.mScalingMode),
|
||||||
bufferItem.mTransform, bufferItem.mIsDroppable,
|
bufferItem.mTransform, bufferItem.mIsDroppable,
|
||||||
bufferItem.mFence);
|
bufferItem.mFence);
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@ Surface::Surface(
|
||||||
mReqFormat = 0;
|
mReqFormat = 0;
|
||||||
mReqUsage = 0;
|
mReqUsage = 0;
|
||||||
mTimestamp = NATIVE_WINDOW_TIMESTAMP_AUTO;
|
mTimestamp = NATIVE_WINDOW_TIMESTAMP_AUTO;
|
||||||
|
mDataSpace = HAL_DATASPACE_UNKNOWN;
|
||||||
mCrop.clear();
|
mCrop.clear();
|
||||||
mScalingMode = NATIVE_WINDOW_SCALING_MODE_FREEZE;
|
mScalingMode = NATIVE_WINDOW_SCALING_MODE_FREEZE;
|
||||||
mTransform = 0;
|
mTransform = 0;
|
||||||
|
@ -317,8 +318,8 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) {
|
||||||
sp<Fence> fence(fenceFd >= 0 ? new Fence(fenceFd) : Fence::NO_FENCE);
|
sp<Fence> fence(fenceFd >= 0 ? new Fence(fenceFd) : Fence::NO_FENCE);
|
||||||
IGraphicBufferProducer::QueueBufferOutput output;
|
IGraphicBufferProducer::QueueBufferOutput output;
|
||||||
IGraphicBufferProducer::QueueBufferInput input(timestamp, isAutoTimestamp,
|
IGraphicBufferProducer::QueueBufferInput input(timestamp, isAutoTimestamp,
|
||||||
crop, mScalingMode, mTransform ^ mStickyTransform, mSwapIntervalZero,
|
mDataSpace, crop, mScalingMode, mTransform ^ mStickyTransform,
|
||||||
fence, mStickyTransform);
|
mSwapIntervalZero, fence, mStickyTransform);
|
||||||
status_t err = mGraphicBufferProducer->queueBuffer(i, input, &output);
|
status_t err = mGraphicBufferProducer->queueBuffer(i, input, &output);
|
||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
ALOGE("queueBuffer: error queuing buffer to SurfaceTexture, %d", err);
|
ALOGE("queueBuffer: error queuing buffer to SurfaceTexture, %d", err);
|
||||||
|
@ -449,6 +450,9 @@ int Surface::perform(int operation, va_list args)
|
||||||
case NATIVE_WINDOW_SET_SIDEBAND_STREAM:
|
case NATIVE_WINDOW_SET_SIDEBAND_STREAM:
|
||||||
res = dispatchSetSidebandStream(args);
|
res = dispatchSetSidebandStream(args);
|
||||||
break;
|
break;
|
||||||
|
case NATIVE_WINDOW_SET_BUFFERS_DATASPACE:
|
||||||
|
res = dispatchSetBuffersDataSpace(args);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
res = NAME_NOT_FOUND;
|
res = NAME_NOT_FOUND;
|
||||||
break;
|
break;
|
||||||
|
@ -546,6 +550,12 @@ int Surface::dispatchSetSidebandStream(va_list args) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Surface::dispatchSetBuffersDataSpace(va_list args) {
|
||||||
|
android_dataspace dataspace =
|
||||||
|
static_cast<android_dataspace>(va_arg(args, int));
|
||||||
|
return setBuffersDataSpace(dataspace);
|
||||||
|
}
|
||||||
|
|
||||||
int Surface::connect(int api) {
|
int Surface::connect(int api) {
|
||||||
ATRACE_CALL();
|
ATRACE_CALL();
|
||||||
ALOGV("Surface::connect");
|
ALOGV("Surface::connect");
|
||||||
|
@ -723,6 +733,14 @@ int Surface::setBuffersTimestamp(int64_t timestamp)
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Surface::setBuffersDataSpace(android_dataspace dataSpace)
|
||||||
|
{
|
||||||
|
ALOGV("Surface::setBuffersDataSpace");
|
||||||
|
Mutex::Autolock lock(mMutex);
|
||||||
|
mDataSpace = dataSpace;
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
void Surface::freeAllBuffers() {
|
void Surface::freeAllBuffers() {
|
||||||
for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
|
for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
|
||||||
mSlots[i].buffer = 0;
|
mSlots[i].buffer = 0;
|
||||||
|
|
|
@ -124,7 +124,8 @@ TEST_F(BufferQueueTest, BufferQueueInAnotherProcess) {
|
||||||
*dataIn = 0x12345678;
|
*dataIn = 0x12345678;
|
||||||
ASSERT_EQ(OK, buffer->unlock());
|
ASSERT_EQ(OK, buffer->unlock());
|
||||||
|
|
||||||
IGraphicBufferProducer::QueueBufferInput input(0, false, Rect(0, 0, 1, 1),
|
IGraphicBufferProducer::QueueBufferInput input(0, false,
|
||||||
|
HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
|
||||||
NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
|
NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
|
||||||
ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
|
ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
|
||||||
|
|
||||||
|
@ -150,7 +151,8 @@ TEST_F(BufferQueueTest, AcquireBuffer_ExceedsMaxAcquireCount_Fails) {
|
||||||
int slot;
|
int slot;
|
||||||
sp<Fence> fence;
|
sp<Fence> fence;
|
||||||
sp<GraphicBuffer> buf;
|
sp<GraphicBuffer> buf;
|
||||||
IGraphicBufferProducer::QueueBufferInput qbi(0, false, Rect(0, 0, 1, 1),
|
IGraphicBufferProducer::QueueBufferInput qbi(0, false,
|
||||||
|
HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
|
||||||
NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
|
NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
|
||||||
BufferQueue::BufferItem item;
|
BufferQueue::BufferItem item;
|
||||||
|
|
||||||
|
@ -244,7 +246,8 @@ TEST_F(BufferQueueTest, DetachAndReattachOnProducerSide) {
|
||||||
ASSERT_EQ(BAD_VALUE, mProducer->attachBuffer(&newSlot, NULL));
|
ASSERT_EQ(BAD_VALUE, mProducer->attachBuffer(&newSlot, NULL));
|
||||||
|
|
||||||
ASSERT_EQ(OK, mProducer->attachBuffer(&newSlot, buffer));
|
ASSERT_EQ(OK, mProducer->attachBuffer(&newSlot, buffer));
|
||||||
IGraphicBufferProducer::QueueBufferInput input(0, false, Rect(0, 0, 1, 1),
|
IGraphicBufferProducer::QueueBufferInput input(0, false,
|
||||||
|
HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
|
||||||
NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
|
NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
|
||||||
ASSERT_EQ(OK, mProducer->queueBuffer(newSlot, input, &output));
|
ASSERT_EQ(OK, mProducer->queueBuffer(newSlot, input, &output));
|
||||||
|
|
||||||
|
@ -273,7 +276,8 @@ TEST_F(BufferQueueTest, DetachAndReattachOnConsumerSide) {
|
||||||
mProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
|
mProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
|
||||||
GRALLOC_USAGE_SW_WRITE_OFTEN));
|
GRALLOC_USAGE_SW_WRITE_OFTEN));
|
||||||
ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buffer));
|
ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buffer));
|
||||||
IGraphicBufferProducer::QueueBufferInput input(0, false, Rect(0, 0, 1, 1),
|
IGraphicBufferProducer::QueueBufferInput input(0, false,
|
||||||
|
HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
|
||||||
NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
|
NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
|
||||||
ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
|
ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
|
||||||
|
|
||||||
|
@ -338,7 +342,8 @@ TEST_F(BufferQueueTest, MoveFromConsumerToProducer) {
|
||||||
*dataIn = 0x12345678;
|
*dataIn = 0x12345678;
|
||||||
ASSERT_EQ(OK, buffer->unlock());
|
ASSERT_EQ(OK, buffer->unlock());
|
||||||
|
|
||||||
IGraphicBufferProducer::QueueBufferInput input(0, false, Rect(0, 0, 1, 1),
|
IGraphicBufferProducer::QueueBufferInput input(0, false,
|
||||||
|
HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
|
||||||
NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
|
NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
|
||||||
ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
|
ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ void checkPixel(const CpuConsumer::LockedBuffer &buf,
|
||||||
uint32_t x, uint32_t y, uint32_t r, uint32_t g=0, uint32_t b=0) {
|
uint32_t x, uint32_t y, uint32_t r, uint32_t g=0, uint32_t b=0) {
|
||||||
// Ignores components that don't exist for given pixel
|
// Ignores components that don't exist for given pixel
|
||||||
switch(buf.format) {
|
switch(buf.format) {
|
||||||
case HAL_PIXEL_FORMAT_RAW_SENSOR: {
|
case HAL_PIXEL_FORMAT_RAW16: {
|
||||||
String8 msg;
|
String8 msg;
|
||||||
uint16_t *bPtr = (uint16_t*)buf.data;
|
uint16_t *bPtr = (uint16_t*)buf.data;
|
||||||
bPtr += y * buf.stride + x;
|
bPtr += y * buf.stride + x;
|
||||||
|
@ -429,7 +429,7 @@ void checkBayerRawBuffer(const CpuConsumer::LockedBuffer &buf) {
|
||||||
|
|
||||||
void checkAnyBuffer(const CpuConsumer::LockedBuffer &buf, int format) {
|
void checkAnyBuffer(const CpuConsumer::LockedBuffer &buf, int format) {
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case HAL_PIXEL_FORMAT_RAW_SENSOR:
|
case HAL_PIXEL_FORMAT_RAW16:
|
||||||
checkBayerRawBuffer(buf);
|
checkBayerRawBuffer(buf);
|
||||||
break;
|
break;
|
||||||
case HAL_PIXEL_FORMAT_Y8:
|
case HAL_PIXEL_FORMAT_Y8:
|
||||||
|
@ -505,7 +505,7 @@ void produceOneFrame(const sp<ANativeWindow>& anw,
|
||||||
case HAL_PIXEL_FORMAT_YV12:
|
case HAL_PIXEL_FORMAT_YV12:
|
||||||
fillYV12Buffer(img, params.width, params.height, *stride);
|
fillYV12Buffer(img, params.width, params.height, *stride);
|
||||||
break;
|
break;
|
||||||
case HAL_PIXEL_FORMAT_RAW_SENSOR:
|
case HAL_PIXEL_FORMAT_RAW16:
|
||||||
fillBayerRawBuffer(img, params.width, params.height, buf->getStride());
|
fillBayerRawBuffer(img, params.width, params.height, buf->getStride());
|
||||||
break;
|
break;
|
||||||
case HAL_PIXEL_FORMAT_Y8:
|
case HAL_PIXEL_FORMAT_Y8:
|
||||||
|
@ -537,7 +537,7 @@ void produceOneFrame(const sp<ANativeWindow>& anw,
|
||||||
ASSERT_NO_ERROR(err, "queueBuffer error:");
|
ASSERT_NO_ERROR(err, "queueBuffer error:");
|
||||||
};
|
};
|
||||||
|
|
||||||
// This test is disabled because the HAL_PIXEL_FORMAT_RAW_SENSOR format is not
|
// This test is disabled because the HAL_PIXEL_FORMAT_RAW16 format is not
|
||||||
// supported on all devices.
|
// supported on all devices.
|
||||||
TEST_P(CpuConsumerTest, FromCpuSingle) {
|
TEST_P(CpuConsumerTest, FromCpuSingle) {
|
||||||
status_t err;
|
status_t err;
|
||||||
|
@ -571,7 +571,7 @@ TEST_P(CpuConsumerTest, FromCpuSingle) {
|
||||||
mCC->unlockBuffer(b);
|
mCC->unlockBuffer(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This test is disabled because the HAL_PIXEL_FORMAT_RAW_SENSOR format is not
|
// This test is disabled because the HAL_PIXEL_FORMAT_RAW16 format is not
|
||||||
// supported on all devices.
|
// supported on all devices.
|
||||||
TEST_P(CpuConsumerTest, FromCpuManyInQueue) {
|
TEST_P(CpuConsumerTest, FromCpuManyInQueue) {
|
||||||
status_t err;
|
status_t err;
|
||||||
|
@ -614,7 +614,7 @@ TEST_P(CpuConsumerTest, FromCpuManyInQueue) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This test is disabled because the HAL_PIXEL_FORMAT_RAW_SENSOR format is not
|
// This test is disabled because the HAL_PIXEL_FORMAT_RAW16 format is not
|
||||||
// supported on all devices.
|
// supported on all devices.
|
||||||
TEST_P(CpuConsumerTest, FromCpuLockMax) {
|
TEST_P(CpuConsumerTest, FromCpuLockMax) {
|
||||||
status_t err;
|
status_t err;
|
||||||
|
@ -710,12 +710,12 @@ CpuConsumerTestParams y16TestSets[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
CpuConsumerTestParams rawTestSets[] = {
|
CpuConsumerTestParams rawTestSets[] = {
|
||||||
{ 512, 512, 1, HAL_PIXEL_FORMAT_RAW_SENSOR},
|
{ 512, 512, 1, HAL_PIXEL_FORMAT_RAW16},
|
||||||
{ 512, 512, 3, HAL_PIXEL_FORMAT_RAW_SENSOR},
|
{ 512, 512, 3, HAL_PIXEL_FORMAT_RAW16},
|
||||||
{ 2608, 1960, 1, HAL_PIXEL_FORMAT_RAW_SENSOR},
|
{ 2608, 1960, 1, HAL_PIXEL_FORMAT_RAW16},
|
||||||
{ 2608, 1960, 3, HAL_PIXEL_FORMAT_RAW_SENSOR},
|
{ 2608, 1960, 3, HAL_PIXEL_FORMAT_RAW16},
|
||||||
{ 100, 100, 1, HAL_PIXEL_FORMAT_RAW_SENSOR},
|
{ 100, 100, 1, HAL_PIXEL_FORMAT_RAW16},
|
||||||
{ 100, 100, 3, HAL_PIXEL_FORMAT_RAW_SENSOR},
|
{ 100, 100, 3, HAL_PIXEL_FORMAT_RAW16},
|
||||||
};
|
};
|
||||||
|
|
||||||
CpuConsumerTestParams rgba8888TestSets[] = {
|
CpuConsumerTestParams rgba8888TestSets[] = {
|
||||||
|
|
|
@ -57,6 +57,7 @@ namespace {
|
||||||
// Parameters for a generic "valid" input for queueBuffer.
|
// Parameters for a generic "valid" input for queueBuffer.
|
||||||
const int64_t QUEUE_BUFFER_INPUT_TIMESTAMP = 1384888611;
|
const int64_t QUEUE_BUFFER_INPUT_TIMESTAMP = 1384888611;
|
||||||
const bool QUEUE_BUFFER_INPUT_IS_AUTO_TIMESTAMP = false;
|
const bool QUEUE_BUFFER_INPUT_IS_AUTO_TIMESTAMP = false;
|
||||||
|
const android_dataspace QUEUE_BUFFER_INPUT_DATASPACE = HAL_DATASPACE_UNKNOWN;
|
||||||
const Rect QUEUE_BUFFER_INPUT_RECT = Rect(DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
const Rect QUEUE_BUFFER_INPUT_RECT = Rect(DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
||||||
const int QUEUE_BUFFER_INPUT_SCALING_MODE = 0;
|
const int QUEUE_BUFFER_INPUT_SCALING_MODE = 0;
|
||||||
const int QUEUE_BUFFER_INPUT_TRANSFORM = 0;
|
const int QUEUE_BUFFER_INPUT_TRANSFORM = 0;
|
||||||
|
@ -126,6 +127,7 @@ protected:
|
||||||
QueueBufferInputBuilder() {
|
QueueBufferInputBuilder() {
|
||||||
timestamp = QUEUE_BUFFER_INPUT_TIMESTAMP;
|
timestamp = QUEUE_BUFFER_INPUT_TIMESTAMP;
|
||||||
isAutoTimestamp = QUEUE_BUFFER_INPUT_IS_AUTO_TIMESTAMP;
|
isAutoTimestamp = QUEUE_BUFFER_INPUT_IS_AUTO_TIMESTAMP;
|
||||||
|
dataSpace = QUEUE_BUFFER_INPUT_DATASPACE;
|
||||||
crop = QUEUE_BUFFER_INPUT_RECT;
|
crop = QUEUE_BUFFER_INPUT_RECT;
|
||||||
scalingMode = QUEUE_BUFFER_INPUT_SCALING_MODE;
|
scalingMode = QUEUE_BUFFER_INPUT_SCALING_MODE;
|
||||||
transform = QUEUE_BUFFER_INPUT_TRANSFORM;
|
transform = QUEUE_BUFFER_INPUT_TRANSFORM;
|
||||||
|
@ -137,6 +139,7 @@ protected:
|
||||||
return IGraphicBufferProducer::QueueBufferInput(
|
return IGraphicBufferProducer::QueueBufferInput(
|
||||||
timestamp,
|
timestamp,
|
||||||
isAutoTimestamp,
|
isAutoTimestamp,
|
||||||
|
dataSpace,
|
||||||
crop,
|
crop,
|
||||||
scalingMode,
|
scalingMode,
|
||||||
transform,
|
transform,
|
||||||
|
@ -154,6 +157,11 @@ protected:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QueueBufferInputBuilder& setDataSpace(android_dataspace dataSpace) {
|
||||||
|
this->dataSpace = dataSpace;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
QueueBufferInputBuilder& setCrop(Rect crop) {
|
QueueBufferInputBuilder& setCrop(Rect crop) {
|
||||||
this->crop = crop;
|
this->crop = crop;
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -182,6 +190,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
int64_t timestamp;
|
int64_t timestamp;
|
||||||
bool isAutoTimestamp;
|
bool isAutoTimestamp;
|
||||||
|
android_dataspace dataSpace;
|
||||||
Rect crop;
|
Rect crop;
|
||||||
int scalingMode;
|
int scalingMode;
|
||||||
uint32_t transform;
|
uint32_t transform;
|
||||||
|
|
|
@ -214,10 +214,11 @@ protected:
|
||||||
ASSERT_EQ(GL_NO_ERROR, glGetError());
|
ASSERT_EQ(GL_NO_ERROR, glGetError());
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkLockedBuffer(PixelFormat format) {
|
void checkLockedBuffer(PixelFormat format, android_dataspace dataSpace) {
|
||||||
ASSERT_EQ(mLockedBuffer.format, format);
|
ASSERT_EQ(mLockedBuffer.format, format);
|
||||||
ASSERT_EQ(mLockedBuffer.width, DISPLAY_WIDTH);
|
ASSERT_EQ(mLockedBuffer.width, DISPLAY_WIDTH);
|
||||||
ASSERT_EQ(mLockedBuffer.height, DISPLAY_HEIGHT);
|
ASSERT_EQ(mLockedBuffer.height, DISPLAY_HEIGHT);
|
||||||
|
ASSERT_EQ(mLockedBuffer.dataSpace, dataSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool withinTolerance(int a, int b) {
|
static bool withinTolerance(int a, int b) {
|
||||||
|
@ -335,7 +336,8 @@ private:
|
||||||
if (mLockedBuffer.format == outBuffer.format) {
|
if (mLockedBuffer.format == outBuffer.format) {
|
||||||
memcpy(outBuffer.bits, mLockedBuffer.data, bufferSize);
|
memcpy(outBuffer.bits, mLockedBuffer.data, bufferSize);
|
||||||
} else {
|
} else {
|
||||||
ASSERT_EQ(mLockedBuffer.format, PIXEL_FORMAT_sRGB_A_8888);
|
ASSERT_EQ(mLockedBuffer.format, PIXEL_FORMAT_RGBA_8888);
|
||||||
|
ASSERT_EQ(mLockedBuffer.dataSpace, HAL_DATASPACE_SRGB);
|
||||||
ASSERT_EQ(outBuffer.format, PIXEL_FORMAT_RGBA_8888);
|
ASSERT_EQ(outBuffer.format, PIXEL_FORMAT_RGBA_8888);
|
||||||
uint8_t* outPointer = reinterpret_cast<uint8_t*>(outBuffer.bits);
|
uint8_t* outPointer = reinterpret_cast<uint8_t*>(outBuffer.bits);
|
||||||
for (int y = 0; y < outBuffer.height; ++y) {
|
for (int y = 0; y < outBuffer.height; ++y) {
|
||||||
|
@ -380,7 +382,8 @@ TEST_F(SRGBTest, GLRenderFromSRGBTexture) {
|
||||||
|
|
||||||
// Lock
|
// Lock
|
||||||
ASSERT_EQ(NO_ERROR, mCpuConsumer->lockNextBuffer(&mLockedBuffer));
|
ASSERT_EQ(NO_ERROR, mCpuConsumer->lockNextBuffer(&mLockedBuffer));
|
||||||
ASSERT_NO_FATAL_FAILURE(checkLockedBuffer(PIXEL_FORMAT_RGBA_8888));
|
ASSERT_NO_FATAL_FAILURE(
|
||||||
|
checkLockedBuffer(PIXEL_FORMAT_RGBA_8888, HAL_DATASPACE_UNKNOWN));
|
||||||
|
|
||||||
// Compare a pixel in the middle of each texture
|
// Compare a pixel in the middle of each texture
|
||||||
int midSRGBOffset = (DISPLAY_HEIGHT / 4) * mLockedBuffer.stride *
|
int midSRGBOffset = (DISPLAY_HEIGHT / 4) * mLockedBuffer.stride *
|
||||||
|
@ -411,7 +414,8 @@ TEST_F(SRGBTest, RenderToSRGBSurface) {
|
||||||
|
|
||||||
// Lock
|
// Lock
|
||||||
ASSERT_EQ(NO_ERROR, mCpuConsumer->lockNextBuffer(&mLockedBuffer));
|
ASSERT_EQ(NO_ERROR, mCpuConsumer->lockNextBuffer(&mLockedBuffer));
|
||||||
ASSERT_NO_FATAL_FAILURE(checkLockedBuffer(PIXEL_FORMAT_RGBA_8888));
|
ASSERT_NO_FATAL_FAILURE(
|
||||||
|
checkLockedBuffer(PIXEL_FORMAT_RGBA_8888, HAL_DATASPACE_UNKNOWN));
|
||||||
|
|
||||||
// Save the values of the middle pixel for later comparison against SRGB
|
// Save the values of the middle pixel for later comparison against SRGB
|
||||||
uint8_t values[PIXEL_SIZE] = {};
|
uint8_t values[PIXEL_SIZE] = {};
|
||||||
|
@ -460,7 +464,8 @@ TEST_F(SRGBTest, RenderToSRGBSurface) {
|
||||||
ASSERT_EQ(NO_ERROR, mCpuConsumer->lockNextBuffer(&mLockedBuffer));
|
ASSERT_EQ(NO_ERROR, mCpuConsumer->lockNextBuffer(&mLockedBuffer));
|
||||||
|
|
||||||
// Make sure we actually got the SRGB buffer on the consumer side
|
// Make sure we actually got the SRGB buffer on the consumer side
|
||||||
ASSERT_NO_FATAL_FAILURE(checkLockedBuffer(PIXEL_FORMAT_sRGB_A_8888));
|
ASSERT_NO_FATAL_FAILURE(
|
||||||
|
checkLockedBuffer(PIXEL_FORMAT_RGBA_8888, HAL_DATASPACE_SRGB));
|
||||||
|
|
||||||
// Verify that the stored value is the same, accounting for RGB/SRGB
|
// Verify that the stored value is the same, accounting for RGB/SRGB
|
||||||
for (int c = 0; c < PIXEL_SIZE; ++c) {
|
for (int c = 0; c < PIXEL_SIZE; ++c) {
|
||||||
|
|
|
@ -111,6 +111,7 @@ TEST_F(StreamSplitterTest, OneInputOneOutput) {
|
||||||
ASSERT_EQ(OK, buffer->unlock());
|
ASSERT_EQ(OK, buffer->unlock());
|
||||||
|
|
||||||
IGraphicBufferProducer::QueueBufferInput qbInput(0, false,
|
IGraphicBufferProducer::QueueBufferInput qbInput(0, false,
|
||||||
|
HAL_DATASPACE_UNKNOWN,
|
||||||
Rect(0, 0, 1, 1), NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false,
|
Rect(0, 0, 1, 1), NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false,
|
||||||
Fence::NO_FENCE);
|
Fence::NO_FENCE);
|
||||||
ASSERT_EQ(OK, inputProducer->queueBuffer(slot, qbInput, &qbOutput));
|
ASSERT_EQ(OK, inputProducer->queueBuffer(slot, qbInput, &qbOutput));
|
||||||
|
@ -177,6 +178,7 @@ TEST_F(StreamSplitterTest, OneInputMultipleOutputs) {
|
||||||
ASSERT_EQ(OK, buffer->unlock());
|
ASSERT_EQ(OK, buffer->unlock());
|
||||||
|
|
||||||
IGraphicBufferProducer::QueueBufferInput qbInput(0, false,
|
IGraphicBufferProducer::QueueBufferInput qbInput(0, false,
|
||||||
|
HAL_DATASPACE_UNKNOWN,
|
||||||
Rect(0, 0, 1, 1), NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false,
|
Rect(0, 0, 1, 1), NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false,
|
||||||
Fence::NO_FENCE);
|
Fence::NO_FENCE);
|
||||||
ASSERT_EQ(OK, inputProducer->queueBuffer(slot, qbInput, &qbOutput));
|
ASSERT_EQ(OK, inputProducer->queueBuffer(slot, qbInput, &qbOutput));
|
||||||
|
@ -234,6 +236,7 @@ TEST_F(StreamSplitterTest, OutputAbandonment) {
|
||||||
outputConsumer->consumerDisconnect();
|
outputConsumer->consumerDisconnect();
|
||||||
|
|
||||||
IGraphicBufferProducer::QueueBufferInput qbInput(0, false,
|
IGraphicBufferProducer::QueueBufferInput qbInput(0, false,
|
||||||
|
HAL_DATASPACE_UNKNOWN,
|
||||||
Rect(0, 0, 1, 1), NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false,
|
Rect(0, 0, 1, 1), NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false,
|
||||||
Fence::NO_FENCE);
|
Fence::NO_FENCE);
|
||||||
ASSERT_EQ(OK, inputProducer->queueBuffer(slot, qbInput, &qbOutput));
|
ASSERT_EQ(OK, inputProducer->queueBuffer(slot, qbInput, &qbOutput));
|
||||||
|
|
|
@ -155,4 +155,26 @@ TEST_F(SurfaceTest, QueryConsumerUsage) {
|
||||||
ASSERT_EQ(TEST_USAGE_FLAGS, flags);
|
ASSERT_EQ(TEST_USAGE_FLAGS, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(SurfaceTest, QueryDefaultBuffersDataSpace) {
|
||||||
|
const android_dataspace TEST_DATASPACE = HAL_DATASPACE_SRGB;
|
||||||
|
sp<IGraphicBufferProducer> producer;
|
||||||
|
sp<IGraphicBufferConsumer> consumer;
|
||||||
|
BufferQueue::createBufferQueue(&producer, &consumer);
|
||||||
|
sp<CpuConsumer> cpuConsumer = new CpuConsumer(consumer, 1);
|
||||||
|
|
||||||
|
cpuConsumer->setDefaultBufferDataSpace(TEST_DATASPACE);
|
||||||
|
|
||||||
|
sp<Surface> s = new Surface(producer);
|
||||||
|
|
||||||
|
sp<ANativeWindow> anw(s);
|
||||||
|
|
||||||
|
android_dataspace dataSpace;
|
||||||
|
|
||||||
|
int err = anw->query(anw.get(), NATIVE_WINDOW_DEFAULT_DATASPACE,
|
||||||
|
reinterpret_cast<int*>(&dataSpace));
|
||||||
|
|
||||||
|
ASSERT_EQ(NO_ERROR, err);
|
||||||
|
ASSERT_EQ(TEST_DATASPACE, dataSpace);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,6 @@ uint32_t bytesPerPixel(PixelFormat format) {
|
||||||
case PIXEL_FORMAT_RGBA_8888:
|
case PIXEL_FORMAT_RGBA_8888:
|
||||||
case PIXEL_FORMAT_RGBX_8888:
|
case PIXEL_FORMAT_RGBX_8888:
|
||||||
case PIXEL_FORMAT_BGRA_8888:
|
case PIXEL_FORMAT_BGRA_8888:
|
||||||
case PIXEL_FORMAT_sRGB_A_8888:
|
|
||||||
case PIXEL_FORMAT_sRGB_X_8888:
|
|
||||||
return 4;
|
return 4;
|
||||||
case PIXEL_FORMAT_RGB_888:
|
case PIXEL_FORMAT_RGB_888:
|
||||||
return 3;
|
return 3;
|
||||||
|
@ -57,4 +55,3 @@ uint32_t bitsPerPixel(PixelFormat format) {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
}; // namespace android
|
}; // namespace android
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -381,20 +381,15 @@ EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
|
||||||
// Turn linear formats into corresponding sRGB formats when colorspace is
|
// Turn linear formats into corresponding sRGB formats when colorspace is
|
||||||
// EGL_GL_COLORSPACE_SRGB_KHR, or turn sRGB formats into corresponding linear
|
// EGL_GL_COLORSPACE_SRGB_KHR, or turn sRGB formats into corresponding linear
|
||||||
// formats when colorspace is EGL_GL_COLORSPACE_LINEAR_KHR. In any cases where
|
// formats when colorspace is EGL_GL_COLORSPACE_LINEAR_KHR. In any cases where
|
||||||
// the modification isn't possible, the original format is returned.
|
// the modification isn't possible, the original dataSpace is returned.
|
||||||
static int modifyFormatColorspace(int fmt, EGLint colorspace) {
|
static android_dataspace modifyBufferDataspace( android_dataspace dataSpace,
|
||||||
|
EGLint colorspace) {
|
||||||
if (colorspace == EGL_GL_COLORSPACE_LINEAR_KHR) {
|
if (colorspace == EGL_GL_COLORSPACE_LINEAR_KHR) {
|
||||||
switch (fmt) {
|
return HAL_DATASPACE_SRGB_LINEAR;
|
||||||
case HAL_PIXEL_FORMAT_sRGB_A_8888: return HAL_PIXEL_FORMAT_RGBA_8888;
|
|
||||||
case HAL_PIXEL_FORMAT_sRGB_X_8888: return HAL_PIXEL_FORMAT_RGBX_8888;
|
|
||||||
}
|
|
||||||
} else if (colorspace == EGL_GL_COLORSPACE_SRGB_KHR) {
|
} else if (colorspace == EGL_GL_COLORSPACE_SRGB_KHR) {
|
||||||
switch (fmt) {
|
return HAL_DATASPACE_SRGB;
|
||||||
case HAL_PIXEL_FORMAT_RGBA_8888: return HAL_PIXEL_FORMAT_sRGB_A_8888;
|
|
||||||
case HAL_PIXEL_FORMAT_RGBX_8888: return HAL_PIXEL_FORMAT_sRGB_X_8888;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return fmt;
|
return dataSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
|
EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
|
||||||
|
@ -424,6 +419,7 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
|
||||||
|
|
||||||
// by default, just pick RGBA_8888
|
// by default, just pick RGBA_8888
|
||||||
EGLint format = HAL_PIXEL_FORMAT_RGBA_8888;
|
EGLint format = HAL_PIXEL_FORMAT_RGBA_8888;
|
||||||
|
android_dataspace dataSpace = HAL_DATASPACE_UNKNOWN;
|
||||||
|
|
||||||
EGLint a = 0;
|
EGLint a = 0;
|
||||||
cnx->egl.eglGetConfigAttrib(iDpy, config, EGL_ALPHA_SIZE, &a);
|
cnx->egl.eglGetConfigAttrib(iDpy, config, EGL_ALPHA_SIZE, &a);
|
||||||
|
@ -449,7 +445,7 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
|
||||||
for (const EGLint* attr = attrib_list; *attr != EGL_NONE; attr += 2) {
|
for (const EGLint* attr = attrib_list; *attr != EGL_NONE; attr += 2) {
|
||||||
if (*attr == EGL_GL_COLORSPACE_KHR) {
|
if (*attr == EGL_GL_COLORSPACE_KHR) {
|
||||||
if (ENABLE_EGL_KHR_GL_COLORSPACE) {
|
if (ENABLE_EGL_KHR_GL_COLORSPACE) {
|
||||||
format = modifyFormatColorspace(format, *(attr+1));
|
dataSpace = modifyBufferDataspace(dataSpace, *(attr+1));
|
||||||
} else {
|
} else {
|
||||||
// Normally we'd pass through unhandled attributes to
|
// Normally we'd pass through unhandled attributes to
|
||||||
// the driver. But in case the driver implements this
|
// the driver. But in case the driver implements this
|
||||||
|
@ -473,6 +469,16 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dataSpace != 0) {
|
||||||
|
int err = native_window_set_buffers_data_space(window, dataSpace);
|
||||||
|
if (err != 0) {
|
||||||
|
ALOGE("error setting native window pixel dataSpace: %s (%d)",
|
||||||
|
strerror(-err), err);
|
||||||
|
native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL);
|
||||||
|
return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// the EGL spec requires that a new EGLSurface default to swap interval
|
// the EGL spec requires that a new EGLSurface default to swap interval
|
||||||
// 1, so explicitly set that on the window here.
|
// 1, so explicitly set that on the window here.
|
||||||
ANativeWindow* anw = reinterpret_cast<ANativeWindow*>(window);
|
ANativeWindow* anw = reinterpret_cast<ANativeWindow*>(window);
|
||||||
|
|
|
@ -1105,8 +1105,6 @@ static String8 getFormatStr(PixelFormat format) {
|
||||||
case PIXEL_FORMAT_RGB_888: return String8("RGB_888");
|
case PIXEL_FORMAT_RGB_888: return String8("RGB_888");
|
||||||
case PIXEL_FORMAT_RGB_565: return String8("RGB_565");
|
case PIXEL_FORMAT_RGB_565: return String8("RGB_565");
|
||||||
case PIXEL_FORMAT_BGRA_8888: return String8("BGRA_8888");
|
case PIXEL_FORMAT_BGRA_8888: return String8("BGRA_8888");
|
||||||
case PIXEL_FORMAT_sRGB_A_8888: return String8("sRGB_A_8888");
|
|
||||||
case PIXEL_FORMAT_sRGB_X_8888: return String8("sRGB_x_8888");
|
|
||||||
case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
|
case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
|
||||||
return String8("ImplDef");
|
return String8("ImplDef");
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -234,6 +234,7 @@ void VirtualDisplaySurface::onFrameCommitted() {
|
||||||
status_t result = mSource[SOURCE_SINK]->queueBuffer(sslot,
|
status_t result = mSource[SOURCE_SINK]->queueBuffer(sslot,
|
||||||
QueueBufferInput(
|
QueueBufferInput(
|
||||||
systemTime(), false /* isAutoTimestamp */,
|
systemTime(), false /* isAutoTimestamp */,
|
||||||
|
HAL_DATASPACE_UNKNOWN,
|
||||||
Rect(mSinkBufferWidth, mSinkBufferHeight),
|
Rect(mSinkBufferWidth, mSinkBufferHeight),
|
||||||
NATIVE_WINDOW_SCALING_MODE_FREEZE, 0 /* transform */,
|
NATIVE_WINDOW_SCALING_MODE_FREEZE, 0 /* transform */,
|
||||||
true /* async*/,
|
true /* async*/,
|
||||||
|
@ -453,12 +454,13 @@ status_t VirtualDisplaySurface::queueBuffer(int pslot,
|
||||||
// Extract the GLES release fence for HWC to acquire
|
// Extract the GLES release fence for HWC to acquire
|
||||||
int64_t timestamp;
|
int64_t timestamp;
|
||||||
bool isAutoTimestamp;
|
bool isAutoTimestamp;
|
||||||
|
android_dataspace dataSpace;
|
||||||
Rect crop;
|
Rect crop;
|
||||||
int scalingMode;
|
int scalingMode;
|
||||||
uint32_t transform;
|
uint32_t transform;
|
||||||
bool async;
|
bool async;
|
||||||
input.deflate(×tamp, &isAutoTimestamp, &crop, &scalingMode,
|
input.deflate(×tamp, &isAutoTimestamp, &dataSpace, &crop,
|
||||||
&transform, &async, &mFbFence);
|
&scalingMode, &transform, &async, &mFbFence);
|
||||||
|
|
||||||
mFbProducerSlot = pslot;
|
mFbProducerSlot = pslot;
|
||||||
mOutputFence = mFbFence;
|
mOutputFence = mFbFence;
|
||||||
|
|
|
@ -764,7 +764,6 @@ bool Layer::getOpacityForFormat(uint32_t format) {
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case HAL_PIXEL_FORMAT_RGBA_8888:
|
case HAL_PIXEL_FORMAT_RGBA_8888:
|
||||||
case HAL_PIXEL_FORMAT_BGRA_8888:
|
case HAL_PIXEL_FORMAT_BGRA_8888:
|
||||||
case HAL_PIXEL_FORMAT_sRGB_A_8888:
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// in all other case, we have no blending (also for unknown formats)
|
// in all other case, we have no blending (also for unknown formats)
|
||||||
|
|
Loading…
Reference in New Issue