2
* Copyright (C) 2013 Simon Busch <morphis@gravedo.de>
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
8
* http://www.apache.org/licenses/LICENSE-2.0
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.
20
#include <ui/GraphicBuffer.h>
21
#include <ui/GraphicBufferMapper.h>
22
#include <ui/GraphicBufferAllocator.h>
24
#include <hybris/ui_compatibility_layer.h>
28
android::GraphicBuffer *self;
31
struct graphic_buffer* graphic_buffer_new(void)
33
struct graphic_buffer *buffer = NULL;
35
buffer = (struct graphic_buffer*) malloc(sizeof(struct graphic_buffer));
39
buffer->self = new android::GraphicBuffer();
44
struct graphic_buffer* graphic_buffer_new_sized(uint32_t w, uint32_t h,
45
int32_t format, uint32_t usage)
47
struct graphic_buffer *buffer = NULL;
49
buffer = (struct graphic_buffer*) malloc(sizeof(struct graphic_buffer));
53
buffer->self = new android::GraphicBuffer(w, h, format, usage);
58
struct graphic_buffer* graphic_buffer_new_existing(uint32_t w, uint32_t h,
59
int32_t format, uint32_t usage,
60
uint32_t stride, void *handle,
63
struct graphic_buffer *buffer = NULL;
65
buffer = (struct graphic_buffer*) malloc(sizeof(struct graphic_buffer));
69
buffer->self = new android::GraphicBuffer(w, h, format, usage, stride, (native_handle_t*) handle, keepOwnership);
75
void graphic_buffer_free(struct graphic_buffer *buffer)
83
uint32_t graphic_buffer_get_width(struct graphic_buffer *buffer)
85
return buffer->self->getWidth();
88
uint32_t graphic_buffer_get_height(struct graphic_buffer *buffer)
90
return buffer->self->getHeight();
93
uint32_t graphic_buffer_get_stride(struct graphic_buffer *buffer)
95
return buffer->self->getStride();
98
uint32_t graphic_buffer_get_usage(struct graphic_buffer *buffer)
100
return buffer->self->getUsage();
103
int32_t graphic_buffer_get_pixel_format(struct graphic_buffer *buffer)
105
return buffer->self->getPixelFormat();
108
uint32_t graphic_buffer_reallocate(struct graphic_buffer *buffer, uint32_t w,
109
uint32_t h, int32_t f, uint32_t usage)
111
return buffer->self->reallocate(w, h, f, usage);
114
uint32_t graphic_buffer_lock(struct graphic_buffer *buffer, uint32_t usage, void **vaddr)
116
return buffer->self->lock(usage, vaddr);
119
uint32_t graphic_buffer_unlock(struct graphic_buffer *buffer)
121
return buffer->self->unlock();
124
void* graphic_buffer_get_native_buffer(struct graphic_buffer *buffer)
126
return buffer->self->getNativeBuffer();
129
void graphic_buffer_set_index(struct graphic_buffer *buffer, int index)
131
return buffer->self->setIndex(index);
134
int graphic_buffer_get_index(struct graphic_buffer *buffer)
136
return buffer->self->getIndex();
139
int graphic_buffer_init_check(struct graphic_buffer *buffer)
141
return buffer->self->initCheck();