• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * cl_image_bo_buffer.h - cl image bo buffer
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_IMAGE_BO_BUFFER_H
22 #define XCAM_CL_IMAGE_BO_BUFFER_H
23 
24 #include <xcam_std.h>
25 #include <drm_bo_buffer.h>
26 #include <ocl/cl_memory.h>
27 #include <ocl/cl_context.h>
28 
29 namespace XCam {
30 
31 class CLImageBoBuffer;
32 class CLBoBufferPool;
33 
34 class CLImageBoData
35     : public DrmBoData
36 {
37     friend class CLBoBufferPool;
38     friend class CLImageBoBuffer;
39 public:
40     virtual int get_fd ();
41 
42 private:
43     explicit CLImageBoData (SmartPtr<DrmDisplay> &display, SmartPtr<CLImage> &image, drm_intel_bo *bo);
44     XCAM_DEAD_COPY (CLImageBoData);
45 
get_image()46     SmartPtr<CLImage> &get_image () {
47         return _image;
48     }
49 
50 private:
51     SmartPtr<CLImage>          _image;
52 };
53 
54 class CLImageBoBuffer
55     : public DrmBoBuffer
56 {
57     friend class CLBoBufferPool;
58 public:
59     SmartPtr<CLImage> get_cl_image ();
60 
61 protected:
62     CLImageBoBuffer (const VideoBufferInfo &info, const SmartPtr<CLImageBoData> &data);
63 
64     //derived from SwappedBuffer
65     virtual SmartPtr<SwappedBuffer> create_new_swap_buffer (
66         const VideoBufferInfo &info, SmartPtr<BufferData> &data);
67 };
68 
69 class CLBoBufferPool
70     : public DrmBoBufferPool
71 {
72 public:
73     explicit CLBoBufferPool (SmartPtr<DrmDisplay> &display, SmartPtr<CLContext> &context);
74     ~CLBoBufferPool ();
75 
76 protected:
77     // derived from BufferPool
78     virtual bool fixate_video_info (VideoBufferInfo &info);
79     virtual SmartPtr<BufferData> allocate_data (const VideoBufferInfo &buffer_info);
80     virtual SmartPtr<BufferProxy> create_buffer_from_data (SmartPtr<BufferData> &data);
81 
82 private:
83     SmartPtr<CLImageBoData> create_image_bo (const VideoBufferInfo &buffer_info);
84     XCAM_DEAD_COPY (CLBoBufferPool);
85 
86 private:
87     SmartPtr<CLContext>     _context;
88 };
89 
90 
91 };
92 #endif // XCAM_CL_IMAGE_BO_BUFFER_H
93