Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / effects / inc / renderer / engine-model / FUiEffects_RendererEngineModelRenderTarget.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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  * @file                FUiEffects_RendererEngineModelRenderTarget.h
20  * @brief       Base class for representing renderer output instance e.g. for offscreen rendering
21  *
22  */
23
24 #ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_RENDER_TARGET_H_
25 #define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_RENDER_TARGET_H_
26
27 #include <renderer/engine-model/FUiEffects_RendererEngineModelCache.h>
28 #include <renderer/engine-model/FUiEffects_RendererEngineModelTexture2DAttachmentProperty.h>
29 #include <renderer/engine-model/FUiEffects_RendererEngineModelStubAttachment.h>
30
31 #include <renderer/system/FUiEffects_RendererSystemNonCopyable.h>
32 #include <renderer/system/FUiEffects_RendererSystemSmartPtr.h>
33
34 namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel
35 {
36
37 class RenderTargetVisitor;
38
39 class RenderTarget
40 {
41 public:
42         class Attachment
43         {
44         public:
45                 enum AttachmentEnum
46                 {
47                         COLOR_0 = 0             ,
48                         COLOR_1         ,
49                         COLOR_2         ,
50                         COLOR_3         ,
51                         COLOR_4         ,
52                         COLOR_5         ,
53                         COLOR_6         ,
54                         COLOR_7         ,
55                         DEPTH           ,
56                         STENCIL         ,
57                         ATTACHMENT_MAX
58                 };
59                 typedef AttachmentEnum Value;
60         };
61
62         struct AttachInfo: private Tizen::Ui::Effects::_Renderer::System::NonCopyable
63         {
64         public:
65                 enum TextureType {TEXTURE_2D = 0, STUB};
66                 AttachInfo(void) {}
67
68                 void Set(Texture2dAttachmentProperty* pTexture, size_t mipLevel)
69                 {
70                         textureType = TEXTURE_2D;
71                         textureInfo.texture2D.pTexture = pTexture;
72                         textureInfo.texture2D.mipLevel = mipLevel;
73                         return;
74                 }
75
76                 void Set(StubAttachment* pStub)
77                 {
78                         textureType = STUB;
79                         textureInfo.stub.pStub = pStub;
80                         return;
81                 }
82
83                 TextureType textureType;
84                 union _textureInfo
85                 {
86                         struct _Texture2D
87                         {
88                                 Texture2dAttachmentProperty* pTexture;
89                                 size_t mipLevel;
90                         }  texture2D;
91                         struct _Stub
92                         {
93                                 StubAttachment* pStub;
94                         }  stub;
95                 } textureInfo;
96         };
97
98         RenderTarget(void);
99         virtual ~RenderTarget(void);
100
101         virtual void Visit(RenderTargetVisitor& v);
102
103         virtual void AttachTexture2D(Attachment::Value attachment, Texture2DAttachmentPropertyPtr pTexture, size_t mipLevel);
104         virtual void AttachStub(Attachment::Value attachment, StubAttachmentPtr pStub);
105         virtual void Detach(Attachment::Value attachment);
106         virtual AttachInfo* GetAttachment(Attachment::Value attachment);
107
108         unsigned int GetWidth(void);
109         unsigned int GetHeight(void);
110         void SetSize(unsigned int width, unsigned int height);
111
112         virtual CachePtr GetCache(void);
113         virtual void SetCache(CachePtr pCache);
114
115 protected:
116         unsigned int _width;
117         unsigned int _height;
118         AttachInfo _attachments[RenderTarget::Attachment::ATTACHMENT_MAX];
119         TextureAttachmentPtr _pTextures[RenderTarget::Attachment::ATTACHMENT_MAX];
120
121 private:
122         CachePtr __pCache;
123 };
124
125 typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr<RenderTarget> RenderTargetPtr;
126
127 }}}}} //Tizen::Ui::Effects::_Renderer::EngineModel
128
129 #endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_RENDER_TARGET_H_