From 54b6cfa9a9e5b861a9930af873580d6dc20f773c Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Tue, 21 Oct 2008 07:00:00 -0700 Subject: Initial Contribution --- include/ui/BlitHardware.h | 143 ++++++++++++++++++++++ include/ui/Camera.h | 125 ++++++++++++++++++++ include/ui/CameraHardwareInterface.h | 156 ++++++++++++++++++++++++ include/ui/CameraParameters.h | 70 +++++++++++ include/ui/DisplayInfo.h | 43 +++++++ include/ui/EGLDisplaySurface.h | 82 +++++++++++++ include/ui/EGLNativeSurface.h | 64 ++++++++++ include/ui/EGLNativeWindowSurface.h | 60 ++++++++++ include/ui/EventHub.h | 142 ++++++++++++++++++++++ include/ui/ICamera.h | 75 ++++++++++++ include/ui/ICameraClient.h | 54 +++++++++ include/ui/ICameraService.h | 55 +++++++++ include/ui/ISurface.h | 62 ++++++++++ include/ui/ISurfaceComposer.h | 181 ++++++++++++++++++++++++++++ include/ui/ISurfaceFlingerClient.h | 91 ++++++++++++++ include/ui/KeyCharacterMap.h | 72 ++++++++++++ include/ui/KeycodeLabels.h | 222 +++++++++++++++++++++++++++++++++++ include/ui/PixelFormat.h | 106 +++++++++++++++++ include/ui/Point.h | 88 ++++++++++++++ include/ui/Rect.h | 152 ++++++++++++++++++++++++ include/ui/Region.h | 174 +++++++++++++++++++++++++++ include/ui/Surface.h | 137 +++++++++++++++++++++ include/ui/SurfaceComposerClient.h | 179 ++++++++++++++++++++++++++++ 23 files changed, 2533 insertions(+) create mode 100644 include/ui/BlitHardware.h create mode 100644 include/ui/Camera.h create mode 100644 include/ui/CameraHardwareInterface.h create mode 100644 include/ui/CameraParameters.h create mode 100644 include/ui/DisplayInfo.h create mode 100644 include/ui/EGLDisplaySurface.h create mode 100644 include/ui/EGLNativeSurface.h create mode 100644 include/ui/EGLNativeWindowSurface.h create mode 100644 include/ui/EventHub.h create mode 100644 include/ui/ICamera.h create mode 100644 include/ui/ICameraClient.h create mode 100644 include/ui/ICameraService.h create mode 100644 include/ui/ISurface.h create mode 100644 include/ui/ISurfaceComposer.h create mode 100644 include/ui/ISurfaceFlingerClient.h create mode 100644 include/ui/KeyCharacterMap.h create mode 100644 include/ui/KeycodeLabels.h create mode 100644 include/ui/PixelFormat.h create mode 100644 include/ui/Point.h create mode 100644 include/ui/Rect.h create mode 100644 include/ui/Region.h create mode 100644 include/ui/Surface.h create mode 100644 include/ui/SurfaceComposerClient.h (limited to 'include/ui') diff --git a/include/ui/BlitHardware.h b/include/ui/BlitHardware.h new file mode 100644 index 0000000..4de1c12 --- /dev/null +++ b/include/ui/BlitHardware.h @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2008 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_BLIT_HARDWARE_H +#define ANDROID_BLIT_HARDWARE_H + +#include +#include + +#if __cplusplus +extern "C" { +#endif + +/******************************************************************************/ + +/* supported pixel-formats. these must be compatible with + * graphics/PixelFormat.java, ui/PixelFormat.h, pixelflinger/format.h + */ + +enum +{ + COPYBIT_RGBA_8888 = 1, + COPYBIT_RGB_565 = 4, + COPYBIT_RGBA_5551 = 6, + COPYBIT_RGBA_4444 = 7, + COPYBIT_YCbCr_422_SP = 0x10, + COPYBIT_YCbCr_420_SP = 0x11 +}; + +/* name for copybit_set_parameter */ +enum +{ + /* rotation of the source image in degrees (0 to 359) */ + COPYBIT_ROTATION_DEG = 1, + /* plane alpha value */ + COPYBIT_PLANE_ALPHA = 2, + /* enable or disable dithering */ + COPYBIT_DITHER = 3, + /* transformation applied (this is a superset of COPYBIT_ROTATION_DEG) */ + COPYBIT_TRANSFORM = 4, +}; + +/* values for copybit_set_parameter(COPYBIT_TRANSFORM) */ +enum { + /* flip source image horizontally */ + COPYBIT_TRANSFORM_FLIP_H = 0x01, + /* flip source image vertically */ + COPYBIT_TRANSFORM_FLIP_V = 0x02, + /* rotate source image 90 degres */ + COPYBIT_TRANSFORM_ROT_90 = 0x04, + /* rotate source image 180 degres */ + COPYBIT_TRANSFORM_ROT_180 = 0x03, + /* rotate source image 270 degres */ + COPYBIT_TRANSFORM_ROT_270 = 0x07, +}; + +/* enable/disable value copybit_set_parameter */ +enum { + COPYBIT_DISABLE = 0, + COPYBIT_ENABLE = 1 +}; + +/* use get() to query static informations about the hardware */ +enum { + /* Maximum amount of minification supported by the hardware*/ + COPYBIT_MINIFICATION_LIMIT = 1, + /* Maximum amount of magnification supported by the hardware */ + COPYBIT_MAGNIFICATION_LIMIT = 2, + /* Number of fractional bits support by the scaling engine */ + COPYBIT_SCALING_FRAC_BITS = 3, + /* Supported rotation step in degres. */ + COPYBIT_ROTATION_STEP_DEG = 4, +}; + +struct copybit_image_t { + uint32_t w; + uint32_t h; + int32_t format; + uint32_t offset; + void* base; + int fd; +}; + + +struct copybit_rect_t { + int l; + int t; + int r; + int b; +}; + +struct copybit_region_t { + int (*next)(copybit_region_t const*, copybit_rect_t* rect); +}; + +struct copybit_t +{ + int (*set_parameter)(struct copybit_t* handle, int name, int value); + + int (*get)(struct copybit_t* handle, int name); + + int (*blit)( + struct copybit_t* handle, + struct copybit_image_t const* dst, + struct copybit_image_t const* src, + struct copybit_region_t const* region); + + int (*stretch)( + struct copybit_t* handle, + struct copybit_image_t const* dst, + struct copybit_image_t const* src, + struct copybit_rect_t const* dst_rect, + struct copybit_rect_t const* src_rect, + struct copybit_region_t const* region); +}; + +/******************************************************************************/ + +struct copybit_t* copybit_init(); + +int copybit_term(struct copybit_t* handle); + + +/******************************************************************************/ + +#if __cplusplus +} // extern "C" +#endif + +#endif // ANDROID_BLIT_HARDWARE_H diff --git a/include/ui/Camera.h b/include/ui/Camera.h new file mode 100644 index 0000000..562a0a2 --- /dev/null +++ b/include/ui/Camera.h @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2008 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_HARDWARE_CAMERA_H +#define ANDROID_HARDWARE_CAMERA_H + +#include + +namespace android { + +class ICameraService; +class ICamera; +class Surface; +class Mutex; +class String8; + +typedef void (*shutter_callback)(void *cookie); +typedef void (*frame_callback)(const sp& mem, void *cookie); +typedef void (*autofocus_callback)(bool focused, void *cookie); +typedef void (*error_callback)(status_t err, void *cookie); + +class Camera : public BnCameraClient, public IBinder::DeathRecipient +{ +public: + static sp connect(); + ~Camera(); + + void disconnect(); + + status_t getStatus() { return mStatus; } + + // pass the buffered ISurface to the camera service + status_t setPreviewDisplay(const sp& surface); + + // start preview mode, must call setPreviewDisplay first + status_t startPreview(); + + // stop preview mode + void stopPreview(); + + // autoFocus - status returned from callback + status_t autoFocus(); + + // take a picture - picture returned from callback + status_t takePicture(); + + // set preview/capture parameters - key/value pairs + status_t setParameters(const String8& params); + + // get preview/capture parameters - key/value pairs + String8 getParameters() const; + + void setShutterCallback(shutter_callback cb, void *cookie); + void setRawCallback(frame_callback cb, void *cookie); + void setJpegCallback(frame_callback cb, void *cookie); + void setFrameCallback(frame_callback cb, void *cookie); + void setErrorCallback(error_callback cb, void *cookie); + void setAutoFocusCallback(autofocus_callback cb, void *cookie); + // ICameraClient interface + virtual void shutterCallback(); + virtual void rawCallback(const sp& picture); + virtual void jpegCallback(const sp& picture); + virtual void frameCallback(const sp& frame); + virtual void errorCallback(status_t error); + virtual void autoFocusCallback(bool focused); + + +private: + Camera(); + virtual void binderDied(const wp& who); + + class DeathNotifier: public IBinder::DeathRecipient + { + public: + DeathNotifier() { + } + + virtual void binderDied(const wp& who); + }; + + static sp mDeathNotifier; + + // helper function to obtain camera service handle + static const sp& getCameraService(); + + sp mCamera; + status_t mStatus; + + shutter_callback mShutterCallback; + void *mShutterCallbackCookie; + frame_callback mRawCallback; + void *mRawCallbackCookie; + frame_callback mJpegCallback; + void *mJpegCallbackCookie; + frame_callback mFrameCallback; + void *mFrameCallbackCookie; + error_callback mErrorCallback; + void *mErrorCallbackCookie; + autofocus_callback mAutoFocusCallback; + void *mAutoFocusCallbackCookie; + + friend class DeathNotifier; + + static Mutex mLock; + static sp mCameraService; + +}; + +}; // namespace android + +#endif + diff --git a/include/ui/CameraHardwareInterface.h b/include/ui/CameraHardwareInterface.h new file mode 100644 index 0000000..5fa933f --- /dev/null +++ b/include/ui/CameraHardwareInterface.h @@ -0,0 +1,156 @@ +/* + * Copyright (C) 2008 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_HARDWARE_CAMERA_HARDWARE_INTERFACE_H +#define ANDROID_HARDWARE_CAMERA_HARDWARE_INTERFACE_H + +#include +#include +#include + +namespace android { + +/** Callback for startPreview() */ +typedef void (*preview_callback)(const sp& mem, void* user); + +/** Callback for takePicture() */ +typedef void (*shutter_callback)(void* user); + +/** Callback for takePicture() */ +typedef void (*raw_callback)(const sp& mem, void* user); + +/** Callback for takePicture() */ +typedef void (*jpeg_callback)(const sp& mem, void* user); + +/** Callback for autoFocus() */ +typedef void (*autofocus_callback)(bool focused, void* user); + +/** + * This defines the interface to the camera hardware abstraction + * layer. It supports setting and getting parameters, live + * previewing and taking pictures. It is a referenced counted + * interface with RefBase as its base class. + * + * The openCameraHardware function is used to + * retrieve a strong pointer to the instance of this interface + * and may be called multiple times. + * + * After calling openCameraHardware the getParameters and + * setParameters are used to initialize the camera instance. + * + * Then getPreviewHeap is called to get access to the preview + * heap so it can be registered with the SurfaceFlinger for efficient + * display updating while in the preview mode. + * + * Next startPreview is called which is passed a preview_callback + * function and a user parameter. The camera instance then + * periodically calls preview_callback each time a new + * preview frame is available. The call back routine has + * two parameters, the first is a pointer to the the IMemory containing + * the frame and the other is the user parameter. If the preview_callback + * code needs to use this memory after returning it must copy + * the data. + * + * Prior to taking a picture the autoFocus method is usually called with a + * autofocus_callback and a user parameter. When auto focusing + * has completed the camera instance calls autofocus_callback which + * informs the application if focusing was successful or not. + * The camera instance only calls the autofocus_callback once and it + * is up to the application to call autoFocus again if refocusing is desired. + * + * The method takePicture is called to request that the camera instance take a + * picture. This method has three callbacks: shutter_callback, raw_callback, + * and jpeg_callback. As soon as the shutter snaps and it is safe to move the + * camera, shutter_callback is called. Typically, you would want to play the + * shutter sound at this moment. Later, when the raw image is available the + * raw_callback is called with a pointer to the IMemory containing the raw + * image. Finally, when the encoded jpeg image is available the jpeg_callback + * will be called with a pointer to the IMemory containing the jpeg image. As + * with the preview_callback the memory must be copied if it's needed after + * returning. + */ +class CameraHardwareInterface : public virtual RefBase { +public: + virtual ~CameraHardwareInterface() { } + + /** Return the IMemoryHeap for the preview image heap */ + virtual sp getPreviewHeap() const = 0; + + /** + * Start preview mode. When a preview image is available + * preview_callback is called with the user parameter. The + * call back parameter may be null. + */ + virtual status_t startPreview(preview_callback cb, void* user) = 0; + + /** + * Stop a previously started preview. + */ + virtual void stopPreview() = 0; + + /** + * Start auto focus, the callback routine is called + * once when focusing is complete. autoFocus() will + * be called agained if another auto focus is needed. + */ + virtual status_t autoFocus(autofocus_callback, + void* user) = 0; + + /** + * Take a picture. The raw_callback is called when + * the uncompressed image is available. The jpeg_callback + * is called when the compressed image is available. These + * call backs may be null. The user parameter is passed + * to each of the call back routines. + */ + virtual status_t takePicture(shutter_callback, + raw_callback, + jpeg_callback, + void* user) = 0; + + /** + * Cancel a picture that was started with takePicture. You may cancel any + * of the shutter, raw, or jpeg callbacks. Calling this method when no + * picture is being taken is a no-op. + */ + virtual status_t cancelPicture(bool cancel_shutter, + bool cancel_raw, + bool cancel_jpeg) = 0; + + /** Set the camera parameters. */ + virtual status_t setParameters(const CameraParameters& params) = 0; + + /** Return the camera parameters. */ + virtual CameraParameters getParameters() const = 0; + + /** + * Release the hardware resources owned by this object. Note that this is + * *not* done in the destructor. + */ + virtual void release() = 0; + + /** + * Dump state of the camera hardware + */ + virtual status_t dump(int fd, const Vector& args) const = 0; +}; + +/** factory function to instantiate a camera hardware object */ +extern "C" sp openCameraHardware(); + +}; // namespace android + +#endif diff --git a/include/ui/CameraParameters.h b/include/ui/CameraParameters.h new file mode 100644 index 0000000..e35a054 --- /dev/null +++ b/include/ui/CameraParameters.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2008 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_HARDWARE_CAMERA_PARAMETERS_H +#define ANDROID_HARDWARE_CAMERA_PARAMETERS_H + +#include +#include + +namespace android { + +class CameraParameters +{ +public: + CameraParameters(); + CameraParameters(const String8 ¶ms) { unflatten(params); } + ~CameraParameters(); + + String8 flatten() const; + void unflatten(const String8 ¶ms); + + void set(const char *key, const char *value); + void set(const char *key, int value); + const char *get(const char *key) const; + int getInt(const char *key) const; + + /* preview-size=176x144 */ + void setPreviewSize(int width, int height); + void getPreviewSize(int *width, int *height) const; + + /* preview-fps=15 */ + void setPreviewFrameRate(int fps); + int getPreviewFrameRate() const; + + /* preview-format=rgb565|yuv422 */ + void setPreviewFormat(const char *format); + const char *getPreviewFormat() const; + + /* picture-size=1024x768 */ + void setPictureSize(int width, int height); + void getPictureSize(int *width, int *height) const; + + /* picture-format=yuv422|jpeg */ + void setPictureFormat(const char *format); + const char *getPictureFormat() const; + + void dump() const; + status_t dump(int fd, const Vector& args) const; + +private: + DefaultKeyedVector mMap; +}; + + +}; // namespace android + +#endif diff --git a/include/ui/DisplayInfo.h b/include/ui/DisplayInfo.h new file mode 100644 index 0000000..c419efe --- /dev/null +++ b/include/ui/DisplayInfo.h @@ -0,0 +1,43 @@ +/* + * 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_UI_DISPLAY_INFO_H +#define ANDROID_UI_DISPLAY_INFO_H + +#include +#include + +#include + +namespace android { + +struct DisplayInfo { + uint32_t w; + uint32_t h; + PixelFormatInfo pixelFormatInfo; + uint8_t orientation; + uint8_t reserved[3]; + float fps; + float density; + float xdpi; + float ydpi; +}; + +}; // namespace android + +#endif // ANDROID_COMPOSER_DISPLAY_INFO_H + diff --git a/include/ui/EGLDisplaySurface.h b/include/ui/EGLDisplaySurface.h new file mode 100644 index 0000000..a9cfd5a --- /dev/null +++ b/include/ui/EGLDisplaySurface.h @@ -0,0 +1,82 @@ +/* + * 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_EGL_DISPLAY_SURFACE_H +#define ANDROID_EGL_DISPLAY_SURFACE_H + +#include +#include + +#include + +#include +#include + +#include +#include + +// --------------------------------------------------------------------------- +namespace android { +// --------------------------------------------------------------------------- + +class Region; +class Rect; + +class EGLDisplaySurface : public EGLNativeSurface +{ +public: + EGLDisplaySurface(); + ~EGLDisplaySurface(); + + int32_t getPageFlipCount() const; + void copyFrontToBack(const Region& copyback); + +private: + static void hook_incRef(NativeWindowType window); + static void hook_decRef(NativeWindowType window); + static uint32_t hook_swapBuffers(NativeWindowType window); + static void hook_setSwapRectangle(NativeWindowType window, int l, int t, int w, int h); + static uint32_t hook_nextBuffer(NativeWindowType window); + + uint32_t swapBuffers(); + uint32_t nextBuffer(); + void setSwapRectangle(int l, int t, int w, int h); + + status_t mapFrameBuffer(); + + enum { + PAGE_FLIP = 0x00000001 + }; + GGLSurface mFb[2]; + int mIndex; + uint32_t mFlags; + size_t mSize; + fb_var_screeninfo mInfo; + fb_fix_screeninfo mFinfo; + int32_t mPageFlipCount; + nsecs_t mTime; + int32_t mSwapCount; + nsecs_t mSleep; + uint32_t mFeatureFlags; + copybit_t* mBlitEngine; +}; + +// --------------------------------------------------------------------------- +}; // namespace android +// --------------------------------------------------------------------------- + +#endif // ANDROID_EGL_DISPLAY_SURFACE_H + diff --git a/include/ui/EGLNativeSurface.h b/include/ui/EGLNativeSurface.h new file mode 100644 index 0000000..7c9ce99 --- /dev/null +++ b/include/ui/EGLNativeSurface.h @@ -0,0 +1,64 @@ +/* + * 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_EGL_NATIVE_SURFACE_H +#define ANDROID_EGL_NATIVE_SURFACE_H + +#include +#include + +#include +#include + +#include + +// --------------------------------------------------------------------------- +namespace android { +// --------------------------------------------------------------------------- + +template +class EGLNativeSurface : public egl_native_window_t +{ +public: + EGLNativeSurface() : mCount(0) { + memset(egl_native_window_t::reserved, 0, + sizeof(egl_native_window_t::reserved)); + memset(egl_native_window_t::reserved_proc, 0, + sizeof(egl_native_window_t::reserved_proc)); + memset(egl_native_window_t::oem, 0, + sizeof(egl_native_window_t::oem)); + } + inline void incStrong(void*) const { + android_atomic_inc(&mCount); + } + inline void decStrong(void*) const { + if (android_atomic_dec(&mCount) == 1) { + delete static_cast(this); + } + } +protected: + EGLNativeSurface& operator = (const EGLNativeSurface& rhs); + EGLNativeSurface(const EGLNativeSurface& rhs); + inline ~EGLNativeSurface() { }; + mutable volatile int32_t mCount; +}; + +// --------------------------------------------------------------------------- +}; // namespace android +// --------------------------------------------------------------------------- + +#endif // ANDROID_EGL_SURFACE_H + diff --git a/include/ui/EGLNativeWindowSurface.h b/include/ui/EGLNativeWindowSurface.h new file mode 100644 index 0000000..058479a --- /dev/null +++ b/include/ui/EGLNativeWindowSurface.h @@ -0,0 +1,60 @@ +/* + * 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_EGL_NATIVE_WINDOW_SURFACE_H +#define ANDROID_EGL_NATIVE_WINDOW_SURFACE_H + +#include +#include +#include + +// --------------------------------------------------------------------------- +namespace android { +// --------------------------------------------------------------------------- + +class Surface; + +class EGLNativeWindowSurface : public EGLNativeSurface +{ +public: + EGLNativeWindowSurface(const sp& surface); + ~EGLNativeWindowSurface(); + +private: + static void hook_incRef(NativeWindowType window); + static void hook_decRef(NativeWindowType window); + static uint32_t hook_swapBuffers(NativeWindowType window); + static uint32_t hook_nextBuffer(NativeWindowType window); + static void hook_setSwapRectangle(NativeWindowType window, int l, int t, int w, int h); + static void hook_connect(NativeWindowType window); + static void hook_disconnect(NativeWindowType window); + + uint32_t swapBuffers(); + uint32_t nextBuffer(); + void setSwapRectangle(int l, int t, int w, int h); + void connect(); + void disconnect(); + + sp mSurface; + bool mConnected; +}; + +// --------------------------------------------------------------------------- +}; // namespace android +// --------------------------------------------------------------------------- + +#endif // ANDROID_EGL_NATIVE_WINDOW_SURFACE_H + diff --git a/include/ui/EventHub.h b/include/ui/EventHub.h new file mode 100644 index 0000000..101a920 --- /dev/null +++ b/include/ui/EventHub.h @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2005 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 _RUNTIME_EVENT_HUB_H +#define _RUNTIME_EVENT_HUB_H + +#include +#include +#include + +#include + +struct pollfd; + +namespace android { + +class KeyLayoutMap; + +/* + * Grand Central Station for events. With a single call to waitEvent() + * you can wait for: + * - input events from the keypad of a real device + * - input events and meta-events (e.g. "quit") from the simulator + * - synthetic events from the runtime (e.g. "URL fetch completed") + * - real or forged "vsync" events + * + * Do not instantiate this class. Instead, call startUp(). + */ +class EventHub : public RefBase +{ +public: + EventHub(); + + status_t errorCheck() const; + + // bit fields for classes of devices. + enum { + CLASS_KEYBOARD = 0x00000001, + CLASS_TOUCHSCREEN = 0x00000002, + CLASS_TRACKBALL = 0x00000004 + }; + uint32_t getDeviceClasses(int32_t deviceId) const; + + String8 getDeviceName(int32_t deviceId) const; + + int getAbsoluteInfo(int32_t deviceId, int axis, int *outMinValue, + int* outMaxValue, int* outFlat, int* outFuzz) const; + + int getSwitchState(int sw) const; + int getSwitchState(int32_t deviceId, int sw) const; + + int getScancodeState(int key) const; + int getScancodeState(int32_t deviceId, int key) const; + + int getKeycodeState(int key) const; + int getKeycodeState(int32_t deviceId, int key) const; + + // special type codes when devices are added/removed. + enum { + DEVICE_ADDED = 0x10000000, + DEVICE_REMOVED = 0x20000000 + }; + + virtual bool getEvent(int32_t* outDeviceId, int32_t* outType, + int32_t* outScancode, int32_t* outKeycode, uint32_t *outFlags, + int32_t* outValue, nsecs_t* outWhen); + +protected: + virtual ~EventHub(); + virtual void onFirstRef(); + +private: + bool openPlatformInput(void); + int32_t convertDeviceKey_TI_P2(int code); + + int open_device(const char *device); + int close_device(const char *device); + int scan_dir(const char *dirname); + int read_notify(int nfd); + + status_t mError; + + struct device_t { + const int32_t id; + const String8 path; + String8 name; + uint32_t classes; + KeyLayoutMap* layoutMap; + String8 keylayoutFilename; + device_t* next; + + device_t(int32_t _id, const char* _path); + ~device_t(); + }; + + device_t* getDevice(int32_t deviceId) const; + + // Protect all internal state. + mutable Mutex mLock; + + bool mHaveFirstKeyboard; + int32_t mFirstKeyboardId; // the API is that the build in keyboard is id 0, so map it + + struct device_ent { + device_t* device; + uint32_t seq; + }; + device_ent *mDevicesById; + int mNumDevicesById; + + device_t *mOpeningDevices; + device_t *mClosingDevices; + + device_t **mDevices; + struct pollfd *mFDs; + int mFDCount; + + // device ids that report particular switches. +#ifdef EV_SW + int32_t mSwitches[SW_MAX+1]; +#endif + + KeyLayoutMap * mLayoutMap; +}; + +}; // namespace android + +#endif // _RUNTIME_EVENT_HUB_H diff --git a/include/ui/ICamera.h b/include/ui/ICamera.h new file mode 100644 index 0000000..6aa3940 --- /dev/null +++ b/include/ui/ICamera.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2008 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_HARDWARE_ICAMERA_H +#define ANDROID_HARDWARE_ICAMERA_H + +#include +#include +#include + +#include +#include +#include + +namespace android { + +class ICamera: public IInterface +{ +public: + DECLARE_META_INTERFACE(Camera); + + virtual void disconnect() = 0; + + // pass the buffered ISurface to the camera service + virtual status_t setPreviewDisplay(const sp& surface) = 0; + + // tell the service whether to callback with each preview frame + virtual void setHasFrameCallback(bool installed) = 0; + + // start preview mode, must call setPreviewDisplay first + virtual status_t startPreview() = 0; + + // stop preview mode + virtual void stopPreview() = 0; + + // auto focus + virtual status_t autoFocus() = 0; + + // take a picture + virtual status_t takePicture() = 0; + + // set preview/capture parameters - key/value pairs + virtual status_t setParameters(const String8& params) = 0; + + // get preview/capture parameters - key/value pairs + virtual String8 getParameters() const = 0; +}; + +// ---------------------------------------------------------------------------- + +class BnCamera: public BnInterface +{ +public: + virtual status_t onTransact( uint32_t code, + const Parcel& data, + Parcel* reply, + uint32_t flags = 0); +}; + +}; // namespace android + +#endif diff --git a/include/ui/ICameraClient.h b/include/ui/ICameraClient.h new file mode 100644 index 0000000..a286b8e --- /dev/null +++ b/include/ui/ICameraClient.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2008 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_HARDWARE_ICAMERA_APP_H +#define ANDROID_HARDWARE_ICAMERA_APP_H + +#include +#include +#include +#include + +namespace android { + +class ICameraClient: public IInterface +{ +public: + DECLARE_META_INTERFACE(CameraClient); + + virtual void shutterCallback() = 0; + virtual void rawCallback(const sp& picture) = 0; + virtual void jpegCallback(const sp& picture) = 0; + virtual void frameCallback(const sp& frame) = 0; + virtual void errorCallback(status_t error) = 0; + virtual void autoFocusCallback(bool focused) = 0; + +}; + +// ---------------------------------------------------------------------------- + +class BnCameraClient: public BnInterface +{ +public: + virtual status_t onTransact( uint32_t code, + const Parcel& data, + Parcel* reply, + uint32_t flags = 0); +}; + +}; // namespace android + +#endif diff --git a/include/ui/ICameraService.h b/include/ui/ICameraService.h new file mode 100644 index 0000000..dfd8923 --- /dev/null +++ b/include/ui/ICameraService.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2008 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_HARDWARE_ICAMERASERVICE_H +#define ANDROID_HARDWARE_ICAMERASERVICE_H + +#include +#include +#include + +#include +#include + +namespace android { + +class ICameraService : public IInterface +{ +protected: + enum { + CONNECT = IBinder::FIRST_CALL_TRANSACTION, + }; + +public: + DECLARE_META_INTERFACE(CameraService); + + virtual sp connect(const sp& cameraClient) = 0; +}; + +// ---------------------------------------------------------------------------- + +class BnCameraService: public BnInterface +{ +public: + virtual status_t onTransact( uint32_t code, + const Parcel& data, + Parcel* reply, + uint32_t flags = 0); +}; + +}; // namespace android + +#endif diff --git a/include/ui/ISurface.h b/include/ui/ISurface.h new file mode 100644 index 0000000..ca691f5 --- /dev/null +++ b/include/ui/ISurface.h @@ -0,0 +1,62 @@ +/* + * 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_ISURFACE_H +#define ANDROID_ISURFACE_H + +#include +#include + +#include +#include +#include +#include + +namespace android { + +typedef int32_t SurfaceID; + +class IMemoryHeap; + +class ISurface : public IInterface +{ +public: + DECLARE_META_INTERFACE(Surface); + + virtual status_t registerBuffers(int w, int h, int hstride, int vstride, + PixelFormat format, const sp& heap) = 0; + + virtual void postBuffer(ssize_t offset) = 0; // one-way + + virtual void unregisterBuffers() = 0; +}; + +// ---------------------------------------------------------------------------- + +class BnSurface : public BnInterface +{ +public: + virtual status_t onTransact( uint32_t code, + const Parcel& data, + Parcel* reply, + uint32_t flags = 0); +}; + +// ---------------------------------------------------------------------------- + +}; // namespace android + +#endif // ANDROID_ISURFACE_H diff --git a/include/ui/ISurfaceComposer.h b/include/ui/ISurfaceComposer.h new file mode 100644 index 0000000..f9eeb30 --- /dev/null +++ b/include/ui/ISurfaceComposer.h @@ -0,0 +1,181 @@ +/* + * 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_ISURFACE_COMPOSER_H +#define ANDROID_ISURFACE_COMPOSER_H + +#include +#include + +#include +#include +#include + +#include +#include + +namespace android { + +// ---------------------------------------------------------------------------- + +class DisplayInfo; +class IGPUCallback; + +class ISurfaceComposer : public IInterface +{ +public: + DECLARE_META_INTERFACE(SurfaceComposer); + + enum { // (keep in sync with Surface.java) + eHidden = 0x00000004, + eGPU = 0x00000008, + eHardware = 0x00000010, + eDestroyBackbuffer = 0x00000020, + eSecure = 0x00000080, + eNonPremultiplied = 0x00000100, + ePushBuffers = 0x00000200, + + 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, + eDestroyed = 0x00000100 + }; + + enum { + eLayerHidden = 0x01, + eLayerFrozen = 0x02, + eLayerDither = 0x04, + eLayerFilter = 0x08, + eLayerBlurFreeze = 0x10 + }; + + enum { + eOrientationDefault = 0, + eOrientation90 = 1, + eOrientation180 = 2, + eOrientation270 = 3, + eOrientationSwapMask = 0x01 + }; + + /* create connection with surface flinger, requires + * ACCESS_SURFACE_FLINGER permission + */ + + virtual sp createConnection() = 0; + + /* retrieve the control block */ + virtual sp getCblk() const = 0; + + /* open/close transactions. recquires ACCESS_SURFACE_FLINGER permission */ + virtual void openGlobalTransaction() = 0; + virtual void closeGlobalTransaction() = 0; + + /* [un]freeze display. recquires 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. recquires ACCESS_SURFACE_FLINGER permission */ + virtual int setOrientation(DisplayID dpy, int orientation) = 0; + + /* signal that we're done booting. + * recquires ACCESS_SURFACE_FLINGER permission + */ + virtual void bootFinished() = 0; + + /* get access to the GPU. Access is relinquished when releasing regs */ + struct gpu_info_t { + struct gpu_region_t { + sp region; + size_t reserved; + }; + sp regs; + size_t count; + gpu_region_t regions[2]; + }; + virtual status_t requestGPU( + const sp& callback, + gpu_info_t* gpu) = 0; + + /* take the gpu back from any apps using it. They'll get a + * EGL_CONTEXT_LOST error */ + virtual status_t revokeGPU() = 0; + + /* Signal surfaceflinger that there might be some work to do + * This is an ASYNCHRONOUS call. + */ + virtual void signal() const = 0; +}; + +class IGPUCallback : public IInterface +{ +public: + DECLARE_META_INTERFACE(GPUCallback); + virtual void gpuLost() = 0; //one-way +}; + +// ---------------------------------------------------------------------------- + +class BnSurfaceComposer : public BnInterface +{ +public: + enum { + // Note: BOOT_FINISHED must remain this value, it is called from + // Java by ActivityManagerService. + BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION, + CREATE_CONNECTION, + GET_CBLK, + OPEN_GLOBAL_TRANSACTION, + CLOSE_GLOBAL_TRANSACTION, + SET_ORIENTATION, + FREEZE_DISPLAY, + UNFREEZE_DISPLAY, + REQUEST_GPU, + REVOKE_GPU, + SIGNAL + }; + + virtual status_t onTransact( uint32_t code, + const Parcel& data, + Parcel* reply, + uint32_t flags = 0); +}; + +class BnGPUCallback : public BnInterface +{ +public: + virtual status_t onTransact( uint32_t code, + const Parcel& data, + Parcel* reply, + uint32_t flags = 0); +}; + +// ---------------------------------------------------------------------------- + +}; // namespace android + +#endif // ANDROID_ISURFACE_COMPOSER_H diff --git a/include/ui/ISurfaceFlingerClient.h b/include/ui/ISurfaceFlingerClient.h new file mode 100644 index 0000000..bb2d39f --- /dev/null +++ b/include/ui/ISurfaceFlingerClient.h @@ -0,0 +1,91 @@ +/* + * 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_ISURFACE_FLINGER_CLIENT_H +#define ANDROID_ISURFACE_FLINGER_CLIENT_H + +#include +#include + +#include +#include +#include + +#include + +#include + +namespace android { + +// ---------------------------------------------------------------------------- + +class Rect; +class Point; +class IMemory; +class ISurface; + +typedef int32_t ClientID; +typedef int32_t DisplayID; + +// ---------------------------------------------------------------------------- + +class layer_state_t; + +class ISurfaceFlingerClient : public IInterface +{ +public: + DECLARE_META_INTERFACE(SurfaceFlingerClient); + + struct surface_data_t { + int32_t token; + int32_t identity; + int32_t type; + sp heap[2]; + status_t readFromParcel(const Parcel& parcel); + status_t writeToParcel(Parcel* parcel) const; + }; + + virtual void getControlBlocks(sp* ctl) const = 0; + + virtual sp createSurface( surface_data_t* data, + int pid, + DisplayID display, + uint32_t w, + uint32_t h, + PixelFormat format, + uint32_t flags) = 0; + + virtual status_t destroySurface(SurfaceID sid) = 0; + + virtual status_t setState(int32_t count, const layer_state_t* states) = 0; +}; + +// ---------------------------------------------------------------------------- + +class BnSurfaceFlingerClient : public BnInterface +{ +public: + virtual status_t onTransact( uint32_t code, + const Parcel& data, + Parcel* reply, + uint32_t flags = 0); +}; + +// ---------------------------------------------------------------------------- + +}; // namespace android + +#endif // ANDROID_ISURFACE_FLINGER_CLIENT_H diff --git a/include/ui/KeyCharacterMap.h b/include/ui/KeyCharacterMap.h new file mode 100644 index 0000000..bad2cf8 --- /dev/null +++ b/include/ui/KeyCharacterMap.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2008 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 _UI_KEY_CHARACTER_MAP_H +#define _UI_KEY_CHARACTER_MAP_H + +#include +#include + +using namespace android; + +class KeyCharacterMap +{ +public: + ~KeyCharacterMap(); + + // see the javadoc for android.text.method.KeyCharacterMap for what + // these do + unsigned short get(int keycode, int meta); + unsigned short getNumber(int keycode); + unsigned short getMatch(int keycode, const unsigned short* chars, + int charsize, uint32_t modifiers); + unsigned short getDisplayLabel(int keycode); + bool getKeyData(int keycode, unsigned short *displayLabel, + unsigned short *number, unsigned short* results); + inline unsigned int getKeyboardType() { return m_type; } + bool getEvents(uint16_t* chars, size_t len, + Vector* keys, Vector* modifiers); + + static KeyCharacterMap* load(int id); + + enum { + NUMERIC = 1, + Q14 = 2, + QWERTY = 3 // or AZERTY or whatever + }; + +#define META_MASK 3 + +private: + struct Key + { + int32_t keycode; + uint16_t display_label; + uint16_t number; + uint16_t data[META_MASK + 1]; + }; + + KeyCharacterMap(); + static KeyCharacterMap* try_file(const char* filename); + Key* find_key(int keycode); + bool find_char(uint16_t c, uint32_t* key, uint32_t* mods); + + unsigned int m_type; + unsigned int m_keyCount; + Key* m_keys; +}; + +#endif // _UI_KEY_CHARACTER_MAP_H diff --git a/include/ui/KeycodeLabels.h b/include/ui/KeycodeLabels.h new file mode 100644 index 0000000..747925d --- /dev/null +++ b/include/ui/KeycodeLabels.h @@ -0,0 +1,222 @@ +/* + * Copyright (C) 2008 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 _UI_KEYCODE_LABELS_H +#define _UI_KEYCODE_LABELS_H + +struct KeycodeLabel { + const char *literal; + int value; +}; + +static const KeycodeLabel KEYCODES[] = { + { "SOFT_LEFT", 1 }, + { "SOFT_RIGHT", 2 }, + { "HOME", 3 }, + { "BACK", 4 }, + { "CALL", 5 }, + { "ENDCALL", 6 }, + { "0", 7 }, + { "1", 8 }, + { "2", 9 }, + { "3", 10 }, + { "4", 11 }, + { "5", 12 }, + { "6", 13 }, + { "7", 14 }, + { "8", 15 }, + { "9", 16 }, + { "STAR", 17 }, + { "POUND", 18 }, + { "DPAD_UP", 19 }, + { "DPAD_DOWN", 20 }, + { "DPAD_LEFT", 21 }, + { "DPAD_RIGHT", 22 }, + { "DPAD_CENTER", 23 }, + { "VOLUME_UP", 24 }, + { "VOLUME_DOWN", 25 }, + { "POWER", 26 }, + { "CAMERA", 27 }, + { "CLEAR", 28 }, + { "A", 29 }, + { "B", 30 }, + { "C", 31 }, + { "D", 32 }, + { "E", 33 }, + { "F", 34 }, + { "G", 35 }, + { "H", 36 }, + { "I", 37 }, + { "J", 38 }, + { "K", 39 }, + { "L", 40 }, + { "M", 41 }, + { "N", 42 }, + { "O", 43 }, + { "P", 44 }, + { "Q", 45 }, + { "R", 46 }, + { "S", 47 }, + { "T", 48 }, + { "U", 49 }, + { "V", 50 }, + { "W", 51 }, + { "X", 52 }, + { "Y", 53 }, + { "Z", 54 }, + { "COMMA", 55 }, + { "PERIOD", 56 }, + { "ALT_LEFT", 57 }, + { "ALT_RIGHT", 58 }, + { "SHIFT_LEFT", 59 }, + { "SHIFT_RIGHT", 60 }, + { "TAB", 61 }, + { "SPACE", 62 }, + { "SYM", 63 }, + { "EXPLORER", 64 }, + { "ENVELOPE", 65 }, + { "ENTER", 66 }, + { "DEL", 67 }, + { "GRAVE", 68 }, + { "MINUS", 69 }, + { "EQUALS", 70 }, + { "LEFT_BRACKET", 71 }, + { "RIGHT_BRACKET", 72 }, + { "BACKSLASH", 73 }, + { "SEMICOLON", 74 }, + { "APOSTROPHE", 75 }, + { "SLASH", 76 }, + { "AT", 77 }, + { "NUM", 78 }, + { "HEADSETHOOK", 79 }, + { "FOCUS", 80 }, + { "PLUS", 81 }, + { "MENU", 82 }, + { "NOTIFICATION", 83 }, + { "SEARCH", 84 }, + + // NOTE: If you add a new keycode here you must also add it to: + // (enum KeyCode, in this file) + // java/android/android/view/KeyEvent.java + // tools/puppet_master/PuppetMaster.nav_keys.py + // apps/common/res/values/attrs.xml + + { NULL, 0 } +}; + +// These constants need to match the above mappings. +typedef enum KeyCode { + kKeyCodeUnknown = 0, + + kKeyCodeSoftLeft = 1, + kKeyCodeSoftRight = 2, + kKeyCodeHome = 3, + kKeyCodeBack = 4, + kKeyCodeCall = 5, + kKeyCodeEndCall = 6, + kKeyCode0 = 7, + kKeyCode1 = 8, + kKeyCode2 = 9, + kKeyCode3 = 10, + kKeyCode4 = 11, + kKeyCode5 = 12, + kKeyCode6 = 13, + kKeyCode7 = 14, + kKeyCode8 = 15, + kKeyCode9 = 16, + kKeyCodeStar = 17, + kKeyCodePound = 18, + kKeyCodeDpadUp = 19, + kKeyCodeDpadDown = 20, + kKeyCodeDpadLeft = 21, + kKeyCodeDpadRight = 22, + kKeyCodeDpadCenter = 23, + kKeyCodeVolumeUp = 24, + kKeyCodeVolumeDown = 25, + kKeyCodePower = 26, + kKeyCodeCamera = 27, + kKeyCodeClear = 28, + kKeyCodeA = 29, + kKeyCodeB = 30, + kKeyCodeC = 31, + kKeyCodeD = 32, + kKeyCodeE = 33, + kKeyCodeF = 34, + kKeyCodeG = 35, + kKeyCodeH = 36, + kKeyCodeI = 37, + kKeyCodeJ = 38, + kKeyCodeK = 39, + kKeyCodeL = 40, + kKeyCodeM = 41, + kKeyCodeN = 42, + kKeyCodeO = 43, + kKeyCodeP = 44, + kKeyCodeQ = 45, + kKeyCodeR = 46, + kKeyCodeS = 47, + kKeyCodeT = 48, + kKeyCodeU = 49, + kKeyCodeV = 50, + kKeyCodeW = 51, + kKeyCodeX = 52, + kKeyCodeY = 53, + kKeyCodeZ = 54, + kKeyCodeComma = 55, + kKeyCodePeriod = 56, + kKeyCodeAltLeft = 57, + kKeyCodeAltRight = 58, + kKeyCodeShiftLeft = 59, + kKeyCodeShiftRight = 60, + kKeyCodeTab = 61, + kKeyCodeSpace = 62, + kKeyCodeSym = 63, + kKeyCodeExplorer = 64, + kKeyCodeEnvelope = 65, + kKeyCodeNewline = 66, + kKeyCodeDel = 67, + kKeyCodeGrave = 68, + kKeyCodeMinus = 69, + kKeyCodeEquals = 70, + kKeyCodeLeftBracket = 71, + kKeyCodeRightBracket = 72, + kKeyCodeBackslash = 73, + kKeyCodeSemicolon = 74, + kKeyCodeApostrophe = 75, + kKeyCodeSlash = 76, + kKeyCodeAt = 77, + kKeyCodeNum = 78, + kKeyCodeHeadSetHook = 79, + kKeyCodeFocus = 80, + kKeyCodePlus = 81, + kKeyCodeMenu = 82, + kKeyCodeNotification = 83, + kKeyCodeSearch = 84 +} KeyCode; + +static const KeycodeLabel FLAGS[] = { + { "WAKE", 0x00000001 }, + { "WAKE_DROPPED", 0x00000002 }, + { "SHIFT", 0x00000004 }, + { "CAPS_LOCK", 0x00000008 }, + { "ALT", 0x00000010 }, + { "ALT_GR", 0x00000020 }, + { "MENU", 0x00000040 }, + { "LAUNCHER", 0x00000080 }, + { NULL, 0 } +}; + +#endif // _UI_KEYCODE_LABELS_H diff --git a/include/ui/PixelFormat.h b/include/ui/PixelFormat.h new file mode 100644 index 0000000..d56a4a7 --- /dev/null +++ b/include/ui/PixelFormat.h @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2005 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. + */ + +// + +// Pixel formats used across the system. +// These formats might not all be supported by all renderers, for instance +// skia or SurfaceFlinger are not required to support all of these formats +// (either as source or destination) + +// XXX: we should consolidate these formats and skia's + +#ifndef UI_PIXELFORMAT_H +#define UI_PIXELFORMAT_H + +#include +#include +#include +#include + +namespace android { + +enum { + // + // these constants need to match those + // in graphics/PixelFormat.java & pixelflinger/format.h + // + PIXEL_FORMAT_UNKNOWN = 0, + PIXEL_FORMAT_NONE = 0, + + // logical pixel formats used by the SurfaceFlinger ----------------------- + PIXEL_FORMAT_CUSTOM = -4, + // Custom pixel-format described by a PixelFormatInfo sructure + + PIXEL_FORMAT_TRANSLUCENT = -3, + // System chooses a format that supports translucency (many alpha bits) + + PIXEL_FORMAT_TRANSPARENT = -2, + // System chooses a format that supports transparency + // (at least 1 alpha bit) + + PIXEL_FORMAT_OPAQUE = -1, + // System chooses an opaque format (no alpha bits required) + + // real pixel formats supported for rendering ----------------------------- + + PIXEL_FORMAT_RGBA_8888 = GGL_PIXEL_FORMAT_RGBA_8888, // 4x8-bit RGBA + PIXEL_FORMAT_RGBX_8888 = GGL_PIXEL_FORMAT_RGBX_8888, // 4x8-bit RGB0 + PIXEL_FORMAT_RGB_888 = GGL_PIXEL_FORMAT_RGB_888, // 3x8-bit RGB + PIXEL_FORMAT_RGB_565 = GGL_PIXEL_FORMAT_RGB_565, // 16-bit RGB + PIXEL_FORMAT_RGBA_5551 = GGL_PIXEL_FORMAT_RGBA_5551, // 16-bit ARGB + PIXEL_FORMAT_RGBA_4444 = GGL_PIXEL_FORMAT_RGBA_4444, // 16-bit ARGB + PIXEL_FORMAT_A_8 = GGL_PIXEL_FORMAT_A_8, // 8-bit A + PIXEL_FORMAT_L_8 = GGL_PIXEL_FORMAT_L_8, // 8-bit L (R=G=B=L) + PIXEL_FORMAT_LA_88 = GGL_PIXEL_FORMAT_LA_88, // 16-bit LA + PIXEL_FORMAT_RGB_332 = GGL_PIXEL_FORMAT_RGB_332, // 8-bit RGB + + PIXEL_FORMAT_YCbCr_422_SP= GGL_PIXEL_FORMAT_YCbCr_422_SP, + PIXEL_FORMAT_YCbCr_420_SP= GGL_PIXEL_FORMAT_YCbCr_420_SP, + + // New formats can be added if they're also defined in + // pixelflinger/format.h +}; + +typedef int32_t PixelFormat; + +struct PixelFormatInfo +{ + inline PixelFormatInfo() : version(sizeof(PixelFormatInfo)) { } + size_t version; + PixelFormat format; + size_t bytesPerPixel; + size_t bitsPerPixel; + uint8_t h_alpha; + uint8_t l_alpha; + uint8_t h_red; + uint8_t l_red; + uint8_t h_green; + uint8_t l_green; + uint8_t h_blue; + uint8_t l_blue; + uint32_t reserved[2]; +}; + +// considere caching the results of these functions are they're not +// guaranteed to be fast. +ssize_t bytesPerPixel(PixelFormat format); +ssize_t bitsPerPixel(PixelFormat format); +status_t getPixelFormatInfo(PixelFormat format, PixelFormatInfo* info); + +}; // namespace android + +#endif // UI_PIXELFORMAT_H diff --git a/include/ui/Point.h b/include/ui/Point.h new file mode 100644 index 0000000..dbbad1e --- /dev/null +++ b/include/ui/Point.h @@ -0,0 +1,88 @@ +/* + * 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_UI_POINT +#define ANDROID_UI_POINT + +#include + +namespace android { + +class Point +{ +public: + int x; + int y; + + // we don't provide copy-ctor and operator= on purpose + // because we want the compiler generated versions + + // Default constructor doesn't initialize the Point + inline Point() + { + } + + inline Point(int _x, int _y) : x(_x), y(_y) + { + } + + inline bool operator == (const Point& rhs) const { + return (x == rhs.x) && (y == rhs.y); + } + inline bool operator != (const Point& rhs) const { + return !operator == (rhs); + } + + inline bool isOrigin() const { + return !(x|y); + } + + // operator < defines an order which allows to use points in sorted + // vectors. + bool operator < (const Point& rhs) const { + return y +#include + +namespace android { + +class Rect +{ +public: + int left; + int top; + int right; + int bottom; + + // we don't provide copy-ctor and operator= on purpose + // because we want the compiler generated versions + + inline Rect() + { + } + + inline Rect(int w, int h) + : left(0), top(0), right(w), bottom(h) + { + } + + inline Rect(int l, int t, int r, int b) + : left(l), top(t), right(r), bottom(b) + { + } + + inline Rect(const Point& lt, const Point& rb) + : left(lt.x), top(lt.y), right(rb.x), bottom(rb.y) + { + } + + void makeInvalid(); + + // a valid rectangle has a non negative width and height + inline bool isValid() const { + return (width()>=0) && (height()>=0); + } + + // an empty rect has a zero width or height, or is invalid + inline bool isEmpty() const { + return (width()<=0) || (height()<=0); + } + + inline void set(const Rect& rhs) { + operator = (rhs); + } + + // rectangle's width + inline int width() const { + return right-left; + } + + // rectangle's height + inline int height() const { + return bottom-top; + } + + // returns left-top Point non-const reference, can be assigned + inline Point& leftTop() { + return reinterpret_cast(left); + } + // returns right bottom non-const reference, can be assigned + inline Point& rightBottom() { + return reinterpret_cast(right); + } + + // the following 4 functions return the 4 corners of the rect as Point + inline const Point& leftTop() const { + return reinterpret_cast(left); + } + inline const Point& rightBottom() const { + return reinterpret_cast(right); + } + Point rightTop() const { + return Point(right, top); + } + Point leftBottom() const { + return Point(left, bottom); + } + + // comparisons + inline bool operator == (const Rect& rhs) const { + return (left == rhs.left) && (top == rhs.top) && + (right == rhs.right) && (bottom == rhs.bottom); + } + + inline bool operator != (const Rect& rhs) const { + return !operator == (rhs); + } + + // operator < defines an order which allows to use rectangles in sorted + // vectors. + bool operator < (const Rect& rhs) const; + + Rect& offsetToOrigin() { + right -= left; + bottom -= top; + left = top = 0; + return *this; + } + Rect& offsetTo(const Point& p) { + return offsetTo(p.x, p.y); + } + Rect& offsetBy(const Point& dp) { + return offsetBy(dp.x, dp.y); + } + Rect& operator += (const Point& rhs) { + return offsetBy(rhs.x, rhs.y); + } + Rect& operator -= (const Point& rhs) { + return offsetBy(-rhs.x, -rhs.y); + } + Rect operator + (const Point& rhs) const; + Rect operator - (const Point& rhs) const; + + void translate(int dx, int dy) { // legacy, don't use. + offsetBy(dx, dy); + } + + Rect& offsetTo(int x, int y); + Rect& offsetBy(int x, int y); + bool intersect(const Rect& with, Rect* result) const; +}; + +ANDROID_BASIC_TYPES_TRAITS(Rect) + +}; // namespace android + +#endif // ANDROID_UI_RECT diff --git a/include/ui/Region.h b/include/ui/Region.h new file mode 100644 index 0000000..a86e630 --- /dev/null +++ b/include/ui/Region.h @@ -0,0 +1,174 @@ +/* + * 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_UI_REGION_H +#define ANDROID_UI_REGION_H + +#include +#include + +#include +#include + +#include +#include + +#include + +namespace android { +// --------------------------------------------------------------------------- + +class String8; + +// --------------------------------------------------------------------------- +class Region +{ +public: + Region(); + Region(const Region& rhs); + explicit Region(const SkRegion& rhs); + explicit Region(const Rect& rhs); + explicit Region(const Parcel& parcel); + explicit Region(const void* buffer); + ~Region(); + + Region& operator = (const Region& rhs); + + inline bool isEmpty() const { return mRegion.isEmpty(); } + inline bool isRect() const { return mRegion.isRect(); } + + Rect bounds() const; + + const SkRegion& toSkRegion() const; + + void clear(); + void set(const Rect& r); + + Region& orSelf(const Rect& rhs); + Region& andSelf(const Rect& rhs); + + // boolean operators, applied on this + Region& orSelf(const Region& rhs); + Region& andSelf(const Region& rhs); + Region& subtractSelf(const Region& rhs); + + // these translate rhs first + Region& translateSelf(int dx, int dy); + Region& orSelf(const Region& rhs, int dx, int dy); + Region& andSelf(const Region& rhs, int dx, int dy); + Region& subtractSelf(const Region& rhs, int dx, int dy); + + // boolean operators + Region merge(const Region& rhs) const; + Region intersect(const Region& rhs) const; + Region subtract(const Region& rhs) const; + + // these translate rhs first + Region translate(int dx, int dy) const; + Region merge(const Region& rhs, int dx, int dy) const; + Region intersect(const Region& rhs, int dx, int dy) const; + Region subtract(const Region& rhs, int dx, int dy) const; + + // convenience operators overloads + inline Region operator | (const Region& rhs) const; + inline Region operator & (const Region& rhs) const; + inline Region operator - (const Region& rhs) const; + inline Region operator + (const Point& pt) const; + + inline Region& operator |= (const Region& rhs); + inline Region& operator &= (const Region& rhs); + inline Region& operator -= (const Region& rhs); + inline Region& operator += (const Point& pt); + + class iterator { + SkRegion::Iterator mIt; + public: + iterator(const Region& r); + inline operator bool () const { return !done(); } + int iterate(Rect* rect); + private: + inline bool done() const { + return const_cast(mIt).done(); + } + }; + + size_t rects(Vector& rectList) const; + + // flatten/unflatten a region to/from a Parcel + status_t write(Parcel& parcel) const; + status_t read(const Parcel& parcel); + + // flatten/unflatten a region to/from a raw buffer + ssize_t write(void* buffer, size_t size) const; + static ssize_t writeEmpty(void* buffer, size_t size); + + ssize_t read(const void* buffer); + static bool isEmpty(void* buffer); + + void dump(String8& out, const char* what, uint32_t flags=0) const; + void dump(const char* what, uint32_t flags=0) const; + +private: + SkRegion mRegion; +}; + + +Region Region::operator | (const Region& rhs) const { + return merge(rhs); +} +Region Region::operator & (const Region& rhs) const { + return intersect(rhs); +} +Region Region::operator - (const Region& rhs) const { + return subtract(rhs); +} +Region Region::operator + (const Point& pt) const { + return translate(pt.x, pt.y); +} + + +Region& Region::operator |= (const Region& rhs) { + return orSelf(rhs); +} +Region& Region::operator &= (const Region& rhs) { + return andSelf(rhs); +} +Region& Region::operator -= (const Region& rhs) { + return subtractSelf(rhs); +} +Region& Region::operator += (const Point& pt) { + return translateSelf(pt.x, pt.y); +} + +// --------------------------------------------------------------------------- + +struct region_iterator : public copybit_region_t { + region_iterator(const Region& region) : i(region) { + this->next = iterate; + } +private: + static int iterate(copybit_region_t const * self, copybit_rect_t* rect) { + return static_cast(self) + ->i.iterate(reinterpret_cast(rect)); + } + mutable Region::iterator i; +}; + +// --------------------------------------------------------------------------- +}; // namespace android + +#endif // ANDROID_UI_REGION_H + diff --git a/include/ui/Surface.h b/include/ui/Surface.h new file mode 100644 index 0000000..0a75bf3 --- /dev/null +++ b/include/ui/Surface.h @@ -0,0 +1,137 @@ +/* + * 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_UI_SURFACE_H +#define ANDROID_UI_SURFACE_H + +#include +#include + +#include +#include + +#include +#include +#include +#include + +namespace android { + +// --------------------------------------------------------------------------- + +class Rect; +class SurfaceComposerClient; + +class Surface : public RefBase +{ + +public: + struct SurfaceInfo { + uint32_t w; + uint32_t h; + uint32_t bpr; + PixelFormat format; + void* bits; + void* base; + uint32_t reserved[2]; + }; + + bool isValid() const { return this && mToken>=0 && mClient!=0; } + SurfaceID ID() const { return mToken; } + + status_t lock(SurfaceInfo* info, bool blocking = true); + status_t lock(SurfaceInfo* info, Region* dirty, bool blocking = true); + status_t unlockAndPost(); + status_t unlock(); + + void* heapBase(int i) const; + uint32_t getFlags() const { return mFlags; } + int getMemoryType() const { return mMemoryType; } + + // setSwapRectangle() is mainly used by EGL + void setSwapRectangle(const Rect& r); + const Rect& swapRectangle() const; + status_t nextBuffer(SurfaceInfo* info); + + sp dup() const; + static sp readFromParcel(Parcel* parcel); + static status_t writeToParcel(const sp& surface, Parcel* parcel); + static bool isSameSurface(const sp& lhs, const sp& rhs); + + 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 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); + + uint32_t getIdentity() const { return mIdentity; } +private: + friend class SurfaceComposerClient; + + // camera needs access to the ISurface binder interface for preview + friend class Camera; + // mediaplayer needs access to ISurface for display + friend class MediaPlayer; + const sp& getISurface() const { return mSurface; } + + // can't be copied + Surface& operator = (Surface& rhs); + Surface(const Surface& rhs); + + Surface(const sp& client, + const sp& surface, + const ISurfaceFlingerClient::surface_data_t& data, + uint32_t w, uint32_t h, PixelFormat format, uint32_t flags, + bool owner = true); + + Surface(Surface const* rhs); + + ~Surface(); + + Region dirtyRegion() const; + void setDirtyRegion(const Region& region) const; + + // this locks protects calls to lockSurface() / unlockSurface() + // and is called by SurfaceComposerClient. + Mutex& getLock() const { return mSurfaceLock; } + + sp mClient; + sp mSurface; + sp mHeap[2]; + int mMemoryType; + SurfaceID mToken; + uint32_t mIdentity; + PixelFormat mFormat; + uint32_t mFlags; + const bool mOwner; + mutable void* mSurfaceHeapBase[2]; + mutable Region mDirtyRegion; + mutable Rect mSwapRectangle; + mutable uint8_t mBackbufferIndex; + mutable Mutex mSurfaceLock; +}; + +}; // namespace android + +#endif // ANDROID_UI_SURFACE_H + diff --git a/include/ui/SurfaceComposerClient.h b/include/ui/SurfaceComposerClient.h new file mode 100644 index 0000000..3b875be --- /dev/null +++ b/include/ui/SurfaceComposerClient.h @@ -0,0 +1,179 @@ +/* + * 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_COMPOSER_CLIENT_H +#define ANDROID_SURFACE_COMPOSER_CLIENT_H + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace android { + +// --------------------------------------------------------------------------- + +class Region; +class SurfaceFlingerSynchro; +struct per_client_cblk_t; +struct layer_cblk_t; + +class SurfaceComposerClient : virtual public RefBase +{ +public: + SurfaceComposerClient(); + virtual ~SurfaceComposerClient(); + + // Always make sure we could initialize + status_t initCheck() const; + + // Return the connection of this client + sp connection() const; + + // Retrieve a client for an existing connection. + static sp + clientForConnection(const sp& conn); + + // Forcibly remove connection before all references have gone away. + void dispose(); + + // ------------------------------------------------------------------------ + // surface creation / destruction + + //! Create a surface + sp createSurface( + int pid, //!< pid of the process the surfacec 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 paramters + // 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); + + // 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); + + +private: + friend class Surface; + + SurfaceComposerClient(const sp& sm, + const sp& conn); + + status_t hide(Surface* surface); + status_t show(Surface* surface, int32_t layer = -1); + status_t freeze(Surface* surface); + status_t unfreeze(Surface* surface); + status_t setFlags(Surface* surface, uint32_t flags, uint32_t mask); + status_t setTransparentRegionHint(Surface* surface, const Region& transparent); + status_t setLayer(Surface* surface, int32_t layer); + status_t setAlpha(Surface* surface, float alpha=1.0f); + status_t setFreezeTint(Surface* surface, uint32_t tint); + status_t setMatrix(Surface* surface, float dsdx, float dtdx, float dsdy, float dtdy); + status_t setPosition(Surface* surface, int32_t x, int32_t y); + status_t setSize(Surface* surface, uint32_t w, uint32_t h); + + //! Unlock the surface, and specify the dirty region if any + status_t unlockAndPostSurface(Surface* surface); + status_t unlockSurface(Surface* surface); + + status_t lockSurface(Surface* surface, + Surface::SurfaceInfo* info, + Region* dirty, + bool blocking = true); + + status_t nextBuffer(Surface* surface, + Surface::SurfaceInfo* info); + + status_t destroySurface(SurfaceID sid); + + void _init(const sp& sm, + const sp& conn); + void _signal_server(); + static void _send_dirty_region(layer_cblk_t* lcblk, const Region& dirty); + + inline layer_state_t* _get_state_l(const sp& surface); + layer_state_t* _lockLayerState(const sp& surface); + inline void _unlockLayerState(); + + status_t validateSurface( + per_client_cblk_t const* cblk, Surface const * surface); + + void pinHeap(const sp& heap); + + mutable Mutex mLock; + layer_state_t* mPrebuiltLayerState; + SortedVector mStates; + int32_t mTransactionOpen; + + // these don't need to be protected because they never change + // after assignment + status_t mStatus; + per_client_cblk_t* mControl; + sp mControlMemory; + sp mClient; + sp mSurfaceHeap; + uint8_t* mSurfaceHeapBase; + void* mGL; + SurfaceFlingerSynchro* mSignalServer; +}; + +}; // namespace android + +#endif // ANDROID_SURFACE_COMPOSER_CLIENT_H + -- cgit v1.1