blob: 79dcc23560b3ae17b9b0210a8613bdab0fb87721 [file] [log] [blame]
Wind Yuan5ddbfd22015-02-10 18:04:09 +08001/*
2 * cl_memory.h - CL memory
3 *
4 * Copyright (c) 2015 Intel Corporation
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Wind Yuan <feng.yuan@intel.com>
19 */
20
21#ifndef XCAM_CL_MEMORY_H
22#define XCAM_CL_MEMORY_H
23
24#include "xcam_utils.h"
25#include "cl_context.h"
26#include "drm_bo_buffer.h"
27
28namespace XCam {
29
30class CLMemory {
31public:
32 CLMemory (SmartPtr<CLContext> &context);
33 virtual ~CLMemory ();
34
Wind Yuan87926782015-02-15 15:53:15 +080035 cl_mem &get_mem_id () {
Wind Yuan5ddbfd22015-02-10 18:04:09 +080036 return _mem_id;
37 }
38 bool is_valid () const {
39 return _mem_id != NULL;
40 }
41
42private:
43 XCAM_DEAD_COPY (CLMemory);
44
45protected:
46 SmartPtr<CLContext> _context;
47 cl_mem _mem_id;
48};
49
50class CLVaImage
51 : public CLMemory
52{
53public:
54 explicit CLVaImage (
55 SmartPtr<CLContext> &context,
56 SmartPtr<DrmBoBuffer> &bo,
57 const cl_libva_image *image_info = NULL);
58 ~CLVaImage () {}
59 const cl_libva_image & get_image_info () const {
60 return _image_info;
61 }
62
Wind Yuan41c93782015-03-18 15:36:02 +080063 static bool video_info_2_cl_image_info (
64 const VideoBufferInfo & video_info,
65 cl_libva_image &cl_image_info);
66
67 static uint32_t get_pixel_bytes (cl_image_format fmt);
68
Wind Yuan5ddbfd22015-02-10 18:04:09 +080069private:
70 XCAM_DEAD_COPY (CLVaImage);
71private:
72 SmartPtr<DrmBoBuffer> _bo;
73 cl_libva_image _image_info;
74};
75
76};
77#endif //