[Tizen] Revert "Remove TypeRegistration from deprecated Image classes"
[platform/core/uifw/dali-core.git] / dali / internal / event / images / frame-buffer-image-impl.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/event/images/frame-buffer-image-impl.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/object/type-registry.h>
23 #include <dali/internal/event/common/thread-local-storage.h>
24
25 namespace Dali
26 {
27
28 namespace Internal
29 {
30
31 namespace
32 {
33 TypeRegistration mType( typeid( Dali::FrameBufferImage ), typeid( Dali::Image ), NULL );
34
35 const int RenderBufferFormatToFrameBufferAttachments[]  = { Dali::FrameBuffer::Attachment::NONE,
36                                                             Dali::FrameBuffer::Attachment::DEPTH,
37                                                             Dali::FrameBuffer::Attachment::STENCIL,
38                                                             Dali::FrameBuffer::Attachment::DEPTH_STENCIL
39                                                           };
40
41 } // unnamed namespace
42
43 FrameBufferImagePtr FrameBufferImage::New( unsigned int width,
44                                            unsigned int height,
45                                            Pixel::Format pixelFormat,
46                                            RenderBuffer::Format bufferformat )
47 {
48   FrameBufferImagePtr image = new FrameBufferImage( width, height );
49   image->Initialize();
50
51   image->mTexture = Texture::New( Dali::TextureType::TEXTURE_2D, pixelFormat, width, height );
52   image->mFrameBufferObject = FrameBuffer::New( width, height, RenderBufferFormatToFrameBufferAttachments[bufferformat] );
53   image->mFrameBufferObject->AttachColorTexture( image->mTexture, 0u, 0u );
54
55   return image;
56 }
57
58 FrameBufferImagePtr FrameBufferImage::New( NativeImageInterface& nativeImage )
59 {
60   FrameBufferImagePtr image = new FrameBufferImage( nativeImage );
61   image->Initialize();
62
63   image->mTexture = Texture::New( nativeImage );
64   image->mFrameBufferObject = FrameBuffer::New( image->mTexture->GetWidth(), image->mTexture->GetHeight(), Dali::FrameBuffer::Attachment::NONE );
65   image->mFrameBufferObject->AttachColorTexture( image->mTexture, 0u, 0u );
66
67   return image;
68 }
69
70 FrameBufferImage::FrameBufferImage( unsigned int width, unsigned int height)
71 : Image(),
72   mNativeImage(0),
73   mIsNativeFbo( false )
74 {
75   mWidth  = width;
76   mHeight = height;
77 }
78
79 FrameBufferImage::FrameBufferImage( NativeImageInterface& nativeImage )
80 : Image(),
81   mNativeImage( &nativeImage ),
82   mIsNativeFbo( true )
83 {
84   mWidth = nativeImage.GetWidth();
85   mHeight = nativeImage.GetHeight();
86 }
87
88
89 bool FrameBufferImage::IsNativeFbo() const
90 {
91   return mIsNativeFbo;
92 }
93
94 FrameBufferImage::~FrameBufferImage()
95 {
96 }
97
98 } // namespace Internal
99
100 } // namespace Dali