2009-03-04 03:31:44 +00:00
|
|
|
/*
|
|
|
|
* 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_SURFACE_FLINGER_H
|
|
|
|
#define ANDROID_SURFACE_FLINGER_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include <utils/SortedVector.h>
|
|
|
|
#include <utils/KeyedVector.h>
|
|
|
|
#include <utils/threads.h>
|
|
|
|
#include <utils/Atomic.h>
|
|
|
|
#include <utils/Errors.h>
|
2009-04-10 21:24:30 +00:00
|
|
|
#include <utils/RefBase.h>
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2009-07-03 01:11:53 +00:00
|
|
|
#include <binder/IMemory.h>
|
2009-06-16 01:24:59 +00:00
|
|
|
#include <binder/Permission.h>
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
#include <ui/PixelFormat.h>
|
|
|
|
#include <ui/ISurfaceComposer.h>
|
|
|
|
#include <ui/ISurfaceFlingerClient.h>
|
|
|
|
|
fix [2068105] implement queueBuffer/lockBuffer/dequeueBuffer properly
Rewrote SurfaceFlinger's buffer management from the ground-up.
The design now support an arbitrary number of buffers per surface, however the current implementation is limited to four. Currently only 2 buffers are used in practice.
The main new feature is to be able to dequeue all buffers at once (very important when there are only two).
A client can dequeue all buffers until there are none available, it can lock all buffers except the last one that is used for composition. The client will block then, until a new buffer is enqueued.
The current implementation requires that buffers are locked in the same order they are dequeued and enqueued in the same order they are locked. Only one buffer can be locked at a time.
eg. Allowed sequence: DQ, DQ, LOCK, Q, LOCK, Q
eg. Forbidden sequence: DQ, DQ, LOCK, LOCK, Q, Q
2009-09-07 23:32:45 +00:00
|
|
|
#include <private/ui/SharedBufferStack.h>
|
2009-03-04 03:31:44 +00:00
|
|
|
#include <private/ui/LayerState.h>
|
|
|
|
|
|
|
|
#include "Barrier.h"
|
|
|
|
#include "Layer.h"
|
|
|
|
#include "Tokenizer.h"
|
|
|
|
|
2009-04-21 02:39:12 +00:00
|
|
|
#include "MessageQueue.h"
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
struct copybit_device_t;
|
|
|
|
struct overlay_device_t;
|
|
|
|
|
|
|
|
namespace android {
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class Client;
|
|
|
|
class BClient;
|
|
|
|
class DisplayHardware;
|
|
|
|
class FreezeLock;
|
|
|
|
class Layer;
|
|
|
|
class LayerBuffer;
|
|
|
|
|
|
|
|
typedef int32_t ClientID;
|
|
|
|
|
|
|
|
#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
|
|
|
|
#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
2009-06-20 00:00:27 +00:00
|
|
|
class Client : public RefBase
|
2009-03-04 03:31:44 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
Client(ClientID cid, const sp<SurfaceFlinger>& flinger);
|
|
|
|
~Client();
|
|
|
|
|
|
|
|
int32_t generateId(int pid);
|
|
|
|
void free(int32_t id);
|
2009-04-10 21:24:30 +00:00
|
|
|
status_t bindLayer(const sp<LayerBaseClient>& layer, int32_t id);
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
inline bool isValid(int32_t i) const;
|
2009-04-10 21:24:30 +00:00
|
|
|
sp<LayerBaseClient> getLayerUser(int32_t i) const;
|
2009-03-04 03:31:44 +00:00
|
|
|
void dump(const char* what);
|
|
|
|
|
2009-07-03 01:11:53 +00:00
|
|
|
const Vector< wp<LayerBaseClient> >& getLayers() const {
|
|
|
|
return mLayers;
|
|
|
|
}
|
|
|
|
|
|
|
|
const sp<IMemoryHeap>& getControlBlockMemory() const {
|
|
|
|
return mCblkHeap;
|
|
|
|
}
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
// pointer to this client's control block
|
fix [2068105] implement queueBuffer/lockBuffer/dequeueBuffer properly
Rewrote SurfaceFlinger's buffer management from the ground-up.
The design now support an arbitrary number of buffers per surface, however the current implementation is limited to four. Currently only 2 buffers are used in practice.
The main new feature is to be able to dequeue all buffers at once (very important when there are only two).
A client can dequeue all buffers until there are none available, it can lock all buffers except the last one that is used for composition. The client will block then, until a new buffer is enqueued.
The current implementation requires that buffers are locked in the same order they are dequeued and enqueued in the same order they are locked. Only one buffer can be locked at a time.
eg. Allowed sequence: DQ, DQ, LOCK, Q, LOCK, Q
eg. Forbidden sequence: DQ, DQ, LOCK, LOCK, Q, Q
2009-09-07 23:32:45 +00:00
|
|
|
SharedClient* ctrlblk;
|
2009-03-04 03:31:44 +00:00
|
|
|
ClientID cid;
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2009-07-03 01:11:53 +00:00
|
|
|
int getClientPid() const { return mPid; }
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2009-04-10 21:24:30 +00:00
|
|
|
int mPid;
|
|
|
|
uint32_t mBitmap;
|
|
|
|
SortedVector<uint8_t> mInUse;
|
|
|
|
Vector< wp<LayerBaseClient> > mLayers;
|
2009-07-03 01:11:53 +00:00
|
|
|
sp<IMemoryHeap> mCblkHeap;
|
2009-04-10 21:24:30 +00:00
|
|
|
sp<SurfaceFlinger> mFlinger;
|
2009-03-04 03:31:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class GraphicPlane
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static status_t orientationToTransfrom(int orientation, int w, int h,
|
|
|
|
Transform* tr);
|
|
|
|
|
|
|
|
GraphicPlane();
|
|
|
|
~GraphicPlane();
|
|
|
|
|
|
|
|
bool initialized() const;
|
|
|
|
|
|
|
|
void setDisplayHardware(DisplayHardware *);
|
|
|
|
status_t setOrientation(int orientation);
|
2009-03-28 00:58:20 +00:00
|
|
|
int getOrientation() const { return mOrientation; }
|
2010-02-08 23:49:35 +00:00
|
|
|
int getWidth() const;
|
|
|
|
int getHeight() const;
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
const DisplayHardware& displayHardware() const;
|
|
|
|
const Transform& transform() const;
|
2009-04-10 21:24:30 +00:00
|
|
|
EGLDisplay getEGLDisplay() const;
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
private:
|
|
|
|
GraphicPlane(const GraphicPlane&);
|
|
|
|
GraphicPlane operator = (const GraphicPlane&);
|
|
|
|
|
|
|
|
DisplayHardware* mHw;
|
|
|
|
Transform mGlobalTransform;
|
2010-02-08 23:49:35 +00:00
|
|
|
Transform mDisplayTransform;
|
2009-03-28 00:58:20 +00:00
|
|
|
int mOrientation;
|
2010-02-08 23:49:35 +00:00
|
|
|
float mDisplayWidth;
|
|
|
|
float mDisplayHeight;
|
|
|
|
int mWidth;
|
|
|
|
int mHeight;
|
2009-03-04 03:31:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
enum {
|
|
|
|
eTransactionNeeded = 0x01,
|
|
|
|
eTraversalNeeded = 0x02
|
|
|
|
};
|
|
|
|
|
|
|
|
class SurfaceFlinger : public BnSurfaceComposer, protected Thread
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static void instantiate();
|
|
|
|
static void shutdown();
|
|
|
|
|
|
|
|
SurfaceFlinger();
|
|
|
|
virtual ~SurfaceFlinger();
|
|
|
|
void init();
|
|
|
|
|
|
|
|
virtual status_t onTransact(
|
|
|
|
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
|
|
|
|
|
|
|
|
virtual status_t dump(int fd, const Vector<String16>& args);
|
|
|
|
|
|
|
|
// ISurfaceComposer interface
|
|
|
|
virtual sp<ISurfaceFlingerClient> createConnection();
|
2009-07-03 01:11:53 +00:00
|
|
|
virtual sp<IMemoryHeap> getCblk() const;
|
2009-03-04 03:31:44 +00:00
|
|
|
virtual void bootFinished();
|
|
|
|
virtual void openGlobalTransaction();
|
|
|
|
virtual void closeGlobalTransaction();
|
|
|
|
virtual status_t freezeDisplay(DisplayID dpy, uint32_t flags);
|
|
|
|
virtual status_t unfreezeDisplay(DisplayID dpy, uint32_t flags);
|
2009-03-28 01:11:38 +00:00
|
|
|
virtual int setOrientation(DisplayID dpy, int orientation, uint32_t flags);
|
2009-03-04 03:31:44 +00:00
|
|
|
virtual void signal() const;
|
|
|
|
|
|
|
|
void screenReleased(DisplayID dpy);
|
|
|
|
void screenAcquired(DisplayID dpy);
|
|
|
|
|
|
|
|
overlay_control_device_t* getOverlayEngine() const;
|
|
|
|
|
|
|
|
|
2009-04-10 21:24:30 +00:00
|
|
|
status_t removeLayer(const sp<LayerBase>& layer);
|
|
|
|
status_t addLayer(const sp<LayerBase>& layer);
|
|
|
|
status_t invalidateLayerVisibility(const sp<LayerBase>& layer);
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class BClient;
|
|
|
|
friend class LayerBase;
|
|
|
|
friend class LayerBuffer;
|
|
|
|
friend class LayerBaseClient;
|
2009-07-07 02:04:03 +00:00
|
|
|
friend class LayerBaseClient::Surface;
|
2009-03-04 03:31:44 +00:00
|
|
|
friend class Layer;
|
|
|
|
friend class LayerBlur;
|
2009-06-19 01:48:39 +00:00
|
|
|
friend class LayerDim;
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
sp<ISurface> createSurface(ClientID client, int pid,
|
|
|
|
ISurfaceFlingerClient::surface_data_t* params,
|
|
|
|
DisplayID display, uint32_t w, uint32_t h, PixelFormat format,
|
|
|
|
uint32_t flags);
|
|
|
|
|
2009-04-10 21:24:30 +00:00
|
|
|
sp<LayerBaseClient> createNormalSurfaceLocked(
|
2009-06-20 00:00:27 +00:00
|
|
|
const sp<Client>& client, DisplayID display,
|
2009-08-20 00:46:26 +00:00
|
|
|
int32_t id, uint32_t w, uint32_t h, uint32_t flags,
|
|
|
|
PixelFormat& format);
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2009-04-10 21:24:30 +00:00
|
|
|
sp<LayerBaseClient> createBlurSurfaceLocked(
|
2009-06-20 00:00:27 +00:00
|
|
|
const sp<Client>& client, DisplayID display,
|
2009-03-04 03:31:44 +00:00
|
|
|
int32_t id, uint32_t w, uint32_t h, uint32_t flags);
|
|
|
|
|
2009-04-10 21:24:30 +00:00
|
|
|
sp<LayerBaseClient> createDimSurfaceLocked(
|
2009-06-20 00:00:27 +00:00
|
|
|
const sp<Client>& client, DisplayID display,
|
2009-03-04 03:31:44 +00:00
|
|
|
int32_t id, uint32_t w, uint32_t h, uint32_t flags);
|
|
|
|
|
2009-04-10 21:24:30 +00:00
|
|
|
sp<LayerBaseClient> createPushBuffersSurfaceLocked(
|
2009-06-20 00:00:27 +00:00
|
|
|
const sp<Client>& client, DisplayID display,
|
2009-03-04 03:31:44 +00:00
|
|
|
int32_t id, uint32_t w, uint32_t h, uint32_t flags);
|
|
|
|
|
2009-04-18 02:36:26 +00:00
|
|
|
status_t removeSurface(SurfaceID surface_id);
|
|
|
|
status_t destroySurface(const sp<LayerBaseClient>& layer);
|
2009-04-10 21:24:30 +00:00
|
|
|
status_t setClientState(ClientID cid, int32_t count, const layer_state_t* states);
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
class LayerVector {
|
|
|
|
public:
|
|
|
|
inline LayerVector() { }
|
|
|
|
LayerVector(const LayerVector&);
|
|
|
|
inline size_t size() const { return layers.size(); }
|
2009-04-10 21:24:30 +00:00
|
|
|
inline sp<LayerBase> const* array() const { return layers.array(); }
|
|
|
|
ssize_t add(const sp<LayerBase>&, Vector< sp<LayerBase> >::compar_t);
|
|
|
|
ssize_t remove(const sp<LayerBase>&);
|
|
|
|
ssize_t reorder(const sp<LayerBase>&, Vector< sp<LayerBase> >::compar_t);
|
|
|
|
ssize_t indexOf(const sp<LayerBase>& key, size_t guess=0) const;
|
|
|
|
inline sp<LayerBase> operator [] (size_t i) const { return layers[i]; }
|
2009-03-04 03:31:44 +00:00
|
|
|
private:
|
2009-04-10 21:24:30 +00:00
|
|
|
KeyedVector< sp<LayerBase> , size_t> lookup;
|
|
|
|
Vector< sp<LayerBase> > layers;
|
2009-03-04 03:31:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct State {
|
|
|
|
State() {
|
|
|
|
orientation = ISurfaceComposer::eOrientationDefault;
|
|
|
|
freezeDisplay = 0;
|
|
|
|
}
|
|
|
|
LayerVector layersSortedByZ;
|
|
|
|
uint8_t orientation;
|
2009-03-28 01:11:38 +00:00
|
|
|
uint8_t orientationType;
|
2009-03-04 03:31:44 +00:00
|
|
|
uint8_t freezeDisplay;
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual bool threadLoop();
|
|
|
|
virtual status_t readyToRun();
|
|
|
|
virtual void onFirstRef();
|
|
|
|
|
2009-10-29 17:19:34 +00:00
|
|
|
public: // hack to work around gcc 4.0.3 bug
|
2009-03-04 03:31:44 +00:00
|
|
|
const GraphicPlane& graphicPlane(int dpy) const;
|
|
|
|
GraphicPlane& graphicPlane(int dpy);
|
2009-10-29 17:19:34 +00:00
|
|
|
private:
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
void waitForEvent();
|
2009-09-21 21:33:20 +00:00
|
|
|
public: // hack to work around gcc 4.0.3 bug
|
2009-03-04 03:31:44 +00:00
|
|
|
void signalEvent();
|
2009-09-21 21:33:20 +00:00
|
|
|
private:
|
2009-03-04 03:31:44 +00:00
|
|
|
void signalDelayedEvent(nsecs_t delay);
|
|
|
|
|
|
|
|
void handleConsoleEvents();
|
|
|
|
void handleTransaction(uint32_t transactionFlags);
|
2009-06-05 01:46:21 +00:00
|
|
|
void handleTransactionLocked(
|
|
|
|
uint32_t transactionFlags,
|
|
|
|
Vector< sp<LayerBase> >& ditchedLayers);
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
void computeVisibleRegions(
|
|
|
|
LayerVector& currentLayers,
|
|
|
|
Region& dirtyRegion,
|
|
|
|
Region& wormholeRegion);
|
|
|
|
|
|
|
|
void handlePageFlip();
|
|
|
|
bool lockPageFlip(const LayerVector& currentLayers);
|
|
|
|
void unlockPageFlip(const LayerVector& currentLayers);
|
|
|
|
void handleRepaint();
|
|
|
|
void postFramebuffer();
|
|
|
|
void composeSurfaces(const Region& dirty);
|
|
|
|
void unlockClients();
|
|
|
|
|
|
|
|
|
|
|
|
void destroyConnection(ClientID cid);
|
2009-04-10 21:24:30 +00:00
|
|
|
sp<LayerBaseClient> getLayerUser_l(SurfaceID index) const;
|
|
|
|
status_t addLayer_l(const sp<LayerBase>& layer);
|
|
|
|
status_t removeLayer_l(const sp<LayerBase>& layer);
|
2009-04-18 02:36:26 +00:00
|
|
|
status_t purgatorizeLayer_l(const sp<LayerBase>& layer);
|
2009-03-04 03:31:44 +00:00
|
|
|
void free_resources_l();
|
|
|
|
|
|
|
|
uint32_t getTransactionFlags(uint32_t flags);
|
|
|
|
uint32_t setTransactionFlags(uint32_t flags, nsecs_t delay = 0);
|
|
|
|
void commitTransaction();
|
|
|
|
|
|
|
|
|
|
|
|
friend class FreezeLock;
|
|
|
|
sp<FreezeLock> getFreezeLock() const;
|
2009-12-02 01:23:28 +00:00
|
|
|
inline void incFreezeCount() {
|
|
|
|
if (mFreezeCount == 0)
|
|
|
|
mFreezeDisplayTime = 0;
|
|
|
|
mFreezeCount++;
|
|
|
|
}
|
2009-03-04 03:31:44 +00:00
|
|
|
inline void decFreezeCount() { if (mFreezeCount > 0) mFreezeCount--; }
|
|
|
|
inline bool hasFreezeRequest() const { return mFreezeDisplay; }
|
|
|
|
inline bool isFrozen() const {
|
2009-10-06 00:07:12 +00:00
|
|
|
return (mFreezeDisplay || mFreezeCount>0) && mBootFinished;
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void debugFlashRegions();
|
|
|
|
void debugShowFPS() const;
|
|
|
|
void drawWormhole() const;
|
|
|
|
|
2009-04-21 02:39:12 +00:00
|
|
|
|
|
|
|
mutable MessageQueue mEventQueue;
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
// access must be protected by mStateLock
|
|
|
|
mutable Mutex mStateLock;
|
|
|
|
State mCurrentState;
|
|
|
|
State mDrawingState;
|
|
|
|
volatile int32_t mTransactionFlags;
|
|
|
|
volatile int32_t mTransactionCount;
|
|
|
|
Condition mTransactionCV;
|
fix [2068105] implement queueBuffer/lockBuffer/dequeueBuffer properly
Rewrote SurfaceFlinger's buffer management from the ground-up.
The design now support an arbitrary number of buffers per surface, however the current implementation is limited to four. Currently only 2 buffers are used in practice.
The main new feature is to be able to dequeue all buffers at once (very important when there are only two).
A client can dequeue all buffers until there are none available, it can lock all buffers except the last one that is used for composition. The client will block then, until a new buffer is enqueued.
The current implementation requires that buffers are locked in the same order they are dequeued and enqueued in the same order they are locked. Only one buffer can be locked at a time.
eg. Allowed sequence: DQ, DQ, LOCK, Q, LOCK, Q
eg. Forbidden sequence: DQ, DQ, LOCK, LOCK, Q, Q
2009-09-07 23:32:45 +00:00
|
|
|
bool mResizeTransationPending;
|
2009-04-18 02:36:26 +00:00
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
// protected by mStateLock (but we could use another lock)
|
|
|
|
Tokenizer mTokens;
|
2009-06-20 00:00:27 +00:00
|
|
|
DefaultKeyedVector<ClientID, sp<Client> > mClientsMap;
|
2009-04-10 21:24:30 +00:00
|
|
|
DefaultKeyedVector<SurfaceID, sp<LayerBaseClient> > mLayerMap;
|
2009-03-04 03:31:44 +00:00
|
|
|
GraphicPlane mGraphicPlanes[1];
|
2009-04-10 21:24:30 +00:00
|
|
|
bool mLayersRemoved;
|
2009-06-20 00:00:27 +00:00
|
|
|
Vector< sp<Client> > mDisconnectedClients;
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
// constant members (no synchronization needed for access)
|
2009-07-03 01:11:53 +00:00
|
|
|
sp<IMemoryHeap> mServerHeap;
|
2009-03-04 03:31:44 +00:00
|
|
|
surface_flinger_cblk_t* mServerCblk;
|
|
|
|
GLuint mWormholeTexName;
|
|
|
|
nsecs_t mBootTime;
|
2009-06-16 01:24:59 +00:00
|
|
|
Permission mHardwareTest;
|
|
|
|
Permission mAccessSurfaceFlinger;
|
|
|
|
Permission mDump;
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
// Can only accessed from the main thread, these members
|
|
|
|
// don't need synchronization
|
|
|
|
Region mDirtyRegion;
|
2009-07-28 17:57:27 +00:00
|
|
|
Region mDirtyRegionRemovedLayer;
|
2009-03-04 03:31:44 +00:00
|
|
|
Region mInvalidRegion;
|
|
|
|
Region mWormholeRegion;
|
|
|
|
bool mVisibleRegionsDirty;
|
|
|
|
bool mDeferReleaseConsole;
|
|
|
|
bool mFreezeDisplay;
|
|
|
|
int32_t mFreezeCount;
|
|
|
|
nsecs_t mFreezeDisplayTime;
|
|
|
|
|
|
|
|
// don't use a lock for these, we don't care
|
|
|
|
int mDebugRegion;
|
|
|
|
int mDebugBackground;
|
2009-08-26 23:36:26 +00:00
|
|
|
volatile nsecs_t mDebugInSwapBuffers;
|
|
|
|
nsecs_t mLastSwapBufferTime;
|
|
|
|
volatile nsecs_t mDebugInTransaction;
|
|
|
|
nsecs_t mLastTransactionTime;
|
2009-10-06 00:07:12 +00:00
|
|
|
bool mBootFinished;
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
// these are thread safe
|
|
|
|
mutable Barrier mReadyToRunBarrier;
|
|
|
|
|
|
|
|
// atomic variables
|
|
|
|
enum {
|
|
|
|
eConsoleReleased = 1,
|
|
|
|
eConsoleAcquired = 2
|
|
|
|
};
|
|
|
|
volatile int32_t mConsoleSignals;
|
|
|
|
|
|
|
|
// only written in the main thread, only read in other threads
|
|
|
|
volatile int32_t mSecureFrameBuffer;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class FreezeLock : public LightRefBase<FreezeLock> {
|
|
|
|
SurfaceFlinger* mFlinger;
|
|
|
|
public:
|
|
|
|
FreezeLock(SurfaceFlinger* flinger)
|
|
|
|
: mFlinger(flinger) {
|
|
|
|
mFlinger->incFreezeCount();
|
|
|
|
}
|
|
|
|
~FreezeLock() {
|
|
|
|
mFlinger->decFreezeCount();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class BClient : public BnSurfaceFlingerClient
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BClient(SurfaceFlinger *flinger, ClientID cid,
|
2009-07-03 01:11:53 +00:00
|
|
|
const sp<IMemoryHeap>& cblk);
|
2009-03-04 03:31:44 +00:00
|
|
|
~BClient();
|
|
|
|
|
|
|
|
// ISurfaceFlingerClient interface
|
2009-07-03 01:11:53 +00:00
|
|
|
virtual sp<IMemoryHeap> getControlBlock() const;
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
virtual sp<ISurface> createSurface(
|
|
|
|
surface_data_t* params, int pid,
|
|
|
|
DisplayID display, uint32_t w, uint32_t h,PixelFormat format,
|
|
|
|
uint32_t flags);
|
|
|
|
|
|
|
|
virtual status_t destroySurface(SurfaceID surfaceId);
|
|
|
|
virtual status_t setState(int32_t count, const layer_state_t* states);
|
|
|
|
|
|
|
|
private:
|
|
|
|
ClientID mId;
|
|
|
|
SurfaceFlinger* mFlinger;
|
2009-07-03 01:11:53 +00:00
|
|
|
sp<IMemoryHeap> mCblk;
|
2009-03-04 03:31:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
}; // namespace android
|
|
|
|
|
|
|
|
#endif // ANDROID_SURFACE_FLINGER_H
|