blob: 0a6e4fbd5e927309b107616036311f1e1c7f97dc [file] [log] [blame]
Mathias Agopian1473f462009-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 Hackborn8b49bd12010-06-30 13:56:17 -070025#include <android/native_window.h>
26
Mathias Agopian1473f462009-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 Agopian16a86ee2010-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 Agopian1473f462009-04-10 14:24:30 -070054// ---------------------------------------------------------------------------
55
Mathias Agopianf2339152009-08-13 17:57:53 -070056typedef struct android_native_base_t
Mathias Agopian1473f462009-04-10 14:24:30 -070057{
58 /* a magic value defined by the actual EGL native type */
59 int magic;
Eino-Ville Talvalac5f94d82011-02-18 11:02:42 -080060
Mathias Agopian1473f462009-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 Agopian2b895482009-08-17 12:33:20 -070067 void (*incRef)(struct android_native_base_t* base);
68 void (*decRef)(struct android_native_base_t* base);
Mathias Agopianf2339152009-08-13 17:57:53 -070069} android_native_base_t;
Mathias Agopian1473f462009-04-10 14:24:30 -070070
Mathias Agopian9bd5da42009-05-05 18:29:35 -070071// ---------------------------------------------------------------------------
Mathias Agopian1473f462009-04-10 14:24:30 -070072
Mathias Agopian5b5c9142009-07-30 18:14:56 -070073/* attributes queriable with query() */
74enum {
75 NATIVE_WINDOW_WIDTH = 0,
Mathias Agopian16a86ee2010-04-15 18:48:26 -070076 NATIVE_WINDOW_HEIGHT,
77 NATIVE_WINDOW_FORMAT,
Jamie Gennis96dcc972011-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 Gennisd2acedf2011-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 Gennisc4ca7c52011-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 Agopian5b5c9142009-07-30 18:14:56 -0700121};
122
Mathias Agopian5cec4742009-08-11 22:34:02 -0700123/* valid operations for the (*perform)() hook */
124enum {
Mathias Agopianf6331a42010-03-11 15:05:52 -0800125 NATIVE_WINDOW_SET_USAGE = 0,
Mathias Agopian16a86ee2010-04-15 18:48:26 -0700126 NATIVE_WINDOW_CONNECT,
127 NATIVE_WINDOW_DISCONNECT,
128 NATIVE_WINDOW_SET_CROP,
Mathias Agopian25f0bda2010-05-21 14:19:50 -0700129 NATIVE_WINDOW_SET_BUFFER_COUNT,
Mathias Agopian2be352a2010-05-21 17:24:35 -0700130 NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
Mathias Agopiane96aa3e2010-08-19 17:01:19 -0700131 NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
Eino-Ville Talvalac5f94d82011-02-18 11:02:42 -0800132 NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
Mathias Agopianf6331a42010-03-11 15:05:52 -0800133};
134
135/* parameter for NATIVE_WINDOW_[DIS]CONNECT */
136enum {
137 NATIVE_WINDOW_API_EGL = 1
Mathias Agopian5cec4742009-08-11 22:34:02 -0700138};
139
Mathias Agopiane96aa3e2010-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 Gennisc4ca7c52011-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 Talvalac5f94d82011-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 Agopian1473f462009-04-10 14:24:30 -0700170{
171#ifdef __cplusplus
Dianne Hackborn8b49bd12010-06-30 13:56:17 -0700172 ANativeWindow()
Mathias Agopian1473f462009-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 Hackborn8b49bd12010-06-30 13:56:17 -0700176 common.version = sizeof(ANativeWindow);
Mathias Agopian1473f462009-04-10 14:24:30 -0700177 memset(common.reserved, 0, sizeof(common.reserved));
178 }
Jamie Gennis505cef32010-05-10 17:33:32 -0700179
Dianne Hackborn8b49bd12010-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 Gennis505cef32010-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 Agopian1473f462009-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 Agopian1473f462009-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 Hackborn8b49bd12010-06-30 13:56:17 -0700214 int (*setSwapInterval)(struct ANativeWindow* window,
Mathias Agopian1473f462009-04-10 14:24:30 -0700215 int interval);
216
Mathias Agopian1473f462009-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 Agopiandff8e582009-05-04 14:17:04 -0700220 * this call may block if no buffers are available.
Mathias Agopian1473f462009-04-10 14:24:30 -0700221 *
222 * Returns 0 on success or -errno on error.
223 */
Dianne Hackborn8b49bd12010-06-30 13:56:17 -0700224 int (*dequeueBuffer)(struct ANativeWindow* window,
Mathias Agopian1473f462009-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 Hackborn8b49bd12010-06-30 13:56:17 -0700234 int (*lockBuffer)(struct ANativeWindow* window,
Mathias Agopian1473f462009-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 Hackborn8b49bd12010-06-30 13:56:17 -0700244 int (*queueBuffer)(struct ANativeWindow* window,
Mathias Agopian1473f462009-04-10 14:24:30 -0700245 struct android_native_buffer_t* buffer);
246
Mathias Agopian5b5c9142009-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 Hackborn8b49bd12010-06-30 13:56:17 -0700252 int (*query)(struct ANativeWindow* window,
Mathias Agopian5cec4742009-08-11 22:34:02 -0700253 int what, int* value);
Mathias Agopian1473f462009-04-10 14:24:30 -0700254
Mathias Agopian5cec4742009-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 Hackborn8b49bd12010-06-30 13:56:17 -0700258 * ANativeWindow while keeping backward binary compatibility.
Mathias Agopian5cec4742009-08-11 22:34:02 -0700259 *
260 * This hook should not be called directly, instead use the helper functions
261 * defined below.
262 *
Mathias Agopianf6331a42010-03-11 15:05:52 -0800263 * (*perform)() returns -ENOENT if the 'what' parameter is not supported
264 * by the surface's implementation.
265 *
Mathias Agopian5cec4742009-08-11 22:34:02 -0700266 * The valid operations are:
267 * NATIVE_WINDOW_SET_USAGE
Mathias Agopianf6331a42010-03-11 15:05:52 -0800268 * NATIVE_WINDOW_CONNECT
269 * NATIVE_WINDOW_DISCONNECT
Mathias Agopian16a86ee2010-04-15 18:48:26 -0700270 * NATIVE_WINDOW_SET_CROP
Mathias Agopian25f0bda2010-05-21 14:19:50 -0700271 * NATIVE_WINDOW_SET_BUFFER_COUNT
Mathias Agopian2be352a2010-05-21 17:24:35 -0700272 * NATIVE_WINDOW_SET_BUFFERS_GEOMETRY
Mathias Agopiane96aa3e2010-08-19 17:01:19 -0700273 * NATIVE_WINDOW_SET_BUFFERS_TRANSFORM
Eino-Ville Talvalac5f94d82011-02-18 11:02:42 -0800274 * NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
275 *
Mathias Agopian5cec4742009-08-11 22:34:02 -0700276 */
277
Dianne Hackborn8b49bd12010-06-30 13:56:17 -0700278 int (*perform)(struct ANativeWindow* window,
Mathias Agopian5cec4742009-08-11 22:34:02 -0700279 int operation, ... );
280
Mathias Agopian8ddd2c72010-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 Hackborn8b49bd12010-06-30 13:56:17 -0700292};
Mathias Agopian1473f462009-04-10 14:24:30 -0700293
Mathias Agopian2c341902011-03-30 15:28:21 -0700294// Backwards compatibility... please switch to ANativeWindow.
295typedef struct ANativeWindow android_native_window_t;
296
Mathias Agopian5cec4742009-08-11 22:34:02 -0700297/*
Mathias Agopian25f0bda2010-05-21 14:19:50 -0700298 * native_window_set_usage(..., usage)
299 * Sets the intended usage flags for the next buffers
300 * acquired with (*lockBuffer)() and on.
Mathias Agopian5cec4742009-08-11 22:34:02 -0700301 * By default (if this function is never called), a usage of
302 * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE
303 * is assumed.
304 * Calling this function will usually cause following buffers to be
305 * reallocated.
306 */
307
Dima Zavin8db93382009-08-13 16:50:54 -0700308static inline int native_window_set_usage(
Dianne Hackborn8b49bd12010-06-30 13:56:17 -0700309 ANativeWindow* window, int usage)
Mathias Agopian5cec4742009-08-11 22:34:02 -0700310{
311 return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
312}
313
Mathias Agopianf6331a42010-03-11 15:05:52 -0800314/*
Mathias Agopian25f0bda2010-05-21 14:19:50 -0700315 * native_window_connect(..., NATIVE_WINDOW_API_EGL)
316 * Must be called by EGL when the window is made current.
Mathias Agopianf6331a42010-03-11 15:05:52 -0800317 * Returns -EINVAL if for some reason the window cannot be connected, which
318 * can happen if it's connected to some other API.
319 */
320static inline int native_window_connect(
Dianne Hackborn8b49bd12010-06-30 13:56:17 -0700321 ANativeWindow* window, int api)
Mathias Agopianf6331a42010-03-11 15:05:52 -0800322{
323 return window->perform(window, NATIVE_WINDOW_CONNECT, api);
324}
325
326/*
Mathias Agopian25f0bda2010-05-21 14:19:50 -0700327 * native_window_disconnect(..., NATIVE_WINDOW_API_EGL)
328 * Must be called by EGL when the window is made not current.
Mathias Agopianf6331a42010-03-11 15:05:52 -0800329 * An error is returned if for instance the window wasn't connected in the
330 * first place.
331 */
332static inline int native_window_disconnect(
Dianne Hackborn8b49bd12010-06-30 13:56:17 -0700333 ANativeWindow* window, int api)
Mathias Agopianf6331a42010-03-11 15:05:52 -0800334{
335 return window->perform(window, NATIVE_WINDOW_DISCONNECT, api);
336}
337
Mathias Agopian16a86ee2010-04-15 18:48:26 -0700338/*
Mathias Agopian25f0bda2010-05-21 14:19:50 -0700339 * native_window_set_crop(..., crop)
340 * Sets which region of the next queued buffers needs to be considered.
Mathias Agopian16a86ee2010-04-15 18:48:26 -0700341 * A buffer's crop region is scaled to match the surface's size.
342 *
343 * The specified crop region applies to all buffers queued after it is called.
344 *
345 * if 'crop' is NULL, subsequently queued buffers won't be cropped.
346 *
347 * An error is returned if for instance the crop region is invalid,
348 * out of the buffer's bound or if the window is invalid.
349 */
350static inline int native_window_set_crop(
Dianne Hackborn8b49bd12010-06-30 13:56:17 -0700351 ANativeWindow* window,
Mathias Agopian16a86ee2010-04-15 18:48:26 -0700352 android_native_rect_t const * crop)
353{
354 return window->perform(window, NATIVE_WINDOW_SET_CROP, crop);
355}
Mathias Agopian5cec4742009-08-11 22:34:02 -0700356
Mathias Agopian25f0bda2010-05-21 14:19:50 -0700357/*
358 * native_window_set_buffer_count(..., count)
359 * Sets the number of buffers associated with this native window.
360 */
361static inline int native_window_set_buffer_count(
Dianne Hackborn8b49bd12010-06-30 13:56:17 -0700362 ANativeWindow* window,
Mathias Agopian25f0bda2010-05-21 14:19:50 -0700363 size_t bufferCount)
364{
365 return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount);
366}
367
Mathias Agopian2be352a2010-05-21 17:24:35 -0700368/*
369 * native_window_set_buffers_geometry(..., int w, int h, int format)
370 * All buffers dequeued after this call will have the geometry specified.
371 * In particular, all buffers will have a fixed-size, independent form the
372 * native-window size. They will be appropriately scaled to the window-size
373 * upon composition.
374 *
375 * If all parameters are 0, the normal behavior is restored. That is,
376 * dequeued buffers following this call will be sized to the window's size.
377 *
Jamie Gennis2ece4cd2011-01-28 18:21:54 -0800378 * Calling this function will reset the window crop to a NULL value, which
379 * disables cropping of the buffers.
Mathias Agopian2be352a2010-05-21 17:24:35 -0700380 */
381static inline int native_window_set_buffers_geometry(
Dianne Hackborn8b49bd12010-06-30 13:56:17 -0700382 ANativeWindow* window,
Mathias Agopian2be352a2010-05-21 17:24:35 -0700383 int w, int h, int format)
384{
385 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY,
386 w, h, format);
387}
388
Mathias Agopiane96aa3e2010-08-19 17:01:19 -0700389/*
390 * native_window_set_buffers_transform(..., int transform)
391 * All buffers queued after this call will be displayed transformed according
392 * to the transform parameter specified.
393 */
394static inline int native_window_set_buffers_transform(
395 ANativeWindow* window,
396 int transform)
397{
398 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM,
399 transform);
400}
401
Eino-Ville Talvalac5f94d82011-02-18 11:02:42 -0800402/*
403 * native_window_set_buffers_timestamp(..., int64_t timestamp)
404 * All buffers queued after this call will be associated with the timestamp
405 * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO
406 * (the default), timestamps will be generated automatically when queueBuffer is
407 * called. The timestamp is measured in nanoseconds, and must be monotonically
408 * increasing.
409 */
410static inline int native_window_set_buffers_timestamp(
411 ANativeWindow* window,
412 int64_t timestamp)
413{
414 return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP,
415 timestamp);
416}
417
Mathias Agopian9bd5da42009-05-05 18:29:35 -0700418// ---------------------------------------------------------------------------
Mathias Agopian1473f462009-04-10 14:24:30 -0700419
Mathias Agopian1473f462009-04-10 14:24:30 -0700420/* FIXME: this is legacy for pixmaps */
Mathias Agopianf2339152009-08-13 17:57:53 -0700421typedef struct egl_native_pixmap_t
Mathias Agopian1473f462009-04-10 14:24:30 -0700422{
423 int32_t version; /* must be 32 */
424 int32_t width;
425 int32_t height;
426 int32_t stride;
427 uint8_t* data;
428 uint8_t format;
429 uint8_t rfu[3];
430 union {
431 uint32_t compressedFormat;
432 int32_t vstride;
433 };
434 int32_t reserved;
Mathias Agopianf2339152009-08-13 17:57:53 -0700435} egl_native_pixmap_t;
Mathias Agopian1473f462009-04-10 14:24:30 -0700436
437/*****************************************************************************/
438
439#ifdef __cplusplus
440}
441#endif
442
443
444/*****************************************************************************/
445
446#ifdef __cplusplus
447
448#include <utils/RefBase.h>
449
450namespace android {
451
452/*
453 * This helper class turns an EGL android_native_xxx type into a C++
454 * reference-counted object; with proper type conversions.
455 */
456template <typename NATIVE_TYPE, typename TYPE, typename REF>
457class EGLNativeBase : public NATIVE_TYPE, public REF
458{
Jamie Gennis505cef32010-05-10 17:33:32 -0700459public:
460 // Disambiguate between the incStrong in REF and NATIVE_TYPE
461 void incStrong(const void* id) const {
462 REF::incStrong(id);
463 }
464 void decStrong(const void* id) const {
465 REF::decStrong(id);
466 }
467
Mathias Agopian1473f462009-04-10 14:24:30 -0700468protected:
469 typedef EGLNativeBase<NATIVE_TYPE, TYPE, REF> BASE;
470 EGLNativeBase() : NATIVE_TYPE(), REF() {
471 NATIVE_TYPE::common.incRef = incRef;
472 NATIVE_TYPE::common.decRef = decRef;
473 }
474 static inline TYPE* getSelf(NATIVE_TYPE* self) {
475 return static_cast<TYPE*>(self);
476 }
477 static inline TYPE const* getSelf(NATIVE_TYPE const* self) {
478 return static_cast<TYPE const *>(self);
479 }
480 static inline TYPE* getSelf(android_native_base_t* base) {
481 return getSelf(reinterpret_cast<NATIVE_TYPE*>(base));
482 }
483 static inline TYPE const * getSelf(android_native_base_t const* base) {
484 return getSelf(reinterpret_cast<NATIVE_TYPE const*>(base));
485 }
486 static void incRef(android_native_base_t* base) {
487 EGLNativeBase* self = getSelf(base);
488 self->incStrong(self);
489 }
490 static void decRef(android_native_base_t* base) {
491 EGLNativeBase* self = getSelf(base);
492 self->decStrong(self);
493 }
494};
495
496} // namespace android
497#endif // __cplusplus
498
499/*****************************************************************************/
500
501#endif /* ANDROID_ANDROID_NATIVES_H */