• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * cl_wire_frame_handler.h - CL wire frame handler
3  *
4  *  Copyright (c) 2016 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: Yinhang Liu <yinhangx.liu@intel.com>
19  */
20 
21 #ifndef XCAM_CL_WIRE_FRAME_H
22 #define XCAM_CL_WIRE_FRAME_H
23 
24 #include "ocl/cl_image_handler.h"
25 
26 #define XCAM_WIRE_FRAME_MAX_COUNT 160
27 
28 namespace XCam {
29 
30 typedef struct _CLWireFrame {
31     uint32_t pos_x;
32     uint32_t pos_y;
33     uint32_t width;
34     uint32_t height;
35 } CLWireFrame;
36 
37 class CLWireFrameImageHandler;
38 
39 class CLWireFrameImageKernel
40     : public CLImageKernel
41 {
42 public:
43     explicit CLWireFrameImageKernel (
44         const SmartPtr<CLContext> &context,
45         const SmartPtr<CLWireFrameImageHandler> &handler,
46         const char *name);
47     ~CLWireFrameImageKernel ();
48 
49 protected:
50     virtual XCamReturn prepare_arguments (
51         CLArgList &args, CLWorkSize &work_size);
52 
53 private:
54     SmartPtr<CLWireFrameImageHandler>        _handler;
55     uint32_t                                 _wire_frames_coords_num;
56     uint32_t                                 *_wire_frames_coords;
57 };
58 
59 class CLWireFrameImageHandler
60     : public CLImageHandler
61 {
62 public:
63     explicit CLWireFrameImageHandler (const SmartPtr<CLContext> &context, const char *name);
64     bool set_wire_frame_kernel (SmartPtr<CLWireFrameImageKernel> &kernel);
65     bool set_wire_frame_config (const XCamFDResult *config, double scaler_factor = 1.0);
66 
67     bool check_wire_frames_validity (uint32_t image_width, uint32_t image_height);
68     uint32_t get_border_coordinates_num ();
69     bool get_border_coordinates (uint32_t *coords);
70 
71 protected:
72     virtual XCamReturn prepare_output_buf (SmartPtr<VideoBuffer> &input, SmartPtr<VideoBuffer> &output);
73 
74 private:
75     XCAM_DEAD_COPY (CLWireFrameImageHandler);
76     SmartPtr<CLWireFrameImageKernel>         _wire_frame_kernel;
77 
78     uint32_t                                 _wire_frames_num;
79     CLWireFrame                              _wire_frames [XCAM_WIRE_FRAME_MAX_COUNT];
80 };
81 
82 SmartPtr<CLImageHandler>
83 create_cl_wire_frame_image_handler (const SmartPtr<CLContext> &context);
84 
85 };
86 
87 #endif // XCAM_CL_WIRE_FRAME_H
88