go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkOpenCLImage.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright UMC Utrecht and contributors
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkOpenCLImage_h
19 #define __itkOpenCLImage_h
20 
21 #include "itkOpenCLMemoryObject.h"
22 #include "itkOpenCLImageFormat.h"
23 #include "itkOpenCLEvent.h"
24 #include "itkOpenCLSize.h"
25 
26 namespace itk
27 {
35 // Forward declaration
36 class OpenCLBuffer;
37 
39 {
40 public:
41 
43  typedef OpenCLImage Self;
45 
48 
53  OpenCLImage( OpenCLContext * context, const cl_mem id ) :
54  OpenCLMemoryObject( context, id ) {}
55 
57  OpenCLImage( const OpenCLImage & other );
58 
60  OpenCLImage & operator=( const OpenCLImage & other );
61 
63  OpenCLImageFormat GetFormat() const;
64 
68  std::size_t GetElementSizeInBytes() const;
69 
71  std::size_t GetRowSizeInBytes() const;
72 
76  std::size_t GetSliceSizeInBytes() const;
77 
79  std::size_t GetDimension() const;
80 
83  std::size_t GetWidth() const;
84 
88  std::size_t GetHeight() const;
89 
94  std::size_t GetDepth() const;
95 
102  bool Read( void * data, const OpenCLSize & origin, const OpenCLSize & region,
103  const std::size_t rowPitch = 0, const std::size_t slicePitch = 0 );
104 
111  OpenCLEvent ReadAsync( void * data,
112  const OpenCLSize & origin, const OpenCLSize & region,
113  const OpenCLEventList & event_list = OpenCLEventList(),
114  const std::size_t rowPitch = 0, const std::size_t slicePitch = 0 );
115 
122  bool Write( const void * data,
123  const OpenCLSize & origin, const OpenCLSize & region,
124  const std::size_t rowPitch = 0, const std::size_t slicePitch = 0 );
125 
132  OpenCLEvent WriteAsync( const void * data,
133  const OpenCLSize & origin, const OpenCLSize & region,
134  const OpenCLEventList & event_list = OpenCLEventList(),
135  const std::size_t rowPitch = 0, const std::size_t slicePitch = 0 );
136 
144  void * Map( const OpenCLMemoryObject::Access access,
145  const OpenCLSize & origin, const OpenCLSize & region,
146  std::size_t * rowPitch = 0, std::size_t * slicePitch = 0 );
147 
154  OpenCLEvent MapAsync( void ** data,
155  const OpenCLMemoryObject::Access access,
156  const OpenCLSize & origin, const OpenCLSize & region,
157  const OpenCLEventList & event_list = OpenCLEventList(),
158  std::size_t * rowPitch = 0, std::size_t * slicePitch = 0 );
159 
165  bool Copy( const OpenCLImage & dest,
166  const OpenCLSize & origin, const OpenCLSize & region,
167  const OpenCLSize & destOrigin );
168 
175  OpenCLEvent CopyAsync( const OpenCLImage & dest,
176  const OpenCLSize & origin, const OpenCLSize & region,
177  const OpenCLSize & destOrigin,
178  const OpenCLEventList & event_list = OpenCLEventList() );
179 
185  bool Copy( const OpenCLBuffer & dest,
186  const OpenCLSize & origin, const OpenCLSize & region,
187  const std::size_t dst_offset = 0 );
188 
195  OpenCLEvent CopyAsync( const OpenCLBuffer & dest,
196  const OpenCLSize & origin, const OpenCLSize & region,
197  const OpenCLEventList & event_list = OpenCLEventList(),
198  const std::size_t dst_offset = 0 );
199 
200 #ifdef CL_VERSION_1_2
201 
202  static void SetImageDescription( cl_image_desc & imageDescription,
203  const OpenCLImageFormat & format,
204  const OpenCLSize & size );
205 
206 #endif
207 
208 protected:
209 
211  std::size_t GetImageInfo( const cl_image_info name ) const;
212 
214  void SetOrigin( std::size_t * origin_t, const OpenCLSize & origin ) const;
215 
217  void SetRegion( std::size_t * region_t, const OpenCLSize & region ) const;
218 
220  void SetSize( std::size_t * region_t, const OpenCLSize & region, const std::size_t value ) const;
221 
223  friend class OpenCLBuffer;
224 };
225 
227 template< typename charT, typename traits >
228 inline
229 std::basic_ostream< charT, traits > &
230 operator<<( std::basic_ostream< charT, traits > & strm,
231  const OpenCLImage & image )
232 {
233  if( image.IsNull() )
234  {
235  strm << "OpenCLImage(null)";
236  return strm;
237  }
238 
239  const char indent = ' ';
240 
241  strm << "OpenCLImage" << std::endl
242  << indent << "Element size(bytes): " << image.GetElementSizeInBytes() << std::endl
243  << indent << "Row size(bytes): " << image.GetRowSizeInBytes() << std::endl
244  << indent << "Slice size(bytes): " << image.GetSliceSizeInBytes() << std::endl
245  << indent << "Dimension: " << image.GetDimension() << std::endl
246  << indent << "Width: " << image.GetWidth() << std::endl
247  << indent << "Height: " << image.GetHeight() << std::endl
248  << indent << "Depth: " << image.GetDepth() << std::endl;
249 
250  // Stream OpenCLMemoryObject
251  const OpenCLMemoryObject & memObj = image;
252  strm << memObj;
253 
254  return strm;
255 }
256 
257 
258 } // end namespace itk
259 
260 #endif /* __itkOpenCLImage_h */
OpenCLImage(OpenCLContext *context, const cl_mem id)
The OpenCLImage class represents an image object is used to store a one, two or three dimensional tex...
OpenCLEventList class represents a list of OpenCLEvent objects.
The OpenCLSize class defines the size of an item of work for an OpenCL kernel.
Definition: itkOpenCLSize.h:49
The OpenCLImageFormat class represents the format of a OpenCLImage.
The OpenCLBuffer class represents an OpenCL buffer object.
The OpenCLContext class represents an OpenCL context.
OpenCLMemoryObject Superclass
The OpenCLMemoryObject class represents all common memory objects such as buffers and image objects...
#define ITKOpenCL_EXPORT
OpenCLEvent class represents an OpenCL event object.
OpenCLImage Self
std::vcl_size_t GetElementSizeInBytes() const


Generated on 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo