diff options
Diffstat (limited to 'include/ui')
-rw-r--r-- | include/ui/DisplayInfo.h | 22 | ||||
-rw-r--r-- | include/ui/Fence.h | 105 | ||||
-rw-r--r-- | include/ui/FramebufferNativeWindow.h | 16 | ||||
-rw-r--r-- | include/ui/Point.h | 3 | ||||
-rw-r--r-- | include/ui/Rect.h | 3 | ||||
-rw-r--r-- | include/ui/Region.h | 14 |
6 files changed, 135 insertions, 28 deletions
diff --git a/include/ui/DisplayInfo.h b/include/ui/DisplayInfo.h index edd28a6..c7dc354 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,16 @@ 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; + uint8_t reserved[3]; + // 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 +45,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..17cb018 --- /dev/null +++ b/include/ui/Fence.h @@ -0,0 +1,105 @@ +/* + * 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 <limits.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. + int wait(unsigned int timeout); + + // TIMEOUT_NEVER may be passed to the wait method to indicate that it + // should wait indefinitely for the fence to signal. + enum { TIMEOUT_NEVER = UINT_MAX }; + + // 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/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..f0819af 100644 --- a/include/ui/Region.h +++ b/include/ui/Region.h @@ -23,6 +23,7 @@ #include <utils/Vector.h> #include <ui/Rect.h> +#include <utils/Flattenable.h> namespace android { // --------------------------------------------------------------------------- @@ -30,13 +31,12 @@ namespace android { 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); @@ -122,12 +122,10 @@ public: // 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; |