summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Stoza <stoza@google.com>2014-04-07 16:33:59 -0700
committerDan Stoza <stoza@google.com>2014-04-07 17:00:26 -0700
commitb3d0bdf0dbc19f0a0d7d924693025371e24828fd (patch)
tree283a71a3cfe5940fb0b3385e657c1b16f7048867
parentfc9aeb859096cc02ec9241fad589d361cf9c3ddd (diff)
downloadframeworks_native-b3d0bdf0dbc19f0a0d7d924693025371e24828fd.zip
frameworks_native-b3d0bdf0dbc19f0a0d7d924693025371e24828fd.tar.gz
frameworks_native-b3d0bdf0dbc19f0a0d7d924693025371e24828fd.tar.bz2
BufferQueue: Remove Bn version of create*
It turns out that there's no reason to have both I* and Bn* versions of the createBufferQueue method, so I removed the Bn* version. Change-Id: I66aeb09e10458ae540ddf1f38d2d0154ea8f315b
-rw-r--r--include/gui/BufferQueue.h4
-rw-r--r--libs/gui/BufferQueue.cpp28
-rw-r--r--libs/gui/tests/BufferQueue_test.cpp8
-rw-r--r--services/surfaceflinger/Layer.cpp4
-rw-r--r--services/surfaceflinger/MonitoredProducer.cpp9
-rw-r--r--services/surfaceflinger/MonitoredProducer.h7
6 files changed, 29 insertions, 31 deletions
diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h
index f74dc26..99147cd 100644
--- a/include/gui/BufferQueue.h
+++ b/include/gui/BufferQueue.h
@@ -112,10 +112,6 @@ public:
// needed gralloc buffers.
BufferQueue(const sp<IGraphicBufferAlloc>& allocator = NULL);
- static void createBufferQueue(sp<BnGraphicBufferProducer>* outProducer,
- sp<BnGraphicBufferConsumer>* outConsumer,
- const sp<IGraphicBufferAlloc>& allocator = NULL);
-
static void createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
sp<IGraphicBufferConsumer>* outConsumer,
const sp<IGraphicBufferAlloc>& allocator = NULL);
diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp
index c306f9d..782afcc 100644
--- a/libs/gui/BufferQueue.cpp
+++ b/libs/gui/BufferQueue.cpp
@@ -43,19 +43,6 @@ void BufferQueue::ProxyConsumerListener::onBuffersReleased() {
}
}
-void BufferQueue::createBufferQueue(sp<BnGraphicBufferProducer>* outProducer,
- sp<BnGraphicBufferConsumer>* outConsumer,
- const sp<IGraphicBufferAlloc>& allocator) {
- LOG_ALWAYS_FATAL_IF(outProducer == NULL,
- "BufferQueue: outProducer must not be NULL");
- LOG_ALWAYS_FATAL_IF(outConsumer == NULL,
- "BufferQueue: outConsumer must not be NULL");
-
- sp<BufferQueueCore> core(new BufferQueueCore(allocator));
- *outProducer = new BufferQueueProducer(core);
- *outConsumer = new BufferQueueConsumer(core);
-}
-
void BufferQueue::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
sp<IGraphicBufferConsumer>* outConsumer,
const sp<IGraphicBufferAlloc>& allocator) {
@@ -65,8 +52,19 @@ void BufferQueue::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
"BufferQueue: outConsumer must not be NULL");
sp<BufferQueueCore> core(new BufferQueueCore(allocator));
- *outProducer = new BufferQueueProducer(core);
- *outConsumer = new BufferQueueConsumer(core);
+ LOG_ALWAYS_FATAL_IF(core == NULL,
+ "BufferQueue: failed to create BufferQueueCore");
+
+ sp<IGraphicBufferProducer> producer(new BufferQueueProducer(core));
+ LOG_ALWAYS_FATAL_IF(producer == NULL,
+ "BufferQueue: failed to create BufferQueueProducer");
+
+ sp<IGraphicBufferConsumer> consumer(new BufferQueueConsumer(core));
+ LOG_ALWAYS_FATAL_IF(consumer == NULL,
+ "BufferQueue: failed to create BufferQueueConsumer");
+
+ *outProducer = producer;
+ *outConsumer = consumer;
}
BufferQueue::BufferQueue(const sp<IGraphicBufferAlloc>& allocator) :
diff --git a/libs/gui/tests/BufferQueue_test.cpp b/libs/gui/tests/BufferQueue_test.cpp
index 7943476..e02c780 100644
--- a/libs/gui/tests/BufferQueue_test.cpp
+++ b/libs/gui/tests/BufferQueue_test.cpp
@@ -81,12 +81,12 @@ TEST_F(BufferQueueTest, BufferQueueInAnotherProcess) {
if (forkPid == 0) {
// Child process
- sp<BnGraphicBufferProducer> producer;
- sp<BnGraphicBufferConsumer> consumer;
+ sp<IGraphicBufferProducer> producer;
+ sp<IGraphicBufferConsumer> consumer;
BufferQueue::createBufferQueue(&producer, &consumer);
sp<IServiceManager> serviceManager = defaultServiceManager();
- serviceManager->addService(PRODUCER_NAME, producer.get());
- serviceManager->addService(CONSUMER_NAME, consumer.get());
+ serviceManager->addService(PRODUCER_NAME, producer->asBinder());
+ serviceManager->addService(CONSUMER_NAME, consumer->asBinder());
ProcessState::self()->startThreadPool();
IPCThreadState::self()->joinThreadPool();
LOG_ALWAYS_FATAL("Shouldn't be here");
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 7f2ee2a..58a3040 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -117,8 +117,8 @@ Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client,
void Layer::onFirstRef() {
// Creates a custom BufferQueue for SurfaceFlingerConsumer to use
- sp<BnGraphicBufferProducer> producer;
- sp<BnGraphicBufferConsumer> consumer;
+ sp<IGraphicBufferProducer> producer;
+ sp<IGraphicBufferConsumer> consumer;
BufferQueue::createBufferQueue(&producer, &consumer);
mProducer = new MonitoredProducer(producer, mFlinger);
mSurfaceFlingerConsumer = new SurfaceFlingerConsumer(consumer, mTextureName);
diff --git a/services/surfaceflinger/MonitoredProducer.cpp b/services/surfaceflinger/MonitoredProducer.cpp
index 8fed676..cd3fdf1 100644
--- a/services/surfaceflinger/MonitoredProducer.cpp
+++ b/services/surfaceflinger/MonitoredProducer.cpp
@@ -20,7 +20,7 @@
namespace android {
-MonitoredProducer::MonitoredProducer(const sp<BnGraphicBufferProducer>& producer,
+MonitoredProducer::MonitoredProducer(const sp<IGraphicBufferProducer>& producer,
const sp<SurfaceFlinger>& flinger) :
mProducer(producer),
mFlinger(flinger) {}
@@ -49,8 +49,7 @@ MonitoredProducer::~MonitoredProducer() {
wp<IBinder> mProducer;
};
- mFlinger->postMessageAsync(new MessageCleanUpList(mFlinger,
- static_cast<BnGraphicBufferProducer*>(this)));
+ mFlinger->postMessageAsync(new MessageCleanUpList(mFlinger, asBinder()));
}
status_t MonitoredProducer::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
@@ -101,5 +100,9 @@ status_t MonitoredProducer::setSidebandStream(const sp<NativeHandle>& stream) {
return mProducer->setSidebandStream(stream);
}
+IBinder* MonitoredProducer::onAsBinder() {
+ return mProducer->asBinder().get();
+}
+
// ---------------------------------------------------------------------------
}; // namespace android
diff --git a/services/surfaceflinger/MonitoredProducer.h b/services/surfaceflinger/MonitoredProducer.h
index f78be20..7ac6f06 100644
--- a/services/surfaceflinger/MonitoredProducer.h
+++ b/services/surfaceflinger/MonitoredProducer.h
@@ -27,9 +27,9 @@ class SurfaceFlinger;
// MonitoredProducer wraps an IGraphicBufferProducer so that SurfaceFlinger will
// be notified upon its destruction
-class MonitoredProducer : public BnGraphicBufferProducer {
+class MonitoredProducer : public IGraphicBufferProducer {
public:
- MonitoredProducer(const sp<BnGraphicBufferProducer>& producer,
+ MonitoredProducer(const sp<IGraphicBufferProducer>& producer,
const sp<SurfaceFlinger>& flinger);
virtual ~MonitoredProducer();
@@ -49,9 +49,10 @@ public:
bool producerControlledByApp, QueueBufferOutput* output);
virtual status_t disconnect(int api);
virtual status_t setSidebandStream(const sp<NativeHandle>& stream);
+ virtual IBinder* onAsBinder();
private:
- sp<BnGraphicBufferProducer> mProducer;
+ sp<IGraphicBufferProducer> mProducer;
sp<SurfaceFlinger> mFlinger;
};