blob: 301c411ee8a4313947b380a04b7c67c2a4f6187f [file] [log] [blame]
Iliyan Malchev202a77d2012-06-11 14:41:12 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 * Copyright (c) 2011 Code Aurora Forum. All rights reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef GRALLOC_GPU_H_
19#define GRALLOC_GPU_H_
20
21#include <errno.h>
22#include <pthread.h>
23#include <stdlib.h>
24#include <string.h>
25
26#include <cutils/log.h>
27#include <cutils/ashmem.h>
28#include <utils/RefBase.h>
29
30#include "gralloc_priv.h"
31
32namespace gralloc {
33 class IAllocController;
34 class gpu_context_t : public alloc_device_t {
35 public:
36 gpu_context_t(const private_module_t* module,
37 android::sp<IAllocController>alloc_ctrl);
38
39 int gralloc_alloc_framebuffer_locked(size_t size, int usage,
40 buffer_handle_t* pHandle);
41
42 int gralloc_alloc_framebuffer(size_t size, int usage,
43 buffer_handle_t* pHandle);
44
45 int gralloc_alloc_buffer(size_t size, int usage,
46 buffer_handle_t* pHandle,
47 int bufferType, int format,
48 int width, int height);
49
50 int free_impl(private_handle_t const* hnd);
51
52 int alloc_impl(int w, int h, int format, int usage,
53 buffer_handle_t* pHandle, int* pStride,
54 size_t bufferSize = 0);
55
56 static int gralloc_alloc(alloc_device_t* dev, int w, int h,
57 int format, int usage,
58 buffer_handle_t* pHandle,
59 int* pStride);
60
61 static int gralloc_free(alloc_device_t* dev, buffer_handle_t handle);
62
63 static int gralloc_alloc_size(alloc_device_t* dev,
64 int w, int h, int format,
65 int usage, buffer_handle_t* pHandle,
66 int* pStride, int bufferSize);
67
68 static int gralloc_close(struct hw_device_t *dev);
69
70 int get_composition_type() const { return compositionType; }
71
72
73 private:
74 android::sp<IAllocController> mAllocCtrl;
75 int compositionType;
76 void getGrallocInformationFromFormat(int inputFormat,
77 int *colorFormat,
78 int *bufferType);
79 };
80}
81#endif // GRALLOC_GPU_H