blob: 6826ffeabeb644b7eecb92b0444c2a76542185c7 [file] [log] [blame]
Iliyan Malchev202a77d2012-06-11 14:41:12 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
Duy Truong73d36df2013-02-09 20:33:23 -08003 * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
Iliyan Malchev202a77d2012-06-11 14:41:12 -07004 *
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>
Iliyan Malchev202a77d2012-06-11 14:41:12 -070028
29#include "gralloc_priv.h"
Jeykumar Sankaranc1f86822013-02-20 18:32:01 -080030#include "fb_priv.h"
Iliyan Malchev202a77d2012-06-11 14:41:12 -070031
32namespace gralloc {
Naseer Ahmed29a26812012-06-14 00:56:20 -070033class IAllocController;
34class gpu_context_t : public alloc_device_t {
35 public:
36 gpu_context_t(const private_module_t* module,
Naseer Ahmed01d3fd32012-07-14 21:08:13 -070037 IAllocController* alloc_ctrl);
Iliyan Malchev202a77d2012-06-11 14:41:12 -070038
Naseer Ahmed29a26812012-06-14 00:56:20 -070039 int gralloc_alloc_buffer(size_t size, int usage,
40 buffer_handle_t* pHandle,
41 int bufferType, int format,
42 int width, int height);
Iliyan Malchev202a77d2012-06-11 14:41:12 -070043
Naseer Ahmed29a26812012-06-14 00:56:20 -070044 int free_impl(private_handle_t const* hnd);
Iliyan Malchev202a77d2012-06-11 14:41:12 -070045
Naseer Ahmed29a26812012-06-14 00:56:20 -070046 int alloc_impl(int w, int h, int format, int usage,
47 buffer_handle_t* pHandle, int* pStride,
48 size_t bufferSize = 0);
Iliyan Malchev202a77d2012-06-11 14:41:12 -070049
Naseer Ahmed29a26812012-06-14 00:56:20 -070050 static int gralloc_alloc(alloc_device_t* dev, int w, int h,
51 int format, int usage,
52 buffer_handle_t* pHandle,
53 int* pStride);
Iliyan Malchev202a77d2012-06-11 14:41:12 -070054
Naseer Ahmed29a26812012-06-14 00:56:20 -070055 static int gralloc_free(alloc_device_t* dev, buffer_handle_t handle);
Iliyan Malchev202a77d2012-06-11 14:41:12 -070056
Naseer Ahmed29a26812012-06-14 00:56:20 -070057 static int gralloc_alloc_size(alloc_device_t* dev,
58 int w, int h, int format,
59 int usage, buffer_handle_t* pHandle,
60 int* pStride, int bufferSize);
Iliyan Malchev202a77d2012-06-11 14:41:12 -070061
Naseer Ahmed29a26812012-06-14 00:56:20 -070062 static int gralloc_close(struct hw_device_t *dev);
Iliyan Malchev202a77d2012-06-11 14:41:12 -070063
Naseer Ahmed29a26812012-06-14 00:56:20 -070064 private:
Naseer Ahmed01d3fd32012-07-14 21:08:13 -070065 IAllocController* mAllocCtrl;
Naseer Ahmed29a26812012-06-14 00:56:20 -070066 void getGrallocInformationFromFormat(int inputFormat,
Naseer Ahmed29a26812012-06-14 00:56:20 -070067 int *bufferType);
68};
Iliyan Malchev202a77d2012-06-11 14:41:12 -070069}
70#endif // GRALLOC_GPU_H