am 64f7549b: Merge "fix [2712278] The preview buffer left some black borders in left and bottom edges" into kraken
This commit is contained in:
@@ -159,7 +159,6 @@ public:
|
|||||||
SharedBufferBase(SharedClient* sharedClient, int surface,
|
SharedBufferBase(SharedClient* sharedClient, int surface,
|
||||||
int32_t identity);
|
int32_t identity);
|
||||||
~SharedBufferBase();
|
~SharedBufferBase();
|
||||||
uint32_t getIdentity();
|
|
||||||
status_t getStatus() const;
|
status_t getStatus() const;
|
||||||
size_t getFrontBuffer() const;
|
size_t getFrontBuffer() const;
|
||||||
String8 dump(char const* prefix) const;
|
String8 dump(char const* prefix) const;
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
void init();
|
void init();
|
||||||
status_t validate() const;
|
status_t validate() const;
|
||||||
sp<SurfaceComposerClient> getClient() const;
|
status_t initCheck() const;
|
||||||
sp<ISurface> getISurface() const;
|
sp<ISurface> getISurface() const;
|
||||||
|
|
||||||
inline const GraphicBufferMapper& getBufferMapper() const { return mBufferMapper; }
|
inline const GraphicBufferMapper& getBufferMapper() const { return mBufferMapper; }
|
||||||
@@ -271,6 +271,7 @@ private:
|
|||||||
uint32_t mFlags;
|
uint32_t mFlags;
|
||||||
GraphicBufferMapper& mBufferMapper;
|
GraphicBufferMapper& mBufferMapper;
|
||||||
SharedBufferClient* mSharedBufferClient;
|
SharedBufferClient* mSharedBufferClient;
|
||||||
|
status_t mInitCheck;
|
||||||
|
|
||||||
// protected by mSurfaceLock
|
// protected by mSurfaceLock
|
||||||
Rect mSwapRectangle;
|
Rect mSwapRectangle;
|
||||||
|
|||||||
@@ -123,13 +123,6 @@ public:
|
|||||||
status_t linkToComposerDeath(const sp<IBinder::DeathRecipient>& recipient,
|
status_t linkToComposerDeath(const sp<IBinder::DeathRecipient>& recipient,
|
||||||
void* cookie = NULL, uint32_t flags = 0);
|
void* cookie = NULL, uint32_t flags = 0);
|
||||||
|
|
||||||
private:
|
|
||||||
friend class Surface;
|
|
||||||
friend class SurfaceControl;
|
|
||||||
|
|
||||||
SurfaceComposerClient(const sp<ISurfaceComposer>& sm,
|
|
||||||
const sp<IBinder>& conn);
|
|
||||||
|
|
||||||
status_t hide(SurfaceID id);
|
status_t hide(SurfaceID id);
|
||||||
status_t show(SurfaceID id, int32_t layer = -1);
|
status_t show(SurfaceID id, int32_t layer = -1);
|
||||||
status_t freeze(SurfaceID id);
|
status_t freeze(SurfaceID id);
|
||||||
@@ -142,17 +135,21 @@ private:
|
|||||||
status_t setMatrix(SurfaceID id, float dsdx, float dtdx, float dsdy, float dtdy);
|
status_t setMatrix(SurfaceID id, float dsdx, float dtdx, float dsdy, float dtdy);
|
||||||
status_t setPosition(SurfaceID id, int32_t x, int32_t y);
|
status_t setPosition(SurfaceID id, int32_t x, int32_t y);
|
||||||
status_t setSize(SurfaceID id, uint32_t w, uint32_t h);
|
status_t setSize(SurfaceID id, uint32_t w, uint32_t h);
|
||||||
|
|
||||||
void signalServer();
|
void signalServer();
|
||||||
|
|
||||||
status_t destroySurface(SurfaceID sid);
|
status_t destroySurface(SurfaceID sid);
|
||||||
|
|
||||||
void _init(const sp<ISurfaceComposer>& sm,
|
SharedClient* getSharedClient() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SurfaceComposerClient(const sp<ISurfaceComposer>& sm,
|
||||||
|
const sp<IBinder>& conn);
|
||||||
|
|
||||||
|
void init(const sp<ISurfaceComposer>& sm,
|
||||||
const sp<ISurfaceFlingerClient>& conn);
|
const sp<ISurfaceFlingerClient>& conn);
|
||||||
|
|
||||||
inline layer_state_t* _get_state_l(SurfaceID id);
|
inline layer_state_t* get_state_l(SurfaceID id);
|
||||||
layer_state_t* _lockLayerState(SurfaceID id);
|
layer_state_t* lockLayerState(SurfaceID id);
|
||||||
inline void _unlockLayerState();
|
inline void unlockLayerState();
|
||||||
|
|
||||||
mutable Mutex mLock;
|
mutable Mutex mLock;
|
||||||
layer_state_t* mPrebuiltLayerState;
|
layer_state_t* mPrebuiltLayerState;
|
||||||
|
|||||||
@@ -500,7 +500,7 @@ void LayerBase::dump(String8& result, char* buffer, size_t SIZE) const
|
|||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
int32_t LayerBaseClient::sIdentity = 0;
|
int32_t LayerBaseClient::sIdentity = 1;
|
||||||
|
|
||||||
LayerBaseClient::LayerBaseClient(SurfaceFlinger* flinger, DisplayID display,
|
LayerBaseClient::LayerBaseClient(SurfaceFlinger* flinger, DisplayID display,
|
||||||
const sp<Client>& client, int32_t i)
|
const sp<Client>& client, int32_t i)
|
||||||
|
|||||||
@@ -155,12 +155,6 @@ SharedBufferBase::~SharedBufferBase()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SharedBufferBase::getIdentity()
|
|
||||||
{
|
|
||||||
SharedBufferStack& stack( *mSharedStack );
|
|
||||||
return stack.identity;
|
|
||||||
}
|
|
||||||
|
|
||||||
status_t SharedBufferBase::getStatus() const
|
status_t SharedBufferBase::getStatus() const
|
||||||
{
|
{
|
||||||
SharedBufferStack& stack( *mSharedStack );
|
SharedBufferStack& stack( *mSharedStack );
|
||||||
|
|||||||
@@ -151,75 +151,75 @@ bool SurfaceControl::isSameSurface(
|
|||||||
}
|
}
|
||||||
|
|
||||||
status_t SurfaceControl::setLayer(int32_t layer) {
|
status_t SurfaceControl::setLayer(int32_t layer) {
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->setLayer(mToken, layer);
|
return client->setLayer(mToken, layer);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::setPosition(int32_t x, int32_t y) {
|
status_t SurfaceControl::setPosition(int32_t x, int32_t y) {
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->setPosition(mToken, x, y);
|
return client->setPosition(mToken, x, y);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::setSize(uint32_t w, uint32_t h) {
|
status_t SurfaceControl::setSize(uint32_t w, uint32_t h) {
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->setSize(mToken, w, h);
|
return client->setSize(mToken, w, h);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::hide() {
|
status_t SurfaceControl::hide() {
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->hide(mToken);
|
return client->hide(mToken);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::show(int32_t layer) {
|
status_t SurfaceControl::show(int32_t layer) {
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->show(mToken, layer);
|
return client->show(mToken, layer);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::freeze() {
|
status_t SurfaceControl::freeze() {
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->freeze(mToken);
|
return client->freeze(mToken);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::unfreeze() {
|
status_t SurfaceControl::unfreeze() {
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->unfreeze(mToken);
|
return client->unfreeze(mToken);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::setFlags(uint32_t flags, uint32_t mask) {
|
status_t SurfaceControl::setFlags(uint32_t flags, uint32_t mask) {
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->setFlags(mToken, flags, mask);
|
return client->setFlags(mToken, flags, mask);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::setTransparentRegionHint(const Region& transparent) {
|
status_t SurfaceControl::setTransparentRegionHint(const Region& transparent) {
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->setTransparentRegionHint(mToken, transparent);
|
return client->setTransparentRegionHint(mToken, transparent);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::setAlpha(float alpha) {
|
status_t SurfaceControl::setAlpha(float alpha) {
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->setAlpha(mToken, alpha);
|
return client->setAlpha(mToken, 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) {
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->setMatrix(mToken, dsdx, dtdx, dsdy, dtdy);
|
return client->setMatrix(mToken, dsdx, dtdx, dsdy, dtdy);
|
||||||
}
|
}
|
||||||
status_t SurfaceControl::setFreezeTint(uint32_t tint) {
|
status_t SurfaceControl::setFreezeTint(uint32_t tint) {
|
||||||
const sp<SurfaceComposerClient>& client(mClient);
|
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err < 0) return err;
|
if (err < 0) return err;
|
||||||
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
return client->setFreezeTint(mToken, tint);
|
return client->setFreezeTint(mToken, tint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,23 +230,6 @@ status_t SurfaceControl::validate() const
|
|||||||
mToken, mIdentity, mClient.get());
|
mToken, mIdentity, mClient.get());
|
||||||
return NO_INIT;
|
return NO_INIT;
|
||||||
}
|
}
|
||||||
SharedClient const* cblk = mClient->mControl;
|
|
||||||
if (cblk == 0) {
|
|
||||||
LOGE("cblk is null (surface id=%d, identity=%u)", mToken, mIdentity);
|
|
||||||
return NO_INIT;
|
|
||||||
}
|
|
||||||
status_t err = cblk->validate(mToken);
|
|
||||||
if (err != NO_ERROR) {
|
|
||||||
LOGE("surface (id=%d, identity=%u) is invalid, err=%d (%s)",
|
|
||||||
mToken, mIdentity, err, strerror(-err));
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
uint32_t identity = cblk->getIdentity(mToken);
|
|
||||||
if (mIdentity != identity) {
|
|
||||||
LOGE("using an invalid surface id=%d, identity=%u should be %d",
|
|
||||||
mToken, mIdentity, identity);
|
|
||||||
return NO_INIT;
|
|
||||||
}
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,16 +283,15 @@ Surface::Surface(const sp<SurfaceControl>& surface)
|
|||||||
mToken(surface->mToken), mIdentity(surface->mIdentity),
|
mToken(surface->mToken), mIdentity(surface->mIdentity),
|
||||||
mFormat(surface->mFormat), mFlags(surface->mFlags),
|
mFormat(surface->mFormat), mFlags(surface->mFlags),
|
||||||
mBufferMapper(GraphicBufferMapper::get()), mSharedBufferClient(NULL),
|
mBufferMapper(GraphicBufferMapper::get()), mSharedBufferClient(NULL),
|
||||||
|
mInitCheck(NO_INIT),
|
||||||
mWidth(surface->mWidth), mHeight(surface->mHeight)
|
mWidth(surface->mWidth), mHeight(surface->mHeight)
|
||||||
{
|
{
|
||||||
mSharedBufferClient = new SharedBufferClient(
|
|
||||||
mClient->mControl, mToken, 2, mIdentity);
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
Surface::Surface(const Parcel& parcel)
|
Surface::Surface(const Parcel& parcel)
|
||||||
: mBufferMapper(GraphicBufferMapper::get()), mSharedBufferClient(NULL)
|
: mBufferMapper(GraphicBufferMapper::get()),
|
||||||
|
mSharedBufferClient(NULL), mInitCheck(NO_INIT)
|
||||||
{
|
{
|
||||||
sp<IBinder> clientBinder = parcel.readStrongBinder();
|
sp<IBinder> clientBinder = parcel.readStrongBinder();
|
||||||
mSurface = interface_cast<ISurface>(parcel.readStrongBinder());
|
mSurface = interface_cast<ISurface>(parcel.readStrongBinder());
|
||||||
@@ -323,9 +305,6 @@ Surface::Surface(const Parcel& parcel)
|
|||||||
// FIXME: what does that mean if clientBinder is NULL here?
|
// FIXME: what does that mean if clientBinder is NULL here?
|
||||||
if (clientBinder != NULL) {
|
if (clientBinder != NULL) {
|
||||||
mClient = SurfaceComposerClient::clientForConnection(clientBinder);
|
mClient = SurfaceComposerClient::clientForConnection(clientBinder);
|
||||||
|
|
||||||
mSharedBufferClient = new SharedBufferClient(
|
|
||||||
mClient->mControl, mToken, 2, mIdentity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
@@ -339,7 +318,7 @@ void Surface::init()
|
|||||||
android_native_window_t::queueBuffer = queueBuffer;
|
android_native_window_t::queueBuffer = queueBuffer;
|
||||||
android_native_window_t::query = query;
|
android_native_window_t::query = query;
|
||||||
android_native_window_t::perform = perform;
|
android_native_window_t::perform = perform;
|
||||||
mSwapRectangle.makeInvalid();
|
|
||||||
DisplayInfo dinfo;
|
DisplayInfo dinfo;
|
||||||
SurfaceComposerClient::getDisplayInfo(0, &dinfo);
|
SurfaceComposerClient::getDisplayInfo(0, &dinfo);
|
||||||
const_cast<float&>(android_native_window_t::xdpi) = dinfo.xdpi;
|
const_cast<float&>(android_native_window_t::xdpi) = dinfo.xdpi;
|
||||||
@@ -348,11 +327,19 @@ void Surface::init()
|
|||||||
const_cast<int&>(android_native_window_t::minSwapInterval) = 1;
|
const_cast<int&>(android_native_window_t::minSwapInterval) = 1;
|
||||||
const_cast<int&>(android_native_window_t::maxSwapInterval) = 1;
|
const_cast<int&>(android_native_window_t::maxSwapInterval) = 1;
|
||||||
const_cast<uint32_t&>(android_native_window_t::flags) = 0;
|
const_cast<uint32_t&>(android_native_window_t::flags) = 0;
|
||||||
// be default we request a hardware surface
|
|
||||||
mConnected = 0;
|
mConnected = 0;
|
||||||
|
mSwapRectangle.makeInvalid();
|
||||||
// two buffers by default
|
// two buffers by default
|
||||||
mBuffers.setCapacity(2);
|
mBuffers.setCapacity(2);
|
||||||
mBuffers.insertAt(0, 2);
|
mBuffers.insertAt(0, 2);
|
||||||
|
|
||||||
|
if (mClient != 0) {
|
||||||
|
mSharedBufferClient = new SharedBufferClient(
|
||||||
|
mClient->getSharedClient(), mToken, 2, mIdentity);
|
||||||
|
}
|
||||||
|
|
||||||
|
mInitCheck = initCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
Surface::~Surface()
|
Surface::~Surface()
|
||||||
@@ -375,56 +362,73 @@ Surface::~Surface()
|
|||||||
IPCThreadState::self()->flushCommands();
|
IPCThreadState::self()->flushCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
sp<SurfaceComposerClient> Surface::getClient() const {
|
status_t Surface::initCheck() const
|
||||||
return mClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
sp<ISurface> Surface::getISurface() const {
|
|
||||||
return mSurface;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Surface::isValid() {
|
|
||||||
return mToken>=0 && mClient!=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
status_t Surface::validate() const
|
|
||||||
{
|
{
|
||||||
sp<SurfaceComposerClient> client(getClient());
|
|
||||||
if (mToken<0 || mClient==0) {
|
if (mToken<0 || mClient==0) {
|
||||||
LOGE("invalid token (%d, identity=%u) or client (%p)",
|
|
||||||
mToken, mIdentity, client.get());
|
|
||||||
return NO_INIT;
|
return NO_INIT;
|
||||||
}
|
}
|
||||||
SharedClient const* cblk = mClient->mControl;
|
SharedClient const* cblk = mClient->getSharedClient();
|
||||||
if (cblk == 0) {
|
if (cblk == 0) {
|
||||||
LOGE("cblk is null (surface id=%d, identity=%u)", mToken, mIdentity);
|
LOGE("cblk is null (surface id=%d, identity=%u)", mToken, mIdentity);
|
||||||
return NO_INIT;
|
return NO_INIT;
|
||||||
}
|
}
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Surface::isValid() {
|
||||||
|
return mInitCheck == NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t Surface::validate() const
|
||||||
|
{
|
||||||
|
// check that we initialized ourself properly
|
||||||
|
if (mInitCheck != NO_ERROR) {
|
||||||
|
LOGE("invalid token (%d, identity=%u) or client (%p)",
|
||||||
|
mToken, mIdentity, mClient.get());
|
||||||
|
return mInitCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
// verify the identity of this surface
|
||||||
|
SharedClient const* cblk = mClient->getSharedClient();
|
||||||
|
|
||||||
|
uint32_t identity = cblk->getIdentity(mToken);
|
||||||
|
|
||||||
|
// this is a bit of a (temporary) special case, identity==0 means that
|
||||||
|
// no operation are allowed from the client (eg: dequeue/queue), this
|
||||||
|
// is used with PUSH_BUFFER surfaces for instance
|
||||||
|
if (identity == 0) {
|
||||||
|
LOGE("[Surface] invalid operation (identity=%u)", mIdentity);
|
||||||
|
return INVALID_OPERATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mIdentity != identity) {
|
||||||
|
LOGE("[Surface] using an invalid surface id=%d, "
|
||||||
|
"identity=%u should be %d",
|
||||||
|
mToken, mIdentity, identity);
|
||||||
|
return NO_INIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check the surface didn't become invalid
|
||||||
status_t err = cblk->validate(mToken);
|
status_t err = cblk->validate(mToken);
|
||||||
if (err != NO_ERROR) {
|
if (err != NO_ERROR) {
|
||||||
LOGE("surface (id=%d, identity=%u) is invalid, err=%d (%s)",
|
LOGE("surface (id=%d, identity=%u) is invalid, err=%d (%s)",
|
||||||
mToken, mIdentity, err, strerror(-err));
|
mToken, mIdentity, err, strerror(-err));
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
uint32_t identity = cblk->getIdentity(mToken);
|
|
||||||
if (mIdentity != identity) {
|
|
||||||
LOGE("using an invalid surface id=%d, identity=%u should be %d",
|
|
||||||
mToken, mIdentity, identity);
|
|
||||||
return NO_INIT;
|
|
||||||
}
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Surface::isSameSurface(const sp<Surface>& lhs, const sp<Surface>& rhs) {
|
||||||
bool Surface::isSameSurface(
|
|
||||||
const sp<Surface>& lhs, const sp<Surface>& rhs)
|
|
||||||
{
|
|
||||||
if (lhs == 0 || rhs == 0)
|
if (lhs == 0 || rhs == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return lhs->mSurface->asBinder() == rhs->mSurface->asBinder();
|
return lhs->mSurface->asBinder() == rhs->mSurface->asBinder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sp<ISurface> Surface::getISurface() const {
|
||||||
|
return mSurface;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
int Surface::setSwapInterval(android_native_window_t* window, int interval) {
|
int Surface::setSwapInterval(android_native_window_t* window, int interval) {
|
||||||
@@ -485,7 +489,6 @@ bool Surface::needNewBuffer(int bufIdx,
|
|||||||
|
|
||||||
int Surface::dequeueBuffer(android_native_buffer_t** buffer)
|
int Surface::dequeueBuffer(android_native_buffer_t** buffer)
|
||||||
{
|
{
|
||||||
sp<SurfaceComposerClient> client(getClient());
|
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err != NO_ERROR)
|
if (err != NO_ERROR)
|
||||||
return err;
|
return err;
|
||||||
@@ -534,7 +537,6 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer)
|
|||||||
|
|
||||||
int Surface::lockBuffer(android_native_buffer_t* buffer)
|
int Surface::lockBuffer(android_native_buffer_t* buffer)
|
||||||
{
|
{
|
||||||
sp<SurfaceComposerClient> client(getClient());
|
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err != NO_ERROR)
|
if (err != NO_ERROR)
|
||||||
return err;
|
return err;
|
||||||
@@ -547,7 +549,6 @@ int Surface::lockBuffer(android_native_buffer_t* buffer)
|
|||||||
|
|
||||||
int Surface::queueBuffer(android_native_buffer_t* buffer)
|
int Surface::queueBuffer(android_native_buffer_t* buffer)
|
||||||
{
|
{
|
||||||
sp<SurfaceComposerClient> client(getClient());
|
|
||||||
status_t err = validate();
|
status_t err = validate();
|
||||||
if (err != NO_ERROR)
|
if (err != NO_ERROR)
|
||||||
return err;
|
return err;
|
||||||
@@ -564,6 +565,7 @@ int Surface::queueBuffer(android_native_buffer_t* buffer)
|
|||||||
|
|
||||||
if (err == NO_ERROR) {
|
if (err == NO_ERROR) {
|
||||||
// FIXME: can we avoid this IPC if we know there is one pending?
|
// FIXME: can we avoid this IPC if we know there is one pending?
|
||||||
|
const sp<SurfaceComposerClient>& client(mClient);
|
||||||
client->signalServer();
|
client->signalServer();
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
|
|||||||
@@ -123,11 +123,11 @@ SurfaceComposerClient::SurfaceComposerClient()
|
|||||||
{
|
{
|
||||||
sp<ISurfaceComposer> sm(getComposerService());
|
sp<ISurfaceComposer> sm(getComposerService());
|
||||||
if (sm == 0) {
|
if (sm == 0) {
|
||||||
_init(0, 0);
|
init(0, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_init(sm, sm->createConnection());
|
init(sm, sm->createConnection());
|
||||||
|
|
||||||
if (mClient != 0) {
|
if (mClient != 0) {
|
||||||
Mutex::Autolock _l(gLock);
|
Mutex::Autolock _l(gLock);
|
||||||
@@ -139,9 +139,14 @@ SurfaceComposerClient::SurfaceComposerClient()
|
|||||||
SurfaceComposerClient::SurfaceComposerClient(
|
SurfaceComposerClient::SurfaceComposerClient(
|
||||||
const sp<ISurfaceComposer>& sm, const sp<IBinder>& conn)
|
const sp<ISurfaceComposer>& sm, const sp<IBinder>& conn)
|
||||||
{
|
{
|
||||||
_init(sm, interface_cast<ISurfaceFlingerClient>(conn));
|
init(sm, interface_cast<ISurfaceFlingerClient>(conn));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SurfaceComposerClient::~SurfaceComposerClient()
|
||||||
|
{
|
||||||
|
VERBOSE("Destroying client %p, conn %p", this, mClient.get());
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
|
||||||
status_t SurfaceComposerClient::linkToComposerDeath(
|
status_t SurfaceComposerClient::linkToComposerDeath(
|
||||||
const sp<IBinder::DeathRecipient>& recipient,
|
const sp<IBinder::DeathRecipient>& recipient,
|
||||||
@@ -151,7 +156,7 @@ status_t SurfaceComposerClient::linkToComposerDeath(
|
|||||||
return sm->asBinder()->linkToDeath(recipient, cookie, flags);
|
return sm->asBinder()->linkToDeath(recipient, cookie, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceComposerClient::_init(
|
void SurfaceComposerClient::init(
|
||||||
const sp<ISurfaceComposer>& sm, const sp<ISurfaceFlingerClient>& conn)
|
const sp<ISurfaceComposer>& sm, const sp<ISurfaceFlingerClient>& conn)
|
||||||
{
|
{
|
||||||
VERBOSE("Creating client %p, conn %p", this, conn.get());
|
VERBOSE("Creating client %p, conn %p", this, conn.get());
|
||||||
@@ -172,10 +177,9 @@ void SurfaceComposerClient::_init(
|
|||||||
mControl = static_cast<SharedClient *>(mControlMemory->getBase());
|
mControl = static_cast<SharedClient *>(mControlMemory->getBase());
|
||||||
}
|
}
|
||||||
|
|
||||||
SurfaceComposerClient::~SurfaceComposerClient()
|
SharedClient* SurfaceComposerClient::getSharedClient() const
|
||||||
{
|
{
|
||||||
VERBOSE("Destroying client %p, conn %p", this, mClient.get());
|
return mControl;
|
||||||
dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t SurfaceComposerClient::initCheck() const
|
status_t SurfaceComposerClient::initCheck() const
|
||||||
@@ -488,7 +492,7 @@ status_t SurfaceComposerClient::closeTransaction()
|
|||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
layer_state_t* SurfaceComposerClient::_get_state_l(SurfaceID index)
|
layer_state_t* SurfaceComposerClient::get_state_l(SurfaceID index)
|
||||||
{
|
{
|
||||||
// API usage error, do nothing.
|
// API usage error, do nothing.
|
||||||
if (mTransactionOpen<=0) {
|
if (mTransactionOpen<=0) {
|
||||||
@@ -508,49 +512,49 @@ layer_state_t* SurfaceComposerClient::_get_state_l(SurfaceID index)
|
|||||||
return mStates.editArray() + i;
|
return mStates.editArray() + i;
|
||||||
}
|
}
|
||||||
|
|
||||||
layer_state_t* SurfaceComposerClient::_lockLayerState(SurfaceID id)
|
layer_state_t* SurfaceComposerClient::lockLayerState(SurfaceID id)
|
||||||
{
|
{
|
||||||
layer_state_t* s;
|
layer_state_t* s;
|
||||||
mLock.lock();
|
mLock.lock();
|
||||||
s = _get_state_l(id);
|
s = get_state_l(id);
|
||||||
if (!s) mLock.unlock();
|
if (!s) mLock.unlock();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceComposerClient::_unlockLayerState()
|
void SurfaceComposerClient::unlockLayerState()
|
||||||
{
|
{
|
||||||
mLock.unlock();
|
mLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t SurfaceComposerClient::setPosition(SurfaceID id, int32_t x, int32_t y)
|
status_t SurfaceComposerClient::setPosition(SurfaceID id, int32_t x, int32_t y)
|
||||||
{
|
{
|
||||||
layer_state_t* s = _lockLayerState(id);
|
layer_state_t* s = lockLayerState(id);
|
||||||
if (!s) return BAD_INDEX;
|
if (!s) return BAD_INDEX;
|
||||||
s->what |= ISurfaceComposer::ePositionChanged;
|
s->what |= ISurfaceComposer::ePositionChanged;
|
||||||
s->x = x;
|
s->x = x;
|
||||||
s->y = y;
|
s->y = y;
|
||||||
_unlockLayerState();
|
unlockLayerState();
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t SurfaceComposerClient::setSize(SurfaceID id, uint32_t w, uint32_t h)
|
status_t SurfaceComposerClient::setSize(SurfaceID id, uint32_t w, uint32_t h)
|
||||||
{
|
{
|
||||||
layer_state_t* s = _lockLayerState(id);
|
layer_state_t* s = lockLayerState(id);
|
||||||
if (!s) return BAD_INDEX;
|
if (!s) return BAD_INDEX;
|
||||||
s->what |= ISurfaceComposer::eSizeChanged;
|
s->what |= ISurfaceComposer::eSizeChanged;
|
||||||
s->w = w;
|
s->w = w;
|
||||||
s->h = h;
|
s->h = h;
|
||||||
_unlockLayerState();
|
unlockLayerState();
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t SurfaceComposerClient::setLayer(SurfaceID id, int32_t z)
|
status_t SurfaceComposerClient::setLayer(SurfaceID id, int32_t z)
|
||||||
{
|
{
|
||||||
layer_state_t* s = _lockLayerState(id);
|
layer_state_t* s = lockLayerState(id);
|
||||||
if (!s) return BAD_INDEX;
|
if (!s) return BAD_INDEX;
|
||||||
s->what |= ISurfaceComposer::eLayerChanged;
|
s->what |= ISurfaceComposer::eLayerChanged;
|
||||||
s->z = z;
|
s->z = z;
|
||||||
_unlockLayerState();
|
unlockLayerState();
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -579,34 +583,34 @@ status_t SurfaceComposerClient::unfreeze(SurfaceID id)
|
|||||||
status_t SurfaceComposerClient::setFlags(SurfaceID id,
|
status_t SurfaceComposerClient::setFlags(SurfaceID id,
|
||||||
uint32_t flags, uint32_t mask)
|
uint32_t flags, uint32_t mask)
|
||||||
{
|
{
|
||||||
layer_state_t* s = _lockLayerState(id);
|
layer_state_t* s = lockLayerState(id);
|
||||||
if (!s) return BAD_INDEX;
|
if (!s) return BAD_INDEX;
|
||||||
s->what |= ISurfaceComposer::eVisibilityChanged;
|
s->what |= ISurfaceComposer::eVisibilityChanged;
|
||||||
s->flags &= ~mask;
|
s->flags &= ~mask;
|
||||||
s->flags |= (flags & mask);
|
s->flags |= (flags & mask);
|
||||||
s->mask |= mask;
|
s->mask |= mask;
|
||||||
_unlockLayerState();
|
unlockLayerState();
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t SurfaceComposerClient::setTransparentRegionHint(
|
status_t SurfaceComposerClient::setTransparentRegionHint(
|
||||||
SurfaceID id, const Region& transparentRegion)
|
SurfaceID id, const Region& transparentRegion)
|
||||||
{
|
{
|
||||||
layer_state_t* s = _lockLayerState(id);
|
layer_state_t* s = lockLayerState(id);
|
||||||
if (!s) return BAD_INDEX;
|
if (!s) return BAD_INDEX;
|
||||||
s->what |= ISurfaceComposer::eTransparentRegionChanged;
|
s->what |= ISurfaceComposer::eTransparentRegionChanged;
|
||||||
s->transparentRegion = transparentRegion;
|
s->transparentRegion = transparentRegion;
|
||||||
_unlockLayerState();
|
unlockLayerState();
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t SurfaceComposerClient::setAlpha(SurfaceID id, float alpha)
|
status_t SurfaceComposerClient::setAlpha(SurfaceID id, float alpha)
|
||||||
{
|
{
|
||||||
layer_state_t* s = _lockLayerState(id);
|
layer_state_t* s = lockLayerState(id);
|
||||||
if (!s) return BAD_INDEX;
|
if (!s) return BAD_INDEX;
|
||||||
s->what |= ISurfaceComposer::eAlphaChanged;
|
s->what |= ISurfaceComposer::eAlphaChanged;
|
||||||
s->alpha = alpha;
|
s->alpha = alpha;
|
||||||
_unlockLayerState();
|
unlockLayerState();
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -615,7 +619,7 @@ status_t SurfaceComposerClient::setMatrix(
|
|||||||
float dsdx, float dtdx,
|
float dsdx, float dtdx,
|
||||||
float dsdy, float dtdy )
|
float dsdy, float dtdy )
|
||||||
{
|
{
|
||||||
layer_state_t* s = _lockLayerState(id);
|
layer_state_t* s = lockLayerState(id);
|
||||||
if (!s) return BAD_INDEX;
|
if (!s) return BAD_INDEX;
|
||||||
s->what |= ISurfaceComposer::eMatrixChanged;
|
s->what |= ISurfaceComposer::eMatrixChanged;
|
||||||
layer_state_t::matrix22_t matrix;
|
layer_state_t::matrix22_t matrix;
|
||||||
@@ -624,17 +628,17 @@ status_t SurfaceComposerClient::setMatrix(
|
|||||||
matrix.dsdy = dsdy;
|
matrix.dsdy = dsdy;
|
||||||
matrix.dtdy = dtdy;
|
matrix.dtdy = dtdy;
|
||||||
s->matrix = matrix;
|
s->matrix = matrix;
|
||||||
_unlockLayerState();
|
unlockLayerState();
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t SurfaceComposerClient::setFreezeTint(SurfaceID id, uint32_t tint)
|
status_t SurfaceComposerClient::setFreezeTint(SurfaceID id, uint32_t tint)
|
||||||
{
|
{
|
||||||
layer_state_t* s = _lockLayerState(id);
|
layer_state_t* s = lockLayerState(id);
|
||||||
if (!s) return BAD_INDEX;
|
if (!s) return BAD_INDEX;
|
||||||
s->what |= ISurfaceComposer::eFreezeTintChanged;
|
s->what |= ISurfaceComposer::eFreezeTintChanged;
|
||||||
s->tint = tint;
|
s->tint = tint;
|
||||||
_unlockLayerState();
|
unlockLayerState();
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user