summaryrefslogtreecommitdiffstats
path: root/include/private
diff options
context:
space:
mode:
Diffstat (limited to 'include/private')
-rw-r--r--include/private/media/AudioTrackShared.h64
-rw-r--r--include/private/opengles/gl_context.h624
-rw-r--r--include/private/ui/LayerState.h75
-rw-r--r--include/private/ui/SharedState.h168
-rw-r--r--include/private/ui/SurfaceFlingerSynchro.h76
-rw-r--r--include/private/utils/Static.h58
-rw-r--r--include/private/utils/binder_module.h148
-rw-r--r--include/private/utils/futex_synchro.h60
8 files changed, 1273 insertions, 0 deletions
diff --git a/include/private/media/AudioTrackShared.h b/include/private/media/AudioTrackShared.h
new file mode 100644
index 0000000..1878f3c
--- /dev/null
+++ b/include/private/media/AudioTrackShared.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_AUDIO_TRACK_SHARED_H
+#define ANDROID_AUDIO_TRACK_SHARED_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <utils/threads.h>
+
+namespace android {
+
+// ----------------------------------------------------------------------------
+
+#define MAX_SAMPLE_RATE 65535
+#define THREAD_PRIORITY_AUDIO_CLIENT (ANDROID_PRIORITY_AUDIO)
+
+struct audio_track_cblk_t
+{
+ enum {
+ SEQUENCE_MASK = 0xFFFFFF00,
+ BUFFER_MASK = 0x000000FF
+ };
+
+ Mutex lock;
+ Condition cv;
+ volatile uint32_t user;
+ volatile uint32_t server;
+ volatile union {
+ uint16_t volume[2];
+ uint32_t volumeLR;
+ };
+ uint16_t sampleRate;
+ uint16_t reserved;
+
+ void* buffers;
+ size_t size;
+
+ audio_track_cblk_t();
+ uint32_t stepUser(int bufferCount);
+ bool stepServer(int bufferCount);
+ void* buffer(int id) const;
+};
+
+
+// ----------------------------------------------------------------------------
+
+}; // namespace android
+
+#endif // ANDROID_AUDIO_TRACK_SHARED_H
diff --git a/include/private/opengles/gl_context.h b/include/private/opengles/gl_context.h
new file mode 100644
index 0000000..67d50fd
--- /dev/null
+++ b/include/private/opengles/gl_context.h
@@ -0,0 +1,624 @@
+/*
+ * 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_OPENGLES_CONTEXT_H
+#define ANDROID_OPENGLES_CONTEXT_H
+
+#include <stdint.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <pthread.h>
+#ifdef HAVE_ANDROID_OS
+#include <sys/tls.h>
+#endif
+
+#include <private/pixelflinger/ggl_context.h>
+
+#include <GLES/gl.h>
+
+namespace android {
+
+const unsigned int OGLES_NUM_COMPRESSED_TEXTURE_FORMATS = 10;
+
+class EGLTextureObject;
+class EGLSurfaceManager;
+class EGLBufferObjectManager;
+
+namespace gl {
+
+struct ogles_context_t;
+struct matrixx_t;
+struct transform_t;
+struct buffer_t;
+
+ogles_context_t* getGlContext();
+
+template<typename T>
+static inline void swap(T& a, T& b) {
+ T t(a); a = b; b = t;
+}
+template<typename T>
+inline T max(T a, T b) {
+ return a<b ? b : a;
+}
+template<typename T>
+inline T max(T a, T b, T c) {
+ return max(a, max(b, c));
+}
+template<typename T>
+inline T min(T a, T b) {
+ return a<b ? a : b;
+}
+template<typename T>
+inline T min(T a, T b, T c) {
+ return min(a, min(b, c));
+}
+template<typename T>
+inline T min(T a, T b, T c, T d) {
+ return min(min(a,b), min(c,d));
+}
+
+// ----------------------------------------------------------------------------
+// vertices
+// ----------------------------------------------------------------------------
+
+struct vec3_t {
+ union {
+ struct { GLfixed x, y, z; };
+ struct { GLfixed r, g, b; };
+ struct { GLfixed S, T, R; };
+ GLfixed v[3];
+ };
+};
+
+struct vec4_t {
+ union {
+ struct { GLfixed x, y, z, w; };
+ struct { GLfixed r, g, b, a; };
+ struct { GLfixed S, T, R, Q; };
+ GLfixed v[4];
+ };
+};
+
+struct vertex_t {
+ enum {
+ // these constant matter for our clipping
+ CLIP_L = 0x0001, // clipping flags
+ CLIP_R = 0x0002,
+ CLIP_B = 0x0004,
+ CLIP_T = 0x0008,
+ CLIP_N = 0x0010,
+ CLIP_F = 0x0020,
+
+ EYE = 0x0040,
+ RESERVED = 0x0080,
+
+ USER_CLIP_0 = 0x0100, // user clipping flags
+ USER_CLIP_1 = 0x0200,
+ USER_CLIP_2 = 0x0400,
+ USER_CLIP_3 = 0x0800,
+ USER_CLIP_4 = 0x1000,
+ USER_CLIP_5 = 0x2000,
+
+ LIT = 0x4000, // lighting has been applied
+ TT = 0x8000, // texture coords transformed
+
+ FRUSTUM_CLIP_ALL= 0x003F,
+ USER_CLIP_ALL = 0x3F00,
+ CLIP_ALL = 0x3F3F,
+ };
+
+ // the fields below are arranged to minimize d-cache usage
+ // we group together, by cache-line, the fields most likely to be used
+
+ union {
+ vec4_t obj;
+ vec4_t eye;
+ };
+ vec4_t clip;
+
+ uint32_t flags;
+ size_t index; // cache tag, and vertex index
+ GLfixed fog;
+ uint8_t locked;
+ uint8_t mru;
+ uint8_t reserved[2];
+ vec4_t window;
+
+ vec4_t color;
+ vec4_t texture[GGL_TEXTURE_UNIT_COUNT];
+ uint32_t reserved1[4];
+
+ inline void clear() {
+ flags = index = locked = mru = 0;
+ }
+};
+
+struct point_size_t {
+ GGLcoord size;
+ GLboolean smooth;
+};
+
+struct line_width_t {
+ GGLcoord width;
+ GLboolean smooth;
+};
+
+struct polygon_offset_t {
+ GLfixed factor;
+ GLfixed units;
+ GLboolean enable;
+};
+
+// ----------------------------------------------------------------------------
+// arrays
+// ----------------------------------------------------------------------------
+
+struct array_t {
+ typedef void (*fetcher_t)(ogles_context_t*, GLfixed*, const GLvoid*);
+ fetcher_t fetch;
+ GLvoid const* physical_pointer;
+ GLint size;
+ GLsizei stride;
+ GLvoid const* pointer;
+ buffer_t const* bo;
+ uint16_t type;
+ GLboolean enable;
+ GLboolean pad;
+ GLsizei bounds;
+ void init(GLint, GLenum, GLsizei, const GLvoid *, const buffer_t*, GLsizei);
+ inline void resolve();
+ inline const GLubyte* element(GLint i) const {
+ return (const GLubyte*)physical_pointer + i * stride;
+ }
+};
+
+struct array_machine_t {
+ array_t vertex;
+ array_t normal;
+ array_t color;
+ array_t texture[GGL_TEXTURE_UNIT_COUNT];
+ uint8_t activeTexture;
+ uint8_t tmu;
+ uint16_t cull;
+ uint32_t flags;
+ GLenum indicesType;
+ buffer_t const* array_buffer;
+ buffer_t const* element_array_buffer;
+
+ void (*compileElements)(ogles_context_t*, vertex_t*, GLint, GLsizei);
+ void (*compileElement)(ogles_context_t*, vertex_t*, GLint);
+
+ void (*mvp_transform)(transform_t const*, vec4_t*, vec4_t const*);
+ void (*mv_transform)(transform_t const*, vec4_t*, vec4_t const*);
+ void (*tex_transform[2])(transform_t const*, vec4_t*, vec4_t const*);
+ void (*perspective)(ogles_context_t*c, vertex_t* v);
+ void (*clipVertex)(ogles_context_t* c, vertex_t* nv,
+ GGLfixed t, const vertex_t* s, const vertex_t* p);
+ void (*clipEye)(ogles_context_t* c, vertex_t* nv,
+ GGLfixed t, const vertex_t* s, const vertex_t* p);
+};
+
+struct vertex_cache_t {
+ enum {
+ // must be at least 4
+ // 3 vertice for triangles
+ // or 2 + 2 for indexed triangles w/ cache contention
+ VERTEX_BUFFER_SIZE = 8,
+ // must be a power of two and at least 3
+ VERTEX_CACHE_SIZE = 64, // 8 KB
+
+ INDEX_BITS = 16,
+ INDEX_MASK = ((1LU<<INDEX_BITS)-1),
+ INDEX_SEQ = 1LU<<INDEX_BITS,
+ };
+ vertex_t* vBuffer;
+ vertex_t* vCache;
+ uint32_t sequence;
+ void* base;
+ uint32_t total;
+ uint32_t misses;
+ int64_t startTime;
+ void init();
+ void uninit();
+ void clear();
+ void dump_stats(GLenum mode);
+};
+
+// ----------------------------------------------------------------------------
+// fog
+// ----------------------------------------------------------------------------
+
+struct fog_t {
+ GLfixed density;
+ GLfixed start;
+ GLfixed end;
+ GLfixed invEndMinusStart;
+ GLenum mode;
+ GLfixed (*fog)(ogles_context_t* c, GLfixed z);
+};
+
+// ----------------------------------------------------------------------------
+// user clip planes
+// ----------------------------------------------------------------------------
+
+const unsigned int OGLES_MAX_CLIP_PLANES = 6;
+
+struct clip_plane_t {
+ vec4_t equation;
+};
+
+struct user_clip_planes_t {
+ clip_plane_t plane[OGLES_MAX_CLIP_PLANES];
+ uint32_t enable;
+};
+
+// ----------------------------------------------------------------------------
+// lighting
+// ----------------------------------------------------------------------------
+
+const unsigned int OGLES_MAX_LIGHTS = 8;
+
+struct light_t {
+ vec4_t ambient;
+ vec4_t diffuse;
+ vec4_t specular;
+ vec4_t implicitAmbient;
+ vec4_t implicitDiffuse;
+ vec4_t implicitSpecular;
+ vec4_t position; // position in eye space
+ vec4_t objPosition;
+ vec4_t normalizedObjPosition;
+ vec4_t spotDir;
+ vec4_t normalizedSpotDir;
+ GLfixed spotExp;
+ GLfixed spotCutoff;
+ GLfixed spotCutoffCosine;
+ GLfixed attenuation[3];
+ GLfixed rConstAttenuation;
+ GLboolean enable;
+};
+
+struct material_t {
+ vec4_t ambient;
+ vec4_t diffuse;
+ vec4_t specular;
+ vec4_t emission;
+ GLfixed shininess;
+};
+
+struct light_model_t {
+ vec4_t ambient;
+ GLboolean twoSide;
+};
+
+struct color_material_t {
+ GLenum face;
+ GLenum mode;
+ GLboolean enable;
+};
+
+struct lighting_t {
+ light_t lights[OGLES_MAX_LIGHTS];
+ material_t front;
+ light_model_t lightModel;
+ color_material_t colorMaterial;
+ uint32_t enabledLights;
+ GLboolean enable;
+ vec4_t implicitSceneEmissionAndAmbient;
+ GLenum shadeModel;
+ typedef void (*light_fct_t)(ogles_context_t*, vertex_t*);
+ void (*lightVertex)(ogles_context_t* c, vertex_t* v);
+ void (*lightTriangle)(ogles_context_t* c,
+ vertex_t* v0, vertex_t* v1, vertex_t* v2);
+};
+
+struct culling_t {
+ GLenum cullFace;
+ GLenum frontFace;
+ GLboolean enable;
+};
+
+// ----------------------------------------------------------------------------
+// textures
+// ----------------------------------------------------------------------------
+
+struct texture_unit_t {
+ GLuint name;
+ EGLTextureObject* texture;
+ uint8_t dirty;
+};
+
+struct texture_state_t
+{
+ texture_unit_t tmu[GGL_TEXTURE_UNIT_COUNT];
+ int active; // active tmu
+ EGLTextureObject* defaultTexture;
+ GGLContext* ggl;
+ uint8_t packAlignment;
+ uint8_t unpackAlignment;
+};
+
+// ----------------------------------------------------------------------------
+// transformation and matrices
+// ----------------------------------------------------------------------------
+
+struct matrixf_t;
+
+struct matrixx_t {
+ GLfixed m[16];
+ void load(const matrixf_t& rhs);
+};
+
+struct matrix_stack_t;
+
+
+struct matrixf_t {
+ void loadIdentity();
+ void load(const matrixf_t& rhs);
+
+ inline GLfloat* editElements() { return m; }
+ inline GLfloat const* elements() const { return m; }
+
+ void set(const GLfixed* rhs);
+ void set(const GLfloat* rhs);
+
+ static void multiply(matrixf_t& r,
+ const matrixf_t& lhs, const matrixf_t& rhs);
+
+ void dump(const char* what);
+
+private:
+ friend struct matrix_stack_t;
+ GLfloat m[16];
+ void load(const GLfixed* rhs);
+ void load(const GLfloat* rhs);
+ void multiply(const matrixf_t& rhs);
+ void translate(GLfloat x, GLfloat y, GLfloat z);
+ void scale(GLfloat x, GLfloat y, GLfloat z);
+ void rotate(GLfloat a, GLfloat x, GLfloat y, GLfloat z);
+};
+
+enum {
+ OP_IDENTITY = 0x00,
+ OP_TRANSLATE = 0x01,
+ OP_UNIFORM_SCALE = 0x02,
+ OP_SCALE = 0x05,
+ OP_ROTATE = 0x08,
+ OP_SKEW = 0x10,
+ OP_ALL = 0x1F
+};
+
+struct transform_t {
+ enum {
+ FLAGS_2D_PROJECTION = 0x1
+ };
+ matrixx_t matrix;
+ uint32_t flags;
+ uint32_t ops;
+
+ union {
+ struct {
+ void (*point2)(transform_t const* t, vec4_t*, vec4_t const*);
+ void (*point3)(transform_t const* t, vec4_t*, vec4_t const*);
+ void (*point4)(transform_t const* t, vec4_t*, vec4_t const*);
+ };
+ void (*pointv[3])(transform_t const* t, vec4_t*, vec4_t const*);
+ };
+
+ void loadIdentity();
+ void picker();
+ void dump(const char* what);
+};
+
+struct mvui_transform_t : public transform_t
+{
+ void picker();
+};
+
+struct matrix_stack_t {
+ enum {
+ DO_PICKER = 0x1,
+ DO_FLOAT_TO_FIXED = 0x2
+ };
+ transform_t transform;
+ uint8_t maxDepth;
+ uint8_t depth;
+ uint8_t dirty;
+ uint8_t reserved;
+ matrixf_t *stack;
+ uint8_t *ops;
+ void init(int depth);
+ void uninit();
+ void loadIdentity();
+ void load(const GLfixed* rhs);
+ void load(const GLfloat* rhs);
+ void multiply(const matrixf_t& rhs);
+ void translate(GLfloat x, GLfloat y, GLfloat z);
+ void scale(GLfloat x, GLfloat y, GLfloat z);
+ void rotate(GLfloat a, GLfloat x, GLfloat y, GLfloat z);
+ GLint push();
+ GLint pop();
+ void validate();
+ matrixf_t& top() { return stack[depth]; }
+ const matrixf_t& top() const { return stack[depth]; }
+ const uint32_t top_ops() const { return ops[depth]; }
+ inline bool isRigidBody() const {
+ return !(ops[depth] & ~(OP_TRANSLATE|OP_UNIFORM_SCALE|OP_ROTATE));
+ }
+};
+
+struct vp_transform_t {
+ transform_t transform;
+ matrixf_t matrix;
+ GLfloat zNear;
+ GLfloat zFar;
+ void loadIdentity();
+};
+
+struct transform_state_t {
+ enum {
+ MODELVIEW = 0x01,
+ PROJECTION = 0x02,
+ VIEWPORT = 0x04,
+ TEXTURE = 0x08,
+ MVUI = 0x10,
+ MVIT = 0x20,
+ MVP = 0x40,
+ };
+ matrix_stack_t *current;
+ matrix_stack_t modelview;
+ matrix_stack_t projection;
+ matrix_stack_t texture[GGL_TEXTURE_UNIT_COUNT];
+
+ // modelview * projection
+ transform_t mvp __attribute__((aligned(32)));
+ // viewport transformation
+ vp_transform_t vpt __attribute__((aligned(32)));
+ // same for 4-D vertices
+ transform_t mvp4;
+ // full modelview inverse transpose
+ transform_t mvit4;
+ // upper 3x3 of mv-inverse-transpose (for normals)
+ mvui_transform_t mvui;
+
+ GLenum matrixMode;
+ GLenum rescaleNormals;
+ uint32_t dirty;
+ void invalidate();
+ void update_mvp();
+ void update_mvit();
+ void update_mvui();
+};
+
+struct viewport_t {
+ GLint x;
+ GLint y;
+ GLsizei w;
+ GLsizei h;
+ struct {
+ GLint x;
+ GLint y;
+ } surfaceport;
+ struct {
+ GLint x;
+ GLint y;
+ GLsizei w;
+ GLsizei h;
+ } scissor;
+};
+
+// ----------------------------------------------------------------------------
+// Lerping
+// ----------------------------------------------------------------------------
+
+struct compute_iterators_t
+{
+ void initTriangle(
+ vertex_t const* v0,
+ vertex_t const* v1,
+ vertex_t const* v2);
+
+ inline void initLerp(vertex_t const* v0, uint32_t enables);
+
+ int iteratorsScale(int32_t it[3],
+ int32_t c0, int32_t c1, int32_t c2) const;
+
+ void iterators1616(GGLfixed it[3],
+ GGLfixed c0, GGLfixed c1, GGLfixed c2) const;
+
+ void iterators0032(int32_t it[3],
+ int32_t c0, int32_t c1, int32_t c2) const;
+
+ GGLcoord area() const { return m_area; }
+
+private:
+ // don't change order of members here -- used by iterators.S
+ GGLcoord m_dx01, m_dy10, m_dx20, m_dy02;
+ GGLcoord m_x0, m_y0;
+ GGLcoord m_area;
+ uint8_t m_scale;
+ uint8_t m_area_scale;
+ uint8_t m_reserved[2];
+
+};
+
+// ----------------------------------------------------------------------------
+// state
+// ----------------------------------------------------------------------------
+
+#ifdef HAVE_ANDROID_OS
+ // We have a dedicated TLS slot in bionic
+ inline void setGlThreadSpecific(ogles_context_t *value) {
+ ((uint32_t *)__get_tls())[TLS_SLOT_OPENGL] = (uint32_t)value;
+ }
+ inline ogles_context_t* getGlThreadSpecific() {
+ return (ogles_context_t *)(((unsigned *)__get_tls())[TLS_SLOT_OPENGL]);
+ }
+#else
+ extern pthread_key_t gGLKey;
+ inline void setGlThreadSpecific(ogles_context_t *value) {
+ pthread_setspecific(gGLKey, value);
+ }
+ inline ogles_context_t* getGlThreadSpecific() {
+ return static_cast<ogles_context_t*>(pthread_getspecific(gGLKey));
+ }
+#endif
+
+
+struct prims_t {
+ typedef ogles_context_t* GL;
+ void (*renderPoint)(GL, vertex_t*);
+ void (*renderLine)(GL, vertex_t*, vertex_t*);
+ void (*renderTriangle)(GL, vertex_t*, vertex_t*, vertex_t*);
+};
+
+struct ogles_context_t {
+ context_t rasterizer;
+ array_machine_t arrays __attribute__((aligned(32)));
+ texture_state_t textures;
+ transform_state_t transforms;
+ vertex_cache_t vc;
+ prims_t prims;
+ culling_t cull;
+ lighting_t lighting;
+ user_clip_planes_t clipPlanes;
+ compute_iterators_t lerp; __attribute__((aligned(32)));
+ vertex_t current;
+ vec4_t currentColorClamped;
+ vec3_t currentNormal;
+ viewport_t viewport;
+ point_size_t point;
+ line_width_t line;
+ polygon_offset_t polygonOffset;
+ fog_t fog;
+ uint32_t perspective : 1;
+ uint32_t transformTextures : 1;
+ EGLSurfaceManager* surfaceManager;
+ EGLBufferObjectManager* bufferObjectManager;
+ GLenum error;
+
+ static inline ogles_context_t* get() {
+ return getGlThreadSpecific();
+ }
+
+};
+
+}; // namespace gl
+}; // namespace android
+
+#endif // ANDROID_OPENGLES_CONTEXT_H
+
diff --git a/include/private/ui/LayerState.h b/include/private/ui/LayerState.h
new file mode 100644
index 0000000..b6fcd80
--- /dev/null
+++ b/include/private/ui/LayerState.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_COMPOSER_LAYER_STATE_H
+#define ANDROID_COMPOSER_LAYER_STATE_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <utils/Errors.h>
+
+#include <ui/ISurfaceFlingerClient.h>
+#include <ui/Region.h>
+
+#include <private/ui/SharedState.h>
+
+namespace android {
+
+class Parcel;
+
+struct layer_state_t {
+
+ layer_state_t()
+ : surface(0), what(0),
+ x(0), y(0), z(0), w(0), h(0),
+ alpha(0), tint(0), flags(0), mask(0),
+ reserved(0)
+ {
+ matrix.dsdx = matrix.dtdy = 1.0f;
+ matrix.dsdy = matrix.dtdx = 0.0f;
+ }
+
+ status_t write(Parcel& output) const;
+ status_t read(const Parcel& input);
+
+ struct matrix22_t {
+ float dsdx;
+ float dtdx;
+ float dsdy;
+ float dtdy;
+ };
+ SurfaceID surface;
+ uint32_t what;
+ int32_t x;
+ int32_t y;
+ uint32_t z;
+ uint32_t w;
+ uint32_t h;
+ float alpha;
+ uint32_t tint;
+ uint8_t flags;
+ uint8_t mask;
+ uint8_t reserved;
+ matrix22_t matrix;
+ // non POD must be last. see write/read
+ Region transparentRegion;
+};
+
+}; // namespace android
+
+#endif // ANDROID_COMPOSER_LAYER_STATE_H
+
diff --git a/include/private/ui/SharedState.h b/include/private/ui/SharedState.h
new file mode 100644
index 0000000..546d0ad
--- /dev/null
+++ b/include/private/ui/SharedState.h
@@ -0,0 +1,168 @@
+/*
+ * 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_SHARED_STATE_H
+#define ANDROID_UI_SHARED_STATE_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <utils/threads.h>
+
+namespace android {
+
+/*
+ * These structures are shared between the composer process and its clients
+ */
+
+// ---------------------------------------------------------------------------
+
+struct surface_info_t { // 4 longs, 16 bytes
+ enum {
+ eBufferDirty = 0x01
+ };
+ uint16_t w;
+ uint16_t h;
+ uint16_t stride;
+ uint16_t bpr;
+ uint16_t reserved;
+ uint8_t format;
+ uint8_t flags;
+ ssize_t bits_offset;
+};
+
+// ---------------------------------------------------------------------------
+
+const uint32_t NUM_LAYERS_MAX = 31;
+
+enum { // layer_cblk_t swapState
+ eIndex = 0x00000001,
+ eFlipRequested = 0x00000002,
+
+ eResizeBuffer0 = 0x00000004,
+ eResizeBuffer1 = 0x00000008,
+ eResizeRequested = eResizeBuffer0 | eResizeBuffer1,
+
+ eBusy = 0x00000010,
+ eLocked = 0x00000020,
+ eNextFlipPending = 0x00000040,
+ eInvalidSurface = 0x00000080
+};
+
+enum { // layer_cblk_t flags
+ eLayerNotPosted = 0x00000001,
+ eNoCopyBack = 0x00000002,
+ eReserved = 0x0000007C,
+ eBufferIndexShift = 7,
+ eBufferIndex = 1<<eBufferIndexShift,
+};
+
+struct flat_region_t // 40 bytes
+{
+ int32_t count;
+ int16_t l;
+ int16_t t;
+ int16_t r;
+ int16_t b;
+ uint16_t runs[14];
+};
+
+struct layer_cblk_t // (128 bytes)
+{
+ volatile int32_t swapState; // 4
+ volatile int32_t flags; // 4
+ volatile int32_t identity; // 4
+ int32_t reserved; // 4
+ surface_info_t surface[2]; // 32
+ flat_region_t region[2]; // 80
+
+ static inline int backBuffer(uint32_t state) {
+ return ((state & eIndex) ^ ((state & eFlipRequested)>>1));
+ }
+ static inline int frontBuffer(uint32_t state) {
+ return 1 - backBuffer(state);
+ }
+};
+
+// ---------------------------------------------------------------------------
+
+struct per_client_cblk_t // 4KB max
+{
+ Mutex lock;
+ Condition cv;
+ layer_cblk_t layers[NUM_LAYERS_MAX] __attribute__((aligned(32)));
+
+ enum {
+ BLOCKING = 0x00000001,
+ INSPECT = 0x00000002
+ };
+
+ per_client_cblk_t();
+
+ // these functions are used by the clients
+ status_t validate(size_t i) const;
+ int32_t lock_layer(size_t i, uint32_t flags);
+ uint32_t unlock_layer_and_post(size_t i);
+ void unlock_layer(size_t i);
+};
+// ---------------------------------------------------------------------------
+
+const uint32_t NUM_DISPLAY_MAX = 4;
+
+struct display_cblk_t
+{
+ uint16_t w;
+ uint16_t h;
+ uint8_t format;
+ uint8_t orientation;
+ uint8_t reserved[2];
+ float fps;
+ float density;
+ float xdpi;
+ float ydpi;
+ uint32_t pad[2];
+};
+
+struct surface_flinger_cblk_t // 4KB max
+{
+ surface_flinger_cblk_t();
+
+ uint8_t connected;
+ uint8_t reserved[3];
+ uint32_t pad[7];
+
+ display_cblk_t displays[NUM_DISPLAY_MAX];
+};
+
+// ---------------------------------------------------------------------------
+
+template<bool> struct CTA;
+template<> struct CTA<true> { };
+
+// compile-time assertions. just to avoid catastrophes.
+inline void compile_time_asserts() {
+ CTA<sizeof(layer_cblk_t) == 128> sizeof__layer_cblk_t__eq_128;
+ (void)sizeof__layer_cblk_t__eq_128; // we don't want a warning
+ CTA<sizeof(per_client_cblk_t) <= 4096> sizeof__per_client_cblk_t__le_4096;
+ (void)sizeof__per_client_cblk_t__le_4096; // we don't want a warning
+ CTA<sizeof(surface_flinger_cblk_t) <= 4096> sizeof__surface_flinger_cblk_t__le_4096;
+ (void)sizeof__surface_flinger_cblk_t__le_4096; // we don't want a warning
+}
+
+}; // namespace android
+
+#endif // ANDROID_UI_SHARED_STATE_H
+
diff --git a/include/private/ui/SurfaceFlingerSynchro.h b/include/private/ui/SurfaceFlingerSynchro.h
new file mode 100644
index 0000000..ff91b61
--- /dev/null
+++ b/include/private/ui/SurfaceFlingerSynchro.h
@@ -0,0 +1,76 @@
+/*
+ * 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_SURFACE_FLINGER_SYNCHRO_H
+#define ANDROID_SURFACE_FLINGER_SYNCHRO_H
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <utils/Errors.h>
+#include <utils/threads.h>
+#include <ui/ISurfaceComposer.h>
+
+namespace android {
+
+class SurfaceFlinger;
+
+class SurfaceFlingerSynchro
+{
+public:
+
+ // client constructor
+ SurfaceFlingerSynchro(const sp<ISurfaceComposer>& flinger);
+ ~SurfaceFlingerSynchro();
+
+ // signal surfaceflinger for some work
+ status_t signal();
+
+private:
+ class Barrier {
+ public:
+ Barrier();
+ ~Barrier();
+ void open();
+ void close();
+ void waitAndClose();
+ status_t waitAndClose(nsecs_t timeout);
+ private:
+ enum { OPENED, CLOSED };
+ mutable Mutex lock;
+ mutable Condition cv;
+ volatile int state;
+ };
+
+ friend class SurfaceFlinger;
+
+ // server constructor
+ SurfaceFlingerSynchro();
+
+ void open();
+
+ // wait until there is some work to do
+ status_t wait();
+ status_t wait(nsecs_t timeout);
+
+ sp<ISurfaceComposer> mSurfaceComposer;
+ Barrier mBarrier;
+};
+
+}; // namespace android
+
+#endif // ANDROID_SURFACE_FLINGER_SYNCHRO_H
+
diff --git a/include/private/utils/Static.h b/include/private/utils/Static.h
new file mode 100644
index 0000000..f1439b7
--- /dev/null
+++ b/include/private/utils/Static.h
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+// All static variables go here, to control initialization and
+// destruction order in the library.
+
+#include <utils/threads.h>
+#include <utils/KeyedVector.h>
+
+#ifndef LIBUTILS_NATIVE
+#include <utils/IBinder.h>
+#include <utils/IMemory.h>
+#include <utils/ProcessState.h>
+#include <utils/IPermissionController.h>
+#include <utils/IServiceManager.h>
+#endif
+
+namespace android {
+// For TextStream.cpp
+extern Vector<int32_t> gTextBuffers;
+
+// For String8.cpp
+extern void initialize_string8();
+extern void terminate_string8();
+
+// For String16.cpp
+extern void initialize_string16();
+extern void terminate_string16();
+
+
+
+#ifndef LIBUTILS_NATIVE
+
+// For ProcessState.cpp
+extern Mutex gProcessMutex;
+extern sp<ProcessState> gProcess;
+
+// For ServiceManager.cpp
+extern Mutex gDefaultServiceManagerLock;
+extern sp<IServiceManager> gDefaultServiceManager;
+extern sp<IPermissionController> gPermissionController;
+
+#endif
+
+} // namespace android
diff --git a/include/private/utils/binder_module.h b/include/private/utils/binder_module.h
new file mode 100644
index 0000000..fdf327e
--- /dev/null
+++ b/include/private/utils/binder_module.h
@@ -0,0 +1,148 @@
+/*
+ * 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 _BINDER_MODULE_H_
+#define _BINDER_MODULE_H_
+
+#ifdef __cplusplus
+namespace android {
+#endif
+
+#if defined(HAVE_ANDROID_OS)
+
+/* obtain structures and constants from the kernel header */
+
+#include <sys/ioctl.h>
+#include <linux/binder.h>
+
+#else
+
+/* Some parts of the simulator need fake versions of this
+ * stuff in order to compile. Really this should go away
+ * entirely...
+ */
+
+#define BINDER_CURRENT_PROTOCOL_VERSION 7
+
+#define BINDER_TYPE_BINDER 1
+#define BINDER_TYPE_WEAK_BINDER 2
+#define BINDER_TYPE_HANDLE 3
+#define BINDER_TYPE_WEAK_HANDLE 4
+#define BINDER_TYPE_FD 5
+
+struct flat_binder_object {
+ unsigned long type;
+ unsigned long flags;
+ union {
+ void *binder;
+ signed long handle;
+ };
+ void *cookie;
+};
+
+struct binder_write_read {
+ signed long write_size;
+ signed long write_consumed;
+ unsigned long write_buffer;
+ signed long read_size;
+ signed long read_consumed;
+ unsigned long read_buffer;
+};
+
+struct binder_transaction_data {
+ union {
+ size_t handle;
+ void *ptr;
+ } target;
+ void *cookie;
+ unsigned int code;
+
+ unsigned int flags;
+ pid_t sender_pid;
+ uid_t sender_euid;
+ size_t data_size;
+ size_t offsets_size;
+
+ union {
+ struct {
+ const void *buffer;
+ const void *offsets;
+ } ptr;
+ uint8_t buf[8];
+ } data;
+};
+
+enum transaction_flags {
+ TF_ONE_WAY = 0x01,
+ TF_ROOT_OBJECT = 0x04,
+ TF_STATUS_CODE = 0x08,
+ TF_ACCEPT_FDS = 0x10,
+};
+
+
+enum {
+ FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff,
+ FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100,
+};
+
+enum BinderDriverReturnProtocol {
+ BR_ERROR,
+ BR_OK,
+ BR_TRANSACTION,
+ BR_REPLY,
+ BR_ACQUIRE_RESULT,
+ BR_DEAD_REPLY,
+ BR_TRANSACTION_COMPLETE,
+ BR_INCREFS,
+ BR_ACQUIRE,
+ BR_RELEASE,
+ BR_DECREFS,
+ BR_ATTEMPT_ACQUIRE,
+ BR_NOOP,
+ BR_SPAWN_LOOPER,
+ BR_FINISHED,
+ BR_DEAD_BINDER,
+ BR_CLEAR_DEATH_NOTIFICATION_DONE,
+ BR_FAILED_REPLY,
+};
+
+enum BinderDriverCommandProtocol {
+ BC_TRANSACTION,
+ BC_REPLY,
+ BC_ACQUIRE_RESULT,
+ BC_FREE_BUFFER,
+ BC_INCREFS,
+ BC_ACQUIRE,
+ BC_RELEASE,
+ BC_DECREFS,
+ BC_INCREFS_DONE,
+ BC_ACQUIRE_DONE,
+ BC_ATTEMPT_ACQUIRE,
+ BC_REGISTER_LOOPER,
+ BC_ENTER_LOOPER,
+ BC_EXIT_LOOPER,
+ BC_REQUEST_DEATH_NOTIFICATION,
+ BC_CLEAR_DEATH_NOTIFICATION,
+ BC_DEAD_BINDER_DONE,
+};
+
+#endif
+
+#ifdef __cplusplus
+} // namespace android
+#endif
+
+#endif // _BINDER_MODULE_H_
diff --git a/include/private/utils/futex_synchro.h b/include/private/utils/futex_synchro.h
new file mode 100644
index 0000000..ac2ab19
--- /dev/null
+++ b/include/private/utils/futex_synchro.h
@@ -0,0 +1,60 @@
+/*
+ * 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 _FUTEX_SYNCHRO_H
+#define _FUTEX_SYNCHRO_H
+
+#ifndef HAVE_FUTEX
+#error "HAVE_FUTEX not defined"
+#endif
+
+#define FUTEX_WAIT_INFINITE (0)
+
+typedef struct futex_mutex_t futex_mutex_t;
+
+struct futex_mutex_t
+{
+ volatile int value;
+};
+
+typedef struct futex_cond_t futex_cond_t;
+
+struct futex_cond_t
+{
+ volatile int value;
+};
+
+
+#if __cplusplus
+extern "C" {
+#endif
+
+void futex_mutex_init(futex_mutex_t *m);
+int futex_mutex_lock(futex_mutex_t *m, unsigned msec);
+void futex_mutex_unlock(futex_mutex_t *m);
+int futex_mutex_trylock(futex_mutex_t *m);
+
+void futex_cond_init(futex_cond_t *c);
+int futex_cond_wait(futex_cond_t *c, futex_mutex_t *m, unsigned msec);
+void futex_cond_signal(futex_cond_t *c);
+void futex_cond_broadcast(futex_cond_t *c);
+
+#if __cplusplus
+} // extern "C"
+#endif
+
+#endif // _FUTEX_SYNCHRO_H
+