michael@0: /* michael@0: * Copyright (C) 2009 The Android Open Source Project michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #ifndef ANDROID_ANDROID_NATIVES_H michael@0: #define ANDROID_ANDROID_NATIVES_H michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #include michael@0: #include michael@0: // FIXME: remove this header, it's for legacy use. native_window is pulled from frameworks/base/native/include/android/ michael@0: #include michael@0: // --------------------------------------------------------------------------- michael@0: michael@0: /* FIXME: this is legacy for pixmaps */ michael@0: typedef struct egl_native_pixmap_t michael@0: { michael@0: int32_t version; /* must be 32 */ michael@0: int32_t width; michael@0: int32_t height; michael@0: int32_t stride; michael@0: uint8_t* data; michael@0: uint8_t format; michael@0: uint8_t rfu[3]; michael@0: union { michael@0: uint32_t compressedFormat; michael@0: int32_t vstride; michael@0: }; michael@0: int32_t reserved; michael@0: } egl_native_pixmap_t; michael@0: michael@0: /*****************************************************************************/ michael@0: michael@0: #ifdef __cplusplus michael@0: michael@0: #include michael@0: michael@0: namespace android { michael@0: michael@0: /* michael@0: * This helper class turns an EGL android_native_xxx type into a C++ michael@0: * reference-counted object; with proper type conversions. michael@0: */ michael@0: template michael@0: class EGLNativeBase : public NATIVE_TYPE, public REF michael@0: { michael@0: public: michael@0: // Disambiguate between the incStrong in REF and NATIVE_TYPE michael@0: void incStrong(const void* id) const { michael@0: REF::incStrong(id); michael@0: } michael@0: void decStrong(const void* id) const { michael@0: REF::decStrong(id); michael@0: } michael@0: michael@0: protected: michael@0: typedef EGLNativeBase BASE; michael@0: EGLNativeBase() : NATIVE_TYPE(), REF() { michael@0: NATIVE_TYPE::common.incRef = incRef; michael@0: NATIVE_TYPE::common.decRef = decRef; michael@0: } michael@0: static inline TYPE* getSelf(NATIVE_TYPE* self) { michael@0: return static_cast(self); michael@0: } michael@0: static inline TYPE const* getSelf(NATIVE_TYPE const* self) { michael@0: return static_cast(self); michael@0: } michael@0: static inline TYPE* getSelf(android_native_base_t* base) { michael@0: return getSelf(reinterpret_cast(base)); michael@0: } michael@0: static inline TYPE const * getSelf(android_native_base_t const* base) { michael@0: return getSelf(reinterpret_cast(base)); michael@0: } michael@0: static void incRef(android_native_base_t* base) { michael@0: EGLNativeBase* self = getSelf(base); michael@0: self->incStrong(self); michael@0: } michael@0: static void decRef(android_native_base_t* base) { michael@0: EGLNativeBase* self = getSelf(base); michael@0: self->decStrong(self); michael@0: } michael@0: }; michael@0: michael@0: } // namespace android michael@0: #endif // __cplusplus michael@0: michael@0: /*****************************************************************************/ michael@0: michael@0: #endif /* ANDROID_ANDROID_NATIVES_H */