forked from aharter/android_vendor_rpi_libgralloc_brcm
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgralloc_brcm.cpp
More file actions
67 lines (56 loc) · 2.33 KB
/
Copy pathgralloc_brcm.cpp
File metadata and controls
67 lines (56 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* "gralloc" (not in Android terms) to add missing functions to raspberry pi userland driver.
*
* Copyright (C) 2013 Andreas Harter - RazDroid project
*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "gralloc_brcm_def.h"
#include "gralloc_brcm.h"
#include "gralloc_priv.h"
#include <system/window.h>
EGL_DISPMANX_WINDOW_T* gralloc_private_handle_from_native_window(EGLNativeWindowType window)
{
EGL_DISPMANX_WINDOW_T *win = (EGL_DISPMANX_WINDOW_T*) malloc(sizeof(EGL_DISPMANX_WINDOW_T));
ANativeWindow* native_window = (ANativeWindow*) window;
native_window->query(native_window, NATIVE_WINDOW_HEIGHT, &(win->height));
native_window->query(native_window, NATIVE_WINDOW_WIDTH, &(win->width));
LOGD("gralloc_private_handle_from_native_window w: %d, h %d", win->width, win->height);
return win;
}
gralloc_private_handle_t* gralloc_private_handle_from_client_buffer(EGLClientBuffer buffer)
{
ANativeWindowBuffer* native_buffer = (ANativeWindowBuffer*) buffer;
private_handle_t* private_handle = (private_handle_t*) native_buffer->handle;
return private_handle->brcm_handle;
}
uint32_t gralloc_private_handle_get_res_type(gralloc_private_handle_t* private_handle)
{
return private_handle->res_type;
}
uint32_t gralloc_private_handle_get_vc_handle(gralloc_private_handle_t *private_handle)
{
return (uint32_t) private_handle->dispman_resource;
}
uint32_t gralloc_private_handle_get_egl_image(gralloc_private_handle_t *private_handle)
{
//GRALLOC_PRIV_TYPE_GL_RESOURCE or GRALLOC_PRIV_TYPE_MM_RESOURCE
return (uint32_t) private_handle->egl_image;
}
void gralloc_set_egl_image(gralloc_private_handle_t *private_handle, EGLImageKHR image)
{
private_handle->res_type = GRALLOC_PRIV_TYPE_GL_RESOURCE;
private_handle->egl_image = image;
}