2 // Copyright (c) 2016 Intel Corporation
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.
17 #ifndef PUBLIC_NATIVEBUFFERHANDLER_H_
18 #define PUBLIC_NATIVEBUFFERHANDLER_H_
22 #include <platformdefines.h>
25 namespace hwcomposer {
27 class NativeBufferHandler {
29 static NativeBufferHandler *CreateInstance(uint32_t fd);
31 virtual ~NativeBufferHandler() {
34 virtual bool CreateBuffer(uint32_t w, uint32_t h, int format,
35 HWCNativeHandle *handle = NULL,
36 uint32_t layer_type = kLayerNormal) const = 0;
38 virtual bool ReleaseBuffer(HWCNativeHandle handle) const = 0;
40 virtual void DestroyHandle(HWCNativeHandle handle) const = 0;
42 virtual bool ImportBuffer(HWCNativeHandle handle) const = 0;
44 virtual void CopyHandle(HWCNativeHandle source,
45 HWCNativeHandle *target) const = 0;
47 virtual uint32_t GetTotalPlanes(HWCNativeHandle handle) const = 0;
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;
53 virtual int32_t UnMap(HWCNativeHandle handle, void *map_data) const = 0;
55 virtual uint32_t GetFd() const = 0;
58 } // namespace hwcomposer
59 #endif // PUBLIC_NATIVEBUFFERHANDLER_H_