blob: 972e799962308c752f32feab5b4ff8ae14782778 [file] [log] [blame]
Mathias Agopian076b1cc2009-04-10 14:24:30 -07001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_ANDROID_NATIVES_H
18#define ANDROID_ANDROID_NATIVES_H
19
20#include <sys/types.h>
21#include <string.h>
22
23#include <hardware/gralloc.h>
24
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -070025#include <android/native_window.h>
26
Mathias Agopian076b1cc2009-04-10 14:24:30 -070027#ifdef __cplusplus
28extern "C" {
29#endif
30
31/*****************************************************************************/
32
33#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \
34 (((unsigned)(a)<<24)|((unsigned)(b)<<16)|((unsigned)(c)<<8)|(unsigned)(d))
35
36#define ANDROID_NATIVE_WINDOW_MAGIC \
37 ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d')
38
39#define ANDROID_NATIVE_BUFFER_MAGIC \
40 ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r')
41
42// ---------------------------------------------------------------------------
43
44struct android_native_buffer_t;
45
Mathias Agopiancc08e682010-04-15 18:48:26 -070046typedef struct android_native_rect_t
47{
48 int32_t left;
49 int32_t top;
50 int32_t right;
51 int32_t bottom;
52} android_native_rect_t;
53
Mathias Agopian076b1cc2009-04-10 14:24:30 -070054// ---------------------------------------------------------------------------
55
Mathias Agopian238a66e2009-08-13 17:57:53 -070056typedef struct android_native_base_t
Mathias Agopian076b1cc2009-04-10 14:24:30 -070057{
58 /* a magic value defined by the actual EGL native type */
59 int magic;
Eino-Ville Talvala1d01a122011-02-18 11:02:42 -080060
Mathias Agopian076b1cc2009-04-10 14:24:30 -070061 /* the sizeof() of the actual EGL native type */
62 int version;
63
64 void* reserved[4];
65
66 /* reference-counting interface */
Mathias Agopian37b2a372009-08-17 12:33:20 -070067 void (*incRef)(struct android_native_base_t* base);
68 void (*decRef)(struct android_native_base_t* base);
Mathias Agopian238a66e2009-08-13 17:57:53 -070069} android_native_base_t;
Mathias Agopian076b1cc2009-04-10 14:24:30 -070070
Mathias Agopianaa8c0ff2009-05-05 18:29:35 -070071// ---------------------------------------------------------------------------
Mathias Agopian076b1cc2009-04-10 14:24:30 -070072
Mathias Agopiancb6b9042009-07-30 18:14:56 -070073/* attributes queriable with query() */
74enum {
75 NATIVE_WINDOW_WIDTH = 0,
Mathias Agopiancc08e682010-04-15 18:48:26 -070076 NATIVE_WINDOW_HEIGHT,
77 NATIVE_WINDOW_FORMAT,
Jamie Gennis9d4d6c12011-02-27 14:10:20 -080078
79 /* The minimum number of buffers that must remain un-dequeued after a buffer
80 * has been queued. This value applies only if set_buffer_count was used to
81 * override the number of buffers and if a buffer has since been queued.
82 * Users of the set_buffer_count ANativeWindow method should query this
83 * value before calling set_buffer_count. If it is necessary to have N
84 * buffers simultaneously dequeued as part of the steady-state operation,
85 * and this query returns M then N+M buffers should be requested via
86 * native_window_set_buffer_count.
87 *
88 * Note that this value does NOT apply until a single buffer has been
89 * queued. In particular this means that it is possible to:
90 *
91 * 1. Query M = min undequeued buffers
92 * 2. Set the buffer count to N + M
93 * 3. Dequeue all N + M buffers
94 * 4. Cancel M buffers
95 * 5. Queue, dequeue, queue, dequeue, ad infinitum
96 */
97 NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
Jamie Gennis134f0422011-03-08 12:18:54 -080098
99 /* Check whether queueBuffer operations on the ANativeWindow send the buffer
100 * to the window compositor. The query sets the returned 'value' argument
101 * to 1 if the ANativeWindow DOES send queued buffers directly to the window
102 * compositor and 0 if the buffers do not go directly to the window
103 * compositor.
104 *
105 * This can be used to determine whether protected buffer content should be
106 * sent to the ANativeWindow. Note, however, that a result of 1 does NOT
107 * indicate that queued buffers will be protected from applications or users
108 * capturing their contents. If that behavior is desired then some other
109 * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in
110 * conjunction with this query.
111 */
112 NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER,
Jamie Gennis391bbe22011-03-14 15:00:06 -0700113
114 /* Get the concrete type of a ANativeWindow. See below for the list of
115 * possible return values.
116 *
117 * This query should not be used outside the Android framework and will
118 * likely be removed in the near future.
119 */
120 NATIVE_WINDOW_CONCRETE_TYPE,
Mathias Agopiancb6b9042009-07-30 18:14:56 -0700121};
122
Mathias Agopian52212712009-08-11 22:34:02 -0700123/* valid operations for the (*perform)() hook */
124enum {
Mathias Agopiane156e642010-03-11 15:05:52 -0800125 NATIVE_WINDOW_SET_USAGE = 0,
Mathias Agopiancc08e682010-04-15 18:48:26 -0700126 NATIVE_WINDOW_CONNECT,
127 NATIVE_WINDOW_DISCONNECT,
128 NATIVE_WINDOW_SET_CROP,
Mathias Agopianf10d7fd2010-05-21 14:19:50 -0700129 NATIVE_WINDOW_SET_BUFFER_COUNT,
Mathias Agopiana138f892010-05-21 17:24:35 -0700130 NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
Mathias Agopianb661d662010-08-19 17:01:19 -0700131 NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
Eino-Ville Talvala1d01a122011-02-18 11:02:42 -0800132 NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
Mathias Agopiane156e642010-03-11 15:05:52 -0800133};
134
135/* parameter for NATIVE_WINDOW_[DIS]CONNECT */
136enum {
137 NATIVE_WINDOW_API_EGL = 1
Mathias Agopian52212712009-08-11 22:34:02 -0700138};
139
Mathias Agopianb661d662010-08-19 17:01:19 -0700140/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */
141enum {
142 /* flip source image horizontally */
143 NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H ,
144 /* flip source image vertically */
145 NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
146 /* rotate source image 90 degrees clock-wise */
147 NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
148 /* rotate source image 180 degrees */
149 NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
150 /* rotate source image 270 degrees clock-wise */
151 NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
152};
153
Jamie Gennis391bbe22011-03-14 15:00:06 -0700154/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */
155enum {
156 NATIVE_WINDOW_FRAMEBUFFER, // FramebufferNativeWindow
157 NATIVE_WINDOW_SURFACE, // Surface
158 NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT, // SurfaceTextureClient
159};
160
Eino-Ville Talvala1d01a122011-02-18 11:02:42 -0800161/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
162 *
163 * Special timestamp value to indicate that timestamps should be auto-generated
164 * by the native window when queueBuffer is called. This is equal to INT64_MIN,
165 * defined directly to avoid problems with C99/C++ inclusion of stdint.h.
166 */
167const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1);
168
169struct ANativeWindow
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700170{
171#ifdef __cplusplus
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -0700172 ANativeWindow()
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700173 : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0)
174 {
175 common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -0700176 common.version = sizeof(ANativeWindow);
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700177 memset(common.reserved, 0, sizeof(common.reserved));
178 }
Jamie Gennis5e67f872010-05-10 17:33:32 -0700179
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -0700180 // Implement the methods that sp<ANativeWindow> expects so that it
181 // can be used to automatically refcount ANativeWindow's.
Jamie Gennis5e67f872010-05-10 17:33:32 -0700182 void incStrong(const void* id) const {
183 common.incRef(const_cast<android_native_base_t*>(&common));
184 }
185 void decStrong(const void* id) const {
186 common.decRef(const_cast<android_native_base_t*>(&common));
187 }
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700188#endif
189
190 struct android_native_base_t common;
191
192 /* flags describing some attributes of this surface or its updater */
193 const uint32_t flags;
194
195 /* min swap interval supported by this updated */
196 const int minSwapInterval;
197
198 /* max swap interval supported by this updated */
199 const int maxSwapInterval;
200
201 /* horizontal and vertical resolution in DPI */
202 const float xdpi;
203 const float ydpi;
204
205 /* Some storage reserved for the OEM's driver. */
206 intptr_t oem[4];
207
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700208
209 /*
210 * Set the swap interval for this surface.
211 *
212 * Returns 0 on success or -errno on error.
213 */
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -0700214 int (*setSwapInterval)(struct ANativeWindow* window,
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700215 int interval);
216
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700217 /*
218 * hook called by EGL to acquire a buffer. After this call, the buffer
219 * is not locked, so its content cannot be modified.
Mathias Agopian0926f502009-05-04 14:17:04 -0700220 * this call may block if no buffers are available.
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700221 *
222 * Returns 0 on success or -errno on error.
223 */
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -0700224 int (*dequeueBuffer)(struct ANativeWindow* window,
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700225 struct android_native_buffer_t** buffer);
226
227 /*
228 * hook called by EGL to lock a buffer. This MUST be called before modifying
229 * the content of a buffer. The buffer must have been acquired with
230 * dequeueBuffer first.
231 *
232 * Returns 0 on success or -errno on error.
233 */
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -0700234 int (*lockBuffer)(struct ANativeWindow* window,
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700235 struct android_native_buffer_t* buffer);
236 /*
237 * hook called by EGL when modifications to the render buffer are done.
238 * This unlocks and post the buffer.
239 *
240 * Buffers MUST be queued in the same order than they were dequeued.
241 *
242 * Returns 0 on success or -errno on error.
243 */
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -0700244 int (*queueBuffer)(struct ANativeWindow* window,
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700245 struct android_native_buffer_t* buffer);
246
Mathias Agopiancb6b9042009-07-30 18:14:56 -0700247 /*
248 * hook used to retrieve information about the native window.
249 *
250 * Returns 0 on success or -errno on error.
251 */
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -0700252 int (*query)(struct ANativeWindow* window,
Mathias Agopian52212712009-08-11 22:34:02 -0700253 int what, int* value);
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700254
Mathias Agopian52212712009-08-11 22:34:02 -0700255 /*
256 * hook used to perform various operations on the surface.
257 * (*perform)() is a generic mechanism to add functionality to
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -0700258 * ANativeWindow while keeping backward binary compatibility.
Mathias Agopian52212712009-08-11 22:34:02 -0700259 *
260 * This hook should not be called directly, instead use the helper functions
261 * defined below.
262 *
Mathias Agopiane156e642010-03-11 15:05:52 -0800263 * (*perform)() returns -ENOENT if the 'what' parameter is not supported
264 * by the surface's implementation.
265 *
Mathias Agopian52212712009-08-11 22:34:02 -0700266 * The valid operations are:
267 * NATIVE_WINDOW_SET_USAGE
Mathias Agopiane156e642010-03-11 15:05:52 -0800268 * NATIVE_WINDOW_CONNECT
269 * NATIVE_WINDOW_DISCONNECT
Mathias Agopiancc08e682010-04-15 18:48:26 -0700270 * NATIVE_WINDOW_SET_CROP
Mathias Agopianf10d7fd2010-05-21 14:19:50 -0700271 * NATIVE_WINDOW_SET_BUFFER_COUNT
Mathias Agopiana138f892010-05-21 17:24:35 -0700272 * NATIVE_WINDOW_SET_BUFFERS_GEOMETRY
Mathias Agopianb661d662010-08-19 17:01:19 -0700273 * NATIVE_WINDOW_SET_BUFFERS_TRANSFORM
Eino-Ville Talvala1d01a122011-02-18 11:02:42 -0800274 * NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
275 *
Mathias Agopian52212712009-08-11 22:34:02 -0700276 */
277
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -0700278 int (*perform)(struct ANativeWindow* window,
Mathias Agopian52212712009-08-11 22:34:02 -0700279 int operation, ... );
280
Mathias Agopian19957552010-10-01 16:22:41 -0700281 /*
282 * hook used to cancel a buffer that has been dequeued.
283 * No synchronization is performed between dequeue() and cancel(), so
284 * either external synchronization is needed, or these functions must be
285 * called from the same thread.
286 */
287 int (*cancelBuffer)(struct ANativeWindow* window,
288 struct android_native_buffer_t* buffer);
289
290
291 void* reserved_proc[2];
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -0700292};
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700293
Mathias Agopian52212712009-08-11 22:34:02 -0700294/*
Mathias Agopianf10d7fd2010-05-21 14:19:50 -0700295 * native_window_set_usage(..., usage)
296 * Sets the intended usage flags for the next buffers
297 * acquired with (*lockBuffer)() and on.
Mathias Agopian52212712009-08-11 22:34:02 -0700298 * By default (if this function is never called), a usage of
299 * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
300 * is assumed.
301 * Calling this function will usually cause following buffers to be
302 * reallocated.
303 */
304
Dima Zavinfae3e732009-08-13 16:50:54 -0700305static inline int native_window_set_usage(
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -0700306 ANativeWindow* window, int usage)
Mathias Agopian52212712009-08-11 22:34:02 -0700307{
308 return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
309}
310
Mathias Agopiane156e642010-03-11 15:05:52 -0800311/*
Mathias Agopianf10d7fd2010-05-21 14:19:50 -0700312 * native_window_connect(..., NATIVE_WINDOW_API_EGL)
313 * Must be called by EGL when the window is made current.
Mathias Agopiane156e642010-03-11 15:05:52 -0800314 * Returns -EINVAL if for some reason the window cannot be connected, which
315 * can happen if it's connected to some other API.
316 */
317static inline int native_window_connect(
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -0700318 ANativeWindow* window, int api)
Mathias Agopiane156e642010-03-11 15:05:52 -0800319{
320 return window->perform(window, NATIVE_WINDOW_CONNECT, api);
321}
322
323/*
Mathias Agopianf10d7fd2010-05-21 14:19:50 -0700324 * native_window_disconnect(..., NATIVE_WINDOW_API_EGL)
325 * Must be called by EGL when the window is made not current.
Mathias Agopiane156e642010-03-11 15:05:52 -0800326 * An error is returned if for instance the window wasn't connected in the
327 * first place.
328 */
329static inline int native_window_disconnect(
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -0700330 ANativeWindow* window, int api)
Mathias Agopiane156e642010-03-11 15:05:52 -0800331{
332 return window->perform(window, NATIVE_WINDOW_DISCONNECT, api);
333}
334
Mathias Agopiancc08e682010-04-15 18:48:26 -0700335/*
Mathias Agopianf10d7fd2010-05-21 14:19:50 -0700336 * native_window_set_crop(..., crop)
337 * Sets which region of the next queued buffers needs to be considered.
Mathias Agopiancc08e682010-04-15 18:48:26 -0700338 * A buffer's crop region is scaled to match the surface's size.
339 *
340 * The specified crop region applies to all buffers queued after it is called.
341 *
342 * if 'crop' is NULL, subsequently queued buffers won't be cropped.
343 *
344 * An error is returned if for instance the crop region is invalid,
345 * out of the buffer's bound or if the window is invalid.
346 */
347static inline int native_window_set_crop(
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -0700348 ANativeWindow* window,
Mathias Agopiancc08e682010-04-15 18:48:26 -0700349 android_native_rect_t const * crop)
350{
351 return window->perform(window, NATIVE_WINDOW_SET_CROP, crop);
352}
Mathias Agopian52212712009-08-11 22:34:02 -0700353
Mathias Agopianf10d7fd2010-05-21 14:19:50 -0700354/*
355 * native_window_set_buffer_count(..., count)
356 * Sets the number of buffers associated with this native window.
357 */
358static inline int native_window_set_buffer_count(
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -0700359 ANativeWindow* window,
Mathias Agopianf10d7fd2010-05-21 14:19:50 -0700360 size_t bufferCount)
361{
362 return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount);
363}
364
Mathias Agopiana138f892010-05-21 17:24:35 -0700365/*
366 * native_window_set_buffers_geometry(..., int w, int h, int format)
367 * All buffers dequeued after this call will have the geometry specified.
368 * In particular, all buffers will have a fixed-size, independent form the
369 * native-window size. They will be appropriately scaled to the window-size
370 * upon composition.
371 *
372 * If all parameters are 0, the normal behavior is restored. That is,
373 * dequeued buffers following this call will be sized to the window's size.
374 *
Jamie Gennis68f91272011-01-28 18:21:54 -0800375 * Calling this function will reset the window crop to a NULL value, which
376 * disables cropping of the buffers.
Mathias Agopiana138f892010-05-21 17:24:35 -0700377 */
378static inline int native_window_set_buffers_geometry(
Dianne Hackborn4b5e91e2010-06-30 13:56:17 -0700379 ANativeWindow* window,
Mathias Agopiana138f892010-05-21 17:24:35 -0700380 int w, int h, int format)
381{
382 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
383 w, h, format);
384}
385
Mathias Agopianb661d662010-08-19 17:01:19 -0700386/*
387 * native_window_set_buffers_transform(..., int transform)
388 * All buffers queued after this call will be displayed transformed according
389 * to the transform parameter specified.
390 */
391static inline int native_window_set_buffers_transform(
392 ANativeWindow* window,
393 int transform)
394{
395 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
396 transform);
397}
398
Eino-Ville Talvala1d01a122011-02-18 11:02:42 -0800399/*
400 * native_window_set_buffers_timestamp(..., int64_t timestamp)
401 * All buffers queued after this call will be associated with the timestamp
402 * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO
403 * (the default), timestamps will be generated automatically when queueBuffer is
404 * called. The timestamp is measured in nanoseconds, and must be monotonically
405 * increasing.
406 */
407static inline int native_window_set_buffers_timestamp(
408 ANativeWindow* window,
409 int64_t timestamp)
410{
411 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
412 timestamp);
413}
414
Mathias Agopianaa8c0ff2009-05-05 18:29:35 -0700415// ---------------------------------------------------------------------------
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700416
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700417/* FIXME: this is legacy for pixmaps */
Mathias Agopian238a66e2009-08-13 17:57:53 -0700418typedef struct egl_native_pixmap_t
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700419{
420 int32_t version; /* must be 32 */
421 int32_t width;
422 int32_t height;
423 int32_t stride;
424 uint8_t* data;
425 uint8_t format;
426 uint8_t rfu[3];
427 union {
428 uint32_t compressedFormat;
429 int32_t vstride;
430 };
431 int32_t reserved;
Mathias Agopian238a66e2009-08-13 17:57:53 -0700432} egl_native_pixmap_t;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700433
434/*****************************************************************************/
435
436#ifdef __cplusplus
437}
438#endif
439
440
441/*****************************************************************************/
442
443#ifdef __cplusplus
444
445#include <utils/RefBase.h>
446
447namespace android {
448
449/*
450 * This helper class turns an EGL android_native_xxx type into a C++
451 * reference-counted object; with proper type conversions.
452 */
453template <typename NATIVE_TYPE, typename TYPE, typename REF>
454class EGLNativeBase : public NATIVE_TYPE, public REF
455{
Jamie Gennis5e67f872010-05-10 17:33:32 -0700456public:
457 // Disambiguate between the incStrong in REF and NATIVE_TYPE
458 void incStrong(const void* id) const {
459 REF::incStrong(id);
460 }
461 void decStrong(const void* id) const {
462 REF::decStrong(id);
463 }
464
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700465protected:
466 typedef EGLNativeBase<NATIVE_TYPE, TYPE, REF> BASE;
467 EGLNativeBase() : NATIVE_TYPE(), REF() {
468 NATIVE_TYPE::common.incRef = incRef;
469 NATIVE_TYPE::common.decRef = decRef;
470 }
471 static inline TYPE* getSelf(NATIVE_TYPE* self) {
472 return static_cast<TYPE*>(self);
473 }
474 static inline TYPE const* getSelf(NATIVE_TYPE const* self) {
475 return static_cast<TYPE const *>(self);
476 }
477 static inline TYPE* getSelf(android_native_base_t* base) {
478 return getSelf(reinterpret_cast<NATIVE_TYPE*>(base));
479 }
480 static inline TYPE const * getSelf(android_native_base_t const* base) {
481 return getSelf(reinterpret_cast<NATIVE_TYPE const*>(base));
482 }
483 static void incRef(android_native_base_t* base) {
484 EGLNativeBase* self = getSelf(base);
485 self->incStrong(self);
486 }
487 static void decRef(android_native_base_t* base) {
488 EGLNativeBase* self = getSelf(base);
489 self->decStrong(self);
490 }
491};
492
493} // namespace android
494#endif // __cplusplus
495
496/*****************************************************************************/
497
498#endif /* ANDROID_ANDROID_NATIVES_H */