libgui/SurfaceFlinger: Add getConsumerName
Adds a getConsumerName method to IGraphicBufferProducer and Surface.
Currently, the name is cached inside of IGBP and is update on connect
and dequeueBuffer, which should be good enough for most uses.
Bug: 6667401
Change-Id: I22c7881d778e495cf8276de7bbcd769e52429915
(cherry picked from commit c6f30bdee1
)
This commit is contained in:
parent
b169b49aec
commit
53a2e97a78
@ -178,6 +178,9 @@ public:
|
|||||||
// See IGraphicBufferProducer::setGenerationNumber
|
// See IGraphicBufferProducer::setGenerationNumber
|
||||||
virtual status_t setGenerationNumber(uint32_t generationNumber);
|
virtual status_t setGenerationNumber(uint32_t generationNumber);
|
||||||
|
|
||||||
|
// See IGraphicBufferProducer::getConsumerName
|
||||||
|
virtual String8 getConsumerName() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// This is required by the IBinder::DeathRecipient interface
|
// This is required by the IBinder::DeathRecipient interface
|
||||||
virtual void binderDied(const wp<IBinder>& who);
|
virtual void binderDied(const wp<IBinder>& who);
|
||||||
|
@ -480,6 +480,9 @@ public:
|
|||||||
// affected and will retain their current generation number. The generation
|
// affected and will retain their current generation number. The generation
|
||||||
// number defaults to 0.
|
// number defaults to 0.
|
||||||
virtual status_t setGenerationNumber(uint32_t generationNumber) = 0;
|
virtual status_t setGenerationNumber(uint32_t generationNumber) = 0;
|
||||||
|
|
||||||
|
// Returns the name of the connected consumer.
|
||||||
|
virtual String8 getConsumerName() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -106,6 +106,9 @@ public:
|
|||||||
* See IGBP::setGenerationNumber for more information. */
|
* See IGBP::setGenerationNumber for more information. */
|
||||||
status_t setGenerationNumber(uint32_t generationNumber);
|
status_t setGenerationNumber(uint32_t generationNumber);
|
||||||
|
|
||||||
|
// See IGraphicBufferProducer::getConsumerName
|
||||||
|
String8 getConsumerName() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~Surface();
|
virtual ~Surface();
|
||||||
|
|
||||||
|
@ -1089,6 +1089,12 @@ status_t BufferQueueProducer::setGenerationNumber(uint32_t generationNumber) {
|
|||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String8 BufferQueueProducer::getConsumerName() const {
|
||||||
|
ATRACE_CALL();
|
||||||
|
BQ_LOGV("getConsumerName: %s", mConsumerName.string());
|
||||||
|
return mConsumerName;
|
||||||
|
}
|
||||||
|
|
||||||
void BufferQueueProducer::binderDied(const wp<android::IBinder>& /* who */) {
|
void BufferQueueProducer::binderDied(const wp<android::IBinder>& /* who */) {
|
||||||
// If we're here, it means that a producer we were connected to died.
|
// If we're here, it means that a producer we were connected to died.
|
||||||
// We're guaranteed that we are still connected to it because we remove
|
// We're guaranteed that we are still connected to it because we remove
|
||||||
|
@ -48,6 +48,7 @@ enum {
|
|||||||
ALLOCATE_BUFFERS,
|
ALLOCATE_BUFFERS,
|
||||||
ALLOW_ALLOCATION,
|
ALLOW_ALLOCATION,
|
||||||
SET_GENERATION_NUMBER,
|
SET_GENERATION_NUMBER,
|
||||||
|
GET_CONSUMER_NAME,
|
||||||
};
|
};
|
||||||
|
|
||||||
class BpGraphicBufferProducer : public BpInterface<IGraphicBufferProducer>
|
class BpGraphicBufferProducer : public BpInterface<IGraphicBufferProducer>
|
||||||
@ -296,6 +297,17 @@ public:
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual String8 getConsumerName() const {
|
||||||
|
Parcel data, reply;
|
||||||
|
data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
|
||||||
|
status_t result = remote()->transact(GET_CONSUMER_NAME, data, &reply);
|
||||||
|
if (result != NO_ERROR) {
|
||||||
|
ALOGE("getConsumerName failed to transact: %d", result);
|
||||||
|
return String8("TransactFailed");
|
||||||
|
}
|
||||||
|
return reply.readString8();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Out-of-line virtual method definition to trigger vtable emission in this
|
// Out-of-line virtual method definition to trigger vtable emission in this
|
||||||
@ -467,6 +479,11 @@ status_t BnGraphicBufferProducer::onTransact(
|
|||||||
reply->writeInt32(result);
|
reply->writeInt32(result);
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
case GET_CONSUMER_NAME: {
|
||||||
|
CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
|
||||||
|
reply->writeString8(getConsumerName());
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return BBinder::onTransact(code, data, reply, flags);
|
return BBinder::onTransact(code, data, reply, flags);
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,10 @@ status_t Surface::setGenerationNumber(uint32_t generation) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String8 Surface::getConsumerName() const {
|
||||||
|
return mGraphicBufferProducer->getConsumerName();
|
||||||
|
}
|
||||||
|
|
||||||
int Surface::hook_setSwapInterval(ANativeWindow* window, int interval) {
|
int Surface::hook_setSwapInterval(ANativeWindow* window, int interval) {
|
||||||
Surface* c = getSelf(window);
|
Surface* c = getSelf(window);
|
||||||
return c->setSwapInterval(interval);
|
return c->setSwapInterval(interval);
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#define LOG_TAG "BufferQueue_test"
|
#define LOG_TAG "BufferQueue_test"
|
||||||
//#define LOG_NDEBUG 0
|
//#define LOG_NDEBUG 0
|
||||||
|
|
||||||
|
#include "DummyConsumer.h"
|
||||||
|
|
||||||
#include <gui/BufferItem.h>
|
#include <gui/BufferItem.h>
|
||||||
#include <gui/BufferQueue.h>
|
#include <gui/BufferQueue.h>
|
||||||
#include <gui/IProducerListener.h>
|
#include <gui/IProducerListener.h>
|
||||||
@ -67,12 +69,6 @@ protected:
|
|||||||
sp<IGraphicBufferConsumer> mConsumer;
|
sp<IGraphicBufferConsumer> mConsumer;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DummyConsumer : public BnConsumerListener {
|
|
||||||
virtual void onFrameAvailable(const BufferItem& /* item */) {}
|
|
||||||
virtual void onBuffersReleased() {}
|
|
||||||
virtual void onSidebandStreamChanged() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint32_t TEST_DATA = 0x12345678u;
|
static const uint32_t TEST_DATA = 0x12345678u;
|
||||||
|
|
||||||
// XXX: Tests that fork a process to hold the BufferQueue must run before tests
|
// XXX: Tests that fork a process to hold the BufferQueue must run before tests
|
||||||
|
27
libs/gui/tests/DummyConsumer.h
Normal file
27
libs/gui/tests/DummyConsumer.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gui/IConsumerListener.h>
|
||||||
|
|
||||||
|
namespace android {
|
||||||
|
|
||||||
|
struct DummyConsumer : public BnConsumerListener {
|
||||||
|
virtual void onFrameAvailable(const BufferItem& /* item */) {}
|
||||||
|
virtual void onBuffersReleased() {}
|
||||||
|
virtual void onSidebandStreamChanged() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace android
|
@ -14,6 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "DummyConsumer.h"
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <binder/IMemory.h>
|
#include <binder/IMemory.h>
|
||||||
@ -210,4 +212,20 @@ TEST_F(SurfaceTest, SettingGenerationNumber) {
|
|||||||
ASSERT_EQ(1U, graphicBuffer->getGenerationNumber());
|
ASSERT_EQ(1U, graphicBuffer->getGenerationNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(SurfaceTest, GetConsumerName) {
|
||||||
|
sp<IGraphicBufferProducer> producer;
|
||||||
|
sp<IGraphicBufferConsumer> consumer;
|
||||||
|
BufferQueue::createBufferQueue(&producer, &consumer);
|
||||||
|
|
||||||
|
sp<DummyConsumer> dummyConsumer(new DummyConsumer);
|
||||||
|
consumer->consumerConnect(dummyConsumer, false);
|
||||||
|
consumer->setConsumerName(String8("TestConsumer"));
|
||||||
|
|
||||||
|
sp<Surface> surface = new Surface(producer);
|
||||||
|
sp<ANativeWindow> window(surface);
|
||||||
|
native_window_api_connect(window.get(), NATIVE_WINDOW_API_CPU);
|
||||||
|
|
||||||
|
EXPECT_STREQ("TestConsumer", surface->getConsumerName().string());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -535,6 +535,10 @@ status_t VirtualDisplaySurface::setGenerationNumber(uint32_t /* generation */) {
|
|||||||
return INVALID_OPERATION;
|
return INVALID_OPERATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String8 VirtualDisplaySurface::getConsumerName() const {
|
||||||
|
return String8("VirtualDisplaySurface");
|
||||||
|
}
|
||||||
|
|
||||||
void VirtualDisplaySurface::updateQueueBufferOutput(
|
void VirtualDisplaySurface::updateQueueBufferOutput(
|
||||||
const QueueBufferOutput& qbo) {
|
const QueueBufferOutput& qbo) {
|
||||||
uint32_t w, h, transformHint, numPendingBuffers;
|
uint32_t w, h, transformHint, numPendingBuffers;
|
||||||
|
@ -117,6 +117,7 @@ private:
|
|||||||
PixelFormat format, uint32_t usage);
|
PixelFormat format, uint32_t usage);
|
||||||
virtual status_t allowAllocation(bool allow);
|
virtual status_t allowAllocation(bool allow);
|
||||||
virtual status_t setGenerationNumber(uint32_t generationNumber);
|
virtual status_t setGenerationNumber(uint32_t generationNumber);
|
||||||
|
virtual String8 getConsumerName() const override;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Utility methods
|
// Utility methods
|
||||||
|
@ -118,6 +118,10 @@ status_t MonitoredProducer::setGenerationNumber(uint32_t generationNumber) {
|
|||||||
return mProducer->setGenerationNumber(generationNumber);
|
return mProducer->setGenerationNumber(generationNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String8 MonitoredProducer::getConsumerName() const {
|
||||||
|
return mProducer->getConsumerName();
|
||||||
|
}
|
||||||
|
|
||||||
IBinder* MonitoredProducer::onAsBinder() {
|
IBinder* MonitoredProducer::onAsBinder() {
|
||||||
return IInterface::asBinder(mProducer).get();
|
return IInterface::asBinder(mProducer).get();
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ public:
|
|||||||
PixelFormat format, uint32_t usage);
|
PixelFormat format, uint32_t usage);
|
||||||
virtual status_t allowAllocation(bool allow);
|
virtual status_t allowAllocation(bool allow);
|
||||||
virtual status_t setGenerationNumber(uint32_t generationNumber);
|
virtual status_t setGenerationNumber(uint32_t generationNumber);
|
||||||
|
virtual String8 getConsumerName() const override;
|
||||||
virtual IBinder* onAsBinder();
|
virtual IBinder* onAsBinder();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user