2 * Copyright (c) 2020 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.
18 #include <dali-test-suite-utils.h>
19 #include <dali/devel-api/rendering/frame-buffer-devel.h>
20 #include <dali/public-api/dali-core.h>
24 #include <mesh-builder.h>
26 void framebuffer_set_startup(void)
28 test_return_value = TET_UNDEF;
31 void framebuffer_set_cleanup(void)
33 test_return_value = TET_PASS;
36 int UtcDaliFrameBufferNew01(void)
38 TestApplication application;
40 unsigned int width(64);
41 unsigned int height(64);
42 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
44 DALI_TEST_CHECK(frameBuffer);
46 application.SendNotification();
49 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 0u, TEST_LOCATION);
50 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
51 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
56 int UtcDaliFrameBufferNew02(void)
58 TestApplication application;
60 unsigned int width(64);
61 unsigned int height(64);
62 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH);
64 DALI_TEST_CHECK(frameBuffer);
66 application.SendNotification();
69 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 0u, TEST_LOCATION);
70 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
71 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
76 int UtcDaliFrameBufferNew03(void)
78 TestApplication application;
80 unsigned int width(64);
81 unsigned int height(64);
82 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::STENCIL);
84 DALI_TEST_CHECK(frameBuffer);
86 application.SendNotification();
89 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 0u, TEST_LOCATION);
90 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
91 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
96 int UtcDaliFrameBufferNew04(void)
98 TestApplication application;
100 unsigned int width(64);
101 unsigned int height(64);
102 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
104 DALI_TEST_CHECK(frameBuffer);
106 application.SendNotification();
107 application.Render();
109 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 0u, TEST_LOCATION);
110 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
111 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
116 int UtcDaliFrameBufferNew05(void)
118 TestApplication application;
119 FrameBuffer frameBuffer;
120 DALI_TEST_CHECK(!frameBuffer);
124 int UtcDaliFrameBufferNew06(void)
126 TestApplication application;
128 unsigned int width(64);
129 unsigned int height(64);
130 FrameBuffer frameBuffer = FrameBuffer::New(width, height, static_cast<FrameBuffer::Attachment::Mask>(FrameBuffer::Attachment::DEPTH | FrameBuffer::Attachment::STENCIL));
132 DALI_TEST_CHECK(frameBuffer);
134 application.SendNotification();
135 application.Render();
137 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 0u, TEST_LOCATION);
138 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
139 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
144 int UtcDaliFrameBufferNewWithColor01(void)
146 TestApplication application;
148 uint32_t height = 64;
149 FrameBuffer frameBuffer = FrameBuffer::New(width, height);
150 application.SendNotification();
151 application.Render();
152 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
153 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
154 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
155 // check that texture is not empty handle
156 DALI_TEST_CHECK(frameBuffer.GetColorTexture());
160 int UtcDaliFrameBufferNewWithColor02(void)
162 TestApplication application;
164 uint32_t height = 64;
165 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::COLOR);
166 application.SendNotification();
167 application.Render();
168 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
169 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
170 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
171 // check that texture is not empty handle
172 DALI_TEST_CHECK(frameBuffer.GetColorTexture());
176 int UtcDaliFrameBufferNewWithColor03(void)
178 TestApplication application;
180 uint32_t height = 64;
181 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::COLOR_DEPTH);
182 application.SendNotification();
183 application.Render();
184 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
185 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
186 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
187 // check that texture is not empty handle
188 DALI_TEST_CHECK(frameBuffer.GetColorTexture());
192 int UtcDaliFrameBufferNewWithColor04(void)
194 TestApplication application;
196 uint32_t height = 64;
197 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::COLOR_STENCIL);
198 application.SendNotification();
199 application.Render();
200 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
201 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
202 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
203 // check that texture is not empty handle
204 DALI_TEST_CHECK(frameBuffer.GetColorTexture());
208 int UtcDaliFrameBufferNewWithColor05(void)
210 TestApplication application;
212 uint32_t height = 64;
213 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::COLOR_DEPTH_STENCIL);
214 application.SendNotification();
215 application.Render();
216 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
217 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
218 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
219 // check that texture is not empty handle
220 DALI_TEST_CHECK(frameBuffer.GetColorTexture());
224 int UtcDaliFrameBufferCopyConstructor(void)
226 TestApplication application;
228 unsigned int width(64);
229 unsigned int height(64);
230 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
232 FrameBuffer frameBufferCopy(frameBuffer);
234 DALI_TEST_CHECK(frameBufferCopy);
239 int UtcDaliFrameBufferAssignmentOperator(void)
241 TestApplication application;
243 unsigned int width(64);
244 unsigned int height(64);
245 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
247 FrameBuffer frameBuffer2;
248 DALI_TEST_CHECK(!frameBuffer2);
250 frameBuffer2 = frameBuffer;
251 DALI_TEST_CHECK(frameBuffer2);
256 int UtcDaliFrameBufferMoveConstructor(void)
258 TestApplication application;
261 uint32_t height = 64;
262 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
263 DALI_TEST_CHECK(frameBuffer);
264 DALI_TEST_EQUALS(1, frameBuffer.GetBaseObject().ReferenceCount(), TEST_LOCATION);
266 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
267 frameBuffer.AttachColorTexture(texture);
268 DALI_TEST_EQUALS(frameBuffer.GetColorTexture(), texture, TEST_LOCATION);
270 FrameBuffer move = std::move(frameBuffer);
271 DALI_TEST_CHECK(move);
272 DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
273 DALI_TEST_EQUALS(move.GetColorTexture(), texture, TEST_LOCATION);
274 DALI_TEST_CHECK(!frameBuffer);
279 int UtcDaliFrameBufferMoveAssignment(void)
281 TestApplication application;
284 uint32_t height = 64;
285 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
286 DALI_TEST_CHECK(frameBuffer);
287 DALI_TEST_EQUALS(1, frameBuffer.GetBaseObject().ReferenceCount(), TEST_LOCATION);
289 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
290 frameBuffer.AttachColorTexture(texture);
291 DALI_TEST_EQUALS(frameBuffer.GetColorTexture(), texture, TEST_LOCATION);
294 move = std::move(frameBuffer);
295 DALI_TEST_CHECK(move);
296 DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
297 DALI_TEST_EQUALS(move.GetColorTexture(), texture, TEST_LOCATION);
298 DALI_TEST_CHECK(!frameBuffer);
303 int UtcDaliFrameBufferDownCast01(void)
305 TestApplication application;
306 unsigned int width(64);
307 unsigned int height(64);
308 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
310 BaseHandle handle(frameBuffer);
311 FrameBuffer frameBuffer2 = FrameBuffer::DownCast(handle);
312 DALI_TEST_CHECK(frameBuffer2);
317 int UtcDaliFrameBufferDownCast02(void)
319 TestApplication application;
321 Handle handle = Handle::New(); // Create a custom object
322 FrameBuffer frameBuffer = FrameBuffer::DownCast(handle);
323 DALI_TEST_CHECK(!frameBuffer);
327 int UtcDaliFrameBufferAttachColorTexture01(void)
329 TestApplication application;
331 unsigned int width(64);
332 unsigned int height(64);
333 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
334 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
335 frameBuffer.AttachColorTexture(texture);
337 application.SendNotification();
338 application.Render();
340 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
341 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
342 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
347 int UtcDaliFrameBufferAttachColorTexture02(void)
349 TestApplication application;
351 unsigned int width(64);
352 unsigned int height(64);
353 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
354 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
355 texture.GenerateMipmaps();
358 frameBuffer.AttachColorTexture(texture, 0u, 1u);
360 application.SendNotification();
361 application.Render();
363 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
364 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
365 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
370 int UtcDaliFrameBufferAttachColorTexture03(void)
372 TestApplication application;
374 unsigned int width(64);
375 unsigned int height(64);
376 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
377 Texture texture = Texture::New(TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height);
378 texture.GenerateMipmaps();
380 //Attach NEGATIVE_Y face of the cubemap
381 frameBuffer.AttachColorTexture(texture, 0u, CubeMapLayer::NEGATIVE_Y);
383 application.SendNotification();
384 application.Render();
386 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
387 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
388 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
393 int UtcDaliFrameBufferAttachColorTexture04(void)
395 TestApplication application;
397 unsigned int width(64);
398 unsigned int height(64);
399 FrameBuffer frameBuffer = FrameBuffer::New(width, height, static_cast<FrameBuffer::Attachment::Mask>(FrameBuffer::Attachment::DEPTH | FrameBuffer::Attachment::STENCIL));
400 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
401 frameBuffer.AttachColorTexture(texture);
403 application.SendNotification();
404 application.Render();
406 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
407 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
408 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
413 int UtcDaliFrameBufferAttachColorTexture05(void)
415 TestApplication application;
417 unsigned int width(64);
418 unsigned int height(64);
419 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
420 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
422 // N.B. it doesn't make sense per se, however the OGL standard doesn't seem to forbid attaching the same texture to different slots.
423 for(int i = 0; i < Dali::DevelFrameBuffer::MAX_COLOR_ATTACHMENTS + 1; ++i)
425 frameBuffer.AttachColorTexture(texture);
428 application.SendNotification();
429 application.Render();
431 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), Dali::DevelFrameBuffer::MAX_COLOR_ATTACHMENTS, TEST_LOCATION);
432 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
433 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
438 int UtcDaliFrameBufferAttachDepthTexture01(void)
440 TestApplication application;
442 unsigned int width(64);
443 unsigned int height(64);
444 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
445 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
446 frameBuffer.AttachColorTexture(texture);
448 Texture textureDepth = Texture::New(TextureType::TEXTURE_2D, Pixel::DEPTH_UNSIGNED_INT, width, height);
449 DevelFrameBuffer::AttachDepthTexture(frameBuffer, textureDepth);
451 application.SendNotification();
452 application.Render();
454 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
455 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
456 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
461 int UtcDaliFrameBufferAttachDepthStencilTexture01(void)
463 TestApplication application;
465 unsigned int width(64);
466 unsigned int height(64);
467 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
468 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
469 frameBuffer.AttachColorTexture(texture);
471 Texture textureStencil = Texture::New(TextureType::TEXTURE_2D, Pixel::DEPTH_STENCIL, width, height);
472 DevelFrameBuffer::AttachDepthStencilTexture(frameBuffer, textureStencil);
474 application.SendNotification();
475 application.Render();
477 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
478 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
479 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
484 int UtcDaliFrameBufferGetColorTexture01(void)
486 TestApplication application;
488 unsigned int width(64);
489 unsigned int height(64);
490 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
491 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
492 frameBuffer.AttachColorTexture(texture);
494 DALI_TEST_EQUALS(frameBuffer.GetColorTexture(), texture, TEST_LOCATION);
499 int UtcDaliFrameBufferGetColorTexture02(void)
501 TestApplication application;
503 unsigned int width(64);
504 unsigned int height(64);
505 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
506 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
507 frameBuffer.AttachColorTexture(texture, 0u, 1u);
509 DALI_TEST_EQUALS(frameBuffer.GetColorTexture(), texture, TEST_LOCATION);
514 int UtcDaliFrameBufferGetColorTexture03(void)
515 { // FrameBuffer::GetColorTexture() and GetColorTexture(0) are equivalent
516 TestApplication application;
518 unsigned int width(64);
519 unsigned int height(64);
520 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
521 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
522 frameBuffer.AttachColorTexture(texture, 0u, 1u);
524 DALI_TEST_EQUALS(frameBuffer.GetColorTexture(), texture, TEST_LOCATION);
525 DALI_TEST_EQUALS(DevelFrameBuffer::GetColorTexture(frameBuffer, 0), texture, TEST_LOCATION);
530 int UtcDaliFrameBufferGetColorTexture04(void)
532 TestApplication application;
534 unsigned int width(64);
535 unsigned int height(64);
536 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
537 Texture textures[] = {
538 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
539 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
540 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
541 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
542 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
543 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
544 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
545 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
548 for(auto& t : textures)
550 frameBuffer.AttachColorTexture(t, 0u, 1u);
553 for(unsigned int i = 0; i < std::extent<decltype(textures)>::value; ++i)
555 DALI_TEST_EQUALS(DevelFrameBuffer::GetColorTexture(frameBuffer, i), textures[i], TEST_LOCATION);
561 int UtcDaliFrameBufferGetDepthTexture01(void)
563 TestApplication application;
565 unsigned int width(64);
566 unsigned int height(64);
567 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
568 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
569 frameBuffer.AttachColorTexture(texture);
571 Texture textureDepth = Texture::New(TextureType::TEXTURE_2D, Pixel::DEPTH_FLOAT, width, height);
572 DevelFrameBuffer::AttachDepthTexture(frameBuffer, textureDepth);
574 DALI_TEST_EQUALS(DevelFrameBuffer::GetDepthTexture(frameBuffer), textureDepth, TEST_LOCATION);
579 int UtcDaliFrameBufferGetDepthStencilTexture01(void)
581 TestApplication application;
583 unsigned int width(64);
584 unsigned int height(64);
585 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
586 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
587 frameBuffer.AttachColorTexture(texture);
589 Texture textureStencil = Texture::New(TextureType::TEXTURE_2D, Pixel::DEPTH_STENCIL, width, height);
590 DevelFrameBuffer::AttachDepthStencilTexture(frameBuffer, textureStencil);
592 DALI_TEST_EQUALS(DevelFrameBuffer::GetDepthStencilTexture(frameBuffer), textureStencil, TEST_LOCATION);
597 int UtcDaliFramebufferContextLoss(void)
599 tet_infoline("UtcDaliFramebufferContextLoss\n");
600 TestApplication application;
603 unsigned int width(64);
604 unsigned int height(64);
605 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
606 DALI_TEST_CHECK(texture);
607 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
608 DALI_TEST_CHECK(frameBuffer);
609 frameBuffer.AttachColorTexture(texture, 0u, 1u);
611 Geometry geometry = CreateQuadGeometry();
612 Shader shader = CreateShader();
613 Renderer renderer = Renderer::New(geometry, shader);
615 application.SendNotification();
616 application.Render(16);
618 // Lose & regain context (in render 'thread')
619 application.ResetContext();
620 DALI_TEST_CHECK(frameBuffer);
625 int UtcDaliFrameBufferGetColorTextureNegative(void)
627 TestApplication application;
628 Dali::FrameBuffer instance;
631 instance.GetColorTexture();
632 DALI_TEST_CHECK(false); // Should not get here
636 DALI_TEST_CHECK(true); // We expect an assert
641 int UtcDaliFrameBufferAttachColorTextureNegative01(void)
643 TestApplication application;
644 Dali::FrameBuffer instance;
647 Dali::Texture arg1 = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 400u, 400u);
648 instance.AttachColorTexture(arg1);
649 DALI_TEST_CHECK(false); // Should not get here
653 DALI_TEST_CHECK(true); // We expect an assert
658 int UtcDaliFrameBufferAttachColorTextureNegative02(void)
660 TestApplication application;
661 Dali::FrameBuffer instance;
664 Dali::Texture arg1 = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 400u, 400u);
665 unsigned int arg2(0u);
666 unsigned int arg3(0u);
667 instance.AttachColorTexture(arg1, arg2, arg3);
668 DALI_TEST_CHECK(false); // Should not get here
672 DALI_TEST_CHECK(true); // We expect an assert