diff options
Diffstat (limited to 'include/ui')
-rw-r--r-- | include/ui/DisplayInfo.h | 23 | ||||
-rw-r--r-- | include/ui/Fence.h | 111 | ||||
-rw-r--r-- | include/ui/FramebufferNativeWindow.h | 16 | ||||
-rw-r--r-- | include/ui/GraphicBufferAllocator.h | 1 | ||||
-rw-r--r-- | include/ui/Point.h | 3 | ||||
-rw-r--r-- | include/ui/Rect.h | 3 | ||||
-rw-r--r-- | include/ui/Region.h | 51 | ||||
-rw-r--r-- | include/ui/UiConfig.h | 29 |
8 files changed, 196 insertions, 41 deletions
diff --git a/include/ui/DisplayInfo.h b/include/ui/DisplayInfo.h index edd28a6..c3a4d6b 100644 --- a/include/ui/DisplayInfo.h +++ b/include/ui/DisplayInfo.h @@ -14,7 +14,6 @@ * limitations under the License. */ - #ifndef ANDROID_UI_DISPLAY_INFO_H #define ANDROID_UI_DISPLAY_INFO_H @@ -26,15 +25,17 @@ 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; + uint32_t w; + uint32_t h; + float xdpi; + float ydpi; + float fps; + float density; + uint8_t orientation; + bool secure; + uint8_t reserved[2]; + // TODO: this needs to go away (currently needed only by webkit) + PixelFormatInfo pixelFormatInfo; }; /* Display orientations as defined in Surface.java and ISurfaceComposer.h. */ @@ -45,8 +46,6 @@ enum { DISPLAY_ORIENTATION_270 = 3 }; - }; // namespace android #endif // ANDROID_COMPOSER_DISPLAY_INFO_H - diff --git a/include/ui/Fence.h b/include/ui/Fence.h new file mode 100644 index 0000000..ff6cefe --- /dev/null +++ b/include/ui/Fence.h @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2012 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_FENCE_H +#define ANDROID_FENCE_H + +#include <stdint.h> +#include <sys/types.h> + +#include <ui/ANativeObjectBase.h> +#include <ui/PixelFormat.h> +#include <ui/Rect.h> +#include <utils/Flattenable.h> +#include <utils/String8.h> + +struct ANativeWindowBuffer; + +namespace android { + +// =========================================================================== +// Fence +// =========================================================================== + +class Fence + : public LightRefBase<Fence>, public Flattenable +{ +public: + static const sp<Fence> NO_FENCE; + + // Construct a new Fence object with an invalid file descriptor. This + // should be done when the Fence object will be set up by unflattening + // serialized data. + Fence(); + + // Construct a new Fence object to manage a given fence file descriptor. + // When the new Fence object is destructed the file descriptor will be + // closed. + Fence(int fenceFd); + + // Check whether the Fence has an open fence file descriptor. Most Fence + // methods treat an invalid file descriptor just like a valid fence that + // is already signalled, so using this is usually not necessary. + bool isValid() const { return mFenceFd != -1; } + + // wait waits for up to timeout milliseconds for the fence to signal. If + // the fence signals then NO_ERROR is returned. If the timeout expires + // before the fence signals then -ETIME is returned. A timeout of + // TIMEOUT_NEVER may be used to indicate that the call should wait + // indefinitely for the fence to signal. + status_t wait(unsigned int timeout); + + // waitForever is a convenience function for waiting forever for a fence to + // signal (just like wait(TIMEOUT_NEVER)), but issuing an error to the + // system log and fence state to the kernel log if the wait lasts longer + // than warningTimeout. The logname argument should be a string identifying + // the caller and will be included in the log message. + status_t waitForever(unsigned int warningTimeout, const char* logname); + + // TIMEOUT_NEVER may be passed to the wait method to indicate that it + // should wait indefinitely for the fence to signal. + enum { TIMEOUT_NEVER = -1 }; + + // merge combines two Fence objects, creating a new Fence object that + // becomes signaled when both f1 and f2 are signaled (even if f1 or f2 is + // destroyed before it becomes signaled). The name argument specifies the + // human-readable name to associated with the new Fence object. + static sp<Fence> merge(const String8& name, const sp<Fence>& f1, + const sp<Fence>& f2); + + // Return a duplicate of the fence file descriptor. The caller is + // responsible for closing the returned file descriptor. On error, -1 will + // be returned and errno will indicate the problem. + int dup() const; + + // Flattenable interface + size_t getFlattenedSize() const; + size_t getFdCount() const; + status_t flatten(void* buffer, size_t size, + int fds[], size_t count) const; + status_t unflatten(void const* buffer, size_t size, + int fds[], size_t count); + +private: + // Only allow instantiation using ref counting. + friend class LightRefBase<Fence>; + virtual ~Fence(); + + // Disallow copying + Fence(const Fence& rhs); + Fence& operator = (const Fence& rhs); + const Fence& operator = (const Fence& rhs) const; + + int mFenceFd; +}; + +}; // namespace android + +#endif // ANDROID_FENCE_H diff --git a/include/ui/FramebufferNativeWindow.h b/include/ui/FramebufferNativeWindow.h index b202b95..5ec738f 100644 --- a/include/ui/FramebufferNativeWindow.h +++ b/include/ui/FramebufferNativeWindow.h @@ -28,7 +28,8 @@ #include <ui/ANativeObjectBase.h> #include <ui/Rect.h> -#define NUM_FRAME_BUFFERS 2 +#define MIN_NUM_FRAME_BUFFERS 2 +#define MAX_NUM_FRAME_BUFFERS 3 extern "C" EGLNativeWindowType android_createDisplaySurface(void); @@ -65,16 +66,19 @@ private: friend class LightRefBase<FramebufferNativeWindow>; ~FramebufferNativeWindow(); // this class cannot be overloaded static int setSwapInterval(ANativeWindow* window, int interval); - static int dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer); - static int lockBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer); - static int queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer); + static int dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd); + static int queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd); static int query(const ANativeWindow* window, int what, int* value); static int perform(ANativeWindow* window, int operation, ...); - + + static int dequeueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer** buffer); + static int queueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer); + static int lockBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer); + framebuffer_device_t* fbDev; alloc_device_t* grDev; - sp<NativeBuffer> buffers[NUM_FRAME_BUFFERS]; + sp<NativeBuffer> buffers[MAX_NUM_FRAME_BUFFERS]; sp<NativeBuffer> front; mutable Mutex mutex; diff --git a/include/ui/GraphicBufferAllocator.h b/include/ui/GraphicBufferAllocator.h index dffa788..479cd3e 100644 --- a/include/ui/GraphicBufferAllocator.h +++ b/include/ui/GraphicBufferAllocator.h @@ -84,6 +84,7 @@ private: static KeyedVector<buffer_handle_t, alloc_rec_t> sAllocList; friend class Singleton<GraphicBufferAllocator>; + friend class BufferLiberatorThread; GraphicBufferAllocator(); ~GraphicBufferAllocator(); diff --git a/include/ui/Point.h b/include/ui/Point.h index 1653120..1d7f64d 100644 --- a/include/ui/Point.h +++ b/include/ui/Point.h @@ -17,11 +17,12 @@ #ifndef ANDROID_UI_POINT #define ANDROID_UI_POINT +#include <utils/Flattenable.h> #include <utils/TypeHelpers.h> namespace android { -class Point +class Point : public LightFlattenablePod<Point> { public: int x; diff --git a/include/ui/Rect.h b/include/ui/Rect.h index c2c2675..47d37b6 100644 --- a/include/ui/Rect.h +++ b/include/ui/Rect.h @@ -17,6 +17,7 @@ #ifndef ANDROID_UI_RECT #define ANDROID_UI_RECT +#include <utils/Flattenable.h> #include <utils/TypeHelpers.h> #include <ui/Point.h> @@ -24,7 +25,7 @@ namespace android { -class Rect : public ARect +class Rect : public ARect, public LightFlattenablePod<Rect> { public: typedef ARect::value_type value_type; diff --git a/include/ui/Region.h b/include/ui/Region.h index f242f18..43a4450 100644 --- a/include/ui/Region.h +++ b/include/ui/Region.h @@ -23,28 +23,29 @@ #include <utils/Vector.h> #include <ui/Rect.h> +#include <utils/Flattenable.h> namespace android { // --------------------------------------------------------------------------- +class SharedBuffer; class String8; // --------------------------------------------------------------------------- -class Region +class Region : public LightFlattenable<Region> { public: Region(); Region(const Region& rhs); explicit Region(const Rect& rhs); - explicit Region(const void* buffer); ~Region(); Region& operator = (const Region& rhs); - inline bool isEmpty() const { return mBounds.isEmpty(); } - inline bool isRect() const { return mStorage.isEmpty(); } + inline bool isEmpty() const { return getBounds().isEmpty(); } + inline bool isRect() const { return mStorage.size() == 1; } - inline Rect getBounds() const { return mBounds; } + inline Rect getBounds() const { return mStorage[mStorage.size() - 1]; } inline Rect bounds() const { return getBounds(); } // the region becomes its bounds @@ -106,28 +107,32 @@ public: /* various ways to access the rectangle list */ + + // STL-like iterators typedef Rect const* const_iterator; - - const_iterator begin() const; - const_iterator end() const; + const_iterator begin() const; + const_iterator end() const; - /* no user serviceable parts here... */ - - size_t getRects(Vector<Rect>& rectList) const; - Rect const* getArray(size_t* count) const; + // returns an array of rect which has the same life-time has this + // Region object. + Rect const* getArray(size_t* count) const; + // returns a SharedBuffer as well as the number of rects. + // ownership is transfered to the caller. + // the caller must call SharedBuffer::release() to free the memory. + SharedBuffer const* getSharedBuffer(size_t* count) const; + + /* no user serviceable parts here... */ // add a rectangle to the internal list. This rectangle must // be sorted in Y and X and must not make the region invalid. void addRectUnchecked(int l, int t, int r, int b); - // 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); + inline bool isFixedSize() const { return false; } + size_t getSize() const; + status_t flatten(void* buffer) const; + status_t unflatten(void const* buffer, size_t size); void dump(String8& out, const char* what, uint32_t flags=0) const; void dump(const char* what, uint32_t flags=0) const; @@ -156,10 +161,14 @@ private: static void translate(Region& reg, int dx, int dy); static void translate(Region& dst, const Region& reg, int dx, int dy); - static bool validate(const Region& reg, const char* name); + static bool validate(const Region& reg, + const char* name, bool silent = false); - Rect mBounds; - Vector<Rect> mStorage; + // mStorage is a (manually) sorted array of Rects describing the region + // with an extra Rect as the last element which is set to the + // bounds of the region. However, if the region is + // a simple Rect then mStorage contains only that rect. + Vector<Rect> mStorage; }; diff --git a/include/ui/UiConfig.h b/include/ui/UiConfig.h new file mode 100644 index 0000000..fcf8ed5 --- /dev/null +++ b/include/ui/UiConfig.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2012 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_CONFIG_H +#define ANDROID_UI_CONFIG_H + +#include <utils/String8.h> + +namespace android { + +// Append the libui configuration details to configStr. +void appendUiConfigString(String8& configStr); + +}; // namespace android + +#endif /*ANDROID_UI_CONFIG_H*/ |