get rid of ISurface
ISurface was only used to get the IGraphicBufferProducer from a Layer. It's now replaced by a BBinder subclass / IBinder and is only used as a handle to the surface, to both refer to it and manage its life-time. Also cleaned-up a bit the ISurfaceComposer interface and "create layer" code path. Change-Id: I68d0e02d57b862cffb31d5168c3bc10cea0906eb
This commit is contained in:
parent
f44e9f91f3
commit
4d9b822e2c
|
@ -1,62 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007 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_ISURFACE_H
|
|
||||||
#define ANDROID_GUI_ISURFACE_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <utils/Errors.h>
|
|
||||||
#include <utils/RefBase.h>
|
|
||||||
|
|
||||||
#include <binder/IInterface.h>
|
|
||||||
|
|
||||||
#include <ui/PixelFormat.h>
|
|
||||||
|
|
||||||
namespace android {
|
|
||||||
|
|
||||||
class IGraphicBufferProducer;
|
|
||||||
|
|
||||||
class ISurface : public IInterface
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
enum {
|
|
||||||
GET_SURFACE_TEXTURE = IBinder::FIRST_CALL_TRANSACTION,
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
DECLARE_META_INTERFACE(Surface);
|
|
||||||
|
|
||||||
virtual sp<IGraphicBufferProducer> getSurfaceTexture() const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class BnSurface : public BnInterface<ISurface>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual status_t onTransact( uint32_t code,
|
|
||||||
const Parcel& data,
|
|
||||||
Parcel* reply,
|
|
||||||
uint32_t flags = 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
}; // namespace android
|
|
||||||
|
|
||||||
#endif // ANDROID_GUI_ISURFACE_H
|
|
|
@ -27,11 +27,11 @@
|
||||||
|
|
||||||
#include <ui/PixelFormat.h>
|
#include <ui/PixelFormat.h>
|
||||||
|
|
||||||
#include <gui/ISurface.h>
|
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class IGraphicBufferProducer;
|
||||||
|
|
||||||
class ISurfaceComposerClient : public IInterface
|
class ISurfaceComposerClient : public IInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -55,9 +55,11 @@ public:
|
||||||
/*
|
/*
|
||||||
* Requires ACCESS_SURFACE_FLINGER permission
|
* Requires ACCESS_SURFACE_FLINGER permission
|
||||||
*/
|
*/
|
||||||
virtual sp<ISurface> createSurface(
|
virtual status_t createSurface(
|
||||||
const String8& name, uint32_t w, uint32_t h,
|
const String8& name, uint32_t w, uint32_t h,
|
||||||
PixelFormat format, uint32_t flags) = 0;
|
PixelFormat format, uint32_t flags,
|
||||||
|
sp<IBinder>* handle,
|
||||||
|
sp<IGraphicBufferProducer>* gbp) = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Requires ACCESS_SURFACE_FLINGER permission
|
* Requires ACCESS_SURFACE_FLINGER permission
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include <ui/PixelFormat.h>
|
#include <ui/PixelFormat.h>
|
||||||
#include <ui/Region.h>
|
#include <ui/Region.h>
|
||||||
|
|
||||||
#include <gui/ISurface.h>
|
|
||||||
#include <gui/ISurfaceComposerClient.h>
|
#include <gui/ISurfaceComposerClient.h>
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
@ -46,9 +45,11 @@ public:
|
||||||
static bool isValid(const sp<SurfaceControl>& surface) {
|
static bool isValid(const sp<SurfaceControl>& surface) {
|
||||||
return (surface != 0) && surface->isValid();
|
return (surface != 0) && surface->isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isValid() {
|
bool isValid() {
|
||||||
return mSurface!=0 && mClient!=0;
|
return mHandle!=0 && mClient!=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isSameSurface(
|
static bool isSameSurface(
|
||||||
const sp<SurfaceControl>& lhs, const sp<SurfaceControl>& rhs);
|
const sp<SurfaceControl>& lhs, const sp<SurfaceControl>& rhs);
|
||||||
|
|
||||||
|
@ -82,7 +83,8 @@ private:
|
||||||
|
|
||||||
SurfaceControl(
|
SurfaceControl(
|
||||||
const sp<SurfaceComposerClient>& client,
|
const sp<SurfaceComposerClient>& client,
|
||||||
const sp<ISurface>& surface);
|
const sp<IBinder>& handle,
|
||||||
|
const sp<IGraphicBufferProducer>& gbp);
|
||||||
|
|
||||||
~SurfaceControl();
|
~SurfaceControl();
|
||||||
|
|
||||||
|
@ -90,7 +92,7 @@ private:
|
||||||
void destroy();
|
void destroy();
|
||||||
|
|
||||||
sp<SurfaceComposerClient> mClient;
|
sp<SurfaceComposerClient> mClient;
|
||||||
sp<IBinder> mSurface;
|
sp<IBinder> mHandle;
|
||||||
sp<IGraphicBufferProducer> mGraphicBufferProducer;
|
sp<IGraphicBufferProducer> mGraphicBufferProducer;
|
||||||
mutable Mutex mLock;
|
mutable Mutex mLock;
|
||||||
mutable sp<Surface> mSurfaceData;
|
mutable sp<Surface> mSurfaceData;
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
#include <ui/Region.h>
|
#include <ui/Region.h>
|
||||||
#include <ui/Rect.h>
|
#include <ui/Rect.h>
|
||||||
#include <gui/ISurface.h>
|
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ LOCAL_SRC_FILES:= \
|
||||||
IGraphicBufferProducer.cpp \
|
IGraphicBufferProducer.cpp \
|
||||||
ISensorEventConnection.cpp \
|
ISensorEventConnection.cpp \
|
||||||
ISensorServer.cpp \
|
ISensorServer.cpp \
|
||||||
ISurface.cpp \
|
|
||||||
ISurfaceComposer.cpp \
|
ISurfaceComposer.cpp \
|
||||||
ISurfaceComposerClient.cpp \
|
ISurfaceComposerClient.cpp \
|
||||||
LayerState.cpp \
|
LayerState.cpp \
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LOG_TAG "ISurface"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <binder/Parcel.h>
|
|
||||||
|
|
||||||
#include <gui/ISurface.h>
|
|
||||||
#include <gui/IGraphicBufferProducer.h>
|
|
||||||
|
|
||||||
namespace android {
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
class BpSurface : public BpInterface<ISurface>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BpSurface(const sp<IBinder>& impl)
|
|
||||||
: BpInterface<ISurface>(impl)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual sp<IGraphicBufferProducer> getSurfaceTexture() const {
|
|
||||||
Parcel data, reply;
|
|
||||||
data.writeInterfaceToken(ISurface::getInterfaceDescriptor());
|
|
||||||
remote()->transact(GET_SURFACE_TEXTURE, data, &reply);
|
|
||||||
return interface_cast<IGraphicBufferProducer>(reply.readStrongBinder());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
IMPLEMENT_META_INTERFACE(Surface, "android.ui.ISurface");
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
status_t BnSurface::onTransact(
|
|
||||||
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
|
|
||||||
{
|
|
||||||
switch(code) {
|
|
||||||
case GET_SURFACE_TEXTURE: {
|
|
||||||
CHECK_INTERFACE(ISurface, data, reply);
|
|
||||||
reply->writeStrongBinder( getSurfaceTexture()->asBinder() );
|
|
||||||
return NO_ERROR;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return BBinder::onTransact(code, data, reply, flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}; // namespace android
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <ui/Point.h>
|
#include <ui/Point.h>
|
||||||
#include <ui/Rect.h>
|
#include <ui/Rect.h>
|
||||||
|
|
||||||
#include <gui/ISurface.h>
|
#include <gui/IGraphicBufferProducer.h>
|
||||||
#include <gui/ISurfaceComposerClient.h>
|
#include <gui/ISurfaceComposerClient.h>
|
||||||
#include <private/gui/LayerState.h>
|
#include <private/gui/LayerState.h>
|
||||||
|
|
||||||
|
@ -46,16 +46,13 @@ class BpSurfaceComposerClient : public BpInterface<ISurfaceComposerClient>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BpSurfaceComposerClient(const sp<IBinder>& impl)
|
BpSurfaceComposerClient(const sp<IBinder>& impl)
|
||||||
: BpInterface<ISurfaceComposerClient>(impl)
|
: BpInterface<ISurfaceComposerClient>(impl) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual sp<ISurface> createSurface( const String8& name,
|
virtual status_t createSurface(const String8& name, uint32_t w,
|
||||||
uint32_t w,
|
uint32_t h, PixelFormat format, uint32_t flags,
|
||||||
uint32_t h,
|
sp<IBinder>* handle,
|
||||||
PixelFormat format,
|
sp<IGraphicBufferProducer>* gbp) {
|
||||||
uint32_t flags)
|
|
||||||
{
|
|
||||||
Parcel data, reply;
|
Parcel data, reply;
|
||||||
data.writeInterfaceToken(ISurfaceComposerClient::getInterfaceDescriptor());
|
data.writeInterfaceToken(ISurfaceComposerClient::getInterfaceDescriptor());
|
||||||
data.writeString8(name);
|
data.writeString8(name);
|
||||||
|
@ -64,11 +61,12 @@ public:
|
||||||
data.writeInt32(format);
|
data.writeInt32(format);
|
||||||
data.writeInt32(flags);
|
data.writeInt32(flags);
|
||||||
remote()->transact(CREATE_SURFACE, data, &reply);
|
remote()->transact(CREATE_SURFACE, data, &reply);
|
||||||
return interface_cast<ISurface>(reply.readStrongBinder());
|
*handle = reply.readStrongBinder();
|
||||||
|
*gbp = interface_cast<IGraphicBufferProducer>(reply.readStrongBinder());
|
||||||
|
return reply.readInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual status_t destroySurface(const sp<IBinder>& handle)
|
virtual status_t destroySurface(const sp<IBinder>& handle) {
|
||||||
{
|
|
||||||
Parcel data, reply;
|
Parcel data, reply;
|
||||||
data.writeInterfaceToken(ISurfaceComposerClient::getInterfaceDescriptor());
|
data.writeInterfaceToken(ISurfaceComposerClient::getInterfaceDescriptor());
|
||||||
data.writeStrongBinder(handle);
|
data.writeStrongBinder(handle);
|
||||||
|
@ -92,8 +90,13 @@ status_t BnSurfaceComposerClient::onTransact(
|
||||||
uint32_t h = data.readInt32();
|
uint32_t h = data.readInt32();
|
||||||
PixelFormat format = data.readInt32();
|
PixelFormat format = data.readInt32();
|
||||||
uint32_t flags = data.readInt32();
|
uint32_t flags = data.readInt32();
|
||||||
sp<ISurface> s = createSurface(name, w, h, format, flags);
|
sp<IBinder> handle;
|
||||||
reply->writeStrongBinder(s->asBinder());
|
sp<IGraphicBufferProducer> gbp;
|
||||||
|
status_t result = createSurface(name, w, h, format, flags,
|
||||||
|
&handle, &gbp);
|
||||||
|
reply->writeStrongBinder(handle);
|
||||||
|
reply->writeStrongBinder(gbp->asBinder());
|
||||||
|
reply->writeInt32(result);
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
} break;
|
} break;
|
||||||
case DESTROY_SURFACE: {
|
case DESTROY_SURFACE: {
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include <ui/DisplayInfo.h>
|
#include <ui/DisplayInfo.h>
|
||||||
|
|
||||||
#include <gui/IGraphicBufferProducer.h>
|
#include <gui/IGraphicBufferProducer.h>
|
||||||
#include <gui/ISurface.h>
|
|
||||||
#include <gui/ISurfaceComposer.h>
|
#include <gui/ISurfaceComposer.h>
|
||||||
#include <gui/ISurfaceComposerClient.h>
|
#include <gui/ISurfaceComposerClient.h>
|
||||||
#include <gui/SurfaceComposerClient.h>
|
#include <gui/SurfaceComposerClient.h>
|
||||||
|
@ -471,14 +470,18 @@ sp<SurfaceControl> SurfaceComposerClient::createSurface(
|
||||||
PixelFormat format,
|
PixelFormat format,
|
||||||
uint32_t flags)
|
uint32_t flags)
|
||||||
{
|
{
|
||||||
sp<SurfaceControl> result;
|
sp<SurfaceControl> sur;
|
||||||
if (mStatus == NO_ERROR) {
|
if (mStatus == NO_ERROR) {
|
||||||
sp<ISurface> surface = mClient->createSurface(name, w, h, format, flags);
|
sp<IBinder> handle;
|
||||||
if (surface != 0) {
|
sp<IGraphicBufferProducer> gbp;
|
||||||
result = new SurfaceControl(this, surface);
|
status_t err = mClient->createSurface(name, w, h, format, flags,
|
||||||
|
&handle, &gbp);
|
||||||
|
ALOGE_IF(err, "SurfaceComposerClient::createSurface error %s", strerror(-err));
|
||||||
|
if (err == NO_ERROR) {
|
||||||
|
sur = new SurfaceControl(this, handle, gbp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return sur;
|
||||||
}
|
}
|
||||||
|
|
||||||
sp<IBinder> SurfaceComposerClient::createDisplay(const String8& displayName,
|
sp<IBinder> SurfaceComposerClient::createDisplay(const String8& displayName,
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
#include <ui/GraphicBuffer.h>
|
#include <ui/GraphicBuffer.h>
|
||||||
#include <ui/Rect.h>
|
#include <ui/Rect.h>
|
||||||
|
|
||||||
#include <gui/ISurface.h>
|
|
||||||
#include <gui/ISurfaceComposer.h>
|
#include <gui/ISurfaceComposer.h>
|
||||||
#include <gui/Surface.h>
|
#include <gui/Surface.h>
|
||||||
#include <gui/SurfaceComposerClient.h>
|
#include <gui/SurfaceComposerClient.h>
|
||||||
|
@ -48,13 +47,10 @@ namespace android {
|
||||||
|
|
||||||
SurfaceControl::SurfaceControl(
|
SurfaceControl::SurfaceControl(
|
||||||
const sp<SurfaceComposerClient>& client,
|
const sp<SurfaceComposerClient>& client,
|
||||||
const sp<ISurface>& surface)
|
const sp<IBinder>& handle,
|
||||||
: mClient(client)
|
const sp<IGraphicBufferProducer>& gbp)
|
||||||
|
: mClient(client), mHandle(handle), mGraphicBufferProducer(gbp)
|
||||||
{
|
{
|
||||||
if (surface != 0) {
|
|
||||||
mSurface = surface->asBinder();
|
|
||||||
mGraphicBufferProducer = surface->getSurfaceTexture();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SurfaceControl::~SurfaceControl()
|
SurfaceControl::~SurfaceControl()
|
||||||
|
@ -65,12 +61,12 @@ SurfaceControl::~SurfaceControl()
|
||||||
void SurfaceControl::destroy()
|
void SurfaceControl::destroy()
|
||||||
{
|
{
|
||||||
if (isValid()) {
|
if (isValid()) {
|
||||||
mClient->destroySurface(mSurface);
|
mClient->destroySurface(mHandle);
|
||||||
}
|
}
|
||||||
// clear all references and trigger an IPC now, to make sure things
|
// clear all references and trigger an IPC now, to make sure things
|
||||||
// happen without delay, since these resources are quite heavy.
|
// happen without delay, since these resources are quite heavy.
|
||||||
mClient.clear();
|
mClient.clear();
|
||||||
mSurface.clear();
|
mHandle.clear();
|
||||||
mGraphicBufferProducer.clear();
|
mGraphicBufferProducer.clear();
|
||||||
IPCThreadState::self()->flushCommands();
|
IPCThreadState::self()->flushCommands();
|
||||||
}
|
}
|
||||||
|
@ -91,81 +87,81 @@ bool SurfaceControl::isSameSurface(
|
||||||
{
|
{
|
||||||
if (lhs == 0 || rhs == 0)
|
if (lhs == 0 || rhs == 0)
|
||||||
return false;
|
return false;
|
||||||
return lhs->mSurface == rhs->mSurface;
|
return lhs->mHandle == rhs->mHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t SurfaceControl::setLayerStack(int32_t layerStack) {
|
status_t SurfaceControl::setLayerStack(int32_t layerStack) {
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->setLayerStack(mSurface, layerStack);
|
return client->setLayerStack(mHandle, layerStack);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::setLayer(int32_t layer) {
|
status_t SurfaceControl::setLayer(int32_t layer) {
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->setLayer(mSurface, layer);
|
return client->setLayer(mHandle, layer);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::setPosition(int32_t x, int32_t y) {
|
status_t SurfaceControl::setPosition(int32_t x, int32_t y) {
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->setPosition(mSurface, x, y);
|
return client->setPosition(mHandle, x, y);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::setSize(uint32_t w, uint32_t h) {
|
status_t SurfaceControl::setSize(uint32_t w, uint32_t h) {
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->setSize(mSurface, w, h);
|
return client->setSize(mHandle, w, h);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::hide() {
|
status_t SurfaceControl::hide() {
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->hide(mSurface);
|
return client->hide(mHandle);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::show() {
|
status_t SurfaceControl::show() {
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->show(mSurface);
|
return client->show(mHandle);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::setFlags(uint32_t flags, uint32_t mask) {
|
status_t SurfaceControl::setFlags(uint32_t flags, uint32_t mask) {
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->setFlags(mSurface, flags, mask);
|
return client->setFlags(mHandle, flags, mask);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::setTransparentRegionHint(const Region& transparent) {
|
status_t SurfaceControl::setTransparentRegionHint(const Region& transparent) {
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->setTransparentRegionHint(mSurface, transparent);
|
return client->setTransparentRegionHint(mHandle, transparent);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::setAlpha(float alpha) {
|
status_t SurfaceControl::setAlpha(float alpha) {
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->setAlpha(mSurface, alpha);
|
return client->setAlpha(mHandle, alpha);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::setMatrix(float dsdx, float dtdx, float dsdy, float dtdy) {
|
status_t SurfaceControl::setMatrix(float dsdx, float dtdx, float dsdy, float dtdy) {
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->setMatrix(mSurface, dsdx, dtdx, dsdy, dtdy);
|
return client->setMatrix(mHandle, dsdx, dtdx, dsdy, dtdy);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::setCrop(const Rect& crop) {
|
status_t SurfaceControl::setCrop(const Rect& crop) {
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->setCrop(mSurface, crop);
|
return client->setCrop(mHandle, crop);
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t SurfaceControl::validate() const
|
status_t SurfaceControl::validate() const
|
||||||
{
|
{
|
||||||
if (mSurface==0 || mClient==0) {
|
if (mHandle==0 || mClient==0) {
|
||||||
ALOGE("invalid ISurface (%p) or client (%p)",
|
ALOGE("invalid handle (%p) or client (%p)",
|
||||||
mSurface.get(), mClient.get());
|
mHandle.get(), mClient.get());
|
||||||
return NO_INIT;
|
return NO_INIT;
|
||||||
}
|
}
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
|
|
|
@ -105,10 +105,11 @@ status_t Client::onTransact(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sp<ISurface> Client::createSurface(
|
status_t Client::createSurface(
|
||||||
const String8& name,
|
const String8& name,
|
||||||
uint32_t w, uint32_t h, PixelFormat format,
|
uint32_t w, uint32_t h, PixelFormat format, uint32_t flags,
|
||||||
uint32_t flags)
|
sp<IBinder>* handle,
|
||||||
|
sp<IGraphicBufferProducer>* gbp)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* createSurface must be called from the GL thread so that it can
|
* createSurface must be called from the GL thread so that it can
|
||||||
|
@ -116,9 +117,11 @@ sp<ISurface> Client::createSurface(
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class MessageCreateLayer : public MessageBase {
|
class MessageCreateLayer : public MessageBase {
|
||||||
sp<ISurface> result;
|
|
||||||
SurfaceFlinger* flinger;
|
SurfaceFlinger* flinger;
|
||||||
Client* client;
|
Client* client;
|
||||||
|
sp<IBinder>* handle;
|
||||||
|
sp<IGraphicBufferProducer>* gbp;
|
||||||
|
status_t result;
|
||||||
const String8& name;
|
const String8& name;
|
||||||
uint32_t w, h;
|
uint32_t w, h;
|
||||||
PixelFormat format;
|
PixelFormat format;
|
||||||
|
@ -126,21 +129,23 @@ sp<ISurface> Client::createSurface(
|
||||||
public:
|
public:
|
||||||
MessageCreateLayer(SurfaceFlinger* flinger,
|
MessageCreateLayer(SurfaceFlinger* flinger,
|
||||||
const String8& name, Client* client,
|
const String8& name, Client* client,
|
||||||
uint32_t w, uint32_t h, PixelFormat format,
|
uint32_t w, uint32_t h, PixelFormat format, uint32_t flags,
|
||||||
uint32_t flags)
|
sp<IBinder>* handle,
|
||||||
: flinger(flinger), client(client), name(name),
|
sp<IGraphicBufferProducer>* gbp)
|
||||||
w(w), h(h), format(format), flags(flags)
|
: flinger(flinger), client(client),
|
||||||
{
|
handle(handle), gbp(gbp),
|
||||||
|
name(name), w(w), h(h), format(format), flags(flags) {
|
||||||
}
|
}
|
||||||
sp<ISurface> getResult() const { return result; }
|
status_t getResult() const { return result; }
|
||||||
virtual bool handler() {
|
virtual bool handler() {
|
||||||
result = flinger->createLayer(name, client, w, h, format, flags);
|
result = flinger->createLayer(name, client, w, h, format, flags,
|
||||||
|
handle, gbp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
sp<MessageBase> msg = new MessageCreateLayer(mFlinger.get(),
|
sp<MessageBase> msg = new MessageCreateLayer(mFlinger.get(),
|
||||||
name, this, w, h, format, flags);
|
name, this, w, h, format, flags, handle, gbp);
|
||||||
mFlinger->postMessageSync(msg);
|
mFlinger->postMessageSync(msg);
|
||||||
return static_cast<MessageCreateLayer*>( msg.get() )->getResult();
|
return static_cast<MessageCreateLayer*>( msg.get() )->getResult();
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,10 +52,11 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// ISurfaceComposerClient interface
|
// ISurfaceComposerClient interface
|
||||||
virtual sp<ISurface> createSurface(
|
virtual status_t createSurface(
|
||||||
const String8& name,
|
const String8& name,
|
||||||
uint32_t w, uint32_t h,PixelFormat format,
|
uint32_t w, uint32_t h,PixelFormat format, uint32_t flags,
|
||||||
uint32_t flags);
|
sp<IBinder>* handle,
|
||||||
|
sp<IGraphicBufferProducer>* gbp);
|
||||||
|
|
||||||
virtual status_t destroySurface(const sp<IBinder>& handle);
|
virtual status_t destroySurface(const sp<IBinder>& handle);
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,8 @@ namespace android {
|
||||||
|
|
||||||
int32_t Layer::sSequence = 1;
|
int32_t Layer::sSequence = 1;
|
||||||
|
|
||||||
Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client)
|
Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client,
|
||||||
|
const String8& name, uint32_t w, uint32_t h, uint32_t flags)
|
||||||
: contentDirty(false),
|
: contentDirty(false),
|
||||||
sequence(uint32_t(android_atomic_inc(&sSequence))),
|
sequence(uint32_t(android_atomic_inc(&sSequence))),
|
||||||
mFlinger(flinger),
|
mFlinger(flinger),
|
||||||
|
@ -79,6 +80,29 @@ Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client)
|
||||||
{
|
{
|
||||||
mCurrentCrop.makeInvalid();
|
mCurrentCrop.makeInvalid();
|
||||||
glGenTextures(1, &mTextureName);
|
glGenTextures(1, &mTextureName);
|
||||||
|
|
||||||
|
uint32_t layerFlags = 0;
|
||||||
|
if (flags & ISurfaceComposerClient::eHidden)
|
||||||
|
layerFlags = layer_state_t::eLayerHidden;
|
||||||
|
|
||||||
|
if (flags & ISurfaceComposerClient::eNonPremultiplied)
|
||||||
|
mPremultipliedAlpha = false;
|
||||||
|
|
||||||
|
mName = name;
|
||||||
|
|
||||||
|
mCurrentState.active.w = w;
|
||||||
|
mCurrentState.active.h = h;
|
||||||
|
mCurrentState.active.crop.makeInvalid();
|
||||||
|
mCurrentState.z = 0;
|
||||||
|
mCurrentState.alpha = 0xFF;
|
||||||
|
mCurrentState.layerStack = 0;
|
||||||
|
mCurrentState.flags = layerFlags;
|
||||||
|
mCurrentState.sequence = 0;
|
||||||
|
mCurrentState.transform.set(0, 0);
|
||||||
|
mCurrentState.requested = mCurrentState.active;
|
||||||
|
|
||||||
|
// drawing state & current state are identical
|
||||||
|
mDrawingState = mCurrentState;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layer::onFirstRef()
|
void Layer::onFirstRef()
|
||||||
|
@ -91,6 +115,7 @@ void Layer::onFirstRef()
|
||||||
mSurfaceFlingerConsumer->setConsumerUsageBits(getEffectiveUsage(0));
|
mSurfaceFlingerConsumer->setConsumerUsageBits(getEffectiveUsage(0));
|
||||||
mSurfaceFlingerConsumer->setFrameAvailableListener(this);
|
mSurfaceFlingerConsumer->setFrameAvailableListener(this);
|
||||||
mSurfaceFlingerConsumer->setSynchronousMode(true);
|
mSurfaceFlingerConsumer->setSynchronousMode(true);
|
||||||
|
mSurfaceFlingerConsumer->setName(mName);
|
||||||
|
|
||||||
#ifdef TARGET_DISABLE_TRIPLE_BUFFERING
|
#ifdef TARGET_DISABLE_TRIPLE_BUFFERING
|
||||||
#warning "disabling triple buffering"
|
#warning "disabling triple buffering"
|
||||||
|
@ -103,8 +128,7 @@ void Layer::onFirstRef()
|
||||||
updateTransformHint(hw);
|
updateTransformHint(hw);
|
||||||
}
|
}
|
||||||
|
|
||||||
Layer::~Layer()
|
Layer::~Layer() {
|
||||||
{
|
|
||||||
sp<Client> c(mClientRef.promote());
|
sp<Client> c(mClientRef.promote());
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
c->detachLayer(this);
|
c->detachLayer(this);
|
||||||
|
@ -139,39 +163,10 @@ void Layer::onRemoved() {
|
||||||
// set-up
|
// set-up
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
void Layer::setName(const String8& name) {
|
|
||||||
mName = name;
|
|
||||||
mSurfaceFlingerConsumer->setName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
String8 Layer::getName() const {
|
String8 Layer::getName() const {
|
||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layer::initStates(uint32_t w, uint32_t h, uint32_t flags)
|
|
||||||
{
|
|
||||||
uint32_t layerFlags = 0;
|
|
||||||
if (flags & ISurfaceComposerClient::eHidden)
|
|
||||||
layerFlags = layer_state_t::eLayerHidden;
|
|
||||||
|
|
||||||
if (flags & ISurfaceComposerClient::eNonPremultiplied)
|
|
||||||
mPremultipliedAlpha = false;
|
|
||||||
|
|
||||||
mCurrentState.active.w = w;
|
|
||||||
mCurrentState.active.h = h;
|
|
||||||
mCurrentState.active.crop.makeInvalid();
|
|
||||||
mCurrentState.z = 0;
|
|
||||||
mCurrentState.alpha = 0xFF;
|
|
||||||
mCurrentState.layerStack = 0;
|
|
||||||
mCurrentState.flags = layerFlags;
|
|
||||||
mCurrentState.sequence = 0;
|
|
||||||
mCurrentState.transform.set(0, 0);
|
|
||||||
mCurrentState.requested = mCurrentState.active;
|
|
||||||
|
|
||||||
// drawing state & current state are identical
|
|
||||||
mDrawingState = mCurrentState;
|
|
||||||
}
|
|
||||||
|
|
||||||
status_t Layer::setBuffers( uint32_t w, uint32_t h,
|
status_t Layer::setBuffers( uint32_t w, uint32_t h,
|
||||||
PixelFormat format, uint32_t flags)
|
PixelFormat format, uint32_t flags)
|
||||||
{
|
{
|
||||||
|
@ -207,59 +202,47 @@ status_t Layer::setBuffers( uint32_t w, uint32_t h,
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
sp<ISurface> Layer::createSurface() {
|
sp<IBinder> Layer::getHandle() {
|
||||||
/*
|
|
||||||
* This class provides an implementation of BnSurface (the "native" or
|
|
||||||
* "remote" side of the Binder IPC interface ISurface), and mixes in
|
|
||||||
* LayerCleaner to ensure that mFlinger->onLayerDestroyed() is called for
|
|
||||||
* this layer when the BSurface is destroyed.
|
|
||||||
*
|
|
||||||
* The idea is to provide a handle to the Layer through ISurface that
|
|
||||||
* is cleaned up automatically when the last reference to the ISurface
|
|
||||||
* goes away. (The references will be held on the "proxy" side, while
|
|
||||||
* the Layer exists on the "native" side.)
|
|
||||||
*
|
|
||||||
* The Layer has a reference to an instance of SurfaceFlinger's variant
|
|
||||||
* of GLConsumer, which holds a reference to the BufferQueue. The
|
|
||||||
* getSurfaceTexture() call returns a Binder interface reference for
|
|
||||||
* the producer interface of the buffer queue associated with the Layer.
|
|
||||||
*/
|
|
||||||
class BSurface : public BnSurface, public LayerCleaner {
|
|
||||||
wp<const Layer> mOwner;
|
|
||||||
virtual sp<IGraphicBufferProducer> getSurfaceTexture() const {
|
|
||||||
sp<IGraphicBufferProducer> res;
|
|
||||||
sp<const Layer> that( mOwner.promote() );
|
|
||||||
if (that != NULL) {
|
|
||||||
res = that->mSurfaceFlingerConsumer->getBufferQueue();
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
public:
|
|
||||||
BSurface(const sp<SurfaceFlinger>& flinger,
|
|
||||||
const sp<Layer>& layer)
|
|
||||||
: LayerCleaner(flinger, layer), mOwner(layer) { }
|
|
||||||
};
|
|
||||||
sp<ISurface> sur(new BSurface(mFlinger, this));
|
|
||||||
return sur;
|
|
||||||
}
|
|
||||||
|
|
||||||
wp<IBinder> Layer::getSurfaceTextureBinder() const {
|
|
||||||
return mSurfaceFlingerConsumer->getBufferQueue()->asBinder();
|
|
||||||
}
|
|
||||||
|
|
||||||
sp<ISurface> Layer::getSurface()
|
|
||||||
{
|
|
||||||
sp<ISurface> s;
|
|
||||||
Mutex::Autolock _l(mLock);
|
Mutex::Autolock _l(mLock);
|
||||||
|
|
||||||
LOG_ALWAYS_FATAL_IF(mHasSurface,
|
LOG_ALWAYS_FATAL_IF(mHasSurface,
|
||||||
"Layer::getSurface() has already been called");
|
"Layer::getHandle() has already been called");
|
||||||
|
|
||||||
mHasSurface = true;
|
mHasSurface = true;
|
||||||
s = createSurface();
|
|
||||||
return s;
|
/*
|
||||||
|
* The layer handle is just a BBinder object passed to the client
|
||||||
|
* (remote process) -- we don't keep any reference on our side such that
|
||||||
|
* the dtor is called when the remote side let go of its reference.
|
||||||
|
*
|
||||||
|
* LayerCleaner ensures that mFlinger->onLayerDestroyed() is called for
|
||||||
|
* this layer when the handle is destroyed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Handle : public BBinder, public LayerCleaner {
|
||||||
|
wp<const Layer> mOwner;
|
||||||
|
public:
|
||||||
|
Handle(const sp<SurfaceFlinger>& flinger, const sp<Layer>& layer)
|
||||||
|
: LayerCleaner(flinger, layer), mOwner(layer) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return new Handle(mFlinger, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sp<BufferQueue> Layer::getBufferQueue() const {
|
||||||
|
return mSurfaceFlingerConsumer->getBufferQueue();
|
||||||
|
}
|
||||||
|
|
||||||
|
//virtual sp<IGraphicBufferProducer> getSurfaceTexture() const {
|
||||||
|
// sp<IGraphicBufferProducer> res;
|
||||||
|
// sp<const Layer> that( mOwner.promote() );
|
||||||
|
// if (that != NULL) {
|
||||||
|
// res = that->mSurfaceFlingerConsumer->getBufferQueue();
|
||||||
|
// }
|
||||||
|
// return res;
|
||||||
|
//}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// h/w composer set-up
|
// h/w composer set-up
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
|
@ -124,16 +124,12 @@ public:
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
Layer(SurfaceFlinger* flinger, const sp<Client>& client);
|
Layer(SurfaceFlinger* flinger, const sp<Client>& client,
|
||||||
|
const String8& name, uint32_t w, uint32_t h, uint32_t flags);
|
||||||
virtual ~Layer();
|
virtual ~Layer();
|
||||||
|
|
||||||
// the this layer's size and format
|
// the this layer's size and format
|
||||||
status_t setBuffers(uint32_t w, uint32_t h,
|
status_t setBuffers(uint32_t w, uint32_t h, PixelFormat format, uint32_t flags);
|
||||||
PixelFormat format, uint32_t flags=0);
|
|
||||||
|
|
||||||
// Creates an ISurface associated with this object. This may only be
|
|
||||||
// called once. to provide your own ISurface, override createSurface().
|
|
||||||
sp<ISurface> getSurface();
|
|
||||||
|
|
||||||
// modify current state
|
// modify current state
|
||||||
bool setPosition(float x, float y);
|
bool setPosition(float x, float y);
|
||||||
|
@ -154,18 +150,14 @@ public:
|
||||||
void computeGeometry(const sp<const DisplayDevice>& hw, LayerMesh* mesh) const;
|
void computeGeometry(const sp<const DisplayDevice>& hw, LayerMesh* mesh) const;
|
||||||
Rect computeBounds() const;
|
Rect computeBounds() const;
|
||||||
|
|
||||||
|
sp<IBinder> getHandle();
|
||||||
|
sp<BufferQueue> getBufferQueue() const;
|
||||||
|
String8 getName() const;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
/*
|
|
||||||
* initStates - called just after construction
|
|
||||||
*/
|
|
||||||
virtual void initStates(uint32_t w, uint32_t h, uint32_t flags);
|
|
||||||
|
|
||||||
virtual const char* getTypeId() const { return "Layer"; }
|
virtual const char* getTypeId() const { return "Layer"; }
|
||||||
|
|
||||||
virtual void setName(const String8& name);
|
|
||||||
String8 getName() const;
|
|
||||||
|
|
||||||
virtual void setGeometry(const sp<const DisplayDevice>& hw,
|
virtual void setGeometry(const sp<const DisplayDevice>& hw,
|
||||||
HWComposer::HWCLayerInterface& layer);
|
HWComposer::HWCLayerInterface& layer);
|
||||||
virtual void setPerFrameData(const sp<const DisplayDevice>& hw,
|
virtual void setPerFrameData(const sp<const DisplayDevice>& hw,
|
||||||
|
@ -277,8 +269,6 @@ public:
|
||||||
virtual void onRemoved();
|
virtual void onRemoved();
|
||||||
|
|
||||||
|
|
||||||
virtual wp<IBinder> getSurfaceTextureBinder() const;
|
|
||||||
|
|
||||||
// Updates the transform hint in our SurfaceFlingerConsumer to match
|
// Updates the transform hint in our SurfaceFlingerConsumer to match
|
||||||
// the current orientation of the display device.
|
// the current orientation of the display device.
|
||||||
virtual void updateTransformHint(const sp<const DisplayDevice>& hw) const;
|
virtual void updateTransformHint(const sp<const DisplayDevice>& hw) const;
|
||||||
|
@ -336,9 +326,6 @@ protected:
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Creates an instance of ISurface for this Layer.
|
|
||||||
virtual sp<ISurface> createSurface();
|
|
||||||
|
|
||||||
// Interface implementation for SurfaceFlingerConsumer::FrameAvailableListener
|
// Interface implementation for SurfaceFlingerConsumer::FrameAvailableListener
|
||||||
virtual void onFrameAvailable();
|
virtual void onFrameAvailable();
|
||||||
|
|
||||||
|
@ -394,7 +381,7 @@ private:
|
||||||
|
|
||||||
// protected by mLock
|
// protected by mLock
|
||||||
mutable Mutex mLock;
|
mutable Mutex mLock;
|
||||||
// Set to true if an ISurface has been associated with this object.
|
// Set to true once we've returned this surface's handle
|
||||||
mutable bool mHasSurface;
|
mutable bool mHasSurface;
|
||||||
const wp<Client> mClientRef;
|
const wp<Client> mClientRef;
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,8 +33,9 @@
|
||||||
namespace android {
|
namespace android {
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
LayerDim::LayerDim(SurfaceFlinger* flinger, const sp<Client>& client)
|
LayerDim::LayerDim(SurfaceFlinger* flinger, const sp<Client>& client,
|
||||||
: Layer(flinger, client) {
|
const String8& name, uint32_t w, uint32_t h, uint32_t flags)
|
||||||
|
: Layer(flinger, client, name, w, h, flags) {
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerDim::~LayerDim() {
|
LayerDim::~LayerDim() {
|
||||||
|
@ -69,19 +70,6 @@ void LayerDim::onDraw(const sp<const DisplayDevice>& hw, const Region& clip) con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sp<ISurface> LayerDim::createSurface()
|
|
||||||
{
|
|
||||||
class BSurface : public BnSurface, public LayerCleaner {
|
|
||||||
virtual sp<IGraphicBufferProducer> getSurfaceTexture() const { return 0; }
|
|
||||||
public:
|
|
||||||
BSurface(const sp<SurfaceFlinger>& flinger,
|
|
||||||
const sp<Layer>& layer)
|
|
||||||
: LayerCleaner(flinger, layer) { }
|
|
||||||
};
|
|
||||||
sp<ISurface> sur(new BSurface(mFlinger, this));
|
|
||||||
return sur;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LayerDim::isVisible() const {
|
bool LayerDim::isVisible() const {
|
||||||
const Layer::State& s(drawingState());
|
const Layer::State& s(drawingState());
|
||||||
return !(s.flags & layer_state_t::eLayerHidden) && s.alpha;
|
return !(s.flags & layer_state_t::eLayerHidden) && s.alpha;
|
||||||
|
|
|
@ -32,7 +32,8 @@ namespace android {
|
||||||
class LayerDim : public Layer
|
class LayerDim : public Layer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LayerDim(SurfaceFlinger* flinger, const sp<Client>& client);
|
LayerDim(SurfaceFlinger* flinger, const sp<Client>& client,
|
||||||
|
const String8& name, uint32_t w, uint32_t h, uint32_t flags);
|
||||||
virtual ~LayerDim();
|
virtual ~LayerDim();
|
||||||
|
|
||||||
virtual void onDraw(const sp<const DisplayDevice>& hw, const Region& clip) const;
|
virtual void onDraw(const sp<const DisplayDevice>& hw, const Region& clip) const;
|
||||||
|
@ -44,7 +45,6 @@ public:
|
||||||
|
|
||||||
virtual bool isFixedSize() const { return true; }
|
virtual bool isFixedSize() const { return true; }
|
||||||
virtual bool isVisible() const;
|
virtual bool isVisible() const;
|
||||||
virtual sp<ISurface> createSurface();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
|
@ -581,11 +581,10 @@ bool SurfaceFlinger::authenticateSurfaceTexture(
|
||||||
size_t count = currentLayers.size();
|
size_t count = currentLayers.size();
|
||||||
for (size_t i=0 ; i<count ; i++) {
|
for (size_t i=0 ; i<count ; i++) {
|
||||||
const sp<Layer>& layer(currentLayers[i]);
|
const sp<Layer>& layer(currentLayers[i]);
|
||||||
// If this is an instance of Layer (as opposed to, say, LayerDim),
|
// Get the consumer interface of SurfaceFlingerConsumer's
|
||||||
// we will get the consumer interface of SurfaceFlingerConsumer's
|
|
||||||
// BufferQueue. If it's the same Binder object as the graphic
|
// BufferQueue. If it's the same Binder object as the graphic
|
||||||
// buffer producer interface, return success.
|
// buffer producer interface, return success.
|
||||||
wp<IBinder> lbcBinder = layer->getSurfaceTextureBinder();
|
sp<IBinder> lbcBinder = layer->getBufferQueue()->asBinder();
|
||||||
if (lbcBinder == surfaceTextureBinder) {
|
if (lbcBinder == surfaceTextureBinder) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -601,7 +600,7 @@ bool SurfaceFlinger::authenticateSurfaceTexture(
|
||||||
size_t purgatorySize = mLayerPurgatory.size();
|
size_t purgatorySize = mLayerPurgatory.size();
|
||||||
for (size_t i=0 ; i<purgatorySize ; i++) {
|
for (size_t i=0 ; i<purgatorySize ; i++) {
|
||||||
const sp<Layer>& layer(mLayerPurgatory.itemAt(i));
|
const sp<Layer>& layer(mLayerPurgatory.itemAt(i));
|
||||||
wp<IBinder> lbcBinder = layer->getSurfaceTextureBinder();
|
sp<IBinder> lbcBinder = layer->getBufferQueue()->asBinder();
|
||||||
if (lbcBinder == surfaceTextureBinder) {
|
if (lbcBinder == surfaceTextureBinder) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1720,7 +1719,7 @@ status_t SurfaceFlinger::purgatorizeLayer_l(const sp<Layer>& layer)
|
||||||
// it's possible that we don't find a layer, because it might
|
// it's possible that we don't find a layer, because it might
|
||||||
// have been destroyed already -- this is not technically an error
|
// have been destroyed already -- this is not technically an error
|
||||||
// from the user because there is a race between Client::destroySurface(),
|
// from the user because there is a race between Client::destroySurface(),
|
||||||
// ~Client() and ~ISurface().
|
// ~Client() and ~LayerCleaner().
|
||||||
return (err == NAME_NOT_FOUND) ? status_t(NO_ERROR) : err;
|
return (err == NAME_NOT_FOUND) ? status_t(NO_ERROR) : err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1924,48 +1923,49 @@ uint32_t SurfaceFlinger::setClientStateLocked(
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
sp<ISurface> SurfaceFlinger::createLayer(
|
status_t SurfaceFlinger::createLayer(
|
||||||
const String8& name,
|
const String8& name,
|
||||||
const sp<Client>& client,
|
const sp<Client>& client,
|
||||||
uint32_t w, uint32_t h, PixelFormat format,
|
uint32_t w, uint32_t h, PixelFormat format, uint32_t flags,
|
||||||
uint32_t flags)
|
sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp)
|
||||||
{
|
{
|
||||||
sp<Layer> layer;
|
//ALOGD("createLayer for (%d x %d), name=%s", w, h, name.string());
|
||||||
sp<ISurface> surfaceHandle;
|
|
||||||
|
|
||||||
if (int32_t(w|h) < 0) {
|
if (int32_t(w|h) < 0) {
|
||||||
ALOGE("createLayer() failed, w or h is negative (w=%d, h=%d)",
|
ALOGE("createLayer() failed, w or h is negative (w=%d, h=%d)",
|
||||||
int(w), int(h));
|
int(w), int(h));
|
||||||
return surfaceHandle;
|
return BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ALOGD("createLayer for (%d x %d), name=%s", w, h, name.string());
|
status_t result = NO_ERROR;
|
||||||
|
|
||||||
|
sp<Layer> layer;
|
||||||
|
|
||||||
switch (flags & ISurfaceComposerClient::eFXSurfaceMask) {
|
switch (flags & ISurfaceComposerClient::eFXSurfaceMask) {
|
||||||
case ISurfaceComposerClient::eFXSurfaceNormal:
|
case ISurfaceComposerClient::eFXSurfaceNormal:
|
||||||
layer = createNormalLayer(client, w, h, flags, format);
|
result = createNormalLayer(client,
|
||||||
|
name, w, h, flags, format,
|
||||||
|
handle, gbp, &layer);
|
||||||
break;
|
break;
|
||||||
case ISurfaceComposerClient::eFXSurfaceDim:
|
case ISurfaceComposerClient::eFXSurfaceDim:
|
||||||
layer = createDimLayer(client, w, h, flags);
|
result = createDimLayer(client,
|
||||||
|
name, w, h, flags,
|
||||||
|
handle, gbp, &layer);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result = BAD_VALUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (layer != 0) {
|
if (result == NO_ERROR) {
|
||||||
layer->initStates(w, h, flags);
|
addClientLayer(client, *handle, layer);
|
||||||
layer->setName(name);
|
|
||||||
surfaceHandle = layer->getSurface();
|
|
||||||
if (surfaceHandle != 0) {
|
|
||||||
addClientLayer(client, surfaceHandle->asBinder(), layer);
|
|
||||||
}
|
|
||||||
setTransactionFlags(eTransactionNeeded);
|
setTransactionFlags(eTransactionNeeded);
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
return surfaceHandle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sp<Layer> SurfaceFlinger::createNormalLayer(
|
status_t SurfaceFlinger::createNormalLayer(const sp<Client>& client,
|
||||||
const sp<Client>& client,
|
const String8& name, uint32_t w, uint32_t h, uint32_t flags, PixelFormat& format,
|
||||||
uint32_t w, uint32_t h, uint32_t flags,
|
sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp, sp<Layer>* outLayer)
|
||||||
PixelFormat& format)
|
|
||||||
{
|
{
|
||||||
// initialize the surfaces
|
// initialize the surfaces
|
||||||
switch (format) {
|
switch (format) {
|
||||||
|
@ -1987,21 +1987,25 @@ sp<Layer> SurfaceFlinger::createNormalLayer(
|
||||||
format = PIXEL_FORMAT_RGBA_8888;
|
format = PIXEL_FORMAT_RGBA_8888;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sp<Layer> layer = new Layer(this, client);
|
*outLayer = new Layer(this, client, name, w, h, flags);
|
||||||
status_t err = layer->setBuffers(w, h, format, flags);
|
status_t err = (*outLayer)->setBuffers(w, h, format, flags);
|
||||||
if (CC_LIKELY(err != NO_ERROR)) {
|
if (err == NO_ERROR) {
|
||||||
ALOGE("createNormalLayer() failed (%s)", strerror(-err));
|
*handle = (*outLayer)->getHandle();
|
||||||
layer.clear();
|
*gbp = (*outLayer)->getBufferQueue();
|
||||||
}
|
}
|
||||||
return layer;
|
|
||||||
|
ALOGE_IF(err, "createNormalLayer() failed (%s)", strerror(-err));
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
sp<LayerDim> SurfaceFlinger::createDimLayer(
|
status_t SurfaceFlinger::createDimLayer(const sp<Client>& client,
|
||||||
const sp<Client>& client,
|
const String8& name, uint32_t w, uint32_t h, uint32_t flags,
|
||||||
uint32_t w, uint32_t h, uint32_t flags)
|
sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp, sp<Layer>* outLayer)
|
||||||
{
|
{
|
||||||
sp<LayerDim> layer = new LayerDim(this, client);
|
*outLayer = new LayerDim(this, client, name, w, h, flags);
|
||||||
return layer;
|
*handle = (*outLayer)->getHandle();
|
||||||
|
*gbp = (*outLayer)->getBufferQueue();
|
||||||
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t SurfaceFlinger::onLayerRemoved(const sp<Client>& client, const sp<IBinder>& handle)
|
status_t SurfaceFlinger::onLayerRemoved(const sp<Client>& client, const sp<IBinder>& handle)
|
||||||
|
@ -2030,7 +2034,7 @@ status_t SurfaceFlinger::onLayerRemoved(const sp<Client>& client, const sp<IBind
|
||||||
|
|
||||||
status_t SurfaceFlinger::onLayerDestroyed(const wp<Layer>& layer)
|
status_t SurfaceFlinger::onLayerDestroyed(const wp<Layer>& layer)
|
||||||
{
|
{
|
||||||
// called by ~ISurface() when all references are gone
|
// called by ~LayerCleaner() when all references are gone
|
||||||
status_t err = NO_ERROR;
|
status_t err = NO_ERROR;
|
||||||
sp<Layer> l(layer.promote());
|
sp<Layer> l(layer.promote());
|
||||||
if (l != NULL) {
|
if (l != NULL) {
|
||||||
|
|
|
@ -257,14 +257,18 @@ private:
|
||||||
/* ------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------
|
||||||
* Layer management
|
* Layer management
|
||||||
*/
|
*/
|
||||||
sp<ISurface> createLayer(const String8& name, const sp<Client>& client,
|
status_t createLayer(const String8& name, const sp<Client>& client,
|
||||||
uint32_t w, uint32_t h, PixelFormat format, uint32_t flags);
|
uint32_t w, uint32_t h, PixelFormat format, uint32_t flags,
|
||||||
|
sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp);
|
||||||
|
|
||||||
sp<Layer> createNormalLayer(const sp<Client>& client,
|
status_t createNormalLayer(const sp<Client>& client, const String8& name,
|
||||||
uint32_t w, uint32_t h, uint32_t flags, PixelFormat& format);
|
uint32_t w, uint32_t h, uint32_t flags, PixelFormat& format,
|
||||||
|
sp<IBinder>* outHandle, sp<IGraphicBufferProducer>* outGbp,
|
||||||
|
sp<Layer>* outLayer);
|
||||||
|
|
||||||
sp<LayerDim> createDimLayer(const sp<Client>& client,
|
status_t createDimLayer(const sp<Client>& client, const String8& name,
|
||||||
uint32_t w, uint32_t h, uint32_t flags);
|
uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* outHandle,
|
||||||
|
sp<IGraphicBufferProducer>* outGbp, sp<Layer>* outLayer);
|
||||||
|
|
||||||
// called in response to the window-manager calling
|
// called in response to the window-manager calling
|
||||||
// ISurfaceComposerClient::destroySurface()
|
// ISurfaceComposerClient::destroySurface()
|
||||||
|
|
Loading…
Reference in New Issue