diff options
Diffstat (limited to 'include')
26 files changed, 549 insertions, 117 deletions
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h index 13e51ee..83ff508 100644 --- a/include/media/AudioRecord.h +++ b/include/media/AudioRecord.h @@ -26,8 +26,8 @@ #include <utils/RefBase.h> #include <utils/Errors.h> -#include <utils/IInterface.h> -#include <utils/IMemory.h> +#include <binder/IInterface.h> +#include <binder/IMemory.h> #include <utils/threads.h> diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h index 7c86a65..2e1fbda 100644 --- a/include/media/AudioTrack.h +++ b/include/media/AudioTrack.h @@ -26,8 +26,8 @@ #include <utils/RefBase.h> #include <utils/Errors.h> -#include <utils/IInterface.h> -#include <utils/IMemory.h> +#include <binder/IInterface.h> +#include <binder/IMemory.h> #include <utils/threads.h> diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h index 3e59d85..bac3d29 100644 --- a/include/media/IAudioFlinger.h +++ b/include/media/IAudioFlinger.h @@ -23,7 +23,7 @@ #include <utils/RefBase.h> #include <utils/Errors.h> -#include <utils/IInterface.h> +#include <binder/IInterface.h> #include <media/IAudioTrack.h> #include <media/IAudioRecord.h> #include <media/IAudioFlingerClient.h> diff --git a/include/media/IAudioFlingerClient.h b/include/media/IAudioFlingerClient.h index c3deb0b..383ec0c 100644 --- a/include/media/IAudioFlingerClient.h +++ b/include/media/IAudioFlingerClient.h @@ -19,7 +19,7 @@ #include <utils/RefBase.h> -#include <utils/IInterface.h> +#include <binder/IInterface.h> namespace android { diff --git a/include/media/IAudioRecord.h b/include/media/IAudioRecord.h index 9d45d2d..46735de 100644 --- a/include/media/IAudioRecord.h +++ b/include/media/IAudioRecord.h @@ -22,8 +22,8 @@ #include <utils/RefBase.h> #include <utils/Errors.h> -#include <utils/IInterface.h> -#include <utils/IMemory.h> +#include <binder/IInterface.h> +#include <binder/IMemory.h> namespace android { diff --git a/include/media/IAudioTrack.h b/include/media/IAudioTrack.h index 12f2111..de6426a 100644 --- a/include/media/IAudioTrack.h +++ b/include/media/IAudioTrack.h @@ -22,8 +22,8 @@ #include <utils/RefBase.h> #include <utils/Errors.h> -#include <utils/IInterface.h> -#include <utils/IMemory.h> +#include <binder/IInterface.h> +#include <binder/IMemory.h> namespace android { diff --git a/include/media/IMediaMetadataRetriever.h b/include/media/IMediaMetadataRetriever.h index c677e83..9baba8e 100644 --- a/include/media/IMediaMetadataRetriever.h +++ b/include/media/IMediaMetadataRetriever.h @@ -19,9 +19,9 @@ #define ANDROID_IMEDIAMETADATARETRIEVER_H #include <utils/RefBase.h> -#include <utils/IInterface.h> -#include <utils/Parcel.h> -#include <utils/IMemory.h> +#include <binder/IInterface.h> +#include <binder/Parcel.h> +#include <binder/IMemory.h> namespace android { diff --git a/include/media/IMediaPlayer.h b/include/media/IMediaPlayer.h index a683e74..85aeb30 100644 --- a/include/media/IMediaPlayer.h +++ b/include/media/IMediaPlayer.h @@ -18,11 +18,12 @@ #define ANDROID_IMEDIAPLAYER_H #include <utils/RefBase.h> -#include <utils/IInterface.h> -#include <utils/Parcel.h> +#include <binder/IInterface.h> +#include <binder/Parcel.h> namespace android { +class Parcel; class ISurface; class IMediaPlayer: public IInterface @@ -45,6 +46,14 @@ public: virtual status_t setAudioStreamType(int type) = 0; virtual status_t setLooping(int loop) = 0; virtual status_t setVolume(float leftVolume, float rightVolume) = 0; + + // Invoke a generic method on the player by using opaque parcels + // for the request and reply. + // @param request Parcel that must start with the media player + // interface token. + // @param[out] reply Parcel to hold the reply data. Cannot be null. + // @return OK if the invocation was made. PERMISSION_DENIED otherwise. + virtual status_t invoke(const Parcel& request, Parcel *reply) = 0; }; // ---------------------------------------------------------------------------- @@ -61,4 +70,3 @@ public: }; // namespace android #endif // ANDROID_IMEDIAPLAYER_H - diff --git a/include/media/IMediaPlayerClient.h b/include/media/IMediaPlayerClient.h index 5d32811..eee6c97 100644 --- a/include/media/IMediaPlayerClient.h +++ b/include/media/IMediaPlayerClient.h @@ -18,8 +18,8 @@ #define ANDROID_IMEDIAPLAYERCLIENT_H #include <utils/RefBase.h> -#include <utils/IInterface.h> -#include <utils/Parcel.h> +#include <binder/IInterface.h> +#include <binder/Parcel.h> namespace android { diff --git a/include/media/IMediaPlayerService.h b/include/media/IMediaPlayerService.h index d1d96b1..f6faf14 100644 --- a/include/media/IMediaPlayerService.h +++ b/include/media/IMediaPlayerService.h @@ -17,9 +17,10 @@ #ifndef ANDROID_IMEDIAPLAYERSERVICE_H #define ANDROID_IMEDIAPLAYERSERVICE_H +#include <utils/Errors.h> // for status_t #include <utils/RefBase.h> -#include <utils/IInterface.h> -#include <utils/Parcel.h> +#include <binder/IInterface.h> +#include <binder/Parcel.h> #include <media/IMediaPlayerClient.h> #include <media/IMediaPlayer.h> @@ -36,7 +37,6 @@ public: virtual sp<IMediaRecorder> createMediaRecorder(pid_t pid) = 0; virtual sp<IMediaMetadataRetriever> createMetadataRetriever(pid_t pid) = 0; - virtual sp<IMediaPlayer> create(pid_t pid, const sp<IMediaPlayerClient>& client, const char* url) = 0; virtual sp<IMediaPlayer> create(pid_t pid, const sp<IMediaPlayerClient>& client, int fd, int64_t offset, int64_t length) = 0; virtual sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) = 0; diff --git a/include/media/IMediaRecorder.h b/include/media/IMediaRecorder.h index 64d3a40..24ac82b 100644 --- a/include/media/IMediaRecorder.h +++ b/include/media/IMediaRecorder.h @@ -18,7 +18,7 @@ #ifndef ANDROID_IMEDIARECORDER_H #define ANDROID_IMEDIARECORDER_H -#include <utils/IInterface.h> +#include <binder/IInterface.h> namespace android { diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h index 7bf555a..21600b2 100644 --- a/include/media/MediaPlayerInterface.h +++ b/include/media/MediaPlayerInterface.h @@ -27,12 +27,15 @@ namespace android { +class Parcel; + enum player_type { PV_PLAYER = 1, SONIVOX_PLAYER = 2, VORBIS_PLAYER = 3 }; + #define DEFAULT_AUDIOSINK_BUFFERCOUNT 4 #define DEFAULT_AUDIOSINK_BUFFERSIZE 1200 #define DEFAULT_AUDIOSINK_SAMPLERATE 44100 @@ -45,7 +48,6 @@ typedef void (*notify_callback_f)(void* cookie, int msg, int ext1, int ext2); class MediaPlayerBase : public RefBase { public: - // AudioSink: abstraction layer for audio output class AudioSink : public RefBase { public: @@ -88,7 +90,14 @@ public: virtual player_type playerType() = 0; virtual void setNotifyCallback(void* cookie, notify_callback_f notifyFunc) { mCookie = cookie; mNotify = notifyFunc; } - + // Invoke a generic method on the player by using opaque parcels + // for the request and reply. + // @param request Parcel that is positioned at the start of the + // data sent by the java layer. + // @param[out] reply Parcel to hold the reply data. Cannot be null. + // @return OK if the invocation was made successfully. A player + // not supporting the direct API should return INVALID_OPERATION. + virtual status_t invoke(const Parcel& request, Parcel *reply) = 0; protected: virtual void sendEvent(int msg, int ext1=0, int ext2=0) { if (mNotify) mNotify(mCookie, msg, ext1, ext2); } diff --git a/include/media/PVPlayer.h b/include/media/PVPlayer.h index 8122df6..eb4595b 100644 --- a/include/media/PVPlayer.h +++ b/include/media/PVPlayer.h @@ -52,6 +52,7 @@ public: virtual status_t reset(); virtual status_t setLooping(int loop); virtual player_type playerType() { return PV_PLAYER; } + virtual status_t invoke(const Parcel& request, Parcel *reply); // make available to PlayerDriver void sendEvent(int msg, int ext1=0, int ext2=0) { MediaPlayerBase::sendEvent(msg, ext1, ext2); } diff --git a/include/media/mediametadataretriever.h b/include/media/mediametadataretriever.h index f2719d3..3db8a0f 100644 --- a/include/media/mediametadataretriever.h +++ b/include/media/mediametadataretriever.h @@ -20,7 +20,7 @@ #include <utils/Errors.h> // for status_t #include <utils/threads.h> -#include <utils/IMemory.h> +#include <binder/IMemory.h> #include <media/IMediaMetadataRetriever.h> namespace android { diff --git a/include/media/mediaplayer.h b/include/media/mediaplayer.h index 513ffe1..dd8ea19 100644 --- a/include/media/mediaplayer.h +++ b/include/media/mediaplayer.h @@ -17,7 +17,7 @@ #ifndef ANDROID_MEDIAPLAYER_H #define ANDROID_MEDIAPLAYER_H -#include <utils/IMemory.h> +#include <binder/IMemory.h> #include <ui/Surface.h> #include <media/IMediaPlayerClient.h> #include <media/IMediaPlayer.h> @@ -151,7 +151,7 @@ public: void notify(int msg, int ext1, int ext2); static sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat); static sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat); - + status_t invoke(const Parcel& request, Parcel *reply); private: void clear_l(); status_t seekTo_l(int msec); diff --git a/include/media/mediarecorder.h b/include/media/mediarecorder.h index 9b54ca9..ad27903 100644 --- a/include/media/mediarecorder.h +++ b/include/media/mediarecorder.h @@ -18,7 +18,10 @@ #ifndef ANDROID_MEDIARECORDER_H #define ANDROID_MEDIARECORDER_H -#include <utils.h> +#include <utils/Log.h> +#include <utils/threads.h> +#include <utils/List.h> +#include <utils/Errors.h> #include <media/IMediaPlayerClient.h> namespace android { diff --git a/include/media/mediascanner.h b/include/media/mediascanner.h index fbef1db..7749566 100644 --- a/include/media/mediascanner.h +++ b/include/media/mediascanner.h @@ -17,7 +17,10 @@ #ifndef MEDIASCANNER_H #define MEDIASCANNER_H -#include <utils.h> +#include <utils/Log.h> +#include <utils/threads.h> +#include <utils/List.h> +#include <utils/Errors.h> #include <pthread.h> namespace android { diff --git a/include/private/binder/Static.h b/include/private/binder/Static.h new file mode 100644 index 0000000..5b0f9fc --- /dev/null +++ b/include/private/binder/Static.h @@ -0,0 +1,39 @@ +/* + * 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 <binder/IBinder.h> +#include <binder/IMemory.h> +#include <binder/ProcessState.h> +#include <binder/IPermissionController.h> +#include <binder/IServiceManager.h> + +namespace android { + +// For ProcessState.cpp +extern Mutex gProcessMutex; +extern sp<ProcessState> gProcess; + +// For ServiceManager.cpp +extern Mutex gDefaultServiceManagerLock; +extern sp<IServiceManager> gDefaultServiceManager; +extern sp<IPermissionController> gPermissionController; + +} // namespace android diff --git a/include/private/utils/binder_module.h b/include/private/binder/binder_module.h index fdf327e..fdf327e 100644 --- a/include/private/utils/binder_module.h +++ b/include/private/binder/binder_module.h diff --git a/include/private/opengles/gl_context.h b/include/private/opengles/gl_context.h index a85f275..523aed0 100644 --- a/include/private/opengles/gl_context.h +++ b/include/private/opengles/gl_context.h @@ -26,6 +26,8 @@ #endif #include <private/pixelflinger/ggl_context.h> +#include <hardware/copybit.h> +#include <hardware/gralloc.h> #include <GLES/gl.h> #include <GLES/glext.h> @@ -39,7 +41,7 @@ class EGLSurfaceManager; class EGLBufferObjectManager; namespace gl { - + struct ogles_context_t; struct matrixx_t; struct transform_t; @@ -96,7 +98,7 @@ struct vec4_t { struct vertex_t { enum { - // these constant matter for our clipping + // these constant matter for our clipping CLIP_L = 0x0001, // clipping flags CLIP_R = 0x0002, CLIP_B = 0x0004, @@ -106,7 +108,7 @@ struct vertex_t { EYE = 0x0040, RESERVED = 0x0080, - + USER_CLIP_0 = 0x0100, // user clipping flags USER_CLIP_1 = 0x0200, USER_CLIP_2 = 0x0400, @@ -121,7 +123,7 @@ struct vertex_t { 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 @@ -130,7 +132,7 @@ struct vertex_t { vec4_t eye; }; vec4_t clip; - + uint32_t flags; size_t index; // cache tag, and vertex index GLfixed fog; @@ -142,7 +144,7 @@ struct vertex_t { vec4_t color; vec4_t texture[GGL_TEXTURE_UNIT_COUNT]; uint32_t reserved1[4]; - + inline void clear() { flags = index = locked = mru = 0; } @@ -199,7 +201,7 @@ struct array_machine_t { 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); @@ -410,7 +412,7 @@ struct transform_t { matrixx_t matrix; uint32_t flags; uint32_t ops; - + union { struct { void (*point2)(transform_t const* t, vec4_t*, vec4_t const*); @@ -509,17 +511,17 @@ struct viewport_t { GLint x; GLint y; GLsizei w; - GLsizei h; + GLsizei h; struct { GLint x; GLint y; - } surfaceport; + } surfaceport; struct { GLint x; GLint y; GLsizei w; - GLsizei h; - } scissor; + GLsizei h; + } scissor; }; // ---------------------------------------------------------------------------- @@ -594,6 +596,14 @@ struct prims_t { void (*renderTriangle)(GL, vertex_t*, vertex_t*, vertex_t*); }; +struct copybits_context_t { + // A handle to the blit engine, if it exists, else NULL. + copybit_device_t* blitEngine; + int32_t minScale; + int32_t maxScale; + buffer_handle_t drawSurfaceBuffer; +}; + struct ogles_context_t { context_t rasterizer; array_machine_t arrays __attribute__((aligned(32))); @@ -617,6 +627,14 @@ struct ogles_context_t { uint32_t transformTextures : 1; EGLSurfaceManager* surfaceManager; EGLBufferObjectManager* bufferObjectManager; + + // copybits is only used if LIBAGL_USE_GRALLOC_COPYBITS is + // defined, but it is always present because ogles_context_t is a public + // struct that is used by clients of libagl. We want the size and offsets + // to stay the same, whether or not LIBAGL_USE_GRALLOC_COPYBITS is defined. + + copybits_context_t copybits; + GLenum error; static inline ogles_context_t* get() { diff --git a/include/private/ui/RegionHelper.h b/include/private/ui/RegionHelper.h new file mode 100644 index 0000000..6c847ff --- /dev/null +++ b/include/private/ui/RegionHelper.h @@ -0,0 +1,279 @@ +/* + * Copyright (C) 2009 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_PRIVATE_REGION_HELPER_H +#define ANDROID_UI_PRIVATE_REGION_HELPER_H + +#include <stdint.h> +#include <sys/types.h> + +namespace android { +// ---------------------------------------------------------------------------- + +template<typename RECT> +class region_operator +{ + typedef typename RECT::value_type TYPE; + static const TYPE max_value = 0x7FFFFFF; + +public: + /* + * Common boolean operations: + * value is computed as 0b101 op 0b110 + * other boolean operation are possible, simply compute + * their corresponding value with the above formulae and use + * it when instantiating a region_operator. + */ + static const uint32_t LHS = 0x5; // 0b101 + static const uint32_t RHS = 0x6; // 0b110 + enum { + op_nand = LHS & ~RHS, + op_and = LHS & RHS, + op_or = LHS | RHS, + op_xor = LHS ^ RHS + }; + + struct region { + RECT const* rects; + size_t count; + TYPE dx; + TYPE dy; + inline region(const region& rhs) + : rects(rhs.rects), count(rhs.count), dx(rhs.dx), dy(rhs.dy) { } + inline region(RECT const* r, size_t c) + : rects(r), count(c), dx(), dy() { } + inline region(RECT const* r, size_t c, TYPE dx, TYPE dy) + : rects(r), count(c), dx(dx), dy(dy) { } + }; + + class region_rasterizer { + friend class region_operator; + virtual void operator()(const RECT& rect) = 0; + }; + + inline region_operator(int op, const region& lhs, const region& rhs) + : op_mask(op), spanner(lhs, rhs) + { + } + + void operator()(region_rasterizer& rasterizer) { + RECT current; + do { + SpannerInner spannerInner(spanner.lhs, spanner.rhs); + int inside = spanner.next(current.top, current.bottom); + spannerInner.prepare(inside); + do { + TYPE left, right; + int inside = spannerInner.next(current.left, current.right); + if ((op_mask >> inside) & 1) { + if (current.left < current.right && + current.top < current.bottom) { + rasterizer(current); + } + } + } while(!spannerInner.isDone()); + } while(!spanner.isDone()); + } + +private: + uint32_t op_mask; + + class SpannerBase + { + public: + enum { + lhs_before_rhs = 0, + lhs_after_rhs = 1, + lhs_coincide_rhs = 2 + }; + + protected: + TYPE lhs_head; + TYPE lhs_tail; + TYPE rhs_head; + TYPE rhs_tail; + + inline int next(TYPE& head, TYPE& tail, + bool& more_lhs, bool& more_rhs) + { + int inside; + more_lhs = false; + more_rhs = false; + if (lhs_head < rhs_head) { + inside = lhs_before_rhs; + head = lhs_head; + if (lhs_tail <= rhs_head) { + tail = lhs_tail; + more_lhs = true; + } else { + lhs_head = rhs_head; + tail = rhs_head; + } + } else if (rhs_head < lhs_head) { + inside = lhs_after_rhs; + head = rhs_head; + if (rhs_tail <= lhs_head) { + tail = rhs_tail; + more_rhs = true; + } else { + rhs_head = lhs_head; + tail = lhs_head; + } + } else { + inside = lhs_coincide_rhs; + head = lhs_head; + if (lhs_tail <= rhs_tail) { + tail = rhs_head = lhs_tail; + more_lhs = true; + } + if (rhs_tail <= lhs_tail) { + tail = lhs_head = rhs_tail; + more_rhs = true; + } + } + return inside; + } + }; + + class Spanner : protected SpannerBase + { + friend class region_operator; + region lhs; + region rhs; + + public: + inline Spanner(const region& lhs, const region& rhs) + : lhs(lhs), rhs(rhs) + { + SpannerBase::lhs_head = lhs.rects->top + lhs.dy; + SpannerBase::lhs_tail = lhs.rects->bottom + lhs.dy; + SpannerBase::rhs_head = rhs.rects->top + rhs.dy; + SpannerBase::rhs_tail = rhs.rects->bottom + rhs.dy; + } + + inline bool isDone() const { + return !rhs.count && !lhs.count; + } + + inline int next(TYPE& top, TYPE& bottom) + { + bool more_lhs = false; + bool more_rhs = false; + int inside = SpannerBase::next(top, bottom, more_lhs, more_rhs); + if (more_lhs) { + advance(lhs, SpannerBase::lhs_head, SpannerBase::lhs_tail); + } + if (more_rhs) { + advance(rhs, SpannerBase::rhs_head, SpannerBase::rhs_tail); + } + return inside; + } + + private: + static inline + void advance(region& reg, TYPE& aTop, TYPE& aBottom) { + // got to next span + size_t count = reg.count; + RECT const * rects = reg.rects; + RECT const * const end = rects + count; + const int top = rects->top; + while (rects != end && rects->top == top) { + rects++; + count--; + } + if (rects != end) { + aTop = rects->top + reg.dy; + aBottom = rects->bottom + reg.dy; + } else { + aTop = max_value; + aBottom = max_value; + } + reg.rects = rects; + reg.count = count; + } + }; + + class SpannerInner : protected SpannerBase + { + region lhs; + region rhs; + + public: + inline SpannerInner(const region& lhs, const region& rhs) + : lhs(lhs), rhs(rhs) + { + } + + inline void prepare(int inside) { + SpannerBase::lhs_head = lhs.rects->left + lhs.dx; + SpannerBase::lhs_tail = lhs.rects->right + lhs.dx; + SpannerBase::rhs_head = rhs.rects->left + rhs.dx; + SpannerBase::rhs_tail = rhs.rects->right + rhs.dx; + if (inside == SpannerBase::lhs_before_rhs) { + SpannerBase::rhs_head = max_value; + SpannerBase::rhs_tail = max_value; + } else if (inside == SpannerBase::lhs_after_rhs) { + SpannerBase::lhs_head = max_value; + SpannerBase::lhs_tail = max_value; + } else { + // use both spans + } + } + + inline bool isDone() const { + return SpannerBase::lhs_head == max_value && + SpannerBase::rhs_head == max_value; + } + + inline int next(TYPE& left, TYPE& right) + { + bool more_lhs = false; + bool more_rhs = false; + int inside = SpannerBase::next(left, right, more_lhs, more_rhs); + if (more_lhs) { + advance(lhs, SpannerBase::lhs_head, SpannerBase::lhs_tail); + } + if (more_rhs) { + advance(rhs, SpannerBase::rhs_head, SpannerBase::rhs_tail); + } + return inside; + } + + private: + static inline + void advance(region& reg, TYPE& left, TYPE& right) { + if (reg.rects && reg.count) { + const int cur_span_top = reg.rects->top; + reg.rects++; + reg.count--; + if (!reg.count || reg.rects->top != cur_span_top) { + left = max_value; + right = max_value; + } else { + left = reg.rects->left + reg.dx; + right = reg.rects->right + reg.dx; + } + } + } + }; + + Spanner spanner; +}; + +// ---------------------------------------------------------------------------- +}; + +#endif /* ANDROID_UI_PRIVATE_REGION_HELPER_H */ diff --git a/include/private/ui/SharedState.h b/include/private/ui/SharedState.h index 546d0ad..3bc7979 100644 --- a/include/private/ui/SharedState.h +++ b/include/private/ui/SharedState.h @@ -20,6 +20,7 @@ #include <stdint.h> #include <sys/types.h> +#include <utils/Debug.h> #include <utils/threads.h> namespace android { @@ -32,16 +33,12 @@ namespace android { struct surface_info_t { // 4 longs, 16 bytes enum { - eBufferDirty = 0x01 + eBufferDirty = 0x01, + eNeedNewBuffer = 0x02 }; - uint16_t w; - uint16_t h; - uint16_t stride; - uint16_t bpr; - uint16_t reserved; - uint8_t format; + uint8_t reserved[11]; uint8_t flags; - ssize_t bits_offset; + status_t status; }; // --------------------------------------------------------------------------- @@ -110,8 +107,6 @@ struct per_client_cblk_t // 4KB max 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); @@ -138,30 +133,19 @@ struct display_cblk_t 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 -} +COMPILE_TIME_ASSERT(sizeof(layer_cblk_t) == 128) +COMPILE_TIME_ASSERT(sizeof(per_client_cblk_t) <= 4096) +COMPILE_TIME_ASSERT(sizeof(surface_flinger_cblk_t) <= 4096) +// --------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_UI_SHARED_STATE_H diff --git a/include/private/ui/SurfaceBuffer.h b/include/private/ui/SurfaceBuffer.h new file mode 100644 index 0000000..bf68406 --- /dev/null +++ b/include/private/ui/SurfaceBuffer.h @@ -0,0 +1,77 @@ +/* + * 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_PRIVATE_SURFACE_BUFFER_H +#define ANDROID_UI_PRIVATE_SURFACE_BUFFER_H + +#include <stdint.h> +#include <sys/types.h> + +#include <utils/RefBase.h> + +#include <private/ui/android_natives_priv.h> + +namespace android { + +// --------------------------------------------------------------------------- + +class BufferMapper; +class Parcel; +class Rect; +class Surface; +class SurfaceBuffer; + +// --------------------------------------------------------------------------- + +class SurfaceBuffer + : public EGLNativeBase< + android_native_buffer_t, + SurfaceBuffer, + LightRefBase<SurfaceBuffer> > +{ +public: + status_t lock(uint32_t usage, void** vaddr); + status_t lock(uint32_t usage, const Rect& rect, void** vaddr); + status_t unlock(); + +protected: + SurfaceBuffer(); + SurfaceBuffer(const Parcel& reply); + virtual ~SurfaceBuffer(); + bool mOwner; + + inline const BufferMapper& getBufferMapper() const { return mBufferMapper; } + inline BufferMapper& getBufferMapper() { return mBufferMapper; } + +private: + friend class Surface; + friend class BpSurface; + friend class BnSurface; + friend class LightRefBase<SurfaceBuffer>; + + SurfaceBuffer& operator = (const SurfaceBuffer& rhs); + const SurfaceBuffer& operator = (const SurfaceBuffer& rhs) const; + + static status_t writeToParcel(Parcel* reply, + android_native_buffer_t const* buffer); + + BufferMapper& mBufferMapper; +}; + +}; // namespace android + +#endif // ANDROID_UI_PRIVATE_SURFACE_BUFFER_H + diff --git a/include/private/ui/SurfaceFlingerSynchro.h b/include/private/ui/SurfaceFlingerSynchro.h index ff91b61..7386d33 100644 --- a/include/private/ui/SurfaceFlingerSynchro.h +++ b/include/private/ui/SurfaceFlingerSynchro.h @@ -21,7 +21,6 @@ #include <stdint.h> #include <sys/types.h> #include <utils/Errors.h> -#include <utils/threads.h> #include <ui/ISurfaceComposer.h> namespace android { @@ -31,7 +30,6 @@ class SurfaceFlinger; class SurfaceFlingerSynchro { public: - // client constructor SurfaceFlingerSynchro(const sp<ISurfaceComposer>& flinger); ~SurfaceFlingerSynchro(); @@ -40,34 +38,8 @@ public: 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 diff --git a/include/private/ui/android_natives_priv.h b/include/private/ui/android_natives_priv.h new file mode 100644 index 0000000..ee843e9 --- /dev/null +++ b/include/private/ui/android_natives_priv.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2009 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_ANDROID_NATIVES_PRIV_H +#define ANDROID_ANDROID_NATIVES_PRIV_H + +#include <ui/egl/android_natives.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/*****************************************************************************/ + +struct android_native_buffer_t +{ +#ifdef __cplusplus + android_native_buffer_t() { + common.magic = ANDROID_NATIVE_BUFFER_MAGIC; + common.version = sizeof(android_native_buffer_t); + memset(common.reserved, 0, sizeof(common.reserved)); + } +#endif + + struct android_native_base_t common; + + int width; + int height; + int stride; + int format; + int usage; + + void* reserved[2]; + + buffer_handle_t handle; + + void* reserved_proc[8]; +}; + + +/*****************************************************************************/ + +#ifdef __cplusplus +} +#endif + +/*****************************************************************************/ + +#endif /* ANDROID_ANDROID_NATIVES_PRIV_H */ diff --git a/include/private/utils/Static.h b/include/private/utils/Static.h index f1439b7..d95ae0d 100644 --- a/include/private/utils/Static.h +++ b/include/private/utils/Static.h @@ -20,14 +20,6 @@ #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; @@ -40,19 +32,4 @@ extern void terminate_string8(); 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 |