summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/binder/Parcel.cpp2
-rw-r--r--libs/gui/BufferItem.cpp25
-rw-r--r--libs/gui/BufferItemConsumer.cpp16
-rw-r--r--libs/gui/BufferQueueProducer.cpp4
-rw-r--r--libs/gui/ConsumerBase.cpp16
-rw-r--r--libs/gui/CpuConsumer.cpp19
-rw-r--r--libs/gui/IGraphicBufferAlloc.cpp3
-rw-r--r--libs/gui/Surface.cpp8
-rw-r--r--libs/gui/tests/IGraphicBufferProducer_test.cpp2
-rw-r--r--libs/gui/tests/SurfaceTextureClient_test.cpp29
-rw-r--r--libs/gui/tests/SurfaceTextureGLToGL_test.cpp19
-rw-r--r--libs/ui/GraphicBufferAllocator.cpp3
12 files changed, 79 insertions, 67 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 015866b..c1cfb1e 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -451,7 +451,7 @@ status_t Parcel::appendFrom(const Parcel *parcel, size_t offset, size_t len)
// Count objects in range
for (int i = 0; i < (int) size; i++) {
size_t off = objects[i];
- if ((off >= offset) && (off < offset + len)) {
+ if ((off >= offset) && (off + sizeof(flat_binder_object) <= offset + len)) {
if (firstIndex == -1) {
firstIndex = i;
}
diff --git a/libs/gui/BufferItem.cpp b/libs/gui/BufferItem.cpp
index 5793d40..8f64ae0 100644
--- a/libs/gui/BufferItem.cpp
+++ b/libs/gui/BufferItem.cpp
@@ -46,15 +46,16 @@ static void addAligned(size_t& size, T /* value */) {
}
size_t BufferItem::getPodSize() const {
- // Must align<8> before writing these fields for this to be correct
size_t size = 0;
addAligned(size, mCrop);
addAligned(size, mTransform);
addAligned(size, mScalingMode);
- addAligned(size, mTimestamp);
+ addAligned(size, mTimestampLo);
+ addAligned(size, mTimestampHi);
addAligned(size, mIsAutoTimestamp);
addAligned(size, mDataSpace);
- addAligned(size, mFrameNumber);
+ addAligned(size, mFrameNumberLo);
+ addAligned(size, mFrameNumberHi);
addAligned(size, mSlot);
addAligned(size, mIsDroppable);
addAligned(size, mAcquireCalled);
@@ -126,9 +127,6 @@ status_t BufferItem::flatten(
if (err) return err;
FlattenableUtils::advance(buffer, size, mSurfaceDamage.getFlattenedSize());
- // Must align<8> so that getPodSize returns the correct value
- size -= FlattenableUtils::align<8>(buffer);
-
// Check we still have enough space
if (size < getPodSize()) {
return NO_MEMORY;
@@ -137,10 +135,12 @@ status_t BufferItem::flatten(
writeAligned(buffer, size, mCrop);
writeAligned(buffer, size, mTransform);
writeAligned(buffer, size, mScalingMode);
- writeAligned(buffer, size, mTimestamp);
+ writeAligned(buffer, size, mTimestampLo);
+ writeAligned(buffer, size, mTimestampHi);
writeAligned(buffer, size, mIsAutoTimestamp);
writeAligned(buffer, size, mDataSpace);
- writeAligned(buffer, size, mFrameNumber);
+ writeAligned(buffer, size, mFrameNumberLo);
+ writeAligned(buffer, size, mFrameNumberHi);
writeAligned(buffer, size, mSlot);
writeAligned(buffer, size, mIsDroppable);
writeAligned(buffer, size, mAcquireCalled);
@@ -183,9 +183,6 @@ status_t BufferItem::unflatten(
if (err) return err;
FlattenableUtils::advance(buffer, size, mSurfaceDamage.getFlattenedSize());
- // Must align<8> so that getPodSize returns the correct value
- size -= FlattenableUtils::align<8>(buffer);
-
// Check we still have enough space
if (size < getPodSize()) {
return NO_MEMORY;
@@ -194,10 +191,12 @@ status_t BufferItem::unflatten(
readAligned(buffer, size, mCrop);
readAligned(buffer, size, mTransform);
readAligned(buffer, size, mScalingMode);
- readAligned(buffer, size, mTimestamp);
+ readAligned(buffer, size, mTimestampLo);
+ readAligned(buffer, size, mTimestampHi);
readAligned(buffer, size, mIsAutoTimestamp);
readAligned(buffer, size, mDataSpace);
- readAligned(buffer, size, mFrameNumber);
+ readAligned(buffer, size, mFrameNumberLo);
+ readAligned(buffer, size, mFrameNumberHi);
readAligned(buffer, size, mSlot);
readAligned(buffer, size, mIsDroppable);
readAligned(buffer, size, mAcquireCalled);
diff --git a/libs/gui/BufferItemConsumer.cpp b/libs/gui/BufferItemConsumer.cpp
index 194121f..578b8d9 100644
--- a/libs/gui/BufferItemConsumer.cpp
+++ b/libs/gui/BufferItemConsumer.cpp
@@ -100,20 +100,4 @@ status_t BufferItemConsumer::releaseBuffer(const BufferItem &item,
return err;
}
-status_t BufferItemConsumer::setDefaultBufferSize(uint32_t w, uint32_t h) {
- Mutex::Autolock _l(mMutex);
- return mConsumer->setDefaultBufferSize(w, h);
-}
-
-status_t BufferItemConsumer::setDefaultBufferFormat(PixelFormat defaultFormat) {
- Mutex::Autolock _l(mMutex);
- return mConsumer->setDefaultBufferFormat(defaultFormat);
-}
-
-status_t BufferItemConsumer::setDefaultBufferDataSpace(
- android_dataspace defaultDataSpace) {
- Mutex::Autolock _l(mMutex);
- return mConsumer->setDefaultBufferDataSpace(defaultDataSpace);
-}
-
} // namespace android
diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp
index 2cf7433..e318484 100644
--- a/libs/gui/BufferQueueProducer.cpp
+++ b/libs/gui/BufferQueueProducer.cpp
@@ -914,8 +914,8 @@ status_t BufferQueueProducer::disconnect(int api) {
mCore->mSidebandStream.clear();
mCore->mDequeueCondition.broadcast();
listener = mCore->mConsumerListener;
- } else if (mCore->mConnectedApi != BufferQueueCore::NO_CONNECTED_API) {
- BQ_LOGE("disconnect(P): still connected to another API "
+ } else {
+ BQ_LOGE("disconnect(P): connected to another API "
"(cur=%d req=%d)", mCore->mConnectedApi, api);
status = BAD_VALUE;
}
diff --git a/libs/gui/ConsumerBase.cpp b/libs/gui/ConsumerBase.cpp
index 0e42daf..04ab06b 100644
--- a/libs/gui/ConsumerBase.cpp
+++ b/libs/gui/ConsumerBase.cpp
@@ -198,6 +198,22 @@ status_t ConsumerBase::detachBuffer(int slot) {
return result;
}
+status_t ConsumerBase::setDefaultBufferSize(uint32_t width, uint32_t height) {
+ Mutex::Autolock _l(mMutex);
+ return mConsumer->setDefaultBufferSize(width, height);
+}
+
+status_t ConsumerBase::setDefaultBufferFormat(PixelFormat defaultFormat) {
+ Mutex::Autolock _l(mMutex);
+ return mConsumer->setDefaultBufferFormat(defaultFormat);
+}
+
+status_t ConsumerBase::setDefaultBufferDataSpace(
+ android_dataspace defaultDataSpace) {
+ Mutex::Autolock _l(mMutex);
+ return mConsumer->setDefaultBufferDataSpace(defaultDataSpace);
+}
+
void ConsumerBase::dump(String8& result) const {
dump(result, "");
}
diff --git a/libs/gui/CpuConsumer.cpp b/libs/gui/CpuConsumer.cpp
index eb39469..e29b740 100644
--- a/libs/gui/CpuConsumer.cpp
+++ b/libs/gui/CpuConsumer.cpp
@@ -56,25 +56,6 @@ void CpuConsumer::setName(const String8& name) {
mConsumer->setConsumerName(name);
}
-status_t CpuConsumer::setDefaultBufferSize(uint32_t width, uint32_t height)
-{
- Mutex::Autolock _l(mMutex);
- return mConsumer->setDefaultBufferSize(width, height);
-}
-
-status_t CpuConsumer::setDefaultBufferFormat(PixelFormat defaultFormat)
-{
- Mutex::Autolock _l(mMutex);
- return mConsumer->setDefaultBufferFormat(defaultFormat);
-}
-
-status_t CpuConsumer::setDefaultBufferDataSpace(
- android_dataspace defaultDataSpace)
-{
- Mutex::Autolock _l(mMutex);
- return mConsumer->setDefaultBufferDataSpace(defaultDataSpace);
-}
-
static bool isPossiblyYUV(PixelFormat format) {
switch (static_cast<int>(format)) {
case HAL_PIXEL_FORMAT_RGBA_8888:
diff --git a/libs/gui/IGraphicBufferAlloc.cpp b/libs/gui/IGraphicBufferAlloc.cpp
index 09b63a1..3009989 100644
--- a/libs/gui/IGraphicBufferAlloc.cpp
+++ b/libs/gui/IGraphicBufferAlloc.cpp
@@ -59,6 +59,9 @@ public:
if (result == NO_ERROR) {
graphicBuffer = new GraphicBuffer();
result = reply.read(*graphicBuffer);
+ if (result != NO_ERROR) {
+ graphicBuffer.clear();
+ }
// reply.readStrongBinder();
// here we don't even have to read the BufferReference from
// the parcel, it'll die with the parcel.
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 35aa7c7..04ac0f4 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -335,10 +335,14 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) {
// the origin being in the bottom-left corner. Here we flip to the
// convention that the rest of the system uses (top-left corner) by
// subtracting all top/bottom coordinates from the buffer height.
+ int height = buffer->height;
+ if ((mTransform ^ mStickyTransform) & NATIVE_WINDOW_TRANSFORM_ROT_90) {
+ height = buffer->width;
+ }
Region flippedRegion;
for (auto rect : mDirtyRegion) {
- auto top = buffer->height - rect.bottom;
- auto bottom = buffer->height - rect.top;
+ auto top = height - rect.bottom;
+ auto bottom = height - rect.top;
Rect flippedRect{rect.left, top, rect.right, bottom};
flippedRegion.orSelf(flippedRect);
}
diff --git a/libs/gui/tests/IGraphicBufferProducer_test.cpp b/libs/gui/tests/IGraphicBufferProducer_test.cpp
index ff58420..4ef9a69 100644
--- a/libs/gui/tests/IGraphicBufferProducer_test.cpp
+++ b/libs/gui/tests/IGraphicBufferProducer_test.cpp
@@ -299,7 +299,7 @@ TEST_F(IGraphicBufferProducerTest, Query_ReturnsError) {
ASSERT_NO_FATAL_FAILURE(ConnectProducer());
// One past the end of the last 'query' enum value. Update this if we add more enums.
- const int NATIVE_WINDOW_QUERY_LAST_OFF_BY_ONE = NATIVE_WINDOW_DEFAULT_DATASPACE + 1;
+ const int NATIVE_WINDOW_QUERY_LAST_OFF_BY_ONE = NATIVE_WINDOW_BUFFER_AGE + 1;
int value;
// What was out of range
diff --git a/libs/gui/tests/SurfaceTextureClient_test.cpp b/libs/gui/tests/SurfaceTextureClient_test.cpp
index d750cd0..1a50b24 100644
--- a/libs/gui/tests/SurfaceTextureClient_test.cpp
+++ b/libs/gui/tests/SurfaceTextureClient_test.cpp
@@ -27,6 +27,9 @@
#include <utils/Log.h>
#include <utils/Thread.h>
+EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name);
+#define CROP_EXT_STR "EGL_ANDROID_image_crop"
+
namespace android {
class SurfaceTextureClientTest : public ::testing::Test {
@@ -615,6 +618,18 @@ TEST_F(SurfaceTextureClientTest, GetTransformMatrixSucceedsAfterFreeingBuffers)
}
TEST_F(SurfaceTextureClientTest, GetTransformMatrixSucceedsAfterFreeingBuffersWithCrop) {
+ // Query to see if the image crop extension exists
+ EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ const char* exts = eglQueryStringImplementationANDROID(dpy, EGL_EXTENSIONS);
+ size_t cropExtLen = strlen(CROP_EXT_STR);
+ size_t extsLen = strlen(exts);
+ bool equal = !strcmp(CROP_EXT_STR, exts);
+ bool atStart = !strncmp(CROP_EXT_STR " ", exts, cropExtLen+1);
+ bool atEnd = (cropExtLen+1) < extsLen &&
+ !strcmp(" " CROP_EXT_STR, exts + extsLen - (cropExtLen+1));
+ bool inMiddle = strstr(exts, " " CROP_EXT_STR " ");
+ bool hasEglAndroidImageCrop = equal || atStart || atEnd || inMiddle;
+
android_native_buffer_t* buf[3];
float mtx[16] = {};
android_native_rect_t crop;
@@ -633,15 +648,17 @@ TEST_F(SurfaceTextureClientTest, GetTransformMatrixSucceedsAfterFreeingBuffersWi
ASSERT_EQ(OK, native_window_set_buffer_count(mANW.get(), 6)); // frees buffers
mST->getTransformMatrix(mtx);
- // This accounts for the .5 texel shrink for each edge that's included in the
- // transform matrix to avoid texturing outside the crop region.
- EXPECT_EQ(0.5, mtx[0]);
+ // If the egl image crop extension is not present, this accounts for the
+ // .5 texel shrink for each edge that's included in the transform matrix
+ // to avoid texturing outside the crop region. Otherwise the crop is not
+ // included in the transform matrix.
+ EXPECT_EQ(hasEglAndroidImageCrop ? 1 : 0.5, mtx[0]);
EXPECT_EQ(0.f, mtx[1]);
EXPECT_EQ(0.f, mtx[2]);
EXPECT_EQ(0.f, mtx[3]);
EXPECT_EQ(0.f, mtx[4]);
- EXPECT_EQ(-0.5, mtx[5]);
+ EXPECT_EQ(hasEglAndroidImageCrop ? -1 : -0.5, mtx[5]);
EXPECT_EQ(0.f, mtx[6]);
EXPECT_EQ(0.f, mtx[7]);
@@ -650,8 +667,8 @@ TEST_F(SurfaceTextureClientTest, GetTransformMatrixSucceedsAfterFreeingBuffersWi
EXPECT_EQ(1.f, mtx[10]);
EXPECT_EQ(0.f, mtx[11]);
- EXPECT_EQ(0.0625f, mtx[12]);
- EXPECT_EQ(0.5625f, mtx[13]);
+ EXPECT_EQ(hasEglAndroidImageCrop ? 0 : 0.0625f, mtx[12]);
+ EXPECT_EQ(hasEglAndroidImageCrop ? 1 : 0.5625f, mtx[13]);
EXPECT_EQ(0.f, mtx[14]);
EXPECT_EQ(1.f, mtx[15]);
}
diff --git a/libs/gui/tests/SurfaceTextureGLToGL_test.cpp b/libs/gui/tests/SurfaceTextureGLToGL_test.cpp
index f4c7961..6edbfb8 100644
--- a/libs/gui/tests/SurfaceTextureGLToGL_test.cpp
+++ b/libs/gui/tests/SurfaceTextureGLToGL_test.cpp
@@ -188,10 +188,10 @@ TEST_F(SurfaceTextureGLToGLTest, EglDestroySurfaceUnrefsBuffers) {
// This test should have the only reference to buffer 0.
EXPECT_EQ(1, buffers[0]->getStrongCount());
- // The GLConsumer should hold a single reference to buffer 1 in its
- // mCurrentBuffer member. All of the references in the slots should have
- // been released.
- EXPECT_EQ(2, buffers[1]->getStrongCount());
+ // The GLConsumer should hold one reference to buffer 1 in its
+ // mCurrentTextureImage member and another reference in mEglSlots. The third
+ // reference is in this test.
+ EXPECT_EQ(3, buffers[1]->getStrongCount());
}
TEST_F(SurfaceTextureGLToGLTest, EglDestroySurfaceAfterAbandonUnrefsBuffers) {
@@ -235,14 +235,19 @@ TEST_F(SurfaceTextureGLToGLTest, EglDestroySurfaceAfterAbandonUnrefsBuffers) {
ASSERT_EQ(EGL_SUCCESS, eglGetError());
mProducerEglSurface = EGL_NO_SURFACE;
- EXPECT_EQ(1, buffers[0]->getStrongCount());
EXPECT_EQ(1, buffers[1]->getStrongCount());
// Depending on how lazily the GL driver dequeues buffers, we may end up
- // with either two or three total buffers. If there are three, make sure
- // the last one was properly down-ref'd.
+ // with either two or three total buffers. If there are three, each entry
+ // of the buffers array will be unique and there should only be one
+ // reference (the one in this test). If there are two the first and last
+ // element in the array will be equal meaning that buffer representing both
+ // 0 and 2 will have two references (one for 0 and one for 2).
if (buffers[2] != buffers[0]) {
+ EXPECT_EQ(1, buffers[0]->getStrongCount());
EXPECT_EQ(1, buffers[2]->getStrongCount());
+ } else {
+ EXPECT_EQ(2, buffers[0]->getStrongCount());
}
}
diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp
index 85e9675..9b265af 100644
--- a/libs/ui/GraphicBufferAllocator.cpp
+++ b/libs/ui/GraphicBufferAllocator.cpp
@@ -104,6 +104,9 @@ status_t GraphicBufferAllocator::alloc(uint32_t width, uint32_t height,
// we have a h/w allocator and h/w buffer is requested
status_t err;
+ // Filter out any usage bits that should not be passed to the gralloc module
+ usage &= GRALLOC_USAGE_ALLOC_MASK;
+
int outStride = 0;
err = mAllocDev->alloc(mAllocDev, static_cast<int>(width),
static_cast<int>(height), format, static_cast<int>(usage), handle,