M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions

View File

@ -0,0 +1,135 @@
/*
* 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_SF_ISURFACE_H
#define ANDROID_SF_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>
#include <hardware/hardware.h>
#include <hardware/gralloc.h>
namespace android {
typedef int32_t SurfaceID;
class IMemoryHeap;
class OverlayRef;
class GraphicBuffer;
class ISurface : public IInterface
{
protected:
enum {
REGISTER_BUFFERS = IBinder::FIRST_CALL_TRANSACTION,
UNREGISTER_BUFFERS,
POST_BUFFER, // one-way transaction
CREATE_OVERLAY,
REQUEST_BUFFER,
SET_BUFFER_COUNT,
SET_STEREOSCOPIC_3D_FORMAT,
USE_ORIGINAL_SURFACE_RESOLUTION,
RECONFIGURE_BUFFERS,
};
public:
DECLARE_META_INTERFACE(Surface);
/*
* requests a new buffer for the given index. If w, h, or format are
* null the buffer is created with the parameters assigned to the
* surface it is bound to. Otherwise the buffer's parameters are
* set to those specified.
*/
virtual sp<GraphicBuffer> requestBuffer(int bufferIdx,
uint32_t w, uint32_t h, uint32_t format, uint32_t usage) = 0;
/*
* sets the number of buffers dequeuable for this surface.
*/
virtual status_t setBufferCount(int bufferCount) = 0;
virtual status_t setStereoscopic3DFormat(int format) = 0;
virtual status_t useOriginalSurfaceResolution(bool flag) = 0;
// ------------------------------------------------------------------------
// Deprecated...
// ------------------------------------------------------------------------
class BufferHeap {
public:
enum {
/* rotate source image */
ROT_0 = 0,
ROT_90 = HAL_TRANSFORM_ROT_90,
ROT_180 = HAL_TRANSFORM_ROT_180,
ROT_270 = HAL_TRANSFORM_ROT_270,
};
BufferHeap();
BufferHeap(uint32_t w, uint32_t h,
int32_t hor_stride, int32_t ver_stride,
PixelFormat format, const sp<IMemoryHeap>& heap);
BufferHeap(uint32_t w, uint32_t h,
int32_t hor_stride, int32_t ver_stride,
PixelFormat format, uint32_t transform, uint32_t flags,
const sp<IMemoryHeap>& heap);
~BufferHeap();
uint32_t w;
uint32_t h;
int32_t hor_stride;
int32_t ver_stride;
PixelFormat format;
uint32_t transform;
uint32_t flags;
sp<IMemoryHeap> heap;
};
virtual status_t registerBuffers(const BufferHeap& buffers) = 0;
virtual void postBuffer(ssize_t offset) = 0; // one-way
virtual void reconfigureBuffers() = 0;
virtual void unregisterBuffers() = 0;
virtual sp<OverlayRef> createOverlay(
uint32_t w, uint32_t h, int32_t format, int32_t orientation) = 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_SF_ISURFACE_H

View File

@ -0,0 +1,176 @@
/*
* Copyright (C) 2006 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_SF_ISURFACE_COMPOSER_H
#define ANDROID_SF_ISURFACE_COMPOSER_H
#include <stdint.h>
#include <sys/types.h>
#include <utils/RefBase.h>
#include <utils/Errors.h>
#include <binder/IInterface.h>
#include <ui/PixelFormat.h>
#include <surfaceflinger/ISurfaceComposerClient.h>
namespace android {
// ----------------------------------------------------------------------------
class ISurfaceComposer : public IInterface
{
public:
DECLARE_META_INTERFACE(SurfaceComposer);
enum { // (keep in sync with Surface.java)
eHidden = 0x00000004,
eDestroyBackbuffer = 0x00000020,
eSecure = 0x00000080,
eNonPremultiplied = 0x00000100,
ePushBuffers = 0x00000200,
eFullScreen = 0x00000400,
eFXSurfaceNormal = 0x00000000,
eFXSurfaceBlur = 0x00010000,
eFXSurfaceDim = 0x00020000,
eFXSurfaceMask = 0x000F0000,
};
enum {
ePositionChanged = 0x00000001,
eLayerChanged = 0x00000002,
eSizeChanged = 0x00000004,
eAlphaChanged = 0x00000008,
eMatrixChanged = 0x00000010,
eTransparentRegionChanged = 0x00000020,
eVisibilityChanged = 0x00000040,
eFreezeTintChanged = 0x00000080,
eVisualParamChanged = 0x00000100,
};
enum {
eLayerHidden = 0x01,
eLayerFrozen = 0x02,
eLayerDither = 0x04,
eLayerFilter = 0x08,
eLayerBlurFreeze = 0x10
};
enum {
eOrientationDefault = 0,
eOrientation90 = 1,
eOrientation180 = 2,
eOrientation270 = 3,
eOrientationSwapMask = 0x01
};
enum {
eElectronBeamAnimationOn = 0x01,
eElectronBeamAnimationOff = 0x10
};
// flags for setOrientation
enum {
eOrientationAnimationDisable = 0x00000001
};
/* create connection with surface flinger, requires
* ACCESS_SURFACE_FLINGER permission
*/
virtual sp<ISurfaceComposerClient> createConnection() = 0;
/* create a client connection with surface flinger
*/
virtual sp<ISurfaceComposerClient> createClientConnection() = 0;
/* retrieve the control block */
virtual sp<IMemoryHeap> getCblk() const = 0;
/* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */
virtual void openGlobalTransaction() = 0;
virtual void closeGlobalTransaction() = 0;
/* [un]freeze display. requires ACCESS_SURFACE_FLINGER permission */
virtual status_t freezeDisplay(DisplayID dpy, uint32_t flags) = 0;
virtual status_t unfreezeDisplay(DisplayID dpy, uint32_t flags) = 0;
/* Set display orientation. requires ACCESS_SURFACE_FLINGER permission */
virtual int setOrientation(DisplayID dpy, int orientation, uint32_t flags) = 0;
/* signal that we're done booting.
* Requires ACCESS_SURFACE_FLINGER permission
*/
virtual void bootFinished() = 0;
/* Capture the specified screen. requires READ_FRAME_BUFFER permission
* This function will fail if there is a secure window on screen.
*/
virtual status_t captureScreen(DisplayID dpy,
sp<IMemoryHeap>* heap,
uint32_t* width, uint32_t* height, PixelFormat* format,
uint32_t reqWidth, uint32_t reqHeight) = 0;
virtual status_t turnElectronBeamOff(int32_t mode) = 0;
virtual status_t turnElectronBeamOn(int32_t mode) = 0;
/* Signal surfaceflinger that there might be some work to do
* This is an ASYNCHRONOUS call.
*/
virtual void signal() const = 0;
virtual void enableHDMIOutput(int enable) = 0;
virtual void setActionSafeWidthRatio(float asWidthRatio) = 0;
virtual void setActionSafeHeightRatio(float asHeightRatio) = 0;
};
// ----------------------------------------------------------------------------
class BnSurfaceComposer : public BnInterface<ISurfaceComposer>
{
public:
enum {
// Note: BOOT_FINISHED must remain this value, it is called from
// Java by ActivityManagerService.
BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
CREATE_CONNECTION,
CREATE_CLIENT_CONNECTION,
GET_CBLK,
OPEN_GLOBAL_TRANSACTION,
CLOSE_GLOBAL_TRANSACTION,
SET_ORIENTATION,
FREEZE_DISPLAY,
UNFREEZE_DISPLAY,
SIGNAL,
ENABLE_HDMI_OUTPUT,
CAPTURE_SCREEN,
TURN_ELECTRON_BEAM_OFF,
TURN_ELECTRON_BEAM_ON,
SET_ACTIONSAFE_WIDTH_RATIO,
SET_ACTIONSAFE_HEIGHT_RATIO
};
virtual status_t onTransact( uint32_t code,
const Parcel& data,
Parcel* reply,
uint32_t flags = 0);
};
// ----------------------------------------------------------------------------
}; // namespace android
#endif // ANDROID_SF_ISURFACE_COMPOSER_H

View File

@ -0,0 +1,101 @@
/*
* 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_SF_ISURFACE_COMPOSER_CLIENT_H
#define ANDROID_SF_ISURFACE_COMPOSER_CLIENT_H
#include <stdint.h>
#include <sys/types.h>
#include <utils/Errors.h>
#include <utils/RefBase.h>
#include <binder/IInterface.h>
#include <ui/PixelFormat.h>
#include <surfaceflinger/ISurface.h>
namespace android {
// ----------------------------------------------------------------------------
class IMemoryHeap;
typedef int32_t ClientID;
typedef int32_t DisplayID;
// ----------------------------------------------------------------------------
class layer_state_t;
class ISurfaceComposerClient : public IInterface
{
public:
DECLARE_META_INTERFACE(SurfaceComposerClient);
struct surface_data_t {
int32_t token;
int32_t identity;
uint32_t width;
uint32_t height;
uint32_t format;
status_t readFromParcel(const Parcel& parcel);
status_t writeToParcel(Parcel* parcel) const;
};
virtual sp<IMemoryHeap> getControlBlock() const = 0;
virtual ssize_t getTokenForSurface(const sp<ISurface>& sur) const = 0;
/*
* Requires ACCESS_SURFACE_FLINGER permission
*/
virtual sp<ISurface> createSurface( surface_data_t* data,
int pid,
const String8& name,
DisplayID display,
uint32_t w,
uint32_t h,
PixelFormat format,
uint32_t flags) = 0;
/*
* Requires ACCESS_SURFACE_FLINGER permission
*/
virtual status_t destroySurface(SurfaceID sid) = 0;
/*
* Requires ACCESS_SURFACE_FLINGER permission
*/
virtual status_t setState(int32_t count, const layer_state_t* states) = 0;
};
// ----------------------------------------------------------------------------
class BnSurfaceComposerClient : public BnInterface<ISurfaceComposerClient>
{
public:
virtual status_t onTransact( uint32_t code,
const Parcel& data,
Parcel* reply,
uint32_t flags = 0);
};
// ----------------------------------------------------------------------------
}; // namespace android
#endif // ANDROID_SF_ISURFACE_COMPOSER_CLIENT_H

View File

@ -0,0 +1,320 @@
/*
* 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_SF_SURFACE_H
#define ANDROID_SF_SURFACE_H
#include <stdint.h>
#include <sys/types.h>
#include <utils/KeyedVector.h>
#include <utils/RefBase.h>
#include <utils/threads.h>
#include <ui/PixelFormat.h>
#include <ui/Region.h>
#include <ui/egl/android_natives.h>
#include <surfaceflinger/ISurface.h>
#include <surfaceflinger/ISurfaceComposerClient.h>
#include <private/surfaceflinger/SharedBufferStack.h>
#define ANDROID_VIEW_SURFACE_JNI_ID "mNativeSurface"
namespace android {
// ---------------------------------------------------------------------------
class GraphicBuffer;
class GraphicBufferMapper;
class IOMX;
class Rect;
class Surface;
class SurfaceComposerClient;
class SharedClient;
class SharedBufferClient;
class SurfaceClient;
// ---------------------------------------------------------------------------
class SurfaceControl : public RefBase
{
public:
static bool isValid(const sp<SurfaceControl>& surface) {
return (surface != 0) && surface->isValid();
}
bool isValid() {
return mToken>=0 && mClient!=0;
}
static bool isSameSurface(
const sp<SurfaceControl>& lhs, const sp<SurfaceControl>& rhs);
uint32_t getFlags() const { return mFlags; }
uint32_t getIdentity() const { return mIdentity; }
// release surface data from java
void clear();
status_t setLayer(int32_t layer);
status_t setPosition(int32_t x, int32_t y);
status_t setSize(uint32_t w, uint32_t h);
status_t setVisualParam(int8_t paramType, float paramValue);
status_t hide();
status_t show(int32_t layer = -1);
status_t freeze();
status_t unfreeze();
status_t setFlags(uint32_t flags, uint32_t mask);
status_t setTransparentRegionHint(const Region& transparent);
status_t setAlpha(float alpha=1.0f);
status_t setMatrix(float dsdx, float dtdx, float dsdy, float dtdy);
status_t setFreezeTint(uint32_t tint);
static status_t writeSurfaceToParcel(
const sp<SurfaceControl>& control, Parcel* parcel);
sp<Surface> getSurface() const;
private:
// can't be copied
SurfaceControl& operator = (SurfaceControl& rhs);
SurfaceControl(const SurfaceControl& rhs);
friend class SurfaceComposerClient;
// camera and camcorder need access to the ISurface binder interface for preview
friend class Camera;
friend class MediaRecorder;
// mediaplayer needs access to ISurface for display
friend class MediaPlayer;
// for testing
friend class Test;
const sp<ISurface>& getISurface() const { return mSurface; }
friend class Surface;
SurfaceControl(
const sp<SurfaceComposerClient>& client,
const sp<ISurface>& surface,
const ISurfaceComposerClient::surface_data_t& data,
uint32_t w, uint32_t h, PixelFormat format, uint32_t flags);
~SurfaceControl();
status_t validate() const;
void destroy();
sp<SurfaceComposerClient> mClient;
sp<ISurface> mSurface;
SurfaceID mToken;
uint32_t mIdentity;
uint32_t mWidth;
uint32_t mHeight;
PixelFormat mFormat;
uint32_t mFlags;
mutable Mutex mLock;
mutable sp<Surface> mSurfaceData;
};
// ---------------------------------------------------------------------------
class Surface
: public EGLNativeBase<ANativeWindow, Surface, RefBase>
{
public:
struct SurfaceInfo {
uint32_t w;
uint32_t h;
uint32_t s;
uint32_t usage;
PixelFormat format;
void* bits;
uint32_t reserved[2];
};
static status_t writeToParcel(
const sp<Surface>& control, Parcel* parcel);
static sp<Surface> readFromParcel(const Parcel& data);
static bool isValid(const sp<Surface>& surface) {
return (surface != 0) && surface->isValid();
}
bool isValid();
uint32_t getFlags() const { return mFlags; }
uint32_t getIdentity() const { return mIdentity; }
// the lock/unlock APIs must be used from the same thread
status_t lock(SurfaceInfo* info, bool blocking = true);
status_t lock(SurfaceInfo* info, Region* dirty, bool blocking = true);
status_t unlockAndPost();
status_t setStereoscopic3DFormat(int format);
status_t useOriginalSurfaceResolution(bool flag);
// setSwapRectangle() is intended to be used by GL ES clients
void setSwapRectangle(const Rect& r);
private:
/*
* Android frameworks friends
* (eventually this should go away and be replaced by proper APIs)
*/
// camera and camcorder need access to the ISurface binder interface for preview
friend class Camera;
friend class MediaRecorder;
// MediaPlayer needs access to ISurface for display
friend class MediaPlayer;
friend class IOMX;
// this is just to be able to write some unit tests
friend class Test;
private:
friend class SurfaceComposerClient;
friend class SurfaceControl;
// can't be copied
Surface& operator = (Surface& rhs);
Surface(const Surface& rhs);
Surface(const sp<SurfaceControl>& control);
Surface(const Parcel& data, const sp<IBinder>& ref);
~Surface();
/*
* ANativeWindow hooks
*/
static int setSwapInterval(ANativeWindow* window, int interval);
static int dequeueBuffer(ANativeWindow* window, android_native_buffer_t** buffer);
static int cancelBuffer(ANativeWindow* window, android_native_buffer_t* buffer);
static int lockBuffer(ANativeWindow* window, android_native_buffer_t* buffer);
static int queueBuffer(ANativeWindow* window, android_native_buffer_t* buffer);
static int query(ANativeWindow* window, int what, int* value);
static int perform(ANativeWindow* window, int operation, ...);
int dequeueBuffer(android_native_buffer_t** buffer);
int lockBuffer(android_native_buffer_t* buffer);
int queueBuffer(android_native_buffer_t* buffer);
int cancelBuffer(android_native_buffer_t* buffer);
int query(int what, int* value);
int perform(int operation, va_list args);
void dispatch_setUsage(va_list args);
int dispatch_connect(va_list args);
int dispatch_disconnect(va_list args);
int dispatch_crop(va_list args);
int dispatch_set_buffer_count(va_list args);
int dispatch_set_buffers_geometry(va_list args);
int dispatch_set_buffers_transform(va_list args);
void setUsage(uint32_t reqUsage);
int connect(int api);
int disconnect(int api);
int crop(Rect const* rect);
int setBufferCount(int bufferCount);
int setBuffersGeometry(int w, int h, int format);
int setBuffersTransform(int transform);
/*
* private stuff...
*/
void init();
status_t validate() const;
sp<ISurface> getISurface() const;
inline const GraphicBufferMapper& getBufferMapper() const { return mBufferMapper; }
inline GraphicBufferMapper& getBufferMapper() { return mBufferMapper; }
status_t getBufferLocked(int index,
uint32_t w, uint32_t h, uint32_t format, uint32_t usage);
int getBufferIndex(const sp<GraphicBuffer>& buffer) const;
int getConnectedApi() const;
bool needNewBuffer(int bufIdx,
uint32_t *pWidth, uint32_t *pHeight,
uint32_t *pFormat, uint32_t *pUsage) const;
static void cleanCachedSurfacesLocked();
class BufferInfo {
uint32_t mWidth;
uint32_t mHeight;
uint32_t mFormat;
uint32_t mUsage;
mutable uint32_t mDirty;
enum {
GEOMETRY = 0x01
};
public:
BufferInfo();
void set(uint32_t w, uint32_t h, uint32_t format);
void set(uint32_t usage);
void get(uint32_t *pWidth, uint32_t *pHeight,
uint32_t *pFormat, uint32_t *pUsage) const;
bool validateBuffer(const sp<GraphicBuffer>& buffer) const;
};
// constants
GraphicBufferMapper& mBufferMapper;
SurfaceClient& mClient;
SharedBufferClient* mSharedBufferClient;
status_t mInitCheck;
sp<ISurface> mSurface;
uint32_t mIdentity;
PixelFormat mFormat;
uint32_t mFlags;
// protected by mSurfaceLock
Rect mSwapRectangle;
int mConnected;
Rect mNextBufferCrop;
uint32_t mNextBufferTransform;
BufferInfo mBufferInfo;
// protected by mSurfaceLock. These are also used from lock/unlock
// but in that case, they must be called form the same thread.
mutable Region mDirtyRegion;
// must be used from the lock/unlock thread
sp<GraphicBuffer> mLockedBuffer;
sp<GraphicBuffer> mPostedBuffer;
mutable Region mOldDirtyRegion[SharedBufferStack::NUM_BUFFER_MAX];
bool mReserved;
// only used from dequeueBuffer()
Vector< sp<GraphicBuffer> > mBuffers;
// query() must be called from dequeueBuffer() thread
uint32_t mWidth;
uint32_t mHeight;
// Inherently thread-safe
mutable Mutex mSurfaceLock;
mutable Mutex mApiLock;
// A cache of Surface objects that have been deserialized into this process.
static Mutex sCachedSurfacesLock;
static DefaultKeyedVector<wp<IBinder>, wp<Surface> > sCachedSurfaces;
};
}; // namespace android
#endif // ANDROID_SF_SURFACE_H

View File

@ -0,0 +1,210 @@
/*
* 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_SF_SURFACE_COMPOSER_CLIENT_H
#define ANDROID_SF_SURFACE_COMPOSER_CLIENT_H
#include <stdint.h>
#include <sys/types.h>
#include <binder/IBinder.h>
#include <utils/RefBase.h>
#include <utils/Singleton.h>
#include <utils/SortedVector.h>
#include <utils/threads.h>
#include <ui/PixelFormat.h>
#include <ui/Region.h>
#include <surfaceflinger/Surface.h>
namespace android {
// ---------------------------------------------------------------------------
class Region;
class SharedClient;
class ISurfaceComposer;
class DisplayInfo;
class surface_flinger_cblk_t;
// ---------------------------------------------------------------------------
class ComposerService : public Singleton<ComposerService>
{
// these are constants
sp<ISurfaceComposer> mComposerService;
sp<IMemoryHeap> mServerCblkMemory;
surface_flinger_cblk_t volatile* mServerCblk;
ComposerService();
friend class Singleton<ComposerService>;
public:
static sp<ISurfaceComposer> getComposerService();
static surface_flinger_cblk_t const volatile * getControlBlock();
};
// ---------------------------------------------------------------------------
class SurfaceComposerClient : public RefBase
{
public:
SurfaceComposerClient();
virtual ~SurfaceComposerClient();
// Always make sure we could initialize
status_t initCheck() const;
// Return the connection of this client
sp<IBinder> connection() const;
// Forcibly remove connection before all references have gone away.
void dispose();
// ------------------------------------------------------------------------
// surface creation / destruction
//! Create a surface
sp<SurfaceControl> createSurface(
int pid, // pid of the process the surface is for
const String8& name,// name of the surface
DisplayID display, // Display to create this surface on
uint32_t w, // width in pixel
uint32_t h, // height in pixel
PixelFormat format, // pixel-format desired
uint32_t flags = 0 // usage flags
);
sp<SurfaceControl> createSurface(
int pid, // pid of the process the surface is for
DisplayID display, // Display to create this surface on
uint32_t w, // width in pixel
uint32_t h, // height in pixel
PixelFormat format, // pixel-format desired
uint32_t flags = 0 // usage flags
);
// ------------------------------------------------------------------------
// Composer parameters
// All composer parameters must be changed within a transaction
// several surfaces can be updated in one transaction, all changes are
// committed at once when the transaction is closed.
// CloseTransaction() usually requires an IPC with the server.
//! Open a composer transaction
status_t openTransaction();
//! commit the transaction
status_t closeTransaction();
//! Open a composer transaction on all active SurfaceComposerClients.
static void openGlobalTransaction();
//! Close a composer transaction on all active SurfaceComposerClients.
static void closeGlobalTransaction();
//! Freeze the specified display but not transactions.
static status_t freezeDisplay(DisplayID dpy, uint32_t flags = 0);
//! Resume updates on the specified display.
static status_t unfreezeDisplay(DisplayID dpy, uint32_t flags = 0);
//! Set the orientation of the given display
static int setOrientation(DisplayID dpy, int orientation, uint32_t flags);
// Query the number of displays
static ssize_t getNumberOfDisplays();
// Get information about a display
static status_t getDisplayInfo(DisplayID dpy, DisplayInfo* info);
static ssize_t getDisplayWidth(DisplayID dpy);
static ssize_t getDisplayHeight(DisplayID dpy);
static ssize_t getDisplayOrientation(DisplayID dpy);
status_t linkToComposerDeath(const sp<IBinder::DeathRecipient>& recipient,
void* cookie = NULL, uint32_t flags = 0);
static void enableHDMIOutput(int enable);
static void setActionSafeWidthRatio(float asWidthRatio);
static void setActionSafeHeightRatio(float asHeightRatio);
status_t hide(SurfaceID id);
status_t show(SurfaceID id, int32_t layer = -1);
status_t freeze(SurfaceID id);
status_t unfreeze(SurfaceID id);
status_t setFlags(SurfaceID id, uint32_t flags, uint32_t mask);
status_t setTransparentRegionHint(SurfaceID id, const Region& transparent);
status_t setLayer(SurfaceID id, int32_t layer);
status_t setAlpha(SurfaceID id, float alpha=1.0f);
status_t setFreezeTint(SurfaceID id, uint32_t tint);
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 setSize(SurfaceID id, uint32_t w, uint32_t h);
status_t setVisualParam(SurfaceID id, int8_t paramType, float paramValue);
status_t destroySurface(SurfaceID sid);
private:
virtual void onFirstRef();
inline layer_state_t* get_state_l(SurfaceID id);
layer_state_t* lockLayerState(SurfaceID id);
inline void unlockLayerState();
mutable Mutex mLock;
SortedVector<layer_state_t> mStates;
int32_t mTransactionOpen;
layer_state_t* mPrebuiltLayerState;
// these don't need to be protected because they never change
// after assignment
status_t mStatus;
sp<ISurfaceComposerClient> mClient;
};
// ---------------------------------------------------------------------------
class ScreenshotClient
{
sp<IMemoryHeap> mHeap;
uint32_t mWidth;
uint32_t mHeight;
PixelFormat mFormat;
public:
ScreenshotClient();
// frees the previous screenshot and capture a new one
status_t update();
status_t update(uint32_t reqWidth, uint32_t reqHeight);
// release memory occupied by the screenshot
void release();
// pixels are valid until this object is freed or
// release() or update() is called
void const* getPixels() const;
uint32_t getWidth() const;
uint32_t getHeight() const;
PixelFormat getFormat() const;
uint32_t getStride() const;
// size of allocated memory in bytes
size_t getSize() const;
};
// ---------------------------------------------------------------------------
}; // namespace android
#endif // ANDROID_SF_SURFACE_COMPOSER_CLIENT_H