diff options
| author | Jamie Gennis <jgennis@google.com> | 2010-05-10 17:33:32 -0700 |
|---|---|---|
| committer | Jamie Gennis <jgennis@google.com> | 2010-05-10 17:33:32 -0700 |
| commit | 505cef3330c422c52564011f31a795a6c6135b3f (patch) | |
| tree | e9c3d729f19a937065fc35b2fa6b6bc830e8788f /include/ui | |
| parent | 82b027e90efc816f96783d47cff1c088d07c7b5a (diff) | |
| download | frameworks_base-505cef3330c422c52564011f31a795a6c6135b3f.zip frameworks_base-505cef3330c422c52564011f31a795a6c6135b3f.tar.gz frameworks_base-505cef3330c422c52564011f31a795a6c6135b3f.tar.bz2 | |
Add incStrong and decStrong methods to android_native_{window,buffer}_t.
This change adds the methods necessary to use sp<> to handle refcounting
android_native_window_t and android_native_buffer_t. The new methods forward
the refcounting operations to the corresponding android_native_base_t
functions.
Change-Id: I7de8e262728e439bc1efdf69374a2a9f6f432ced
Diffstat (limited to 'include/ui')
| -rw-r--r-- | include/ui/android_native_buffer.h | 9 | ||||
| -rw-r--r-- | include/ui/egl/android_natives.h | 18 |
2 files changed, 27 insertions, 0 deletions
diff --git a/include/ui/android_native_buffer.h b/include/ui/android_native_buffer.h index 9c92af8..402843e 100644 --- a/include/ui/android_native_buffer.h +++ b/include/ui/android_native_buffer.h @@ -33,6 +33,15 @@ typedef struct android_native_buffer_t common.version = sizeof(android_native_buffer_t); memset(common.reserved, 0, sizeof(common.reserved)); } + + // Implement the methods that sp<android_native_buffer_t> expects so that it + // can be used to automatically refcount android_native_buffer_t's. + void incStrong(const void* id) const { + common.incRef(const_cast<android_native_base_t*>(&common)); + } + void decStrong(const void* id) const { + common.decRef(const_cast<android_native_base_t*>(&common)); + } #endif struct android_native_base_t common; diff --git a/include/ui/egl/android_natives.h b/include/ui/egl/android_natives.h index 471c3c7..49bfa2b 100644 --- a/include/ui/egl/android_natives.h +++ b/include/ui/egl/android_natives.h @@ -98,6 +98,15 @@ typedef struct android_native_window_t common.version = sizeof(android_native_window_t); memset(common.reserved, 0, sizeof(common.reserved)); } + + // Implement the methods that sp<android_native_window_t> expects so that it + // can be used to automatically refcount android_native_window_t's. + void incStrong(const void* id) const { + common.incRef(const_cast<android_native_base_t*>(&common)); + } + void decStrong(const void* id) const { + common.decRef(const_cast<android_native_base_t*>(&common)); + } #endif struct android_native_base_t common; @@ -291,6 +300,15 @@ namespace android { template <typename NATIVE_TYPE, typename TYPE, typename REF> class EGLNativeBase : public NATIVE_TYPE, public REF { +public: + // Disambiguate between the incStrong in REF and NATIVE_TYPE + void incStrong(const void* id) const { + REF::incStrong(id); + } + void decStrong(const void* id) const { + REF::decStrong(id); + } + protected: typedef EGLNativeBase<NATIVE_TYPE, TYPE, REF> BASE; EGLNativeBase() : NATIVE_TYPE(), REF() { |
