2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/dali-core.h>
23 #include <dali-test-suite-utils.h>
24 #include <test-native-image.h>
25 #include <dali/integration-api/gl-abstraction.h>
30 void utc_dali_framebuffer_startup(void)
32 test_return_value = TET_UNDEF;
35 void utc_dali_framebuffer_cleanup(void)
37 test_return_value = TET_PASS;
40 static const float ROTATION_EPSILON = 0.0001f;
43 int UtcDaliFrameBufferImageNew01(void)
45 TestApplication application;
47 tet_infoline("UtcDaliFrameBufferImageNew01 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format)");
49 // invoke default handle constructor
50 FrameBufferImage image;
51 Vector2 stageSize = Stage::GetCurrent().GetSize();
54 image = FrameBufferImage::New(); // create framebuffer with the same dimensions as the stage
55 ImageActor actor=ImageActor::New(image);
56 Stage::GetCurrent().Add(actor);
58 application.SendNotification();
61 application.SendNotification();
63 DALI_TEST_CHECK( image );
64 DALI_TEST_EQUALS((float)image.GetWidth(), stageSize.width, TEST_LOCATION);
65 DALI_TEST_EQUALS((float)image.GetHeight(), stageSize.height, TEST_LOCATION);
67 image = FrameBufferImage::New(16, 16); // create framebuffer with dimensions of 16x16
68 actor.SetImage(image);
70 application.SendNotification();
73 application.SendNotification();
75 DALI_TEST_CHECK( image );
76 DALI_TEST_EQUALS(image.GetWidth(), 16u, TEST_LOCATION);
77 DALI_TEST_EQUALS(image.GetHeight(), 16u, TEST_LOCATION);
81 int UtcDaliFrameBufferImageNew02(void)
83 TestApplication application;
85 tet_infoline("UtcDaliFrameBufferImageNew02 - FrameBufferImage::New(NativeImageInterface&)");
87 // invoke default handle constructor
88 FrameBufferImage image;
89 TestNativeImagePointer nativeImage = TestNativeImage::New(16, 16);
91 DALI_TEST_CHECK( !image );
94 image = FrameBufferImage::New(*(nativeImage.Get()));
96 DALI_TEST_CHECK( image );
100 int UtcDaliFrameBufferImageNew03(void)
102 TestApplication application;
104 tet_infoline("UtcDaliFrameBufferImageNew03 - FrameBufferImage::New(NativeImageInterface&, ReleasePolicy)");
106 // invoke default handle constructor
107 FrameBufferImage image;
108 TestNativeImagePointer nativeImage = TestNativeImage::New(16, 16);
110 DALI_TEST_CHECK( !image );
112 // initialise handle with UNUSED release policy
113 image = FrameBufferImage::New(*(nativeImage.Get()), Image::UNUSED);
115 DALI_TEST_CHECK( image );
116 DALI_TEST_EQUALS( image.GetReleasePolicy(), Image::UNUSED, TEST_LOCATION );
118 // initialise handle with NEVER release policy
120 DALI_TEST_CHECK( !image );
122 image = FrameBufferImage::New(*(nativeImage.Get()), Image::NEVER);
124 DALI_TEST_CHECK( image );
125 DALI_TEST_EQUALS( image.GetReleasePolicy(), Image::NEVER, TEST_LOCATION );
130 int UtcDaliFrameBufferImageAttachments01(void)
132 TestApplication application;
134 tet_infoline("UtcDaliFrameBufferImageAttachments01 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
136 // invoke default handle constructor
137 FrameBufferImage image;
140 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR); // create framebuffer with Color buffer
141 ImageActor actor=ImageActor::New(image);
142 Stage::GetCurrent().Add(actor);
144 application.SendNotification();
145 application.Render();
146 application.Render();
147 application.SendNotification();
149 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), true, TEST_LOCATION);
150 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), false, TEST_LOCATION);
151 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), false, TEST_LOCATION);
156 int UtcDaliFrameBufferImageAttachments02(void)
158 TestApplication application;
160 tet_infoline("UtcDaliFrameBufferImageAttachments02 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
162 // invoke default handle constructor
163 FrameBufferImage image;
166 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR_DEPTH); // create framebuffer with Color and Depth buffer
167 ImageActor actor=ImageActor::New(image);
168 Stage::GetCurrent().Add(actor);
170 application.SendNotification();
171 application.Render();
172 application.Render();
173 application.SendNotification();
175 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), true, TEST_LOCATION);
176 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), true, TEST_LOCATION);
177 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), false, TEST_LOCATION);
182 int UtcDaliFrameBufferImageAttachments03(void)
184 TestApplication application;
186 tet_infoline("UtcDaliFrameBufferImageAttachments03 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
188 // invoke default handle constructor
189 FrameBufferImage image;
192 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR_STENCIL); // create framebuffer with Color and Stencil
193 ImageActor actor=ImageActor::New(image);
194 Stage::GetCurrent().Add(actor);
196 application.SendNotification();
197 application.Render();
198 application.Render();
199 application.SendNotification();
201 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), true, TEST_LOCATION);
202 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), false, TEST_LOCATION);
203 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), true, TEST_LOCATION);
208 int UtcDaliFrameBufferImageAttachments04(void)
210 TestApplication application;
212 tet_infoline("UtcDaliFrameBufferImageAttachments04 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
214 // invoke default handle constructor
215 FrameBufferImage image;
218 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR_DEPTH_STENCIL); // create framebuffer with Color, Depth and Stencil buffers
219 ImageActor actor=ImageActor::New(image);
220 Stage::GetCurrent().Add(actor);
222 application.SendNotification();
223 application.Render();
224 application.Render();
225 application.SendNotification();
227 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), true, TEST_LOCATION);
228 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), true, TEST_LOCATION);
229 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), true, TEST_LOCATION);
234 int UtcDaliFrameBufferImageDownCast(void)
236 TestApplication application;
237 tet_infoline("Testing Dali::FrameBufferImage::DownCast()");
239 FrameBufferImage image = FrameBufferImage::New();
241 BaseHandle object(image);
243 FrameBufferImage image2 = FrameBufferImage::DownCast(object);
244 DALI_TEST_CHECK(image2);
246 FrameBufferImage image3 = DownCast< FrameBufferImage >(object);
247 DALI_TEST_CHECK(image3);
249 BaseHandle unInitializedObject;
250 FrameBufferImage image4 = FrameBufferImage::DownCast(unInitializedObject);
251 DALI_TEST_CHECK(!image4);
253 FrameBufferImage image5 = DownCast< FrameBufferImage >(unInitializedObject);
254 DALI_TEST_CHECK(!image5);
256 Image image6 = FrameBufferImage::New();
257 FrameBufferImage image7 = FrameBufferImage::DownCast(image6);
258 DALI_TEST_CHECK(image7);