1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/omx-plugin/include/ics/ui/egl/android_natives.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,103 @@ 1.4 +/* 1.5 + * Copyright (C) 2009 The Android Open Source Project 1.6 + * 1.7 + * Licensed under the Apache License, Version 2.0 (the "License"); 1.8 + * you may not use this file except in compliance with the License. 1.9 + * You may obtain a copy of the License at 1.10 + * 1.11 + * http://www.apache.org/licenses/LICENSE-2.0 1.12 + * 1.13 + * Unless required by applicable law or agreed to in writing, software 1.14 + * distributed under the License is distributed on an "AS IS" BASIS, 1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1.16 + * See the License for the specific language governing permissions and 1.17 + * limitations under the License. 1.18 + */ 1.19 + 1.20 +#ifndef ANDROID_ANDROID_NATIVES_H 1.21 +#define ANDROID_ANDROID_NATIVES_H 1.22 + 1.23 +#include <sys/types.h> 1.24 +#include <string.h> 1.25 + 1.26 +#include <hardware/gralloc.h> 1.27 +#include <system/window.h> 1.28 +// FIXME: remove this header, it's for legacy use. native_window is pulled from frameworks/base/native/include/android/ 1.29 +#include <android/native_window.h> 1.30 +// --------------------------------------------------------------------------- 1.31 + 1.32 +/* FIXME: this is legacy for pixmaps */ 1.33 +typedef struct egl_native_pixmap_t 1.34 +{ 1.35 + int32_t version; /* must be 32 */ 1.36 + int32_t width; 1.37 + int32_t height; 1.38 + int32_t stride; 1.39 + uint8_t* data; 1.40 + uint8_t format; 1.41 + uint8_t rfu[3]; 1.42 + union { 1.43 + uint32_t compressedFormat; 1.44 + int32_t vstride; 1.45 + }; 1.46 + int32_t reserved; 1.47 +} egl_native_pixmap_t; 1.48 + 1.49 +/*****************************************************************************/ 1.50 + 1.51 +#ifdef __cplusplus 1.52 + 1.53 +#include <utils/RefBase.h> 1.54 + 1.55 +namespace android { 1.56 + 1.57 +/* 1.58 + * This helper class turns an EGL android_native_xxx type into a C++ 1.59 + * reference-counted object; with proper type conversions. 1.60 + */ 1.61 +template <typename NATIVE_TYPE, typename TYPE, typename REF> 1.62 +class EGLNativeBase : public NATIVE_TYPE, public REF 1.63 +{ 1.64 +public: 1.65 + // Disambiguate between the incStrong in REF and NATIVE_TYPE 1.66 + void incStrong(const void* id) const { 1.67 + REF::incStrong(id); 1.68 + } 1.69 + void decStrong(const void* id) const { 1.70 + REF::decStrong(id); 1.71 + } 1.72 + 1.73 +protected: 1.74 + typedef EGLNativeBase<NATIVE_TYPE, TYPE, REF> BASE; 1.75 + EGLNativeBase() : NATIVE_TYPE(), REF() { 1.76 + NATIVE_TYPE::common.incRef = incRef; 1.77 + NATIVE_TYPE::common.decRef = decRef; 1.78 + } 1.79 + static inline TYPE* getSelf(NATIVE_TYPE* self) { 1.80 + return static_cast<TYPE*>(self); 1.81 + } 1.82 + static inline TYPE const* getSelf(NATIVE_TYPE const* self) { 1.83 + return static_cast<TYPE const *>(self); 1.84 + } 1.85 + static inline TYPE* getSelf(android_native_base_t* base) { 1.86 + return getSelf(reinterpret_cast<NATIVE_TYPE*>(base)); 1.87 + } 1.88 + static inline TYPE const * getSelf(android_native_base_t const* base) { 1.89 + return getSelf(reinterpret_cast<NATIVE_TYPE const*>(base)); 1.90 + } 1.91 + static void incRef(android_native_base_t* base) { 1.92 + EGLNativeBase* self = getSelf(base); 1.93 + self->incStrong(self); 1.94 + } 1.95 + static void decRef(android_native_base_t* base) { 1.96 + EGLNativeBase* self = getSelf(base); 1.97 + self->decStrong(self); 1.98 + } 1.99 +}; 1.100 + 1.101 +} // namespace android 1.102 +#endif // __cplusplus 1.103 + 1.104 +/*****************************************************************************/ 1.105 + 1.106 +#endif /* ANDROID_ANDROID_NATIVES_H */