Get rid of IGraphicBufferAlloc
This reverts commit 527747dce1
.
selinux policy allowing this change fixed.
Test: took a screenshot
Test: ran ImageReaderTest CTS
Bug: 36194109
Change-Id: I72ac17b6c252750aa2a66cd1d94bd8b4e21b5e9d
This commit is contained in:
parent
bb68dcc8af
commit
78491c9f69
24 changed files with 25 additions and 438 deletions
|
@ -25,7 +25,6 @@
|
|||
namespace android {
|
||||
|
||||
GLHelper::GLHelper() :
|
||||
mGraphicBufferAlloc(new GraphicBufferAlloc()),
|
||||
mDisplay(EGL_NO_DISPLAY),
|
||||
mContext(EGL_NO_CONTEXT),
|
||||
mDummySurface(EGL_NO_SURFACE),
|
||||
|
@ -203,7 +202,7 @@ bool GLHelper::createNamedSurfaceTexture(GLuint name, uint32_t w, uint32_t h,
|
|||
sp<GLConsumer>* glConsumer, EGLSurface* surface) {
|
||||
sp<IGraphicBufferProducer> producer;
|
||||
sp<IGraphicBufferConsumer> consumer;
|
||||
BufferQueue::createBufferQueue(&producer, &consumer, mGraphicBufferAlloc);
|
||||
BufferQueue::createBufferQueue(&producer, &consumer);
|
||||
sp<GLConsumer> glc = new GLConsumer(consumer, name,
|
||||
GL_TEXTURE_EXTERNAL_OES, false, true);
|
||||
glc->setDefaultBufferSize(w, h);
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gui/GraphicBufferAlloc.h>
|
||||
#include <gui/GLConsumer.h>
|
||||
#include <gui/Surface.h>
|
||||
#include <gui/SurfaceControl.h>
|
||||
|
@ -75,8 +74,6 @@ private:
|
|||
|
||||
bool setUpShaders(const ShaderDesc* shaderDescs, size_t numShaders);
|
||||
|
||||
sp<GraphicBufferAlloc> mGraphicBufferAlloc;
|
||||
|
||||
EGLDisplay mDisplay;
|
||||
EGLContext mContext;
|
||||
EGLSurface mDummySurface;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
#define ATRACE_TAG ATRACE_TAG_ALWAYS
|
||||
|
||||
#include <gui/GraphicBufferAlloc.h>
|
||||
#include <gui/Surface.h>
|
||||
#include <gui/SurfaceControl.h>
|
||||
#include <gui/GLConsumer.h>
|
||||
|
|
|
@ -23,10 +23,6 @@
|
|||
#include <gui/IGraphicBufferProducer.h>
|
||||
#include <gui/IConsumerListener.h>
|
||||
|
||||
// These are only required to keep other parts of the framework with incomplete
|
||||
// dependencies building successfully
|
||||
#include <gui/IGraphicBufferAlloc.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
class BufferQueue {
|
||||
|
@ -81,11 +77,9 @@ public:
|
|||
// needed gralloc buffers.
|
||||
static void createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
|
||||
sp<IGraphicBufferConsumer>* outConsumer,
|
||||
const sp<IGraphicBufferAlloc>& allocator = NULL,
|
||||
bool consumerIsSurfaceFlinger = false);
|
||||
|
||||
private:
|
||||
BufferQueue(); // Create through createBufferQueue
|
||||
BufferQueue() = delete; // Create through createBufferQueue
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
namespace android {
|
||||
|
||||
class IConsumerListener;
|
||||
class IGraphicBufferAlloc;
|
||||
class IProducerListener;
|
||||
|
||||
class BufferQueueCore : public virtual RefBase {
|
||||
|
@ -79,9 +78,8 @@ public:
|
|||
typedef Vector<BufferItem> Fifo;
|
||||
|
||||
// BufferQueueCore manages a pool of gralloc memory slots to be used by
|
||||
// producers and consumers. allocator is used to allocate all the needed
|
||||
// gralloc buffers.
|
||||
BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator = NULL);
|
||||
// producers and consumers.
|
||||
BufferQueueCore();
|
||||
virtual ~BufferQueueCore();
|
||||
|
||||
private:
|
||||
|
@ -143,10 +141,6 @@ private:
|
|||
void validateConsistencyLocked() const;
|
||||
#endif
|
||||
|
||||
// mAllocator is the connection to SurfaceFlinger that is used to allocate
|
||||
// new GraphicBuffer objects.
|
||||
sp<IGraphicBufferAlloc> mAllocator;
|
||||
|
||||
// mMutex is the mutex used to prevent concurrent access to the member
|
||||
// variables of BufferQueueCore objects. It must be locked whenever any
|
||||
// member variable is accessed.
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2012 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.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_GUI_GRAPHIC_BUFFER_ALLOC_H
|
||||
#define ANDROID_GUI_GRAPHIC_BUFFER_ALLOC_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <gui/IGraphicBufferAlloc.h>
|
||||
#include <ui/PixelFormat.h>
|
||||
#include <utils/Errors.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
class GraphicBuffer;
|
||||
|
||||
/*
|
||||
* Concrete implementation of the IGraphicBufferAlloc interface.
|
||||
*
|
||||
* This can create GraphicBuffer instance across processes. This is mainly used
|
||||
* by surfaceflinger.
|
||||
*/
|
||||
|
||||
class GraphicBufferAlloc : public BnGraphicBufferAlloc {
|
||||
public:
|
||||
GraphicBufferAlloc();
|
||||
virtual ~GraphicBufferAlloc();
|
||||
virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width,
|
||||
uint32_t height, PixelFormat format, uint32_t layerCount,
|
||||
uint64_t producerUsage, uint64_t consumerUsage,
|
||||
std::string requestorName, status_t* error) override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_GUI_GRAPHIC_BUFFER_ALLOC_H
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_GUI_IGRAPHIC_BUFFER_ALLOC_H
|
||||
#define ANDROID_GUI_IGRAPHIC_BUFFER_ALLOC_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <binder/IInterface.h>
|
||||
#include <ui/GraphicBuffer.h>
|
||||
#include <ui/PixelFormat.h>
|
||||
#include <utils/RefBase.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace android {
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class IGraphicBufferAlloc : public IInterface
|
||||
{
|
||||
public:
|
||||
DECLARE_META_INTERFACE(GraphicBufferAlloc)
|
||||
|
||||
/* Create a new GraphicBuffer for the client to use.
|
||||
*/
|
||||
virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
|
||||
PixelFormat format, uint32_t layerCount, uint64_t producerUsage,
|
||||
uint64_t consumerUsage, std::string requestorName,
|
||||
status_t* error) = 0;
|
||||
|
||||
sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
|
||||
PixelFormat format, uint32_t layerCount, uint32_t usage,
|
||||
status_t* error) {
|
||||
return createGraphicBuffer(w, h, format, layerCount, usage,
|
||||
usage, "<Unknown>", error);
|
||||
}
|
||||
|
||||
sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
|
||||
PixelFormat format, uint32_t layerCount, uint32_t usage,
|
||||
std::string requestorName, status_t* error) {
|
||||
return createGraphicBuffer(w, h, format, layerCount, usage,
|
||||
usage, requestorName, error);
|
||||
}
|
||||
|
||||
sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
|
||||
PixelFormat format, uint32_t layerCount, uint64_t producerUsage,
|
||||
uint64_t consumerUsage, status_t* error) {
|
||||
return createGraphicBuffer(w, h, format, layerCount, producerUsage,
|
||||
consumerUsage, "<Unknown>", error);
|
||||
}
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class BnGraphicBufferAlloc : public BnInterface<IGraphicBufferAlloc>
|
||||
{
|
||||
public:
|
||||
virtual status_t onTransact(uint32_t code,
|
||||
const Parcel& data,
|
||||
Parcel* reply,
|
||||
uint32_t flags = 0);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
}; // namespace android
|
||||
|
||||
#endif // ANDROID_GUI_IGRAPHIC_BUFFER_ALLOC_H
|
|
@ -41,7 +41,6 @@ struct DisplayInfo;
|
|||
struct DisplayStatInfo;
|
||||
class HdrCapabilities;
|
||||
class IDisplayEventConnection;
|
||||
class IGraphicBufferAlloc;
|
||||
class IGraphicBufferProducer;
|
||||
class ISurfaceComposerClient;
|
||||
class Rect;
|
||||
|
@ -89,10 +88,6 @@ public:
|
|||
virtual sp<ISurfaceComposerClient> createScopedConnection(
|
||||
const sp<IGraphicBufferProducer>& parent) = 0;
|
||||
|
||||
/* create a graphic buffer allocator
|
||||
*/
|
||||
virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc() = 0;
|
||||
|
||||
/* return an IDisplayEventConnection */
|
||||
virtual sp<IDisplayEventConnection> createDisplayEventConnection() = 0;
|
||||
|
||||
|
@ -205,7 +200,7 @@ public:
|
|||
// Java by ActivityManagerService.
|
||||
BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
|
||||
CREATE_CONNECTION,
|
||||
CREATE_GRAPHIC_BUFFER_ALLOC,
|
||||
UNUSED, // formerly CREATE_GRAPHIC_BUFFER_ALLOC
|
||||
CREATE_DISPLAY_EVENT_CONNECTION,
|
||||
CREATE_DISPLAY,
|
||||
DESTROY_DISPLAY,
|
||||
|
|
|
@ -70,11 +70,9 @@ cc_library_shared {
|
|||
"DisplayEventReceiver.cpp",
|
||||
"FrameTimestamps.cpp",
|
||||
"GLConsumer.cpp",
|
||||
"GraphicBufferAlloc.cpp",
|
||||
"GuiConfig.cpp",
|
||||
"IDisplayEventConnection.cpp",
|
||||
"IConsumerListener.cpp",
|
||||
"IGraphicBufferAlloc.cpp",
|
||||
"IGraphicBufferConsumer.cpp",
|
||||
"IGraphicBufferProducer.cpp",
|
||||
"IProducerListener.cpp",
|
||||
|
|
|
@ -79,14 +79,13 @@ void BufferQueue::ProxyConsumerListener::addAndGetFrameTimestamps(
|
|||
|
||||
void BufferQueue::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
|
||||
sp<IGraphicBufferConsumer>* outConsumer,
|
||||
const sp<IGraphicBufferAlloc>& allocator,
|
||||
bool consumerIsSurfaceFlinger) {
|
||||
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));
|
||||
sp<BufferQueueCore> core(new BufferQueueCore());
|
||||
LOG_ALWAYS_FATAL_IF(core == NULL,
|
||||
"BufferQueue: failed to create BufferQueueCore");
|
||||
|
||||
|
|
|
@ -33,9 +33,7 @@
|
|||
|
||||
#include <gui/BufferItem.h>
|
||||
#include <gui/BufferQueueCore.h>
|
||||
#include <gui/GraphicBufferAlloc.h>
|
||||
#include <gui/IConsumerListener.h>
|
||||
#include <gui/IGraphicBufferAlloc.h>
|
||||
#include <gui/IProducerListener.h>
|
||||
#include <gui/ISurfaceComposer.h>
|
||||
#include <private/gui/ComposerService.h>
|
||||
|
@ -54,8 +52,7 @@ static uint64_t getUniqueId() {
|
|||
return id | counter++;
|
||||
}
|
||||
|
||||
BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) :
|
||||
mAllocator(allocator),
|
||||
BufferQueueCore::BufferQueueCore() :
|
||||
mMutex(),
|
||||
mIsAbandoned(false),
|
||||
mConsumerControlledByApp(false),
|
||||
|
@ -97,30 +94,6 @@ BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) :
|
|||
mLastQueuedSlot(INVALID_BUFFER_SLOT),
|
||||
mUniqueId(getUniqueId())
|
||||
{
|
||||
if (allocator == NULL) {
|
||||
|
||||
#ifdef HAVE_NO_SURFACE_FLINGER
|
||||
// Without a SurfaceFlinger, allocate in-process. This only makes
|
||||
// sense in systems with static SELinux configurations and no
|
||||
// applications (since applications need dynamic SELinux policy).
|
||||
mAllocator = new GraphicBufferAlloc();
|
||||
#else
|
||||
// Run time check for headless, where we also allocate in-process.
|
||||
char value[PROPERTY_VALUE_MAX];
|
||||
property_get("config.headless", value, "0");
|
||||
if (atoi(value) == 1) {
|
||||
mAllocator = new GraphicBufferAlloc();
|
||||
} else {
|
||||
sp<ISurfaceComposer> composer(ComposerService::getComposerService());
|
||||
mAllocator = composer->createGraphicBufferAlloc();
|
||||
}
|
||||
#endif // HAVE_NO_SURFACE_FLINGER
|
||||
|
||||
if (mAllocator == NULL) {
|
||||
BQ_LOGE("createGraphicBufferAlloc failed");
|
||||
}
|
||||
}
|
||||
|
||||
int numStartingBuffers = getMaxBufferCountLocked();
|
||||
for (int s = 0; s < numStartingBuffers; s++) {
|
||||
mFreeSlots.insert(s);
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include <gui/BufferQueueProducer.h>
|
||||
#include <gui/GLConsumer.h>
|
||||
#include <gui/IConsumerListener.h>
|
||||
#include <gui/IGraphicBufferAlloc.h>
|
||||
#include <gui/IProducerListener.h>
|
||||
|
||||
#include <utils/Log.h>
|
||||
|
@ -454,8 +453,7 @@ status_t BufferQueueProducer::dequeueBuffer(int *outSlot,
|
|||
mSlots[found].mBufferState.dequeue();
|
||||
|
||||
if ((buffer == NULL) ||
|
||||
buffer->needsReallocation(width, height, format, BQ_LAYER_COUNT,
|
||||
usage))
|
||||
buffer->needsReallocation(width, height, format, BQ_LAYER_COUNT, usage))
|
||||
{
|
||||
mSlots[found].mAcquireCalled = false;
|
||||
mSlots[found].mGraphicBuffer = NULL;
|
||||
|
@ -503,11 +501,13 @@ status_t BufferQueueProducer::dequeueBuffer(int *outSlot,
|
|||
} // Autolock scope
|
||||
|
||||
if (returnFlags & BUFFER_NEEDS_REALLOCATION) {
|
||||
status_t error;
|
||||
BQ_LOGV("dequeueBuffer: allocating a new buffer for slot %d", *outSlot);
|
||||
sp<GraphicBuffer> graphicBuffer(mCore->mAllocator->createGraphicBuffer(
|
||||
width, height, format, BQ_LAYER_COUNT, usage,
|
||||
{mConsumerName.string(), mConsumerName.size()}, &error));
|
||||
sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(
|
||||
width, height, format, BQ_LAYER_COUNT, usage, usage,
|
||||
{mConsumerName.string(), mConsumerName.size()});
|
||||
|
||||
status_t error = graphicBuffer->initCheck();
|
||||
|
||||
{ // Autolock scope
|
||||
Mutex::Autolock lock(mCore->mMutex);
|
||||
|
||||
|
@ -1329,11 +1329,12 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height,
|
|||
|
||||
Vector<sp<GraphicBuffer>> buffers;
|
||||
for (size_t i = 0; i < newBufferCount; ++i) {
|
||||
status_t result = NO_ERROR;
|
||||
sp<GraphicBuffer> graphicBuffer(mCore->mAllocator->createGraphicBuffer(
|
||||
sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(
|
||||
allocWidth, allocHeight, allocFormat, BQ_LAYER_COUNT,
|
||||
allocUsage, {mConsumerName.string(), mConsumerName.size()},
|
||||
&result));
|
||||
allocUsage, allocUsage, {mConsumerName.string(), mConsumerName.size()});
|
||||
|
||||
status_t result = graphicBuffer->initCheck();
|
||||
|
||||
if (result != NO_ERROR) {
|
||||
BQ_LOGE("allocateBuffers: failed to allocate buffer (%u x %u, format"
|
||||
" %u, usage %u)", width, height, format, usage);
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include <cutils/atomic.h>
|
||||
|
||||
#include <gui/BufferItem.h>
|
||||
#include <gui/IGraphicBufferAlloc.h>
|
||||
#include <gui/ISurfaceComposer.h>
|
||||
#include <gui/SurfaceComposerClient.h>
|
||||
#include <gui/ConsumerBase.h>
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
#include <gui/BufferItem.h>
|
||||
#include <gui/GLConsumer.h>
|
||||
#include <gui/IGraphicBufferAlloc.h>
|
||||
#include <gui/ISurfaceComposer.h>
|
||||
#include <gui/SurfaceComposerClient.h>
|
||||
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
**
|
||||
** Copyright 2012 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/GraphicBufferAlloc.h>
|
||||
|
||||
#include <log/log.h>
|
||||
|
||||
|
||||
namespace android {
|
||||
|
||||
GraphicBufferAlloc::GraphicBufferAlloc() = default;
|
||||
GraphicBufferAlloc::~GraphicBufferAlloc() = default;
|
||||
|
||||
sp<GraphicBuffer> GraphicBufferAlloc::createGraphicBuffer(uint32_t width,
|
||||
uint32_t height, PixelFormat format, uint32_t layerCount,
|
||||
uint64_t producerUsage, uint64_t consumerUsage,
|
||||
std::string requestorName, status_t* error) {
|
||||
sp<GraphicBuffer> graphicBuffer(new GraphicBuffer(
|
||||
width, height, format, layerCount, producerUsage, consumerUsage,
|
||||
std::move(requestorName)));
|
||||
status_t err = graphicBuffer->initCheck();
|
||||
*error = err;
|
||||
if (err != 0 || graphicBuffer->handle == 0) {
|
||||
if (err == NO_MEMORY) {
|
||||
GraphicBuffer::dumpAllocationsToSystemLog();
|
||||
}
|
||||
ALOGE("GraphicBufferAlloc::createGraphicBuffer(w=%u, h=%u, lc=%u) failed (%s), handle=%p",
|
||||
width, height, layerCount, strerror(-err),
|
||||
graphicBuffer->handle);
|
||||
graphicBuffer.clear();
|
||||
}
|
||||
return graphicBuffer;
|
||||
}
|
||||
|
||||
} // namespace android
|
|
@ -1,139 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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.
|
||||
*/
|
||||
|
||||
// tag as surfaceflinger
|
||||
#define LOG_TAG "SurfaceFlinger"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <binder/Parcel.h>
|
||||
|
||||
#include <ui/GraphicBuffer.h>
|
||||
|
||||
#include <gui/IGraphicBufferAlloc.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
namespace android {
|
||||
|
||||
enum {
|
||||
CREATE_GRAPHIC_BUFFER = IBinder::FIRST_CALL_TRANSACTION,
|
||||
};
|
||||
|
||||
class BpGraphicBufferAlloc : public BpInterface<IGraphicBufferAlloc>
|
||||
{
|
||||
public:
|
||||
explicit BpGraphicBufferAlloc(const sp<IBinder>& impl)
|
||||
: BpInterface<IGraphicBufferAlloc>(impl)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~BpGraphicBufferAlloc();
|
||||
|
||||
virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width,
|
||||
uint32_t height, PixelFormat format, uint32_t layerCount,
|
||||
uint64_t producerUsage, uint64_t consumerUsage,
|
||||
std::string requestorName, status_t* error) {
|
||||
Parcel data, reply;
|
||||
data.writeInterfaceToken(IGraphicBufferAlloc::getInterfaceDescriptor());
|
||||
data.writeUint32(width);
|
||||
data.writeUint32(height);
|
||||
data.writeInt32(static_cast<int32_t>(format));
|
||||
data.writeUint32(layerCount);
|
||||
data.writeUint64(producerUsage);
|
||||
data.writeUint64(consumerUsage);
|
||||
if (requestorName.empty()) {
|
||||
requestorName += "[PID ";
|
||||
requestorName += std::to_string(getpid());
|
||||
requestorName += ']';
|
||||
}
|
||||
data.writeUtf8AsUtf16(requestorName);
|
||||
remote()->transact(CREATE_GRAPHIC_BUFFER, data, &reply);
|
||||
sp<GraphicBuffer> graphicBuffer;
|
||||
status_t result = reply.readInt32();
|
||||
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.
|
||||
}
|
||||
*error = result;
|
||||
return graphicBuffer;
|
||||
}
|
||||
};
|
||||
|
||||
// Out-of-line virtual method definition to trigger vtable emission in this
|
||||
// translation unit (see clang warning -Wweak-vtables)
|
||||
BpGraphicBufferAlloc::~BpGraphicBufferAlloc() {}
|
||||
|
||||
IMPLEMENT_META_INTERFACE(GraphicBufferAlloc, "android.ui.IGraphicBufferAlloc");
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
status_t BnGraphicBufferAlloc::onTransact(
|
||||
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
|
||||
{
|
||||
// codes that don't require permission check
|
||||
|
||||
// BufferReference just keeps a strong reference to a GraphicBuffer until it
|
||||
// is destroyed (that is, until no local or remote process have a reference
|
||||
// to it).
|
||||
class BufferReference : public BBinder {
|
||||
sp<GraphicBuffer> mBuffer;
|
||||
public:
|
||||
explicit BufferReference(const sp<GraphicBuffer>& buffer) : mBuffer(buffer) {}
|
||||
};
|
||||
|
||||
|
||||
switch (code) {
|
||||
case CREATE_GRAPHIC_BUFFER: {
|
||||
CHECK_INTERFACE(IGraphicBufferAlloc, data, reply);
|
||||
uint32_t width = data.readUint32();
|
||||
uint32_t height = data.readUint32();
|
||||
PixelFormat format = static_cast<PixelFormat>(data.readInt32());
|
||||
uint32_t layerCount = data.readUint32();
|
||||
uint64_t producerUsage = data.readUint64();
|
||||
uint64_t consumerUsage = data.readUint64();
|
||||
status_t error = NO_ERROR;
|
||||
std::string requestorName;
|
||||
data.readUtf8FromUtf16(&requestorName);
|
||||
sp<GraphicBuffer> result = createGraphicBuffer(width, height,
|
||||
format, layerCount, producerUsage, consumerUsage,
|
||||
requestorName, &error);
|
||||
reply->writeInt32(error);
|
||||
if (result != 0) {
|
||||
reply->write(*result);
|
||||
// We add a BufferReference to this parcel to make sure the
|
||||
// buffer stays alive until the GraphicBuffer object on
|
||||
// the other side has been created.
|
||||
// This is needed so that the buffer handle can be
|
||||
// registered before the buffer is destroyed on implementations
|
||||
// that do not use file-descriptors to track their buffers.
|
||||
reply->writeStrongBinder( new BufferReference(result) );
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
default:
|
||||
return BBinder::onTransact(code, data, reply, flags);
|
||||
}
|
||||
}
|
||||
|
||||
}; // namespace android
|
|
@ -25,7 +25,6 @@
|
|||
#include <binder/IServiceManager.h>
|
||||
|
||||
#include <gui/IDisplayEventConnection.h>
|
||||
#include <gui/IGraphicBufferAlloc.h>
|
||||
#include <gui/IGraphicBufferProducer.h>
|
||||
#include <gui/ISurfaceComposer.h>
|
||||
#include <gui/ISurfaceComposerClient.h>
|
||||
|
@ -72,14 +71,6 @@ public:
|
|||
return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder());
|
||||
}
|
||||
|
||||
virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc()
|
||||
{
|
||||
Parcel data, reply;
|
||||
data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
|
||||
remote()->transact(BnSurfaceComposer::CREATE_GRAPHIC_BUFFER_ALLOC, data, &reply);
|
||||
return interface_cast<IGraphicBufferAlloc>(reply.readStrongBinder());
|
||||
}
|
||||
|
||||
virtual void setTransactionState(
|
||||
const Vector<ComposerState>& state,
|
||||
const Vector<DisplayState>& displays,
|
||||
|
@ -505,12 +496,6 @@ status_t BnSurfaceComposer::onTransact(
|
|||
reply->writeStrongBinder(b);
|
||||
return NO_ERROR;
|
||||
}
|
||||
case CREATE_GRAPHIC_BUFFER_ALLOC: {
|
||||
CHECK_INTERFACE(ISurfaceComposer, data, reply);
|
||||
sp<IBinder> b = IInterface::asBinder(createGraphicBufferAlloc());
|
||||
reply->writeStrongBinder(b);
|
||||
return NO_ERROR;
|
||||
}
|
||||
case SET_TRANSACTION_STATE: {
|
||||
CHECK_INTERFACE(ISurfaceComposer, data, reply);
|
||||
|
||||
|
|
|
@ -366,9 +366,6 @@ public:
|
|||
const sp<IGraphicBufferProducer>& /* parent */) override {
|
||||
return nullptr;
|
||||
}
|
||||
sp<IGraphicBufferAlloc> createGraphicBufferAlloc() override {
|
||||
return nullptr;
|
||||
}
|
||||
sp<IDisplayEventConnection> createDisplayEventConnection() override {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ int AHardwareBuffer_allocate(const AHardwareBuffer_Desc* desc, AHardwareBuffer**
|
|||
if (err == NO_MEMORY) {
|
||||
GraphicBuffer::dumpAllocationsToSystemLog();
|
||||
}
|
||||
ALOGE("GraphicBufferAlloc::createGraphicBuffer(w=%u, h=%u, lc=%u) failed (%s), handle=%p",
|
||||
ALOGE("GraphicBuffer(w=%u, h=%u, lc=%u) failed (%s), handle=%p",
|
||||
desc->width, desc->height, desc->layers, strerror(-err), gbuffer->handle);
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <hardware/hardware.h>
|
||||
#include <gui/BufferItem.h>
|
||||
#include <gui/BufferQueue.h>
|
||||
#include <gui/GraphicBufferAlloc.h>
|
||||
#include <gui/Surface.h>
|
||||
|
||||
#include <ui/GraphicBuffer.h>
|
||||
|
|
|
@ -167,7 +167,7 @@ void Layer::onFirstRef() {
|
|||
// Creates a custom BufferQueue for SurfaceFlingerConsumer to use
|
||||
sp<IGraphicBufferProducer> producer;
|
||||
sp<IGraphicBufferConsumer> consumer;
|
||||
BufferQueue::createBufferQueue(&producer, &consumer, nullptr, true);
|
||||
BufferQueue::createBufferQueue(&producer, &consumer, true);
|
||||
mProducer = new MonitoredProducer(producer, mFlinger, this);
|
||||
mSurfaceFlingerConsumer = new SurfaceFlingerConsumer(consumer, mTextureName, this);
|
||||
mSurfaceFlingerConsumer->setConsumerUsageBits(getEffectiveUsage(0));
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include <gui/GuiConfig.h>
|
||||
#include <gui/IDisplayEventConnection.h>
|
||||
#include <gui/Surface.h>
|
||||
#include <gui/GraphicBufferAlloc.h>
|
||||
|
||||
#include <ui/GraphicBufferAllocator.h>
|
||||
#include <ui/PixelFormat.h>
|
||||
|
@ -326,12 +325,6 @@ sp<IBinder> SurfaceFlinger::getBuiltInDisplay(int32_t id) {
|
|||
return mBuiltinDisplays[id];
|
||||
}
|
||||
|
||||
sp<IGraphicBufferAlloc> SurfaceFlinger::createGraphicBufferAlloc()
|
||||
{
|
||||
sp<GraphicBufferAlloc> gba(new GraphicBufferAlloc());
|
||||
return gba;
|
||||
}
|
||||
|
||||
void SurfaceFlinger::bootFinished()
|
||||
{
|
||||
if (mStartBootAnimThread->join() != NO_ERROR) {
|
||||
|
@ -1137,8 +1130,7 @@ void SurfaceFlinger::onHotplugReceived(int32_t disp, bool connected) {
|
|||
|
||||
sp<IGraphicBufferProducer> producer;
|
||||
sp<IGraphicBufferConsumer> consumer;
|
||||
BufferQueue::createBufferQueue(&producer, &consumer,
|
||||
new GraphicBufferAlloc());
|
||||
BufferQueue::createBufferQueue(&producer, &consumer);
|
||||
|
||||
sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc,
|
||||
DisplayDevice::DISPLAY_PRIMARY, consumer);
|
||||
|
@ -1899,8 +1891,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
|
|||
sp<IGraphicBufferProducer> producer;
|
||||
sp<IGraphicBufferProducer> bqProducer;
|
||||
sp<IGraphicBufferConsumer> bqConsumer;
|
||||
BufferQueue::createBufferQueue(&bqProducer, &bqConsumer,
|
||||
new GraphicBufferAlloc());
|
||||
BufferQueue::createBufferQueue(&bqProducer, &bqConsumer);
|
||||
|
||||
int32_t hwcId = -1;
|
||||
if (state.isVirtualDisplay()) {
|
||||
|
|
|
@ -76,7 +76,6 @@ namespace android {
|
|||
class Client;
|
||||
class DisplayEventConnection;
|
||||
class EventThread;
|
||||
class IGraphicBufferAlloc;
|
||||
class Layer;
|
||||
class LayerDim;
|
||||
class Surface;
|
||||
|
@ -231,7 +230,6 @@ private:
|
|||
*/
|
||||
virtual sp<ISurfaceComposerClient> createConnection();
|
||||
virtual sp<ISurfaceComposerClient> createScopedConnection(const sp<IGraphicBufferProducer>& gbp);
|
||||
virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc();
|
||||
virtual sp<IBinder> createDisplay(const String8& displayName, bool secure);
|
||||
virtual void destroyDisplay(const sp<IBinder>& display);
|
||||
virtual sp<IBinder> getBuiltInDisplay(int32_t id);
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#include <gui/GuiConfig.h>
|
||||
#include <gui/IDisplayEventConnection.h>
|
||||
#include <gui/Surface.h>
|
||||
#include <gui/GraphicBufferAlloc.h>
|
||||
|
||||
#include <ui/GraphicBufferAllocator.h>
|
||||
#include <ui/HdrCapabilities.h>
|
||||
|
@ -299,12 +298,6 @@ sp<IBinder> SurfaceFlinger::getBuiltInDisplay(int32_t id) {
|
|||
return mBuiltinDisplays[id];
|
||||
}
|
||||
|
||||
sp<IGraphicBufferAlloc> SurfaceFlinger::createGraphicBufferAlloc()
|
||||
{
|
||||
sp<GraphicBufferAlloc> gba(new GraphicBufferAlloc());
|
||||
return gba;
|
||||
}
|
||||
|
||||
void SurfaceFlinger::bootFinished()
|
||||
{
|
||||
if (mStartBootAnimThread->join() != NO_ERROR) {
|
||||
|
@ -541,8 +534,7 @@ void SurfaceFlinger::init() {
|
|||
|
||||
sp<IGraphicBufferProducer> producer;
|
||||
sp<IGraphicBufferConsumer> consumer;
|
||||
BufferQueue::createBufferQueue(&producer, &consumer,
|
||||
new GraphicBufferAlloc());
|
||||
BufferQueue::createBufferQueue(&producer, &consumer);
|
||||
|
||||
sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc, i,
|
||||
consumer);
|
||||
|
@ -1672,8 +1664,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
|
|||
sp<IGraphicBufferProducer> producer;
|
||||
sp<IGraphicBufferProducer> bqProducer;
|
||||
sp<IGraphicBufferConsumer> bqConsumer;
|
||||
BufferQueue::createBufferQueue(&bqProducer, &bqConsumer,
|
||||
new GraphicBufferAlloc());
|
||||
BufferQueue::createBufferQueue(&bqProducer, &bqConsumer);
|
||||
|
||||
int32_t hwcDisplayId = -1;
|
||||
if (state.isVirtualDisplay()) {
|
||||
|
|
Loading…
Reference in a new issue