Remove deprecated BufferQueue constructor
Bug: 13415624 Change-Id: I9fe15e45daa7351f1db34ee75bfee6f19cb347d3
This commit is contained in:
parent
74d8acd7fc
commit
b9b088375d
|
@ -11,9 +11,9 @@ LOCAL_SRC_FILES:= \
|
|||
Layer.cpp \
|
||||
LayerDim.cpp \
|
||||
MessageQueue.cpp \
|
||||
MonitoredProducer.cpp \
|
||||
SurfaceFlinger.cpp \
|
||||
SurfaceFlingerConsumer.cpp \
|
||||
SurfaceTextureLayer.cpp \
|
||||
Transform.cpp \
|
||||
DisplayHardware/FramebufferSurface.cpp \
|
||||
DisplayHardware/HWComposer.cpp \
|
||||
|
|
|
@ -47,9 +47,10 @@ static const char* dbgCompositionTypeStr(DisplaySurface::CompositionType type) {
|
|||
|
||||
VirtualDisplaySurface::VirtualDisplaySurface(HWComposer& hwc, int32_t dispId,
|
||||
const sp<IGraphicBufferProducer>& sink,
|
||||
const sp<BufferQueue>& bq,
|
||||
const sp<IGraphicBufferProducer>& bqProducer,
|
||||
const sp<IGraphicBufferConsumer>& bqConsumer,
|
||||
const String8& name)
|
||||
: ConsumerBase(bq),
|
||||
: ConsumerBase(bqConsumer),
|
||||
mHwc(hwc),
|
||||
mDisplayId(dispId),
|
||||
mDisplayName(name),
|
||||
|
@ -60,7 +61,7 @@ VirtualDisplaySurface::VirtualDisplaySurface(HWComposer& hwc, int32_t dispId,
|
|||
mMustRecompose(false)
|
||||
{
|
||||
mSource[SOURCE_SINK] = sink;
|
||||
mSource[SOURCE_SCRATCH] = bq;
|
||||
mSource[SOURCE_SCRATCH] = bqProducer;
|
||||
|
||||
resetPerFrameState();
|
||||
|
||||
|
|
|
@ -73,7 +73,8 @@ class VirtualDisplaySurface : public DisplaySurface,
|
|||
public:
|
||||
VirtualDisplaySurface(HWComposer& hwc, int32_t dispId,
|
||||
const sp<IGraphicBufferProducer>& sink,
|
||||
const sp<BufferQueue>& bq,
|
||||
const sp<IGraphicBufferProducer>& bqProducer,
|
||||
const sp<IGraphicBufferConsumer>& bqConsumer,
|
||||
const String8& name);
|
||||
|
||||
//
|
||||
|
|
|
@ -40,8 +40,8 @@
|
|||
#include "Colorizer.h"
|
||||
#include "DisplayDevice.h"
|
||||
#include "Layer.h"
|
||||
#include "MonitoredProducer.h"
|
||||
#include "SurfaceFlinger.h"
|
||||
#include "SurfaceTextureLayer.h"
|
||||
|
||||
#include "DisplayHardware/HWComposer.h"
|
||||
|
||||
|
@ -117,8 +117,11 @@ Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client,
|
|||
|
||||
void Layer::onFirstRef() {
|
||||
// Creates a custom BufferQueue for SurfaceFlingerConsumer to use
|
||||
mBufferQueue = new SurfaceTextureLayer(mFlinger);
|
||||
mSurfaceFlingerConsumer = new SurfaceFlingerConsumer(mBufferQueue, mTextureName);
|
||||
sp<BnGraphicBufferProducer> producer;
|
||||
sp<BnGraphicBufferConsumer> consumer;
|
||||
BufferQueue::createBufferQueue(&producer, &consumer);
|
||||
mProducer = new MonitoredProducer(producer, mFlinger);
|
||||
mSurfaceFlingerConsumer = new SurfaceFlingerConsumer(consumer, mTextureName);
|
||||
mSurfaceFlingerConsumer->setConsumerUsageBits(getEffectiveUsage(0));
|
||||
mSurfaceFlingerConsumer->setContentsChangedListener(this);
|
||||
mSurfaceFlingerConsumer->setName(mName);
|
||||
|
@ -236,8 +239,8 @@ sp<IBinder> Layer::getHandle() {
|
|||
return new Handle(mFlinger, this);
|
||||
}
|
||||
|
||||
sp<IGraphicBufferProducer> Layer::getBufferQueue() const {
|
||||
return mBufferQueue;
|
||||
sp<IGraphicBufferProducer> Layer::getProducer() const {
|
||||
return mProducer;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
@ -37,9 +37,9 @@
|
|||
|
||||
#include "FrameTracker.h"
|
||||
#include "Client.h"
|
||||
#include "MonitoredProducer.h"
|
||||
#include "SurfaceFlinger.h"
|
||||
#include "SurfaceFlingerConsumer.h"
|
||||
#include "SurfaceTextureLayer.h"
|
||||
#include "Transform.h"
|
||||
|
||||
#include "DisplayHardware/HWComposer.h"
|
||||
|
@ -140,7 +140,7 @@ public:
|
|||
Rect computeBounds() const;
|
||||
|
||||
sp<IBinder> getHandle();
|
||||
sp<IGraphicBufferProducer> getBufferQueue() const;
|
||||
sp<IGraphicBufferProducer> getProducer() const;
|
||||
const String8& getName() const;
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
@ -338,7 +338,7 @@ private:
|
|||
|
||||
// constants
|
||||
sp<SurfaceFlingerConsumer> mSurfaceFlingerConsumer;
|
||||
sp<BufferQueue> mBufferQueue;
|
||||
sp<IGraphicBufferProducer> mProducer;
|
||||
uint32_t mTextureName;
|
||||
bool mPremultipliedAlpha;
|
||||
String8 mName;
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* Copyright 2014 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 "MessageQueue.h"
|
||||
#include "MonitoredProducer.h"
|
||||
#include "SurfaceFlinger.h"
|
||||
|
||||
namespace android {
|
||||
|
||||
MonitoredProducer::MonitoredProducer(const sp<BnGraphicBufferProducer>& producer,
|
||||
const sp<SurfaceFlinger>& flinger) :
|
||||
mProducer(producer),
|
||||
mFlinger(flinger) {}
|
||||
|
||||
MonitoredProducer::~MonitoredProducer() {
|
||||
// Remove ourselves from SurfaceFlinger's list. We do this asynchronously
|
||||
// because we don't know where this destructor is called from. It could be
|
||||
// called with the mStateLock held, leading to a dead-lock (it actually
|
||||
// happens).
|
||||
class MessageCleanUpList : public MessageBase {
|
||||
public:
|
||||
MessageCleanUpList(const sp<SurfaceFlinger>& flinger,
|
||||
const wp<IBinder>& producer)
|
||||
: mFlinger(flinger), mProducer(producer) {}
|
||||
|
||||
virtual ~MessageCleanUpList() {}
|
||||
|
||||
virtual bool handler() {
|
||||
Mutex::Autolock _l(mFlinger->mStateLock);
|
||||
mFlinger->mGraphicBufferProducerList.remove(mProducer);
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
sp<SurfaceFlinger> mFlinger;
|
||||
wp<IBinder> mProducer;
|
||||
};
|
||||
|
||||
mFlinger->postMessageAsync(new MessageCleanUpList(mFlinger,
|
||||
static_cast<BnGraphicBufferProducer*>(this)));
|
||||
}
|
||||
|
||||
status_t MonitoredProducer::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
|
||||
return mProducer->requestBuffer(slot, buf);
|
||||
}
|
||||
|
||||
status_t MonitoredProducer::setBufferCount(int bufferCount) {
|
||||
return mProducer->setBufferCount(bufferCount);
|
||||
}
|
||||
|
||||
status_t MonitoredProducer::dequeueBuffer(int* slot, sp<Fence>* fence,
|
||||
bool async, uint32_t w, uint32_t h, uint32_t format, uint32_t usage) {
|
||||
return mProducer->dequeueBuffer(slot, fence, async, w, h, format, usage);
|
||||
}
|
||||
|
||||
status_t MonitoredProducer::detachBuffer(int slot) {
|
||||
return mProducer->detachBuffer(slot);
|
||||
}
|
||||
|
||||
status_t MonitoredProducer::attachBuffer(int* outSlot,
|
||||
const sp<GraphicBuffer>& buffer) {
|
||||
return mProducer->attachBuffer(outSlot, buffer);
|
||||
}
|
||||
|
||||
status_t MonitoredProducer::queueBuffer(int slot, const QueueBufferInput& input,
|
||||
QueueBufferOutput* output) {
|
||||
return mProducer->queueBuffer(slot, input, output);
|
||||
}
|
||||
|
||||
void MonitoredProducer::cancelBuffer(int slot, const sp<Fence>& fence) {
|
||||
mProducer->cancelBuffer(slot, fence);
|
||||
}
|
||||
|
||||
int MonitoredProducer::query(int what, int* value) {
|
||||
return mProducer->query(what, value);
|
||||
}
|
||||
|
||||
status_t MonitoredProducer::connect(const sp<IBinder>& token, int api,
|
||||
bool producerControlledByApp, QueueBufferOutput* output) {
|
||||
return mProducer->connect(token, api, producerControlledByApp, output);
|
||||
}
|
||||
|
||||
status_t MonitoredProducer::disconnect(int api) {
|
||||
return mProducer->disconnect(api);
|
||||
}
|
||||
|
||||
status_t MonitoredProducer::setSidebandStream(const sp<NativeHandle>& stream) {
|
||||
return mProducer->setSidebandStream(stream);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
}; // namespace android
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright 2014 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_MONITORED_PRODUCER_H
|
||||
#define ANDROID_MONITORED_PRODUCER_H
|
||||
|
||||
#include <gui/IGraphicBufferProducer.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
class IBinder;
|
||||
class NativeHandle;
|
||||
class SurfaceFlinger;
|
||||
|
||||
// MonitoredProducer wraps an IGraphicBufferProducer so that SurfaceFlinger will
|
||||
// be notified upon its destruction
|
||||
class MonitoredProducer : public BnGraphicBufferProducer {
|
||||
public:
|
||||
MonitoredProducer(const sp<BnGraphicBufferProducer>& producer,
|
||||
const sp<SurfaceFlinger>& flinger);
|
||||
virtual ~MonitoredProducer();
|
||||
|
||||
// From IGraphicBufferProducer
|
||||
virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf);
|
||||
virtual status_t setBufferCount(int bufferCount);
|
||||
virtual status_t dequeueBuffer(int* slot, sp<Fence>* fence, bool async,
|
||||
uint32_t w, uint32_t h, uint32_t format, uint32_t usage);
|
||||
virtual status_t detachBuffer(int slot);
|
||||
virtual status_t attachBuffer(int* outSlot,
|
||||
const sp<GraphicBuffer>& buffer);
|
||||
virtual status_t queueBuffer(int slot, const QueueBufferInput& input,
|
||||
QueueBufferOutput* output);
|
||||
virtual void cancelBuffer(int slot, const sp<Fence>& fence);
|
||||
virtual int query(int what, int* value);
|
||||
virtual status_t connect(const sp<IBinder>& token, int api,
|
||||
bool producerControlledByApp, QueueBufferOutput* output);
|
||||
virtual status_t disconnect(int api);
|
||||
virtual status_t setSidebandStream(const sp<NativeHandle>& stream);
|
||||
|
||||
private:
|
||||
sp<BnGraphicBufferProducer> mProducer;
|
||||
sp<SurfaceFlinger> mFlinger;
|
||||
};
|
||||
|
||||
}; // namespace android
|
||||
|
||||
#endif // ANDROID_MONITORED_PRODUCER_H
|
|
@ -420,12 +420,17 @@ void SurfaceFlinger::init() {
|
|||
createBuiltinDisplayLocked(type);
|
||||
wp<IBinder> token = mBuiltinDisplays[i];
|
||||
|
||||
sp<BufferQueue> bq = new BufferQueue(new GraphicBufferAlloc());
|
||||
sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc, i, bq);
|
||||
sp<IGraphicBufferProducer> producer;
|
||||
sp<IGraphicBufferConsumer> consumer;
|
||||
BufferQueue::createBufferQueue(&producer, &consumer,
|
||||
new GraphicBufferAlloc());
|
||||
|
||||
sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc, i,
|
||||
consumer);
|
||||
int32_t hwcId = allocateHwcDisplayId(type);
|
||||
sp<DisplayDevice> hw = new DisplayDevice(this,
|
||||
type, hwcId, mHwc->getFormat(hwcId), isSecure, token,
|
||||
fbs, bq,
|
||||
fbs, producer,
|
||||
mRenderEngine->getEGLConfig());
|
||||
if (i > DisplayDevice::DISPLAY_PRIMARY) {
|
||||
// FIXME: currently we don't get blank/unblank requests
|
||||
|
@ -1152,7 +1157,10 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
|
|||
|
||||
sp<DisplaySurface> dispSurface;
|
||||
sp<IGraphicBufferProducer> producer;
|
||||
sp<BufferQueue> bq = new BufferQueue(new GraphicBufferAlloc());
|
||||
sp<IGraphicBufferProducer> bqProducer;
|
||||
sp<IGraphicBufferConsumer> bqConsumer;
|
||||
BufferQueue::createBufferQueue(&bqProducer, &bqConsumer,
|
||||
new GraphicBufferAlloc());
|
||||
|
||||
int32_t hwcDisplayId = -1;
|
||||
if (state.isVirtualDisplay()) {
|
||||
|
@ -1163,8 +1171,8 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
|
|||
|
||||
hwcDisplayId = allocateHwcDisplayId(state.type);
|
||||
sp<VirtualDisplaySurface> vds = new VirtualDisplaySurface(
|
||||
*mHwc, hwcDisplayId, state.surface, bq,
|
||||
state.displayName);
|
||||
*mHwc, hwcDisplayId, state.surface,
|
||||
bqProducer, bqConsumer, state.displayName);
|
||||
|
||||
dispSurface = vds;
|
||||
if (hwcDisplayId >= 0) {
|
||||
|
@ -1183,8 +1191,9 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
|
|||
hwcDisplayId = allocateHwcDisplayId(state.type);
|
||||
// for supported (by hwc) displays we provide our
|
||||
// own rendering surface
|
||||
dispSurface = new FramebufferSurface(*mHwc, state.type, bq);
|
||||
producer = bq;
|
||||
dispSurface = new FramebufferSurface(*mHwc, state.type,
|
||||
bqConsumer);
|
||||
producer = bqProducer;
|
||||
}
|
||||
|
||||
const wp<IBinder>& display(curr.keyAt(i));
|
||||
|
@ -1978,7 +1987,7 @@ status_t SurfaceFlinger::createNormalLayer(const sp<Client>& client,
|
|||
status_t err = (*outLayer)->setBuffers(w, h, format, flags);
|
||||
if (err == NO_ERROR) {
|
||||
*handle = (*outLayer)->getHandle();
|
||||
*gbp = (*outLayer)->getBufferQueue();
|
||||
*gbp = (*outLayer)->getProducer();
|
||||
}
|
||||
|
||||
ALOGE_IF(err, "createNormalLayer() failed (%s)", strerror(-err));
|
||||
|
@ -1991,7 +2000,7 @@ status_t SurfaceFlinger::createDimLayer(const sp<Client>& client,
|
|||
{
|
||||
*outLayer = new LayerDim(this, client, name, w, h, flags);
|
||||
*handle = (*outLayer)->getHandle();
|
||||
*gbp = (*outLayer)->getBufferQueue();
|
||||
*gbp = (*outLayer)->getProducer();
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ private:
|
|||
friend class Client;
|
||||
friend class DisplayEventConnection;
|
||||
friend class Layer;
|
||||
friend class SurfaceTextureLayer;
|
||||
friend class MonitoredProducer;
|
||||
|
||||
// This value is specified in number of frames. Log frame stats at most
|
||||
// every half hour.
|
||||
|
|
|
@ -31,8 +31,9 @@ public:
|
|||
virtual void onSidebandStreamChanged() = 0;
|
||||
};
|
||||
|
||||
SurfaceFlingerConsumer(const sp<BufferQueue>& bq, uint32_t tex)
|
||||
: GLConsumer(bq, tex, GLConsumer::TEXTURE_EXTERNAL, false)
|
||||
SurfaceFlingerConsumer(const sp<IGraphicBufferConsumer>& consumer,
|
||||
uint32_t tex)
|
||||
: GLConsumer(consumer, tex, GLConsumer::TEXTURE_EXTERNAL, false)
|
||||
{}
|
||||
|
||||
class BufferRejecter {
|
||||
|
|
|
@ -1,56 +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.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <utils/Errors.h>
|
||||
|
||||
#include "SurfaceFlinger.h"
|
||||
#include "SurfaceTextureLayer.h"
|
||||
|
||||
namespace android {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
SurfaceTextureLayer::SurfaceTextureLayer(const sp<SurfaceFlinger>& flinger)
|
||||
: BufferQueue(), flinger(flinger) {
|
||||
}
|
||||
|
||||
SurfaceTextureLayer::~SurfaceTextureLayer() {
|
||||
// remove ourselves from SurfaceFlinger's list. We do this asynchronously
|
||||
// because we don't know where this dtor is called from, it could be
|
||||
// called with the mStateLock held, leading to a dead-lock (it actually
|
||||
// happens).
|
||||
class MessageCleanUpList : public MessageBase {
|
||||
sp<SurfaceFlinger> flinger;
|
||||
wp<IBinder> gbp;
|
||||
public:
|
||||
MessageCleanUpList(const sp<SurfaceFlinger>& flinger, const wp<IBinder>& gbp)
|
||||
: flinger(flinger), gbp(gbp) { }
|
||||
virtual bool handler() {
|
||||
Mutex::Autolock _l(flinger->mStateLock);
|
||||
flinger->mGraphicBufferProducerList.remove(gbp);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
flinger->postMessageAsync(
|
||||
new MessageCleanUpList(flinger, static_cast<BnGraphicBufferProducer*>(this)) );
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
}; // namespace android
|
|
@ -1,46 +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_SURFACE_TEXTURE_LAYER_H
|
||||
#define ANDROID_SURFACE_TEXTURE_LAYER_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <utils/Errors.h>
|
||||
#include <gui/BufferQueue.h>
|
||||
|
||||
namespace android {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class Layer;
|
||||
class SurfaceFlinger;
|
||||
|
||||
/*
|
||||
* This is a thin wrapper around BufferQueue, used by the Layer class.
|
||||
*/
|
||||
class SurfaceTextureLayer : public BufferQueue {
|
||||
sp<SurfaceFlinger> flinger;
|
||||
public:
|
||||
SurfaceTextureLayer(const sp<SurfaceFlinger>& flinger);
|
||||
virtual ~SurfaceTextureLayer();
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
}; // namespace android
|
||||
|
||||
#endif // ANDROID_SURFACE_TEXTURE_LAYER_H
|
Loading…
Reference in New Issue