BufferQueue: Support query of consumer usage bits

Bug: 9592202
Change-Id: I61a17758200e61adaca695b426db3df0f6637d4c
This commit is contained in:
Eino-Ville Talvala 2013-07-30 14:05:02 -07:00
parent aaff4ef717
commit f7c6087bcc
2 changed files with 21 additions and 0 deletions

View File

@ -217,6 +217,9 @@ int BufferQueue::query(int what, int* outValue)
case NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND:
value = (mQueue.size() >= 2);
break;
case NATIVE_WINDOW_CONSUMER_USAGE_BITS:
value = mConsumerUsageBits;
break;
default:
return BAD_VALUE;
}

View File

@ -20,6 +20,7 @@
#include <gui/ISurfaceComposer.h>
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>
#include <gui/BufferItemConsumer.h>
#include <utils/String8.h>
#include <private/gui/ComposerService.h>
@ -132,4 +133,21 @@ TEST_F(SurfaceTest, ConcreteTypeIsSurface) {
EXPECT_EQ(NATIVE_WINDOW_SURFACE, result);
}
TEST_F(SurfaceTest, QueryConsumerUsage) {
const int TEST_USAGE_FLAGS =
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_HW_RENDER;
sp<BufferQueue> bq = new BufferQueue();
sp<BufferItemConsumer> c = new BufferItemConsumer(bq,
TEST_USAGE_FLAGS);
sp<Surface> s = new Surface(c->getProducerInterface());
sp<ANativeWindow> anw(s);
int flags = -1;
int err = anw->query(anw.get(), NATIVE_WINDOW_CONSUMER_USAGE_BITS, &flags);
ASSERT_EQ(NO_ERROR, err);
ASSERT_EQ(TEST_USAGE_FLAGS, flags);
}
}