diff options
author | Andy McFadden <fadden@android.com> | 2013-08-19 07:29:11 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-08-19 07:29:11 -0700 |
commit | 30290a557e596c9bd58f99f9b8a3ea10bcbc8760 (patch) | |
tree | 46698620e6a027896601ed79dc0f6ed870b0ae56 /libs/gui | |
parent | e5df9a069c4570ebe14009701bc43bdc80a358d2 (diff) | |
parent | 90f59bf9eba79b27629505bc2709d84e7c811c8b (diff) | |
download | frameworks_native-30290a557e596c9bd58f99f9b8a3ea10bcbc8760.zip frameworks_native-30290a557e596c9bd58f99f9b8a3ea10bcbc8760.tar.gz frameworks_native-30290a557e596c9bd58f99f9b8a3ea10bcbc8760.tar.bz2 |
am 90f59bf9: Merge "Re-enable frame dropping for non-auto timestamps" into klp-dev
* commit '90f59bf9eba79b27629505bc2709d84e7c811c8b':
Re-enable frame dropping for non-auto timestamps
Diffstat (limited to 'libs/gui')
-rw-r--r-- | libs/gui/BufferQueue.cpp | 12 | ||||
-rw-r--r-- | libs/gui/IGraphicBufferConsumer.cpp | 4 | ||||
-rw-r--r-- | libs/gui/IGraphicBufferProducer.cpp | 4 | ||||
-rw-r--r-- | libs/gui/Surface.cpp | 6 |
4 files changed, 22 insertions, 4 deletions
diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp index 033c2a6..65007fa 100644 --- a/libs/gui/BufferQueue.cpp +++ b/libs/gui/BufferQueue.cpp @@ -475,10 +475,12 @@ status_t BufferQueue::queueBuffer(int buf, uint32_t transform; int scalingMode; int64_t timestamp; + bool isAutoTimestamp; bool async; sp<Fence> fence; - input.deflate(×tamp, &crop, &scalingMode, &transform, &async, &fence); + input.deflate(×tamp, &isAutoTimestamp, &crop, &scalingMode, &transform, + &async, &fence); if (fence == NULL) { ST_LOGE("queueBuffer: fence is NULL"); @@ -558,6 +560,7 @@ status_t BufferQueue::queueBuffer(int buf, item.mTransform = transform; item.mScalingMode = scalingMode; item.mTimestamp = timestamp; + item.mIsAutoTimestamp = isAutoTimestamp; item.mFrameNumber = mFrameCounter; item.mBuf = buf; item.mFence = fence; @@ -860,7 +863,12 @@ status_t BufferQueue::acquireBuffer(BufferItem *buffer, nsecs_t expectedPresent) // // NOTE: code assumes monotonic time values from the system clock are // positive. - while (false && mQueue.size() > 1) { + + // Start by checking to see if we can drop frames. We skip this check + // if the timestamps are being auto-generated by Surface -- if the + // app isn't generating timestamps explicitly, they probably don't + // want frames to be discarded based on them. + while (mQueue.size() > 1 && !mQueue[0].mIsAutoTimestamp) { // If entry[1] is timely, drop entry[0] (and repeat). We apply // an additional criteria here: we only drop the earlier buffer if // our desiredPresent falls within +/- 1 second of the expected diff --git a/libs/gui/IGraphicBufferConsumer.cpp b/libs/gui/IGraphicBufferConsumer.cpp index 6d65016..4db635c 100644 --- a/libs/gui/IGraphicBufferConsumer.cpp +++ b/libs/gui/IGraphicBufferConsumer.cpp @@ -43,6 +43,7 @@ IGraphicBufferConsumer::BufferItem::BufferItem() : mTransform(0), mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE), mTimestamp(0), + mIsAutoTimestamp(false), mFrameNumber(0), mBuf(INVALID_BUFFER_SLOT), mIsDroppable(false), @@ -55,6 +56,7 @@ size_t IGraphicBufferConsumer::BufferItem::getPodSize() const { sizeof(mTransform) + sizeof(mScalingMode) + sizeof(mTimestamp) + + sizeof(mIsAutoTimestamp) + sizeof(mFrameNumber) + sizeof(mBuf) + sizeof(mIsDroppable) + @@ -123,6 +125,7 @@ status_t IGraphicBufferConsumer::BufferItem::flatten( FlattenableUtils::write(buffer, size, mTransform); FlattenableUtils::write(buffer, size, mScalingMode); FlattenableUtils::write(buffer, size, mTimestamp); + FlattenableUtils::write(buffer, size, mIsAutoTimestamp); FlattenableUtils::write(buffer, size, mFrameNumber); FlattenableUtils::write(buffer, size, mBuf); FlattenableUtils::write(buffer, size, mIsDroppable); @@ -163,6 +166,7 @@ status_t IGraphicBufferConsumer::BufferItem::unflatten( FlattenableUtils::read(buffer, size, mTransform); FlattenableUtils::read(buffer, size, mScalingMode); FlattenableUtils::read(buffer, size, mTimestamp); + FlattenableUtils::read(buffer, size, mIsAutoTimestamp); FlattenableUtils::read(buffer, size, mFrameNumber); FlattenableUtils::read(buffer, size, mBuf); FlattenableUtils::read(buffer, size, mIsDroppable); diff --git a/libs/gui/IGraphicBufferProducer.cpp b/libs/gui/IGraphicBufferProducer.cpp index b7625f2..704fa50 100644 --- a/libs/gui/IGraphicBufferProducer.cpp +++ b/libs/gui/IGraphicBufferProducer.cpp @@ -273,6 +273,7 @@ IGraphicBufferProducer::QueueBufferInput::QueueBufferInput(const Parcel& parcel) size_t IGraphicBufferProducer::QueueBufferInput::getFlattenedSize() const { return sizeof(timestamp) + + sizeof(isAutoTimestamp) + sizeof(crop) + sizeof(scalingMode) + sizeof(transform) @@ -291,6 +292,7 @@ status_t IGraphicBufferProducer::QueueBufferInput::flatten( return NO_MEMORY; } FlattenableUtils::write(buffer, size, timestamp); + FlattenableUtils::write(buffer, size, isAutoTimestamp); FlattenableUtils::write(buffer, size, crop); FlattenableUtils::write(buffer, size, scalingMode); FlattenableUtils::write(buffer, size, transform); @@ -303,6 +305,7 @@ status_t IGraphicBufferProducer::QueueBufferInput::unflatten( { size_t minNeeded = sizeof(timestamp) + + sizeof(isAutoTimestamp) + sizeof(crop) + sizeof(scalingMode) + sizeof(transform) @@ -313,6 +316,7 @@ status_t IGraphicBufferProducer::QueueBufferInput::unflatten( } FlattenableUtils::read(buffer, size, timestamp); + FlattenableUtils::read(buffer, size, isAutoTimestamp); FlattenableUtils::read(buffer, size, crop); FlattenableUtils::read(buffer, size, scalingMode); FlattenableUtils::read(buffer, size, transform); diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp index f3a7e5e..b9a12ed 100644 --- a/libs/gui/Surface.cpp +++ b/libs/gui/Surface.cpp @@ -262,8 +262,10 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) { ALOGV("Surface::queueBuffer"); Mutex::Autolock lock(mMutex); int64_t timestamp; + bool isAutoTimestamp = false; if (mTimestamp == NATIVE_WINDOW_TIMESTAMP_AUTO) { timestamp = systemTime(SYSTEM_TIME_MONOTONIC); + isAutoTimestamp = true; ALOGV("Surface::queueBuffer making up timestamp: %.2f ms", timestamp / 1000000.f); } else { @@ -281,8 +283,8 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) { sp<Fence> fence(fenceFd >= 0 ? new Fence(fenceFd) : Fence::NO_FENCE); IGraphicBufferProducer::QueueBufferOutput output; - IGraphicBufferProducer::QueueBufferInput input(timestamp, crop, mScalingMode, - mTransform, mSwapIntervalZero, fence); + IGraphicBufferProducer::QueueBufferInput input(timestamp, isAutoTimestamp, + crop, mScalingMode, mTransform, mSwapIntervalZero, fence); status_t err = mGraphicBufferProducer->queueBuffer(i, input, &output); if (err != OK) { ALOGE("queueBuffer: error queuing buffer to SurfaceTexture, %d", err); |