00001 // Sh: A GPU metaprogramming language. 00002 // 00003 // Copyright 2003-2005 Serious Hack Inc. 00004 // 00005 // This library is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 of the License, or (at your option) any later version. 00009 // 00010 // This library is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with this library; if not, write to the Free Software 00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00018 // MA 02110-1301, USA 00020 #ifndef SHIMAGE_HPP 00021 #define SHIMAGE_HPP 00022 00023 #include <string> 00024 #include "ShDllExport.hpp" 00025 #include "ShRefCount.hpp" 00026 #include "ShMemory.hpp" 00027 00028 namespace SH { 00029 00035 template<typename T> 00036 class ShTypedImage : public ShRefCountable { 00037 public: 00038 ShTypedImage(); 00039 ShTypedImage(int width, int height, int depth); 00040 00041 ShTypedImage(const ShTypedImage& other); 00042 00043 ~ShTypedImage(); 00044 00045 ShTypedImage& operator=(const ShTypedImage& other); 00046 00047 00048 int width() const; 00049 int height() const; 00050 int elements() const; 00051 00052 00053 void set_size(int width, int height, int depth); 00054 00055 00056 T operator()(int x, int y, int i) const; 00057 00058 00059 T& operator()(int x, int y, int i); 00060 00061 00062 00063 ShTypedImage getNormalImage(); 00064 00065 const T* data() const; 00066 T* data(); 00067 00068 void dirty(); 00069 ShMemoryPtr memory(); 00070 ShPointer<const ShMemory> memory() const; 00071 00072 private: 00073 int m_width, m_height; 00074 int m_elements; 00075 ShHostMemoryPtr m_memory; 00076 }; 00077 00078 typedef ShTypedImage<float> ShImage; 00079 00080 } 00081 00082 #include "ShImageImpl.hpp" 00083 00084 #endif
1.4.5