ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkGPUImageDataManager.h
Go to the documentation of this file.
1 /*=========================================================================
2 *
3 * Copyright Insight Software Consortium
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 
19 #ifndef __itkGPUImageDataManager_h
20 #define __itkGPUImageDataManager_h
21 
22 #include <itkObject.h>
23 #include <itkTimeStamp.h>
24 #include <itkLightObject.h>
25 #include <itkObjectFactory.h>
26 #include "itkOpenCLUtil.h"
27 #include "itkGPUDataManager.h"
28 #include "itkGPUContextManager.h"
29 #include "itkSimpleFastMutexLock.h"
30 
31 namespace itk
32 {
33 template < class TPixel, unsigned int NDimension > class GPUImage;
34 
43 template < class ImageType >
44 class ITK_EXPORT GPUImageDataManager : public GPUDataManager
45 {
46  // allow GPUKernelManager to access GPU buffer pointer
47  friend class GPUKernelManager;
48  friend class GPUImage< typename ImageType::PixelType, ImageType::ImageDimension >;
49 
50 public:
53  typedef SmartPointer<Self> Pointer;
54  typedef SmartPointer<const Self> ConstPointer;
55 
56  itkNewMacro(Self);
57  itkTypeMacro(GPUImageDataManager, GPUDataManager);
58 
59  static const unsigned int ImageDimension = ImageType::ImageDimension;
60 
61  itkGetObjectMacro(GPUBufferedRegionIndex, GPUDataManager);
62  itkGetObjectMacro(GPUBufferedRegionSize, GPUDataManager);
63 
64  void SetImagePointer( typename ImageType::Pointer img );
65  ImageType *GetImagePointer()
66  {
67  return this->m_Image.GetPointer();
68  }
69 
71  virtual void MakeCPUBufferUpToDate();
72 
74  virtual void MakeGPUBufferUpToDate();
75 
77  virtual void Graft(const GPUDataManager* data);
78 
79 protected:
81  virtual ~GPUImageDataManager() {}
82 
83 private:
84  GPUImageDataManager(const Self&); //purposely not implemented
85  void operator=(const Self&);
86 
87  typename ImageType::Pointer m_Image;
88  int m_BufferedRegionIndex[ImageType::ImageDimension];
89  int m_BufferedRegionSize[ImageType::ImageDimension];
92 
93 };
94 
95 } // namespace itk
96 
97 #ifndef ITK_MANUAL_INSTANTIATION
98 #include "itkGPUImageDataManager.hxx"
99 #endif
100 
101 #endif
102