media/omx-plugin/include/ics/ui/egl/android_natives.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 * Copyright (C) 2009 The Android Open Source Project
michael@0 3 *
michael@0 4 * Licensed under the Apache License, Version 2.0 (the "License");
michael@0 5 * you may not use this file except in compliance with the License.
michael@0 6 * You may obtain a copy of the License at
michael@0 7 *
michael@0 8 * http://www.apache.org/licenses/LICENSE-2.0
michael@0 9 *
michael@0 10 * Unless required by applicable law or agreed to in writing, software
michael@0 11 * distributed under the License is distributed on an "AS IS" BASIS,
michael@0 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
michael@0 13 * See the License for the specific language governing permissions and
michael@0 14 * limitations under the License.
michael@0 15 */
michael@0 16
michael@0 17 #ifndef ANDROID_ANDROID_NATIVES_H
michael@0 18 #define ANDROID_ANDROID_NATIVES_H
michael@0 19
michael@0 20 #include <sys/types.h>
michael@0 21 #include <string.h>
michael@0 22
michael@0 23 #include <hardware/gralloc.h>
michael@0 24 #include <system/window.h>
michael@0 25 // FIXME: remove this header, it's for legacy use. native_window is pulled from frameworks/base/native/include/android/
michael@0 26 #include <android/native_window.h>
michael@0 27 // ---------------------------------------------------------------------------
michael@0 28
michael@0 29 /* FIXME: this is legacy for pixmaps */
michael@0 30 typedef struct egl_native_pixmap_t
michael@0 31 {
michael@0 32 int32_t version; /* must be 32 */
michael@0 33 int32_t width;
michael@0 34 int32_t height;
michael@0 35 int32_t stride;
michael@0 36 uint8_t* data;
michael@0 37 uint8_t format;
michael@0 38 uint8_t rfu[3];
michael@0 39 union {
michael@0 40 uint32_t compressedFormat;
michael@0 41 int32_t vstride;
michael@0 42 };
michael@0 43 int32_t reserved;
michael@0 44 } egl_native_pixmap_t;
michael@0 45
michael@0 46 /*****************************************************************************/
michael@0 47
michael@0 48 #ifdef __cplusplus
michael@0 49
michael@0 50 #include <utils/RefBase.h>
michael@0 51
michael@0 52 namespace android {
michael@0 53
michael@0 54 /*
michael@0 55 * This helper class turns an EGL android_native_xxx type into a C++
michael@0 56 * reference-counted object; with proper type conversions.
michael@0 57 */
michael@0 58 template <typename NATIVE_TYPE, typename TYPE, typename REF>
michael@0 59 class EGLNativeBase : public NATIVE_TYPE, public REF
michael@0 60 {
michael@0 61 public:
michael@0 62 // Disambiguate between the incStrong in REF and NATIVE_TYPE
michael@0 63 void incStrong(const void* id) const {
michael@0 64 REF::incStrong(id);
michael@0 65 }
michael@0 66 void decStrong(const void* id) const {
michael@0 67 REF::decStrong(id);
michael@0 68 }
michael@0 69
michael@0 70 protected:
michael@0 71 typedef EGLNativeBase<NATIVE_TYPE, TYPE, REF> BASE;
michael@0 72 EGLNativeBase() : NATIVE_TYPE(), REF() {
michael@0 73 NATIVE_TYPE::common.incRef = incRef;
michael@0 74 NATIVE_TYPE::common.decRef = decRef;
michael@0 75 }
michael@0 76 static inline TYPE* getSelf(NATIVE_TYPE* self) {
michael@0 77 return static_cast<TYPE*>(self);
michael@0 78 }
michael@0 79 static inline TYPE const* getSelf(NATIVE_TYPE const* self) {
michael@0 80 return static_cast<TYPE const *>(self);
michael@0 81 }
michael@0 82 static inline TYPE* getSelf(android_native_base_t* base) {
michael@0 83 return getSelf(reinterpret_cast<NATIVE_TYPE*>(base));
michael@0 84 }
michael@0 85 static inline TYPE const * getSelf(android_native_base_t const* base) {
michael@0 86 return getSelf(reinterpret_cast<NATIVE_TYPE const*>(base));
michael@0 87 }
michael@0 88 static void incRef(android_native_base_t* base) {
michael@0 89 EGLNativeBase* self = getSelf(base);
michael@0 90 self->incStrong(self);
michael@0 91 }
michael@0 92 static void decRef(android_native_base_t* base) {
michael@0 93 EGLNativeBase* self = getSelf(base);
michael@0 94 self->decStrong(self);
michael@0 95 }
michael@0 96 };
michael@0 97
michael@0 98 } // namespace android
michael@0 99 #endif // __cplusplus
michael@0 100
michael@0 101 /*****************************************************************************/
michael@0 102
michael@0 103 #endif /* ANDROID_ANDROID_NATIVES_H */

mercurial