00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright (c) 2000-2012 Torus Knot Software Ltd 00008 00009 Permission is hereby granted, free of charge, to any person obtaining a copy 00010 of this software and associated documentation files (the "Software"), to deal 00011 in the Software without restriction, including without limitation the rights 00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00013 copies of the Software, and to permit persons to whom the Software is 00014 furnished to do so, subject to the following conditions: 00015 00016 The above copyright notice and this permission notice shall be included in 00017 all copies or substantial portions of the Software. 00018 00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00025 THE SOFTWARE. 00026 ----------------------------------------------------------------------------- 00027 */ 00028 #ifndef __CompositorManager_H__ 00029 #define __CompositorManager_H__ 00030 00031 #include "OgrePrerequisites.h" 00032 #include "OgreResourceManager.h" 00033 #include "OgreCompositor.h" 00034 #include "OgreRectangle2D.h" 00035 #include "OgreRenderSystem.h" 00036 #include "OgreCompositionTechnique.h" 00037 00038 namespace Ogre { 00058 class _OgreExport CompositorManager : public ResourceManager, public Singleton<CompositorManager> 00059 { 00060 public: 00061 CompositorManager(); 00062 virtual ~CompositorManager(); 00063 00065 Resource* createImpl(const String& name, ResourceHandle handle, 00066 const String& group, bool isManual, ManualResourceLoader* loader, 00067 const NameValuePairList* params); 00068 00071 void initialise(void); 00072 00075 void parseScript(DataStreamPtr& stream, const String& groupName); 00076 00082 CompositorChain *getCompositorChain(Viewport *vp); 00083 00086 bool hasCompositorChain(Viewport *vp) const; 00087 00090 void removeCompositorChain(Viewport *vp); 00091 00099 CompositorInstance *addCompositor(Viewport *vp, const String &compositor, int addPosition=-1); 00100 00103 void removeCompositor(Viewport *vp, const String &compositor); 00104 00110 void setCompositorEnabled(Viewport *vp, const String &compositor, bool value); 00111 00114 Renderable *_getTexturedRectangle2D(); 00115 00117 void removeAll(void); 00118 00120 void _reconstructAllCompositorResources(); 00121 00122 typedef set<Texture*>::type UniqueTextureSet; 00123 00131 TexturePtr getPooledTexture(const String& name, const String& localName, 00132 size_t w, size_t h, 00133 PixelFormat f, uint aa, const String& aaHint, bool srgb, UniqueTextureSet& texturesAlreadyAssigned, 00134 CompositorInstance* inst, CompositionTechnique::TextureScope scope); 00135 00139 void freePooledTextures(bool onlyIfUnreferenced = true); 00140 00144 void registerCompositorLogic(const String& name, CompositorLogic* logic); 00145 00148 void unregisterCompositorLogic(const String& name); 00149 00152 CompositorLogic* getCompositorLogic(const String& name); 00153 00156 void registerCustomCompositionPass(const String& name, CustomCompositionPass* customPass); 00157 00160 CustomCompositionPass* getCustomCompositionPass(const String& name); 00161 00177 static CompositorManager& getSingleton(void); 00193 static CompositorManager* getSingletonPtr(void); 00194 00195 00196 private: 00197 typedef map<Viewport*, CompositorChain*>::type Chains; 00198 Chains mChains; 00199 00202 void freeChains(); 00203 00204 Rectangle2D *mRectangle; 00205 00207 typedef vector<CompositorInstance *>::type Instances; 00208 Instances mInstances; 00209 00211 typedef map<String, CompositorLogic*>::type CompositorLogicMap; 00212 CompositorLogicMap mCompositorLogics; 00213 00215 typedef map<String, CustomCompositionPass*>::type CustomCompositionPassMap; 00216 CustomCompositionPassMap mCustomCompositionPasses; 00217 00218 typedef vector<TexturePtr>::type TextureList; 00219 typedef VectorIterator<TextureList> TextureIterator; 00220 00221 struct TextureDef 00222 { 00223 size_t width, height; 00224 PixelFormat format; 00225 uint fsaa; 00226 String fsaaHint; 00227 bool sRGBwrite; 00228 00229 TextureDef(size_t w, size_t h, PixelFormat f, uint aa, const String& aaHint, bool srgb) 00230 : width(w), height(h), format(f), fsaa(aa), fsaaHint(aaHint), sRGBwrite(srgb) 00231 { 00232 00233 } 00234 }; 00235 struct TextureDefLess 00236 { 00237 bool _OgreExport operator()(const TextureDef& x, const TextureDef& y) const 00238 { 00239 if (x.format < y.format) 00240 return true; 00241 else if (x.format == y.format) 00242 { 00243 if (x.width < y.width) 00244 return true; 00245 else if (x.width == y.width) 00246 { 00247 if (x.height < y.height) 00248 return true; 00249 else if (x.height == y.height) 00250 { 00251 if (x.fsaa < y.fsaa) 00252 return true; 00253 else if (x.fsaa == y.fsaa) 00254 { 00255 if (x.fsaaHint < y.fsaaHint) 00256 return true; 00257 else if (x.fsaaHint == y.fsaaHint) 00258 { 00259 if (!x.sRGBwrite && y.sRGBwrite) 00260 return true; 00261 } 00262 00263 } 00264 } 00265 } 00266 } 00267 return false; 00268 } 00269 virtual ~TextureDefLess() {} 00270 }; 00271 typedef map<TextureDef, TextureList*, TextureDefLess>::type TexturesByDef; 00272 TexturesByDef mTexturesByDef; 00273 00274 typedef std::pair<String, String> StringPair; 00275 typedef map<TextureDef, TexturePtr, TextureDefLess>::type TextureDefMap; 00276 typedef std::map<StringPair, TextureDefMap> ChainTexturesByDef; 00277 00278 ChainTexturesByDef mChainTexturesByDef; 00279 00280 bool isInputPreviousTarget(CompositorInstance* inst, const Ogre::String& localName); 00281 bool isInputPreviousTarget(CompositorInstance* inst, TexturePtr tex); 00282 bool isInputToOutputTarget(CompositorInstance* inst, const Ogre::String& localName); 00283 bool isInputToOutputTarget(CompositorInstance* inst, TexturePtr tex); 00284 00285 }; 00289 } 00290 00291 #endif
Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Fri May 25 23:36:23 2012