Path: blob/21.2-virgl/include/android_stub/nativebase/nativebase.h
4547 views
/*1* Copyright (C) 2017 The Android Open Source Project2*3* Licensed under the Apache License, Version 2.0 (the "License");4* you may not use this file except in compliance with the License.5* You may obtain a copy of the License at6*7* http://www.apache.org/licenses/LICENSE-2.08*9* Unless required by applicable law or agreed to in writing, software10* distributed under the License is distributed on an "AS IS" BASIS,11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12* See the License for the specific language governing permissions and13* limitations under the License.14*/1516#pragma once1718#include <stdint.h>19#include <stdbool.h>20#include <string.h>21#include <sys/cdefs.h>22#include <system/graphics-base.h>23#include <cutils/native_handle.h>2425__BEGIN_DECLS2627#ifdef __cplusplus28#define ANDROID_NATIVE_UNSIGNED_CAST(x) static_cast<unsigned int>(x)29#else30#define ANDROID_NATIVE_UNSIGNED_CAST(x) ((unsigned int)(x))31#endif3233#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \34((ANDROID_NATIVE_UNSIGNED_CAST(a) << 24) | \35(ANDROID_NATIVE_UNSIGNED_CAST(b) << 16) | \36(ANDROID_NATIVE_UNSIGNED_CAST(c) << 8) | \37(ANDROID_NATIVE_UNSIGNED_CAST(d)))3839#define ANDROID_NATIVE_BUFFER_MAGIC ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r')404142typedef struct android_native_base_t43{44/* a magic value defined by the actual EGL native type */45int magic;4647/* the sizeof() of the actual EGL native type */48int version;4950void* reserved[4];5152/* reference-counting interface */53void (*incRef)(struct android_native_base_t* base);54void (*decRef)(struct android_native_base_t* base);55} android_native_base_t;5657typedef struct android_native_rect_t58{59int32_t left;60int32_t top;61int32_t right;62int32_t bottom;63} android_native_rect_t;6465typedef struct ANativeWindowBuffer66{67#ifdef __cplusplus68ANativeWindowBuffer() {69common.magic = ANDROID_NATIVE_BUFFER_MAGIC;70common.version = sizeof(ANativeWindowBuffer);71memset(common.reserved, 0, sizeof(common.reserved));72}7374// Implement the methods that sp<ANativeWindowBuffer> expects so that it75// can be used to automatically refcount ANativeWindowBuffer's.76void incStrong(const void* /*id*/) const {77common.incRef(const_cast<android_native_base_t*>(&common));78}79void decStrong(const void* /*id*/) const {80common.decRef(const_cast<android_native_base_t*>(&common));81}82#endif8384struct android_native_base_t common;8586int width;87int height;88int stride;89int format;90int usage_deprecated;91uintptr_t layerCount;9293void* reserved[1];9495const native_handle_t* handle;96uint64_t usage;9798// we needed extra space for storing the 64-bits usage flags99// the number of slots to use from reserved_proc depends on the100// architecture.101void* reserved_proc[8 - (sizeof(uint64_t) / sizeof(void*))];102} ANativeWindowBuffer_t;103104typedef struct ANativeWindowBuffer ANativeWindowBuffer;105106// Old typedef for backwards compatibility.107typedef ANativeWindowBuffer_t android_native_buffer_t;108109__END_DECLS110111112