Revert "[Tizen] Restore Uploaded signal for BufferImage and ResourceImage"
[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 const Dali::FrameBuffer::Attachment::Mask RenderBufferFormatToFrameBufferAttachments[]  =
34   { Dali::FrameBuffer::Attachment::NONE,
35     Dali::FrameBuffer::Attachment::DEPTH,
36     Dali::FrameBuffer::Attachment::STENCIL,
37     Dali::FrameBuffer::Attachment::DEPTH_STENCIL };
38 } // unnamed namespace
39
40 FrameBufferImagePtr FrameBufferImage::New( unsigned int width,
41                                            unsigned int height,
42                                            Pixel::Format pixelFormat,
43                                            RenderBuffer::Format bufferformat )
44 {
45   FrameBufferImagePtr image = new FrameBufferImage( width, height );
46   image->Initialize();
47
48   image->mTexture = Texture::New( Dali::TextureType::TEXTURE_2D, pixelFormat, width, height );
49   image->mFrameBufferObject = FrameBuffer::New( width, height, RenderBufferFormatToFrameBufferAttachments[bufferformat] );
50   image->mFrameBufferObject->AttachColorTexture( image->mTexture, 0u, 0u );
51
52   return image;
53 }
54
55 FrameBufferImagePtr FrameBufferImage::New( NativeImageInterface& nativeImage )
56 {
57   FrameBufferImagePtr image = new FrameBufferImage( nativeImage );
58   image->Initialize();
59
60   image->mTexture = Texture::New( nativeImage );
61   image->mFrameBufferObject = FrameBuffer::New( image->mTexture->GetWidth(), image->mTexture->GetHeight(), Dali::FrameBuffer::Attachment::NONE );
62   image->mFrameBufferObject->AttachColorTexture( image->mTexture, 0u, 0u );
63
64   return image;
65 }
66
67 FrameBufferImage::FrameBufferImage( unsigned int width, unsigned int height)
68 : Image(),
69   mNativeImage(0),
70   mIsNativeFbo( false )
71 {
72   mWidth  = width;
73   mHeight = height;
74 }
75
76 FrameBufferImage::FrameBufferImage( NativeImageInterface& nativeImage )
77 : Image(),
78   mNativeImage( &nativeImage ),
79   mIsNativeFbo( true )
80 {
81   mWidth = nativeImage.GetWidth();
82   mHeight = nativeImage.GetHeight();
83 }
84
85
86 bool FrameBufferImage::IsNativeFbo() const
87 {
88   return mIsNativeFbo;
89 }
90
91 FrameBufferImage::~FrameBufferImage()
92 {
93 }
94
95 } // namespace Internal
96
97 } // namespace Dali