OSDN Git Service

Track GemHandles and FB separately.
[android-x86/external-IA-Hardware-Composer.git] / public / nativebufferhandler.h
1 /*
2 // Copyright (c) 2016 Intel Corporation
3 //
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
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 */
16
17 #ifndef PUBLIC_NATIVEBUFFERHANDLER_H_
18 #define PUBLIC_NATIVEBUFFERHANDLER_H_
19
20 #include <stdint.h>
21
22 #include <platformdefines.h>
23 #include <hwcdefs.h>
24
25 namespace hwcomposer {
26
27 class NativeBufferHandler {
28  public:
29   static NativeBufferHandler *CreateInstance(uint32_t fd);
30
31   virtual ~NativeBufferHandler() {
32   }
33
34   virtual bool CreateBuffer(uint32_t w, uint32_t h, int format,
35                             HWCNativeHandle *handle = NULL,
36                             uint32_t layer_type = kLayerNormal) const = 0;
37
38   virtual bool ReleaseBuffer(HWCNativeHandle handle) const = 0;
39
40   virtual void DestroyHandle(HWCNativeHandle handle) const = 0;
41
42   virtual bool ImportBuffer(HWCNativeHandle handle) const = 0;
43
44   virtual void CopyHandle(HWCNativeHandle source,
45                           HWCNativeHandle *target) const = 0;
46
47   virtual uint32_t GetTotalPlanes(HWCNativeHandle handle) const = 0;
48
49   virtual void *Map(HWCNativeHandle handle, uint32_t x, uint32_t y,
50                     uint32_t width, uint32_t height, uint32_t *stride,
51                     void **map_data, size_t plane) const = 0;
52
53   virtual int32_t UnMap(HWCNativeHandle handle, void *map_data) const = 0;
54
55   virtual uint32_t GetFd() const = 0;
56 };
57
58 }  // namespace hwcomposer
59 #endif  // PUBLIC_NATIVEBUFFERHANDLER_H_