2 * Copyright (c) 2023 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.
24 #include <dali-toolkit-test-suite-utils.h>
26 #include <toolkit-environment-variable.h>
27 #include <toolkit-event-thread-callback.h>
28 #include <toolkit-texture-upload-manager.h>
29 #include <toolkit-timer.h>
31 #include <dali-toolkit/dali-toolkit.h>
32 #include <dali-toolkit/devel-api/controls/control-devel.h>
33 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
34 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
35 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
36 #include <dali-toolkit/devel-api/visuals/image-visual-actions-devel.h>
37 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
38 #include <dali-toolkit/public-api/image-loader/image-url.h>
39 #include <dali-toolkit/public-api/image-loader/image.h>
41 #include <dali/devel-api/adaptor-framework/texture-upload-manager.h>
43 #include "dummy-control.h"
44 #include "test-encoded-image-buffer.h"
45 #include "test-native-image-source.h"
48 using namespace Dali::Toolkit;
50 void dali_image_visual_startup(void)
52 test_return_value = TET_UNDEF;
55 void dali_image_visual_cleanup(void)
57 test_return_value = TET_PASS;
62 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
63 const char* TEST_BROKEN_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/a-random-nonimage.jpg";
64 const char* TEST_LARGE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/tbcol.png";
65 const char* TEST_SMALL_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/icon-edit.png";
66 const char* TEST_REMOTE_IMAGE_FILE_NAME = "https://www.tizen.org/sites/all/themes/tizen_theme/logo.png";
67 const char* TEST_INVALID_FILE_NAME = TEST_RESOURCE_DIR "/invalid.jpg";
68 const char* TEST_REMOTE_INVALID_FILE_NAME = "https://www.tizen.org/invalid.png";
69 const char* TEST_MASK_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/mask.png";
70 const char* TEST_ROTATED_IMAGE = TEST_RESOURCE_DIR "/keyboard-Landscape.jpg";
71 const char* TEST_YUV420_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1-yuv420.jpg";
72 const char* TEST_N_PATCH_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/heartsframe.9.png";
74 constexpr auto LOAD_IMAGE_YUV_PLANES_ENV = "DALI_LOAD_IMAGE_YUV_PLANES";
75 constexpr auto ENABLE_DECODE_JPEG_TO_YUV_420_ENV = "DALI_ENABLE_DECODE_JPEG_TO_YUV_420";
77 bool gResourceReadySignalFired = false;
78 std::vector<int> gReadyIds = {};
79 void ResourceReadySignal(Control control)
81 gResourceReadySignalFired = true;
82 gReadyIds.push_back(control.GetProperty<int>(Actor::Property::ID));
89 Actor CreateActorWithImageVisual(const Property::Map& map)
91 VisualFactory factory = VisualFactory::Get();
92 DummyControl actor = DummyControl::New();
93 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
94 Visual::Base visual = factory.CreateVisual(map);
95 DALI_TEST_CHECK(visual);
96 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
97 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
98 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
102 Visual::Base CreateVisualWithPolicy(const char* url, Property::Index key, const Property::Value& value)
104 VisualFactory factory = VisualFactory::Get();
106 Property::Map propertyMap;
107 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
108 propertyMap.Insert(ImageVisual::Property::URL, url);
109 propertyMap.Insert(ImageVisual::Property::DESIRED_WIDTH, 20);
110 propertyMap.Insert(ImageVisual::Property::DESIRED_HEIGHT, 30);
111 propertyMap.Insert(key, value);
113 return factory.CreateVisual(propertyMap);
118 void TestVisualRender(ToolkitTestApplication& application,
120 Visual::Base& visual,
121 std::size_t expectedSamplers = 0,
122 ImageDimensions imageDimensions = ImageDimensions(),
123 Integration::ResourcePointer resourcePtr = Integration::ResourcePointer())
125 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
126 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
130 // set the image size, for test case, this needs to be set before loading started
131 application.GetPlatform().SetClosestImageSize(Vector2(imageDimensions.GetWidth(), imageDimensions.GetHeight()));
134 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
135 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
137 application.GetScene().Add(actor);
139 application.SendNotification(); // Send messages to update
140 application.Render(); // process update and render
141 application.SendNotification(); // process any signals to event
145 DALI_TEST_EQUALS(application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceSynchronouslyFunc), true, TEST_LOCATION);
148 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
151 static void TestMixColor(Visual::Base visual, Property::Index mixColorIndex, const Vector4& testColor)
154 visual.CreatePropertyMap(map);
155 Property::Value* value = map.Find(mixColorIndex);
156 DALI_TEST_CHECK(value);
158 DALI_TEST_CHECK(value->Get(mixColor1));
159 DALI_TEST_EQUALS(mixColor1, Vector3(testColor), 0.001, TEST_LOCATION);
161 value = map.Find(Visual::Property::MIX_COLOR);
162 DALI_TEST_CHECK(value);
164 DALI_TEST_CHECK(value->Get(mixColor2));
165 DALI_TEST_EQUALS(mixColor2, testColor, 0.001, TEST_LOCATION);
167 value = map.Find(Visual::Property::OPACITY);
168 DALI_TEST_CHECK(value);
170 DALI_TEST_CHECK(value->Get(opacity));
171 DALI_TEST_EQUALS(opacity, testColor.a, 0.001, TEST_LOCATION);
174 int UtcDaliImageVisualPropertyMap(void)
176 ToolkitTestApplication application;
177 tet_infoline("Request image visual with a Property::Map");
179 VisualFactory factory = VisualFactory::Get();
180 DALI_TEST_CHECK(factory);
181 factory.SetPreMultiplyOnLoad(true);
183 Property::Map propertyMap;
184 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
185 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
187 Visual::Base visual = factory.CreateVisual(propertyMap);
188 DALI_TEST_CHECK(visual);
190 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
191 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
193 TestGlAbstraction& gl = application.GetGlAbstraction();
194 TraceCallStack& textureTrace = gl.GetTextureTrace();
195 textureTrace.Enable(true);
197 DummyControl actor = DummyControl::New();
198 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
199 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
201 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
202 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
204 application.GetScene().Add(actor);
205 application.SendNotification();
206 application.Render();
208 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
210 application.SendNotification();
211 application.Render();
213 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
214 auto renderer = actor.GetRendererAt(0);
215 auto preMultipliedIndex = renderer.GetPropertyIndex("preMultipliedAlpha");
216 DALI_TEST_CHECK(preMultipliedIndex != Property::INVALID_INDEX);
217 auto preMultipliedAlpha = renderer.GetProperty<float>(preMultipliedIndex);
218 auto preMultipliedAlpha2 = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
219 DALI_TEST_EQUALS(preMultipliedAlpha, 1.0f, TEST_LOCATION);
220 DALI_TEST_EQUALS(preMultipliedAlpha2, true, TEST_LOCATION);
221 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
223 application.GetScene().Remove(actor);
224 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
229 int UtcDaliImageVisualNoPremultipliedAlpha01(void)
231 ToolkitTestApplication application;
232 tet_infoline("Request image visual without pre-multiplied alpha");
234 VisualFactory factory = VisualFactory::Get();
235 DALI_TEST_CHECK(factory);
236 factory.SetPreMultiplyOnLoad(false);
238 Property::Map propertyMap;
239 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
240 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
242 Visual::Base visual = factory.CreateVisual(propertyMap);
243 DALI_TEST_CHECK(visual);
245 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
246 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
248 TestGlAbstraction& gl = application.GetGlAbstraction();
249 TraceCallStack& textureTrace = gl.GetTextureTrace();
250 textureTrace.Enable(true);
252 DummyControl actor = DummyControl::New();
253 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
254 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
256 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
257 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
259 application.GetScene().Add(actor);
260 application.SendNotification();
261 application.Render();
263 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
265 application.SendNotification();
266 application.Render();
268 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
269 auto renderer = actor.GetRendererAt(0);
270 auto preMultipliedIndex = renderer.GetPropertyIndex("preMultipliedAlpha");
271 DALI_TEST_CHECK(preMultipliedIndex != Property::INVALID_INDEX);
272 auto preMultipliedAlpha = renderer.GetProperty<bool>(preMultipliedIndex);
273 auto preMultipliedAlpha2 = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
275 DALI_TEST_EQUALS(preMultipliedAlpha, false, TEST_LOCATION);
276 DALI_TEST_EQUALS(preMultipliedAlpha2, false, TEST_LOCATION);
278 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
280 application.GetScene().Remove(actor);
281 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
286 int UtcDaliImageVisualNoPremultipliedAlpha02(void)
288 ToolkitTestApplication application;
289 tet_infoline("Request image visual with no alpha channel");
291 VisualFactory factory = VisualFactory::Get();
292 DALI_TEST_CHECK(factory);
294 Property::Map propertyMap;
295 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
296 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
298 Visual::Base visual = factory.CreateVisual(propertyMap);
299 DALI_TEST_CHECK(visual);
301 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
302 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
304 TestGlAbstraction& gl = application.GetGlAbstraction();
305 TraceCallStack& textureTrace = gl.GetTextureTrace();
306 textureTrace.Enable(true);
308 DummyControl actor = DummyControl::New();
309 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
310 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
312 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
313 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
315 application.GetScene().Add(actor);
316 application.SendNotification();
317 application.Render();
319 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
321 application.SendNotification();
322 application.Render();
324 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
325 auto renderer = actor.GetRendererAt(0);
326 auto preMultipliedIndex = renderer.GetPropertyIndex("preMultipliedAlpha");
327 DALI_TEST_CHECK(preMultipliedIndex != Property::INVALID_INDEX);
328 auto preMultipliedAlpha = renderer.GetProperty<bool>(preMultipliedIndex);
329 auto preMultipliedAlpha2 = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
331 DALI_TEST_EQUALS(preMultipliedAlpha, false, TEST_LOCATION);
332 DALI_TEST_EQUALS(preMultipliedAlpha2, false, TEST_LOCATION);
334 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
336 int srcFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
337 int destFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
338 int srcFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
339 int destFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
340 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
341 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
342 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
343 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
345 textureTrace.Reset();
347 // Make a new visual with the same image
348 Visual::Base newVisual = factory.CreateVisual(propertyMap);
349 DALI_TEST_CHECK(newVisual);
351 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
352 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
354 DummyControl newActor = DummyControl::New();
355 DummyControlImpl& newDummyImpl = static_cast<DummyControlImpl&>(newActor.GetImplementation());
356 newDummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, newVisual);
358 newActor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
359 DALI_TEST_EQUALS(newActor.GetRendererCount(), 0u, TEST_LOCATION);
361 application.GetScene().Add(newActor);
363 application.SendNotification();
364 application.Render();
366 DALI_TEST_EQUALS(newActor.GetRendererCount(), 1u, TEST_LOCATION);
367 auto newRenderer = newActor.GetRendererAt(0);
368 preMultipliedIndex = newRenderer.GetPropertyIndex("preMultipliedAlpha");
369 DALI_TEST_CHECK(preMultipliedIndex != Property::INVALID_INDEX);
370 preMultipliedAlpha = newRenderer.GetProperty<bool>(preMultipliedIndex);
371 preMultipliedAlpha2 = newRenderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
373 DALI_TEST_EQUALS(preMultipliedAlpha, false, TEST_LOCATION);
374 DALI_TEST_EQUALS(preMultipliedAlpha2, false, TEST_LOCATION);
376 srcFactorRgb = newRenderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
377 destFactorRgb = newRenderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
378 srcFactorAlpha = newRenderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
379 destFactorAlpha = newRenderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
380 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
381 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
382 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
383 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
385 application.GetScene().Remove(actor);
386 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
391 int UtcDaliImageVisualRemoteImageLoad(void)
393 ToolkitTestApplication application;
394 tet_infoline("Request remote image visual with a Property::Map");
396 VisualFactory factory = VisualFactory::Get();
397 DALI_TEST_CHECK(factory);
399 Property::Map propertyMap;
400 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
401 propertyMap.Insert(ImageVisual::Property::URL, TEST_REMOTE_IMAGE_FILE_NAME);
403 Visual::Base visual = factory.CreateVisual(propertyMap);
404 DALI_TEST_CHECK(visual);
406 TestGlAbstraction& gl = application.GetGlAbstraction();
407 TraceCallStack& textureTrace = gl.GetTextureTrace();
408 textureTrace.Enable(true);
410 DummyControl actor = DummyControl::New();
411 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
412 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
414 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
415 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
417 application.GetScene().Add(actor);
418 application.SendNotification();
420 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
422 application.SendNotification();
423 application.Render();
425 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
426 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
428 application.GetScene().Remove(actor);
429 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
434 int UtcDaliImageVisualWithFrameBufferPreMultipliedAlpha01(void)
436 ToolkitTestApplication application;
437 tet_infoline("Use FrameBuffer as url");
441 FrameBuffer frameBuffer = Dali::FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
443 DALI_TEST_CHECK(frameBuffer);
444 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(frameBuffer, Pixel::Format::RGBA8888, width, height);
445 std::string url = imageUrl.GetUrl();
447 VisualFactory factory = VisualFactory::Get();
448 DALI_TEST_CHECK(factory);
450 Property::Map propertyMap;
451 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
452 propertyMap.Insert(ImageVisual::Property::URL, url);
454 Visual::Base visual = factory.CreateVisual(propertyMap);
455 DALI_TEST_CHECK(visual);
457 DummyControl actor = DummyControl::New();
458 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
459 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
461 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
463 application.GetScene().Add(actor);
465 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
467 application.SendNotification();
468 application.Render(16);
470 Renderer renderer = actor.GetRendererAt(0);
472 // Check whether preMultipliedAlpha is true.
473 auto preMultipliedAlpha = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
474 DALI_TEST_EQUALS(preMultipliedAlpha, true, TEST_LOCATION);
479 int UtcDaliImageVisualWithFrameBufferPreMultipliedAlpha02(void)
481 ToolkitTestApplication application;
482 tet_infoline("Use FrameBuffer as url");
486 FrameBuffer frameBuffer = Dali::FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
488 DALI_TEST_CHECK(frameBuffer);
490 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
491 frameBuffer.AttachColorTexture(texture);
493 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(frameBuffer, 0u);
494 std::string url = imageUrl.GetUrl();
496 VisualFactory factory = VisualFactory::Get();
497 DALI_TEST_CHECK(factory);
499 Property::Map propertyMap;
500 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
501 propertyMap.Insert(ImageVisual::Property::URL, url);
503 Visual::Base visual = factory.CreateVisual(propertyMap);
504 DALI_TEST_CHECK(visual);
506 DummyControl actor = DummyControl::New();
507 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
508 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
510 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
512 application.GetScene().Add(actor);
514 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
516 application.SendNotification();
517 application.Render(16);
519 Renderer renderer = actor.GetRendererAt(0);
521 // Check whether preMultipliedAlpha is true.
522 auto preMultipliedAlpha = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
523 DALI_TEST_EQUALS(preMultipliedAlpha, true, TEST_LOCATION);
528 int UtcDaliImageVisualWithPixelData(void)
530 ToolkitTestApplication application;
531 tet_infoline("Use PixelData as url");
535 uint32_t bufferSize = width * height * Pixel::GetBytesPerPixel(Pixel::RGBA8888);
537 uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(bufferSize));
538 PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
540 DALI_TEST_CHECK(pixelData);
542 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(pixelData);
543 std::string url = imageUrl.GetUrl();
545 VisualFactory factory = VisualFactory::Get();
546 DALI_TEST_CHECK(factory);
548 Property::Map propertyMap;
549 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
550 propertyMap.Insert(ImageVisual::Property::URL, url);
552 Visual::Base visual = factory.CreateVisual(propertyMap);
553 DALI_TEST_CHECK(visual);
555 DummyControl actor = DummyControl::New();
556 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
557 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
559 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
561 application.GetScene().Add(actor);
563 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
565 application.SendNotification();
566 application.Render(16);
568 Renderer renderer = actor.GetRendererAt(0);
570 // Check whether preMultipliedAlpha is false.
571 auto preMultipliedAlpha = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
572 DALI_TEST_EQUALS(preMultipliedAlpha, false, TEST_LOCATION);
577 int UtcDaliImageVisualWithPixelDataPreMultipliedAlpha(void)
579 ToolkitTestApplication application;
580 tet_infoline("Use PixelData as url");
584 uint32_t bufferSize = width * height * Pixel::GetBytesPerPixel(Pixel::RGBA8888);
586 uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(bufferSize));
587 PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
589 DALI_TEST_CHECK(pixelData);
591 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(pixelData, true);
592 std::string url = imageUrl.GetUrl();
594 VisualFactory factory = VisualFactory::Get();
595 DALI_TEST_CHECK(factory);
597 Property::Map propertyMap;
598 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
599 propertyMap.Insert(ImageVisual::Property::URL, url);
601 Visual::Base visual = factory.CreateVisual(propertyMap);
602 DALI_TEST_CHECK(visual);
604 DummyControl actor = DummyControl::New();
605 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
606 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
608 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
610 application.GetScene().Add(actor);
612 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
614 application.SendNotification();
615 application.Render(16);
617 Renderer renderer = actor.GetRendererAt(0);
619 // Check whether preMultipliedAlpha is true.
620 auto preMultipliedAlpha = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
621 DALI_TEST_EQUALS(preMultipliedAlpha, true, TEST_LOCATION);
626 int UtcDaliImageVisualWithPixelDataMasking(void)
628 ToolkitTestApplication application;
629 tet_infoline("Load external texture with mask");
631 TestGlAbstraction& gl = application.GetGlAbstraction();
632 TraceCallStack& textureTrace = gl.GetTextureTrace();
633 textureTrace.Enable(true);
637 uint32_t bufferSize = width * height * Pixel::GetBytesPerPixel(Pixel::RGBA8888);
639 uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(bufferSize));
640 PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
642 DALI_TEST_CHECK(pixelData);
644 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(pixelData, true);
645 std::string url = imageUrl.GetUrl();
647 VisualFactory factory = VisualFactory::Get();
648 DALI_TEST_CHECK(factory);
650 Property::Map propertyMap;
651 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
652 propertyMap.Insert(ImageVisual::Property::URL, url);
653 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
655 Visual::Base visual = factory.CreateVisual(propertyMap);
656 DALI_TEST_CHECK(visual);
658 Property::Map testMap;
659 visual.CreatePropertyMap(testMap);
660 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
662 DummyControl actor = DummyControl::New();
663 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
664 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
666 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
668 application.GetScene().Add(actor);
669 application.SendNotification();
670 application.Render(16);
671 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
673 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
674 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
675 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
677 dummyImpl.UnregisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1);
678 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
683 int UtcDaliImageVisualWithPixelDataMasking02(void)
685 ToolkitTestApplication application;
686 tet_infoline("Load premultiplied external texture with mask");
688 TestGlAbstraction& gl = application.GetGlAbstraction();
689 TraceCallStack& textureTrace = gl.GetTextureTrace();
690 textureTrace.Enable(true);
694 uint32_t bufferSize = width * height * Pixel::GetBytesPerPixel(Pixel::RGBA8888);
696 uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(bufferSize));
697 PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
699 DALI_TEST_CHECK(pixelData);
701 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(pixelData, true);
702 std::string url = imageUrl.GetUrl();
704 VisualFactory factory = VisualFactory::Get();
705 DALI_TEST_CHECK(factory);
707 Property::Map propertyMap;
708 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
709 propertyMap.Insert(ImageVisual::Property::URL, url);
710 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
712 Visual::Base visual = factory.CreateVisual(propertyMap);
713 DALI_TEST_CHECK(visual);
715 Property::Map testMap;
716 visual.CreatePropertyMap(testMap);
717 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
719 DummyControl actor = DummyControl::New();
720 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
721 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
723 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
725 application.GetScene().Add(actor);
726 application.SendNotification();
727 application.Render(16);
728 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
730 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
731 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
732 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
734 Renderer renderer = actor.GetRendererAt(0);
736 //Check visual property
737 DALI_TEST_EQUALS(*testMap.Find(Visual::Property::PREMULTIPLIED_ALPHA), Property::Value(true), TEST_LOCATION);
739 // Check whether preMultipliedAlpha is true.
740 auto preMultipliedAlpha = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
741 DALI_TEST_EQUALS(preMultipliedAlpha, true, TEST_LOCATION);
743 dummyImpl.UnregisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1);
744 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
749 int UtcDaliImageVisualWithPixelDataMaskingSynchronously(void)
751 ToolkitTestApplication application;
752 tet_infoline("Load synchronously external texture with mask");
756 uint32_t bufferSize = width * height * Pixel::GetBytesPerPixel(Pixel::RGBA8888);
758 uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(bufferSize));
759 PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
761 DALI_TEST_CHECK(pixelData);
763 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(pixelData, true);
764 std::string url = imageUrl.GetUrl();
766 VisualFactory factory = VisualFactory::Get();
767 DALI_TEST_CHECK(factory);
769 Property::Map propertyMap;
770 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
771 propertyMap.Insert(ImageVisual::Property::URL, url);
772 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
773 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
775 Visual::Base visual = factory.CreateVisual(propertyMap);
776 DALI_TEST_CHECK(visual);
778 Property::Map testMap;
779 visual.CreatePropertyMap(testMap);
780 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
782 DummyControl actor = DummyControl::New();
783 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
784 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
786 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
788 application.GetScene().Add(actor);
790 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
792 application.SendNotification();
793 application.Render(16);
798 int UtcDaliImageVisualWithNativeImage(void)
800 ToolkitTestApplication application;
801 tet_infoline("Use Native Image as url");
803 NativeImageSourcePtr nativeImageSource = NativeImageSource::New(500, 500, NativeImageSource::COLOR_DEPTH_DEFAULT);
804 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(nativeImageSource);
805 std::string url = imageUrl.GetUrl();
807 VisualFactory factory = VisualFactory::Get();
808 DALI_TEST_CHECK(factory);
810 Property::Map propertyMap;
811 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
812 propertyMap.Insert(ImageVisual::Property::URL, url);
814 Visual::Base visual = factory.CreateVisual(propertyMap);
815 DALI_TEST_CHECK(visual);
817 DummyControl actor = DummyControl::New();
818 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
819 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
821 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
823 application.GetScene().Add(actor);
825 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
827 application.SendNotification();
828 application.Render(16);
830 Renderer renderer = actor.GetRendererAt(0);
831 Shader shader = renderer.GetShader();
833 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
834 DALI_TEST_CHECK(value.GetType() == Property::MAP);
835 const Property::Map* outMap = value.GetMap();
836 std::string fragmentShader = (*outMap)["fragment"].Get<std::string>();
838 const char* fragmentPrefix = Dali::NativeImageSourceTest::GetCustomFragmentPrefix();
839 size_t pos = fragmentShader.find(fragmentPrefix);
841 DALI_TEST_EQUALS(pos != std::string::npos, true, TEST_LOCATION);
843 // Check whether preMultipliedAlpha is false.
844 auto preMultipliedAlpha = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
845 DALI_TEST_EQUALS(preMultipliedAlpha, false, TEST_LOCATION);
850 int UtcDaliImageVisualWithNativeImagePreMultipliedAlpha(void)
852 ToolkitTestApplication application;
853 tet_infoline("Use Native Image as url");
855 NativeImageSourcePtr nativeImageSource = NativeImageSource::New(500, 500, NativeImageSource::COLOR_DEPTH_DEFAULT);
856 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(nativeImageSource, true);
857 std::string url = imageUrl.GetUrl();
859 VisualFactory factory = VisualFactory::Get();
860 DALI_TEST_CHECK(factory);
862 Property::Map propertyMap;
863 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
864 propertyMap.Insert(ImageVisual::Property::URL, url);
866 Visual::Base visual = factory.CreateVisual(propertyMap);
867 DALI_TEST_CHECK(visual);
869 DummyControl actor = DummyControl::New();
870 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
871 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
873 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
875 application.GetScene().Add(actor);
877 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
879 application.SendNotification();
880 application.Render(16);
882 Renderer renderer = actor.GetRendererAt(0);
883 Shader shader = renderer.GetShader();
885 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
886 DALI_TEST_CHECK(value.GetType() == Property::MAP);
887 const Property::Map* outMap = value.GetMap();
888 std::string fragmentShader = (*outMap)["fragment"].Get<std::string>();
890 const char* fragmentPrefix = Dali::NativeImageSourceTest::GetCustomFragmentPrefix();
891 size_t pos = fragmentShader.find(fragmentPrefix);
893 DALI_TEST_EQUALS(pos != std::string::npos, true, TEST_LOCATION);
895 // Check whether preMultipliedAlpha is true.
896 auto preMultipliedAlpha = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
897 DALI_TEST_EQUALS(preMultipliedAlpha, true, TEST_LOCATION);
902 int UtcDaliImageVisualWithNativeImageCustomShader(void)
904 ToolkitTestApplication application;
905 tet_infoline("Use Native Image as url and Use custom shader");
907 NativeImageSourcePtr nativeImageSource = NativeImageSource::New(500, 500, NativeImageSource::COLOR_DEPTH_DEFAULT);
908 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(nativeImageSource, true);
909 std::string url = imageUrl.GetUrl();
911 VisualFactory factory = VisualFactory::Get();
912 DALI_TEST_CHECK(factory);
914 Property::Map propertyMap;
915 Property::Map shaderMap;
916 const std::string customVertexShaderSource = "Foobar";
917 const std::string customFragmentShaderSource = "Foobar";
918 shaderMap[Toolkit::Visual::Shader::Property::FRAGMENT_SHADER] = customFragmentShaderSource;
919 shaderMap[Toolkit::Visual::Shader::Property::VERTEX_SHADER] = customVertexShaderSource;
921 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
922 propertyMap.Insert(Toolkit::Visual::Property::SHADER, shaderMap);
923 propertyMap.Insert(ImageVisual::Property::URL, url);
925 Visual::Base visual = factory.CreateVisual(propertyMap);
926 DALI_TEST_CHECK(visual);
928 DummyControl actor = DummyControl::New();
929 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
930 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
932 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
933 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
935 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
937 application.GetScene().Add(actor);
939 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
941 application.SendNotification();
942 application.Render(16);
944 Renderer renderer = actor.GetRendererAt(0);
945 Shader shader = renderer.GetShader();
947 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
948 DALI_TEST_CHECK(value.GetType() == Property::MAP);
949 const Property::Map* outMap = value.GetMap();
950 std::string fragmentShaderSource = (*outMap)["fragment"].Get<std::string>();
951 std::string vertexShaderSource = (*outMap)["vertex"].Get<std::string>();
953 // Compare vertex shader is equal
954 DALI_TEST_EQUALS(customVertexShaderSource, vertexShaderSource, TEST_LOCATION);
956 // Check fragment shader changed
957 const char* fragmentPrefix = Dali::NativeImageSourceTest::GetCustomFragmentPrefix();
958 size_t pos = fragmentShaderSource.find(fragmentPrefix);
960 DALI_TEST_EQUALS(pos != std::string::npos, true, TEST_LOCATION);
962 DALI_TEST_EQUALS(std::string(fragmentPrefix) + customFragmentShaderSource, fragmentShaderSource, TEST_LOCATION);
964 // Check whether preMultipliedAlpha is false.
965 // Note : We dont use preMultiplied alpha when app developer using custom shader.
966 auto preMultipliedAlpha = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
967 DALI_TEST_EQUALS(preMultipliedAlpha, false, TEST_LOCATION);
972 int UtcDaliImageVisualWithNativeImageRemoved(void)
974 ToolkitTestApplication application;
975 tet_infoline("Use Native Image as url");
977 TestGlAbstraction& gl = application.GetGlAbstraction();
978 TraceCallStack& textureTrace = gl.GetTextureTrace();
979 textureTrace.Enable(true);
981 NativeImageSourcePtr nativeImageSource = NativeImageSource::New(500, 500, NativeImageSource::COLOR_DEPTH_DEFAULT);
982 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(nativeImageSource);
983 std::string url = imageUrl.GetUrl();
985 VisualFactory factory = VisualFactory::Get();
986 DALI_TEST_CHECK(factory);
988 Property::Map propertyMap;
989 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
990 propertyMap.Insert(ImageVisual::Property::URL, url);
992 Visual::Base visual = factory.CreateVisual(propertyMap);
993 DALI_TEST_CHECK(visual);
995 DummyControl actor = DummyControl::New();
996 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
997 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
999 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
1001 application.GetScene().Add(actor);
1002 application.SendNotification();
1003 application.Render();
1005 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1006 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
1008 tet_infoline("No delete texture because reference count is not zero");
1010 application.GetScene().Remove(actor);
1011 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1012 application.SendNotification();
1013 application.Render();
1015 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
1016 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
1018 tet_infoline("Delete texture because reference count is zero");
1020 application.SendNotification();
1021 application.Render();
1023 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION);
1028 int UtcDaliImageVisualWithEncodedImageBuffer(void)
1030 ToolkitTestApplication application;
1031 tet_infoline("Use Encoded Image Buffer as url");
1033 EncodedImageBuffer rawBuffer = ConvertFileToEncodedImageBuffer(TEST_LARGE_IMAGE_FILE_NAME);
1034 ImageUrl url = Dali::Toolkit::Image::GenerateUrl(rawBuffer);
1036 VisualFactory factory = VisualFactory::Get();
1037 DALI_TEST_CHECK(factory);
1039 Property::Map propertyMap;
1040 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1041 propertyMap.Insert(ImageVisual::Property::URL, url.GetUrl());
1043 Visual::Base visual = factory.CreateVisual(propertyMap);
1044 DALI_TEST_CHECK(visual);
1046 TestGlAbstraction& gl = application.GetGlAbstraction();
1047 TraceCallStack& textureTrace = gl.GetTextureTrace();
1048 textureTrace.Enable(true);
1050 DummyControl actor = DummyControl::New();
1051 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1052 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
1054 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
1055 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
1057 application.GetScene().Add(actor);
1058 application.SendNotification();
1060 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1062 application.SendNotification();
1063 application.Render();
1065 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1066 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1068 application.GetScene().Remove(actor);
1069 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
1074 int UtcDaliImageVisualWithEncodedImageBufferRemoved(void)
1076 ToolkitTestApplication application;
1077 tet_infoline("Use Encoded Image Buffer as url");
1079 TestGlAbstraction& gl = application.GetGlAbstraction();
1080 TraceCallStack& textureTrace = gl.GetTextureTrace();
1081 textureTrace.Enable(true);
1083 EncodedImageBuffer rawBuffer = ConvertFileToEncodedImageBuffer(TEST_LARGE_IMAGE_FILE_NAME);
1084 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(rawBuffer);
1085 std::string url = imageUrl.GetUrl();
1087 VisualFactory factory = VisualFactory::Get();
1088 DALI_TEST_CHECK(factory);
1090 Property::Map propertyMap;
1091 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1092 propertyMap.Insert(ImageVisual::Property::URL, url);
1094 Visual::Base visual = factory.CreateVisual(propertyMap);
1095 DALI_TEST_CHECK(visual);
1097 DummyControl actor = DummyControl::New();
1098 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1099 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1101 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
1103 application.GetScene().Add(actor);
1104 application.SendNotification();
1106 // Wait for decode buffer and make texture.
1107 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1109 application.SendNotification();
1110 application.Render();
1112 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1113 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
1115 tet_infoline("Delete texture because there is no actor to use decoded texture");
1117 application.GetScene().Remove(actor);
1118 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1119 application.SendNotification();
1120 application.Render();
1122 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
1123 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION);
1128 int UtcDaliImageVisualTextureReuse1(void)
1130 ToolkitTestApplication application;
1131 tet_infoline("Request remote image visual with a Property::Map; request a second visual with the same property map - should reuse texture");
1133 Property::Map propertyMap;
1134 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1135 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
1136 propertyMap.Insert(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DETACHED);
1138 TestGlAbstraction& gl = application.GetGlAbstraction();
1139 TraceCallStack& textureTrace = gl.GetTextureTrace();
1140 textureTrace.Enable(true);
1141 TraceCallStack& drawTrace = gl.GetDrawTrace();
1142 drawTrace.Enable(true);
1144 Actor actor = CreateActorWithImageVisual(propertyMap);
1145 application.GetScene().Add(actor);
1146 application.SendNotification();
1148 // Wait for image to load
1149 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1151 application.SendNotification();
1152 application.Render();
1154 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1155 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
1156 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1157 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION);
1158 textureTrace.Reset();
1161 Actor actor2 = CreateActorWithImageVisual(propertyMap);
1162 application.GetScene().Add(actor2);
1164 application.SendNotification(); // Send messages to update
1165 application.Render(); // process update and render
1166 application.SendNotification(); // process any signals to event
1168 DALI_TEST_EQUALS(actor2.GetRendererCount(), 1u, TEST_LOCATION);
1170 // Testing for texture re-use in gl side is not relevant - we are not using actual graphics
1171 // backend here, but test graphics backend.
1172 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
1173 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION);
1175 tet_infoline("Test that removing 1 actor doesn't delete the texture\n");
1177 application.GetScene().Remove(actor);
1178 application.SendNotification();
1179 application.Render();
1181 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
1182 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
1184 tet_infoline("Test that removing last actor does delete the texture\n");
1186 application.GetScene().Remove(actor2); // Detaches remaining ImageVisual
1187 application.SendNotification();
1188 application.Render();
1190 DALI_TEST_CHECK(actor2.GetRendererCount() == 0u);
1191 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION);
1196 int UtcDaliImageVisualTextureReuse2(void)
1198 ToolkitTestApplication application;
1199 tet_infoline("Request remote image visual with a Property::Map; request a second visual with the same url but different property map - should create new texture");
1201 Property::Map propertyMap;
1202 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1203 propertyMap.Insert(ImageVisual::Property::URL, TEST_REMOTE_IMAGE_FILE_NAME);
1205 TestGlAbstraction& gl = application.GetGlAbstraction();
1206 TraceCallStack& textureTrace = gl.GetTextureTrace();
1207 textureTrace.Enable(true);
1208 TraceCallStack& drawTrace = gl.GetDrawTrace();
1209 drawTrace.Enable(true);
1211 Actor actor = CreateActorWithImageVisual(propertyMap);
1212 application.GetScene().Add(actor);
1213 application.SendNotification();
1215 // Wait for image to load
1216 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1218 application.SendNotification();
1219 application.Render();
1221 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1222 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
1223 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1224 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION);
1225 textureTrace.Reset();
1228 propertyMap.Insert(ImageVisual::Property::SAMPLING_MODE, Dali::SamplingMode::NEAREST);
1229 propertyMap.Insert(ImageVisual::Property::DESIRED_WIDTH, 100);
1230 propertyMap.Insert(ImageVisual::Property::DESIRED_HEIGHT, 100);
1231 Actor actor2 = CreateActorWithImageVisual(propertyMap);
1232 application.GetScene().Add(actor2);
1234 application.SendNotification();
1236 // Wait for image to load
1237 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1239 application.SendNotification();
1240 application.Render();
1242 DALI_TEST_EQUALS(actor2.GetRendererCount(), 1u, TEST_LOCATION);
1245 "Test that 2 draw calls occur with 1 new texture gen/bind, i.e. both "
1246 "renderers are using different textures\n");
1248 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
1249 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION);
1250 TraceCallStack::NamedParams tex1;
1251 tex1["texture"] << 1;
1252 TraceCallStack::NamedParams tex2;
1253 tex2["texture"] << 2;
1254 DALI_TEST_EQUALS(textureTrace.FindMethodAndParams("BindTexture", tex1), true, TEST_LOCATION);
1255 DALI_TEST_EQUALS(textureTrace.FindMethodAndParams("BindTexture", tex2), true, TEST_LOCATION);
1257 tet_infoline("Test that removing 1 actor deletes it's texture\n");
1259 application.GetScene().Remove(actor);
1260 application.SendNotification();
1261 application.Render();
1263 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
1264 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION);
1266 tet_infoline("Test that removing last actor deletes it's texture\n");
1268 application.GetScene().Remove(actor2);
1269 application.SendNotification();
1270 application.Render();
1272 DALI_TEST_CHECK(actor2.GetRendererCount() == 0u);
1273 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 2, TEST_LOCATION);
1278 int UtcDaliImageVisualCustomWrapModePixelArea(void)
1280 ToolkitTestApplication application;
1281 tet_infoline("Request image visual with a Property::Map, test custom wrap mode and pixel area with atlasing");
1283 static std::vector<UniformData> customUniforms =
1285 UniformData("pixelArea", Property::Type::VECTOR4),
1286 UniformData("wrapMode", Property::Type::VECTOR2),
1289 TestGraphicsController& graphics = application.GetGraphicsController();
1290 graphics.AddCustomUniforms(customUniforms);
1292 VisualFactory factory = VisualFactory::Get();
1293 DALI_TEST_CHECK(factory);
1295 // Test wrap mode with atlasing. Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
1296 const int width = 34;
1297 const int height = 34;
1298 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
1300 Property::Map propertyMap;
1301 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1302 propertyMap.Insert(ImageVisual::Property::URL, TEST_SMALL_IMAGE_FILE_NAME);
1303 propertyMap.Insert(ImageVisual::Property::DESIRED_WIDTH, width);
1304 propertyMap.Insert(ImageVisual::Property::DESIRED_HEIGHT, height);
1305 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
1306 propertyMap.Insert(ImageVisual::Property::PIXEL_AREA, pixelArea);
1307 propertyMap.Insert(ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT);
1308 propertyMap.Insert(ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT);
1309 propertyMap.Insert(ImageVisual::Property::ATLASING, true);
1311 Visual::Base visual = factory.CreateVisual(propertyMap);
1312 DALI_TEST_CHECK(visual);
1314 TestGlAbstraction& gl = application.GetGlAbstraction();
1315 TraceCallStack& textureTrace = gl.GetTextureTrace();
1316 textureTrace.Enable(true);
1317 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
1318 texParameterTrace.Enable(true);
1320 DummyControl actor = DummyControl::New();
1321 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1322 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
1323 actor.SetProperty(Actor::Property::SIZE, Vector2(2000, 2000));
1324 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1325 application.GetScene().Add(actor);
1328 application.SendNotification();
1329 application.Render();
1331 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1333 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1335 // WITH atlasing, the wrapping is handled manually in shader, so the following gl function should not be called
1336 std::stringstream out;
1337 out << std::hex << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
1338 DALI_TEST_CHECK(!texParameterTrace.FindMethodAndParams("TexParameteri", out.str()));
1340 out << std::hex << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
1341 DALI_TEST_CHECK(!texParameterTrace.FindMethodAndParams("TexParameteri", out.str()));
1343 // test the uniforms which used to handle the wrap mode
1344 Renderer renderer = actor.GetRendererAt(0u);
1345 DALI_TEST_CHECK(renderer);
1347 Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
1348 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION);
1349 Vector4 pixelAreaUniform;
1350 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
1351 DALI_TEST_EQUALS(pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
1353 Property::Value wrapModeValue = renderer.GetProperty(renderer.GetPropertyIndex("wrapMode"));
1354 Vector2 wrapMode(WrapMode::MIRRORED_REPEAT - 1, WrapMode::REPEAT - 1);
1355 DALI_TEST_EQUALS(wrapModeValue.Get<Vector2>(), wrapMode, TEST_LOCATION);
1356 Vector2 wrapModeUniform;
1357 DALI_TEST_CHECK(gl.GetUniformValue<Vector2>("wrapMode", wrapModeUniform));
1358 DALI_TEST_EQUALS(wrapMode, wrapModeUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
1361 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
1366 int UtcDaliImageVisualCustomWrapModeNoAtlas(void)
1368 ToolkitTestApplication application;
1369 tet_infoline("Request image visual with a Property::Map, test custom wrap mode and pixel area without atlasing");
1371 static std::vector<UniformData> customUniforms =
1373 UniformData("pixelArea", Property::Type::VECTOR4),
1376 TestGraphicsController& graphics = application.GetGraphicsController();
1377 graphics.AddCustomUniforms(customUniforms);
1379 VisualFactory factory = VisualFactory::Get();
1380 DALI_TEST_CHECK(factory);
1382 // Test wrap mode without atlasing. Image with a size bigger than 512*512 will NOT be uploaded as a part of the atlas.
1383 const int width = 600;
1384 const int height = 600;
1385 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
1387 Property::Map propertyMap;
1388 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1389 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
1390 propertyMap.Insert(ImageVisual::Property::DESIRED_WIDTH, width);
1391 propertyMap.Insert(ImageVisual::Property::DESIRED_HEIGHT, height);
1392 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
1393 propertyMap.Insert(ImageVisual::Property::PIXEL_AREA, pixelArea);
1394 propertyMap.Insert(ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT);
1395 propertyMap.Insert(ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT);
1397 Visual::Base visual = factory.CreateVisual(propertyMap);
1398 DALI_TEST_CHECK(visual);
1400 TestGlAbstraction& gl = application.GetGlAbstraction();
1401 TraceCallStack& textureTrace = gl.GetTextureTrace();
1402 textureTrace.Enable(true);
1403 textureTrace.EnableLogging(true);
1404 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
1405 texParameterTrace.Enable(true);
1406 texParameterTrace.EnableLogging(true);
1408 DummyControl actor = DummyControl::New();
1409 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1410 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
1411 actor.SetProperty(Actor::Property::SIZE, Vector2(2000, 2000));
1412 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1413 application.GetScene().Add(actor);
1416 application.SendNotification();
1417 application.Render();
1418 application.SendNotification();
1420 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1422 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1424 // WITHOUT atlasing, the wrapping is handled by setting gl texture parameters
1425 std::stringstream out;
1426 out << std::hex << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
1427 DALI_TEST_CHECK(texParameterTrace.FindMethodAndParams("TexParameteri", out.str()));
1429 out << std::hex << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
1430 DALI_TEST_CHECK(texParameterTrace.FindMethodAndParams("TexParameteri", out.str()));
1432 // test the uniforms which used to handle the wrap mode
1433 Renderer renderer = actor.GetRendererAt(0u);
1434 DALI_TEST_CHECK(renderer);
1436 Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
1437 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION);
1438 Vector4 pixelAreaUniform;
1439 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
1440 DALI_TEST_EQUALS(pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
1442 Property::Index wrapModeIndex = renderer.GetPropertyIndex("wrapMode");
1443 DALI_TEST_CHECK(wrapModeIndex == Property::INVALID_INDEX);
1446 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
1451 int UtcDaliImageVisualAnimateMixColor(void)
1453 ToolkitTestApplication application;
1454 tet_infoline("Animate mix color");
1456 static std::vector<UniformData> customUniforms =
1458 UniformData("mixColor", Property::Type::VECTOR3),
1461 TestGraphicsController& graphics = application.GetGraphicsController();
1462 graphics.AddCustomUniforms(customUniforms);
1464 application.GetPlatform().SetClosestImageSize(Vector2(100, 100));
1466 VisualFactory factory = VisualFactory::Get();
1467 Property::Map propertyMap;
1468 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1469 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
1470 propertyMap.Insert("mixColor", Color::BLUE);
1471 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
1472 Visual::Base visual = factory.CreateVisual(propertyMap);
1474 DummyControl actor = DummyControl::New(true);
1475 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1476 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1478 actor.SetProperty(Actor::Property::SIZE, Vector2(2000, 2000));
1479 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1480 actor.SetProperty(Actor::Property::COLOR, Color::BLACK);
1481 application.GetScene().Add(actor);
1483 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1485 Renderer renderer = actor.GetRendererAt(0);
1487 // @todo Should we add API to make this code work again?
1488 // Property::Index index = renderer.GetPropertyIndex( Visual::Property::MIX_COLOR );
1490 Property::Value blendModeValue = renderer.GetProperty(Renderer::Property::BLEND_MODE);
1491 DALI_TEST_EQUALS(blendModeValue.Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION);
1493 const Vector4 TARGET_MIX_COLOR(1.0f, 0.0f, 0.0f, 0.5f);
1496 map["target"] = "testVisual";
1497 map["property"] = "mixColor";
1498 map["initialValue"] = Color::MAGENTA;
1499 map["targetValue"] = TARGET_MIX_COLOR;
1500 map["animator"] = Property::Map()
1501 .Add("alphaFunction", "LINEAR")
1502 .Add("timePeriod", Property::Map().Add("delay", 0.0f).Add("duration", 4.0f));
1504 Dali::Toolkit::TransitionData transition = TransitionData::New(map);
1506 Animation animation = dummyImpl.CreateTransition(transition);
1508 animation.AnimateTo(Property(actor, Actor::Property::COLOR), Color::WHITE);
1511 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1512 glAbstraction.EnableEnableDisableCallTrace(true);
1513 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1514 std::ostringstream blendStr;
1515 blendStr << std::hex << GL_BLEND;
1517 application.SendNotification();
1518 application.Render(0); // Ensure animation starts
1519 application.Render(2000u); // Halfway point
1520 Vector3 testColor(1.0f, 0.0f, 0.5f);
1522 // uColor.a should be actor's alpha * mixColor.a.
1523 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("uColor", Vector4(0.5f, 0.5f, 0.5f, 0.75f)), true, TEST_LOCATION);
1524 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", testColor), true, TEST_LOCATION);
1526 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str()));
1528 glEnableStack.Reset();
1530 application.SendNotification();
1531 application.Render(2000u);
1533 application.SendNotification();
1534 application.Render();
1535 application.SendNotification();
1537 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
1538 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("uColor", Vector4(1.0f, 1.0f, 1.0f, 0.5f)), true, TEST_LOCATION);
1539 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(TARGET_MIX_COLOR)), true, TEST_LOCATION);
1541 // (Don't test for caching of capabilities, toolkit uses Test graphics backend, not actual backend)
1543 TestMixColor(visual, Visual::Property::MIX_COLOR, TARGET_MIX_COLOR);
1548 int UtcDaliImageVisualAnimateOpacity(void)
1550 ToolkitTestApplication application;
1551 tet_infoline("Animate image visual opacity");
1553 application.GetPlatform().SetClosestImageSize(Vector2(100, 100));
1555 VisualFactory factory = VisualFactory::Get();
1556 Property::Map propertyMap;
1557 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1558 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
1559 propertyMap.Insert("opacity", 0.5f);
1560 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
1561 Visual::Base visual = factory.CreateVisual(propertyMap);
1563 DummyControl actor = DummyControl::New(true);
1564 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1565 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1567 actor.SetProperty(Actor::Property::SIZE, Vector2(2000, 2000));
1568 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1569 actor.SetProperty(Actor::Property::COLOR, Color::BLACK);
1570 application.GetScene().Add(actor);
1572 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1574 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1575 glAbstraction.EnableEnableDisableCallTrace(true);
1576 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1577 std::ostringstream blendStr;
1578 blendStr << std::hex << GL_BLEND;
1580 application.SendNotification();
1581 application.Render();
1583 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str()));
1586 tet_infoline("Test that the opacity can be increased to full via animation, and that the blend mode is set appropriately at the start and end of the animation.");
1589 map["target"] = "testVisual";
1590 map["property"] = "opacity";
1591 map["targetValue"] = 1.0f;
1592 map["animator"] = Property::Map()
1593 .Add("alphaFunction", "LINEAR")
1594 .Add("timePeriod", Property::Map().Add("delay", 0.0f).Add("duration", 4.0f));
1596 Dali::Toolkit::TransitionData transition = TransitionData::New(map);
1597 Animation animation = dummyImpl.CreateTransition(transition);
1600 glEnableStack.Reset();
1602 application.SendNotification();
1603 application.Render(0); // Ensure animation starts
1604 application.Render(2000u); // Halfway point through animation
1605 application.SendNotification(); // Handle any signals
1608 DALI_TEST_CHECK(application.GetGlAbstraction().GetUniformValue<Vector4>("uColor", color));
1609 DALI_TEST_EQUALS(color.a, 0.75f, TEST_LOCATION);
1611 application.Render(2001u); // end
1612 application.SendNotification(); // ensure animation finished signal is sent
1614 DALI_TEST_CHECK(application.GetGlAbstraction().GetUniformValue<Vector4>("uColor", color));
1615 DALI_TEST_EQUALS(color.a, 1.0f, TEST_LOCATION);
1617 // (Don't test for caching of capabilities, toolkit uses Test graphics backend, not actual backend)
1618 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Disable", blendStr.str()));
1622 tet_infoline("Test that the opacity can be reduced via animation, and that the blend mode is set appropriately at the start and end of the animation.");
1625 map["target"] = "testVisual";
1626 map["property"] = Visual::Property::OPACITY;
1627 map["targetValue"] = 0.1f;
1628 map["animator"] = Property::Map()
1629 .Add("alphaFunction", "LINEAR")
1630 .Add("timePeriod", Property::Map().Add("delay", 0.0f).Add("duration", 4.0f));
1632 Dali::Toolkit::TransitionData transition = TransitionData::New(map);
1633 Animation animation = dummyImpl.CreateTransition(transition);
1636 glEnableStack.Reset();
1638 application.SendNotification();
1639 application.Render(0); // Ensure animation starts
1640 application.Render(2000u); // Halfway point
1641 application.SendNotification();
1644 DALI_TEST_CHECK(application.GetGlAbstraction().GetUniformValue<Vector4>("uColor", color));
1645 DALI_TEST_EQUALS(color.a, 0.55f, TEST_LOCATION);
1647 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str()));
1649 glEnableStack.Reset();
1651 application.Render(2016u); // end
1652 application.SendNotification();
1654 DALI_TEST_CHECK(application.GetGlAbstraction().GetUniformValue<Vector4>("uColor", color));
1655 DALI_TEST_EQUALS(color.a, 0.1f, TEST_LOCATION);
1657 // (Don't test for caching of capabilities, toolkit uses Test graphics backend, not actual backend)
1658 DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Disable", blendStr.str()));
1664 int UtcDaliImageVisualAnimateOpacity02(void)
1666 ToolkitTestApplication application;
1667 tet_infoline("Animate image visual opacity");
1669 application.GetPlatform().SetClosestImageSize(Vector2(100, 100));
1671 VisualFactory factory = VisualFactory::Get();
1672 Property::Map propertyMap;
1673 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1674 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
1675 propertyMap.Insert("opacity", 0.5f);
1676 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
1677 Visual::Base visual = factory.CreateVisual(propertyMap);
1679 DummyControl actor = DummyControl::New(true);
1680 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1681 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1683 actor.SetProperty(Actor::Property::SIZE, Vector2(2000, 2000));
1684 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1685 actor.SetProperty(Actor::Property::COLOR, Color::BLACK);
1687 tet_infoline("Test that the opacity doesn't animate when actor not staged");
1689 Property::Array array;
1692 map["target"] = "testVisual";
1693 map["property"] = "opacity";
1694 map["initialValue"] = 0.0f;
1695 map["targetValue"] = 1.0f;
1696 map["animator"] = Property::Map()
1697 .Add("alphaFunction", "LINEAR")
1698 .Add("timePeriod", Property::Map().Add("delay", 0.0f).Add("duration", 4.0f));
1701 map2["target"] = "testVisual";
1702 map2["property"] = "size";
1703 map2["targetValue"] = Vector2(1.0f, 1.0f);
1705 array.Add(map).Add(map2);
1707 Dali::Toolkit::TransitionData transition = TransitionData::New(array);
1708 Animation animation = dummyImpl.CreateTransition(transition);
1710 application.GetScene().Add(actor);
1711 application.SendNotification();
1712 application.Render(0); // Ensure animation starts
1714 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1716 Renderer renderer = actor.GetRendererAt(0);
1717 Property::Value blendModeValue = renderer.GetProperty(Renderer::Property::BLEND_MODE);
1718 DALI_TEST_EQUALS(blendModeValue.Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION);
1720 animation = dummyImpl.CreateTransition(transition);
1723 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1724 glAbstraction.EnableEnableDisableCallTrace(true);
1725 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1726 std::ostringstream blendStr;
1727 blendStr << std::hex << GL_BLEND;
1729 application.SendNotification();
1730 application.Render(0); // Ensure animation starts
1731 application.Render(2000u); // Halfway point through animation
1732 application.SendNotification(); // Handle any signals
1734 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str()));
1737 DALI_TEST_CHECK(application.GetGlAbstraction().GetUniformValue<Vector4>("uColor", color));
1738 DALI_TEST_EQUALS(color.a, 0.5f, TEST_LOCATION);
1740 glEnableStack.Reset();
1742 application.Render(2001u); // end
1743 application.SendNotification(); // ensure animation finished signal is sent
1745 DALI_TEST_CHECK(application.GetGlAbstraction().GetUniformValue<Vector4>("uColor", color));
1746 DALI_TEST_EQUALS(color.a, 1.0f, TEST_LOCATION);
1748 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Disable", blendStr.str()));
1753 int UtcDaliImageVisualAnimatePixelArea(void)
1755 ToolkitTestApplication application;
1756 tet_infoline("ImageVisual animate pixel area");
1758 static std::vector<UniformData> customUniforms =
1760 UniformData("pixelArea", Property::Type::VECTOR4),
1763 TestGraphicsController& graphics = application.GetGraphicsController();
1764 graphics.AddCustomUniforms(customUniforms);
1766 application.GetPlatform().SetClosestImageSize(Vector2(100, 100));
1768 VisualFactory factory = VisualFactory::Get();
1769 Property::Map propertyMap;
1770 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1771 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
1772 propertyMap.Insert("mixColor", Color::BLUE);
1773 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
1774 Visual::Base visual = factory.CreateVisual(propertyMap);
1776 DummyControl actor = DummyControl::New(true);
1777 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1778 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1780 actor.SetProperty(Actor::Property::SIZE, Vector2(2000, 2000));
1781 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1782 actor.SetProperty(Actor::Property::COLOR, Color::BLACK);
1783 application.GetScene().Add(actor);
1785 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1787 Renderer renderer = actor.GetRendererAt(0);
1788 // @todo Implement this feature?
1789 //Property::Index index = renderer.GetPropertyIndex( Visual::Property::MIX_COLOR );
1790 //tet_infoline("Test that the renderer has the mixColor property");
1791 //DALI_TEST_CHECK( index != Property::INVALID_INDEX );
1793 // TransitionData only takes string keys
1795 map["target"] = "testVisual";
1796 map["property"] = "pixelArea";
1797 map["initialValue"] = Vector4(0, 0, 0, 1);
1798 map["targetValue"] = Vector4(0, 0, 1, 1); // Animate width from zero to full
1799 map["animator"] = Property::Map()
1800 .Add("alphaFunction", "LINEAR")
1801 .Add("timePeriod", Property::Map().Add("delay", 0.0f).Add("duration", 4.0f));
1803 Dali::Toolkit::TransitionData transition = TransitionData::New(map);
1805 Animation animation = dummyImpl.CreateTransition(transition);
1806 animation.AnimateTo(Property(actor, Actor::Property::COLOR), Color::WHITE);
1809 application.SendNotification();
1810 application.Render(0); // Ensure animation starts
1811 application.Render(2000u); // Halfway point
1813 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", Vector4(0.0f, 0.0f, 0.5f, 1.0f)), true, TEST_LOCATION);
1815 application.Render(2000u); // End of animation
1817 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", Vector4(0.0f, 0.0f, 1.0f, 1.0f)), true, TEST_LOCATION);
1822 int UtcDaliImageVisualTextureCancelRemoteLoad(void)
1824 ToolkitTestApplication application;
1825 tet_infoline("Request remote image visual, then destroy visual to cancel load");
1827 Property::Map propertyMap;
1828 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1829 propertyMap.Insert(ImageVisual::Property::URL, TEST_REMOTE_IMAGE_FILE_NAME);
1831 TestGlAbstraction& gl = application.GetGlAbstraction();
1832 TraceCallStack& textureTrace = gl.GetTextureTrace();
1833 textureTrace.Enable(true);
1834 TraceCallStack& drawTrace = gl.GetDrawTrace();
1835 drawTrace.Enable(true);
1837 Actor actor = CreateActorWithImageVisual(propertyMap);
1838 application.GetScene().Add(actor);
1839 application.SendNotification();
1841 application.GetScene().Remove(actor);
1842 application.SendNotification();
1844 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
1845 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
1846 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), false, TEST_LOCATION);
1847 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION);
1852 int UtcDaliImageVisualTextureCancelAsyncLoad(void)
1854 ToolkitTestApplication application;
1855 tet_infoline("Load image asynchronously, cancel loading, then load again");
1857 VisualFactory factory = VisualFactory::Get();
1858 DALI_TEST_CHECK(factory);
1860 Property::Map propertyMap;
1861 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1862 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
1864 Visual::Base visual = factory.CreateVisual(propertyMap);
1865 DALI_TEST_CHECK(visual);
1867 TestGlAbstraction& gl = application.GetGlAbstraction();
1868 TraceCallStack& textureTrace = gl.GetTextureTrace();
1869 textureTrace.Enable(true);
1870 TraceCallStack& drawTrace = gl.GetDrawTrace();
1871 drawTrace.Enable(true);
1873 DummyControl actor = DummyControl::New();
1874 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1875 dummyImpl.RegisterVisual(Control::Property::BACKGROUND, visual);
1877 application.GetScene().Add(actor);
1880 application.GetScene().Remove(actor);
1882 application.GetScene().Add(actor);
1884 // Create another visual with the same image
1885 visual = factory.CreateVisual(propertyMap);
1886 DALI_TEST_CHECK(visual);
1888 dummyImpl.RegisterVisual(Control::Property::BACKGROUND, visual);
1890 application.SendNotification();
1891 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1893 application.SendNotification();
1894 application.Render();
1896 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1897 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
1898 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1899 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION);
1904 int UtcDaliImageVisualSetInvalidAsyncImage(void)
1906 ToolkitTestApplication application;
1907 tet_infoline("Request image visual with invalid images - should draw broken.png");
1909 VisualFactory factory = VisualFactory::Get();
1910 DALI_TEST_CHECK(factory);
1912 Property::Map propertyMap;
1913 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1914 propertyMap.Insert(ImageVisual::Property::URL, TEST_INVALID_FILE_NAME);
1916 Visual::Base visual = factory.CreateVisual(propertyMap);
1917 DALI_TEST_CHECK(visual);
1919 TestGlAbstraction& gl = application.GetGlAbstraction();
1920 TraceCallStack& textureTrace = gl.GetTextureTrace();
1921 textureTrace.Enable(true);
1923 DummyControl actor = DummyControl::New();
1924 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1925 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
1927 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
1928 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
1930 application.GetScene().Add(actor);
1932 application.SendNotification();
1933 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1935 application.SendNotification();
1936 application.Render();
1938 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1939 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1941 application.GetScene().Remove(actor);
1942 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
1947 int UtcDaliImageVisualSetInvalidSyncImage(void)
1949 ToolkitTestApplication application;
1950 tet_infoline("Request image visual with invalid images - should draw broken.png");
1952 VisualFactory factory = VisualFactory::Get();
1953 DALI_TEST_CHECK(factory);
1955 Property::Map propertyMap;
1956 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1957 propertyMap.Insert(ImageVisual::Property::URL, TEST_INVALID_FILE_NAME);
1958 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
1960 Visual::Base visual = factory.CreateVisual(propertyMap);
1961 DALI_TEST_CHECK(visual);
1963 TestGlAbstraction& gl = application.GetGlAbstraction();
1964 TraceCallStack& textureTrace = gl.GetTextureTrace();
1965 textureTrace.Enable(true);
1967 DummyControl actor = DummyControl::New();
1968 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1969 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
1971 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
1972 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
1974 application.GetScene().Add(actor);
1976 application.SendNotification();
1977 application.Render();
1979 // Check resource status
1980 Visual::ResourceStatus status = actor.GetVisualResourceStatus(Control::CONTROL_PROPERTY_END_INDEX + 1);
1981 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1983 // The broken image should be shown.
1984 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1985 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1987 application.GetScene().Remove(actor);
1988 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
1993 int UtcDaliImageVisualSetInvalidRemoteImage(void)
1995 ToolkitTestApplication application;
1996 tet_infoline("Request image visual with invalid images - should draw broken.png");
1998 VisualFactory factory = VisualFactory::Get();
1999 DALI_TEST_CHECK(factory);
2001 // Local invalid file, asynchronous loading
2002 Property::Map propertyMap;
2003 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2004 propertyMap.Insert(ImageVisual::Property::URL, TEST_REMOTE_INVALID_FILE_NAME);
2006 Visual::Base visual = factory.CreateVisual(propertyMap);
2007 DALI_TEST_CHECK(visual);
2009 TestGlAbstraction& gl = application.GetGlAbstraction();
2010 TraceCallStack& textureTrace = gl.GetTextureTrace();
2011 textureTrace.Enable(true);
2013 DummyControl actor = DummyControl::New();
2014 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2015 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2017 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2018 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2020 application.GetScene().Add(actor);
2022 application.SendNotification();
2023 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2025 application.SendNotification();
2026 application.Render();
2028 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2029 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2031 application.GetScene().Remove(actor);
2032 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2037 int UtcDaliImageVisualSetInvalidImageWithDisabledBroken(void)
2039 ToolkitTestApplication application;
2040 tet_infoline("Request image visual with invalid images - should draw broken.png");
2042 VisualFactory factory = VisualFactory::Get();
2043 DALI_TEST_CHECK(factory);
2045 // Load invalid file
2046 Property::Map propertyMap;
2047 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2048 propertyMap.Insert(ImageVisual::Property::URL, "InvalidImage.png");
2050 Visual::Base visual = factory.CreateVisual(propertyMap);
2051 DALI_TEST_CHECK(visual);
2053 TestGlAbstraction& gl = application.GetGlAbstraction();
2054 TraceCallStack& textureTrace = gl.GetTextureTrace();
2055 textureTrace.Enable(true);
2057 DummyControl actor = DummyControl::New();
2058 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2059 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2061 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2062 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2064 application.GetScene().Add(actor);
2066 application.SendNotification();
2067 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2069 application.SendNotification();
2070 application.Render();
2072 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2073 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2075 application.GetScene().Remove(actor);
2076 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2077 textureTrace.Reset();
2079 // Load invalid file with disabled broken
2080 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2081 propertyMap.Insert(ImageVisual::Property::URL, "InvalidImage.png");
2082 propertyMap.Insert(Toolkit::DevelImageVisual::Property::ENABLE_BROKEN_IMAGE, false);
2084 visual = factory.CreateVisual(propertyMap);
2085 DALI_TEST_CHECK(visual);
2087 actor = DummyControl::New();
2088 DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor.GetImplementation());
2089 dummyImpl2.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2091 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2092 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2094 application.GetScene().Add(actor);
2096 application.SendNotification();
2097 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2099 application.SendNotification();
2100 application.Render();
2102 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2103 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), false, TEST_LOCATION);
2105 application.GetScene().Remove(actor);
2106 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2111 int UtcDaliImageVisualAlphaMask01(void)
2113 ToolkitTestApplication application;
2114 tet_infoline("Request image visual with a Property::Map containing an Alpha mask");
2116 VisualFactory factory = VisualFactory::Get();
2117 DALI_TEST_CHECK(factory);
2119 Property::Map propertyMap;
2120 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2121 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
2122 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
2124 Visual::Base visual = factory.CreateVisual(propertyMap);
2125 DALI_TEST_CHECK(visual);
2127 Property::Map testMap;
2128 visual.CreatePropertyMap(testMap);
2129 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
2131 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
2132 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
2134 TestGlAbstraction& gl = application.GetGlAbstraction();
2135 TraceCallStack& textureTrace = gl.GetTextureTrace();
2136 textureTrace.Enable(true);
2138 DummyControl actor = DummyControl::New();
2139 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2140 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2142 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2143 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2144 DALI_TEST_EQUALS(actor.IsResourceReady(), false, TEST_LOCATION);
2146 application.GetScene().Add(actor);
2147 application.SendNotification();
2148 application.Render();
2150 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
2152 application.SendNotification();
2153 application.Render();
2155 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2156 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2157 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
2159 dummyImpl.UnregisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1);
2160 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2165 int UtcDaliImageVisualAlphaMask02(void)
2167 ToolkitTestApplication application;
2168 tet_infoline("Request image visual with a Property::Map containing an Alpha mask for GPU");
2170 VisualFactory factory = VisualFactory::Get();
2171 DALI_TEST_CHECK(factory);
2173 Property::Map propertyMap;
2174 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2175 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
2176 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
2177 propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
2179 Visual::Base visual = factory.CreateVisual(propertyMap);
2180 DALI_TEST_CHECK(visual);
2182 Property::Map testMap;
2183 visual.CreatePropertyMap(testMap);
2184 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
2185 DALI_TEST_EQUALS(*testMap.Find(DevelImageVisual::Property::MASKING_TYPE), Property::Value(DevelImageVisual::MaskingType::MASKING_ON_RENDERING), TEST_LOCATION);
2187 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
2188 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
2190 TestGlAbstraction& gl = application.GetGlAbstraction();
2191 TraceCallStack& textureTrace = gl.GetTextureTrace();
2192 textureTrace.Enable(true);
2194 DummyControl actor = DummyControl::New();
2195 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2196 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2198 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2199 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2200 DALI_TEST_EQUALS(actor.IsResourceReady(), false, TEST_LOCATION);
2202 application.GetScene().Add(actor);
2203 application.SendNotification();
2204 application.Render();
2206 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2208 application.SendNotification();
2209 application.Render();
2211 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2212 Renderer renderer = actor.GetRendererAt(0u);
2213 TextureSet textures = renderer.GetTextures();
2214 DALI_TEST_CHECK(textures);
2215 DALI_TEST_EQUALS(textures.GetTextureCount(), 2u, TEST_LOCATION);
2217 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2218 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
2220 dummyImpl.UnregisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1);
2221 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2226 int UtcDaliImageVisualAlphaMask03(void)
2228 ToolkitTestApplication application;
2229 tet_infoline("Request image visual with a Property::Map containing an Alpha mask for GPU with fail case");
2231 VisualFactory factory = VisualFactory::Get();
2232 DALI_TEST_CHECK(factory);
2234 Property::Map propertyMap;
2235 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2236 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
2237 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, "dummy_path");
2238 propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
2240 Visual::Base visual = factory.CreateVisual(propertyMap);
2241 DALI_TEST_CHECK(visual);
2243 Property::Map testMap;
2244 visual.CreatePropertyMap(testMap);
2246 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
2247 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
2249 TestGlAbstraction& gl = application.GetGlAbstraction();
2250 TraceCallStack& textureTrace = gl.GetTextureTrace();
2251 textureTrace.Enable(true);
2253 DummyControl actor = DummyControl::New();
2254 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2255 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2257 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2258 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2259 DALI_TEST_EQUALS(actor.IsResourceReady(), false, TEST_LOCATION);
2261 application.GetScene().Add(actor);
2262 application.SendNotification();
2263 application.Render();
2265 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2267 application.SendNotification();
2268 application.Render();
2270 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2271 Renderer renderer = actor.GetRendererAt(0u);
2272 TextureSet textures = renderer.GetTextures();
2273 DALI_TEST_CHECK(textures);
2274 DALI_TEST_EQUALS(textures.GetTextureCount(), 1u, TEST_LOCATION);
2276 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2277 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
2279 dummyImpl.UnregisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1);
2280 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2285 int UtcDaliImageVisualSynchronousLoadAlphaMask01(void)
2287 ToolkitTestApplication application;
2288 tet_infoline("Request image visual with a Property::Map containing an Alpha mask with synchronous loading");
2290 VisualFactory factory = VisualFactory::Get();
2291 DALI_TEST_CHECK(factory);
2293 Property::Map propertyMap;
2294 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2295 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
2296 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
2297 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2299 Visual::Base visual = factory.CreateVisual(propertyMap);
2300 DALI_TEST_CHECK(visual);
2302 Property::Map testMap;
2303 visual.CreatePropertyMap(testMap);
2304 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
2306 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
2307 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
2309 TestGlAbstraction& gl = application.GetGlAbstraction();
2310 TraceCallStack& textureTrace = gl.GetTextureTrace();
2311 textureTrace.Enable(true);
2313 DummyControl actor = DummyControl::New();
2314 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2315 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2317 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2318 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2319 DALI_TEST_EQUALS(actor.IsResourceReady(), false, TEST_LOCATION);
2321 application.GetScene().Add(actor);
2323 // Do not wait for any EventThreadTrigger in synchronous alpha mask.
2325 application.SendNotification();
2326 application.Render();
2328 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2329 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2330 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
2332 dummyImpl.UnregisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1);
2333 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2338 int UtcDaliImageVisualSynchronousLoadAlphaMask02(void)
2340 ToolkitTestApplication application;
2341 tet_infoline("Request image visual with a Property::Map containing an Alpha mask for GPU with synchronous loading");
2343 VisualFactory factory = VisualFactory::Get();
2344 DALI_TEST_CHECK(factory);
2346 Property::Map propertyMap;
2347 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2348 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
2349 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
2350 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2351 propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
2353 Visual::Base visual = factory.CreateVisual(propertyMap);
2354 DALI_TEST_CHECK(visual);
2356 Property::Map testMap;
2357 visual.CreatePropertyMap(testMap);
2358 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
2360 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
2361 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
2363 TestGlAbstraction& gl = application.GetGlAbstraction();
2364 TraceCallStack& textureTrace = gl.GetTextureTrace();
2365 textureTrace.Enable(true);
2367 DummyControl actor = DummyControl::New();
2368 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2369 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2371 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2372 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2373 DALI_TEST_EQUALS(actor.IsResourceReady(), false, TEST_LOCATION);
2375 application.GetScene().Add(actor);
2377 // Do not wait for any EventThreadTrigger in synchronous alpha mask.
2379 application.SendNotification();
2380 application.Render();
2382 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2383 Renderer renderer = actor.GetRendererAt(0u);
2384 TextureSet textures = renderer.GetTextures();
2385 DALI_TEST_CHECK(textures);
2386 DALI_TEST_EQUALS(textures.GetTextureCount(), 2u, TEST_LOCATION);
2388 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2389 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
2391 dummyImpl.UnregisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1);
2392 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2397 int UtcDaliImageVisualRemoteAlphaMask(void)
2399 ToolkitTestApplication application;
2400 tet_infoline("Request image visual with a Property::Map containing an Alpha mask");
2402 VisualFactory factory = VisualFactory::Get();
2403 DALI_TEST_CHECK(factory);
2405 const std::string MASK_IMAGE = TEST_REMOTE_IMAGE_FILE_NAME;
2407 Property::Map propertyMap;
2408 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2409 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
2410 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, MASK_IMAGE);
2412 Visual::Base visual = factory.CreateVisual(propertyMap);
2413 DALI_TEST_CHECK(visual);
2415 Property::Map testMap;
2416 visual.CreatePropertyMap(testMap);
2418 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(MASK_IMAGE), TEST_LOCATION);
2420 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
2421 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
2423 TestGlAbstraction& gl = application.GetGlAbstraction();
2424 TraceCallStack& textureTrace = gl.GetTextureTrace();
2425 textureTrace.Enable(true);
2427 DummyControl actor = DummyControl::New();
2428 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2429 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2431 DALI_TEST_EQUALS(actor.IsResourceReady(), false, TEST_LOCATION);
2433 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2434 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2436 application.GetScene().Add(actor);
2437 application.SendNotification();
2438 application.Render();
2440 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
2442 application.SendNotification();
2443 application.Render();
2445 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2446 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2447 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
2452 int UtcDaliImageVisualAlphaMaskCrop(void)
2454 ToolkitTestApplication application;
2455 tet_infoline("Request image visual with an Alpha mask and scale/cropping");
2457 VisualFactory factory = VisualFactory::Get();
2458 DALI_TEST_CHECK(factory);
2460 Property::Map propertyMap;
2461 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2462 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
2463 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
2464 propertyMap.Insert(ImageVisual::Property::MASK_CONTENT_SCALE, 1.6f);
2465 propertyMap.Insert(ImageVisual::Property::CROP_TO_MASK, true);
2467 Visual::Base visual = factory.CreateVisual(propertyMap);
2468 DALI_TEST_CHECK(visual);
2470 Property::Map testMap;
2471 visual.CreatePropertyMap(testMap);
2472 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
2473 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::MASK_CONTENT_SCALE), Property::Value(1.6f), TEST_LOCATION);
2474 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::CROP_TO_MASK), Property::Value(true), TEST_LOCATION);
2476 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
2477 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
2479 TestGlAbstraction& gl = application.GetGlAbstraction();
2480 TraceCallStack& textureTrace = gl.GetTextureTrace();
2481 textureTrace.Enable(true);
2483 DummyControl actor = DummyControl::New();
2484 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2485 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2487 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2488 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2489 DALI_TEST_EQUALS(actor.IsResourceReady(), false, TEST_LOCATION);
2491 application.GetScene().Add(actor);
2492 application.SendNotification();
2493 application.Render();
2495 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
2497 application.SendNotification();
2498 application.Render();
2501 visual.GetNaturalSize(size);
2503 DALI_TEST_EQUALS(size, Vector2(100.0f, 100.0f), 0.001f, TEST_LOCATION);
2504 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2505 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2506 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
2511 int UtcDaliImageVisualReleasePolicy01(void)
2513 ToolkitTestApplication application;
2514 tet_infoline("UtcDaliImageVisualReleasePolicy01 Detached Policy, disabling visual with this policy deletes texture");
2516 Visual::Base imageVisual = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DETACHED);
2517 DALI_TEST_CHECK(imageVisual);
2519 // Set up debug trace
2520 TestGlAbstraction& gl = application.GetGlAbstraction();
2521 TraceCallStack& textureTrace = gl.GetTextureTrace();
2522 textureTrace.Enable(true);
2524 tet_infoline("Register visual with control and ensure it has the only handle");
2525 DummyControl actor = DummyControl::New(true);
2526 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2527 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
2528 imageVisual.Reset();
2530 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2532 application.SendNotification();
2533 application.Render(0);
2534 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2535 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2537 application.GetScene().Add(actor);
2539 // Wait for image to load
2540 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2542 application.SendNotification();
2543 application.Render(0);
2544 // Test renderer and texture created
2545 tet_infoline("Confirm texture created");
2546 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2547 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
2549 tet_infoline("Disable visual causing the texture to be deleted");
2550 dummyImpl.EnableVisual(DummyControl::Property::TEST_VISUAL, false);
2552 application.SendNotification();
2553 application.Render(0);
2554 // Test renderer and textures removed.
2555 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2556 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION);
2561 int UtcDaliImageVisualReleasePolicy02(void)
2563 ToolkitTestApplication application;
2564 tet_infoline("UtcDaliImageVisualReleasePolicy02 Destroyed Policy, Texture should be deleted when visual destroyed");
2566 Visual::Base imageVisual = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DESTROYED);
2567 DALI_TEST_CHECK(imageVisual);
2569 // Setup debug trace
2570 TestGlAbstraction& gl = application.GetGlAbstraction();
2571 TraceCallStack& textureTrace = gl.GetTextureTrace();
2572 textureTrace.Enable(true);
2574 tet_infoline("Register visual with control and ensure it has the only handle");
2575 DummyControl actor = DummyControl::New(true);
2576 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2577 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
2578 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
2580 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2582 application.SendNotification();
2583 application.Render(0);
2584 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2585 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2587 application.GetScene().Add(actor);
2589 // Wait for image to load
2590 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2592 application.SendNotification();
2593 application.Render(0);
2594 // Test renderer and texture created
2595 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2596 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
2598 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
2599 tet_infoline("Destroy visual by UnRegistering visual with control, check renderer is destroyed");
2600 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
2601 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2602 application.SendNotification();
2603 application.Render();
2605 // Test texture removed after visual destroyed.
2606 tet_infoline("Ensure texture is deleted after visual destroyed");
2607 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION);
2612 int UtcDaliImageVisualReleasePolicy03(void)
2614 ToolkitTestApplication application;
2615 tet_infoline("UtcDaliImageVisualReleasePolicy03 Never Policy, texture should not be deleted after visual destroyed");
2617 Visual::Base imageVisual = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
2618 DALI_TEST_CHECK(imageVisual);
2620 TestGlAbstraction& gl = application.GetGlAbstraction();
2621 TraceCallStack& textureTrace = gl.GetTextureTrace();
2622 textureTrace.Enable(true);
2624 tet_infoline("Register visual with control and ensure it has the only handle");
2625 DummyControl actor = DummyControl::New(true);
2626 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2627 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
2628 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
2630 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2632 application.SendNotification();
2633 application.Render(0);
2634 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2635 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2637 application.GetScene().Add(actor);
2639 // Wait for image to load
2640 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2642 application.SendNotification();
2643 application.Render(0);
2644 // Test renderer and texture created
2645 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2646 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
2648 tet_infoline("Destroy visual by UnRegistering visual with control, check renderer is destroyed");
2649 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
2650 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
2651 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2652 application.SendNotification();
2653 application.Render();
2655 tet_infoline("Ensure texture is not deleted as policy is set to NEVER");
2656 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
2661 int UtcDaliImageVisualReleasePolicy04(void)
2663 ToolkitTestApplication application;
2664 tet_infoline("UtcDaliImageVisualReleasePolicy04 Two visuals with different policies sharing a texture");
2666 tet_infoline("Create first visual with Never release policy");
2667 Visual::Base imageVisualNever = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
2669 tet_infoline("Create second visual with Destroyed release policy");
2670 Visual::Base imageVisualDestroyed = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DESTROYED);
2672 // Set up trace debug
2673 TestGlAbstraction& gl = application.GetGlAbstraction();
2674 TraceCallStack& textureTrace = gl.GetTextureTrace();
2675 textureTrace.Enable(true);
2677 tet_infoline("Register visuals with control and ensure it has the only handles");
2678 DummyControl actor = DummyControl::New(true);
2679 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2680 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisualNever);
2681 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL2, imageVisualDestroyed);
2682 imageVisualNever.Reset(); // reduce ref count so only the control keeps the visual alive.
2683 imageVisualDestroyed.Reset(); // reduce ref count so only the control keeps the visual alive.
2685 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2687 // Test initially zero renderers
2688 application.SendNotification();
2689 application.Render(0);
2690 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2691 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2693 application.GetScene().Add(actor);
2695 // Wait for image to load
2696 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2698 application.SendNotification();
2699 application.Render(0);
2700 tet_infoline("Ensure a texture is created, shared amongst both visuals. Each visual has its own renderer");
2701 DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION);
2702 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
2704 // Test renderer removed when visual destroyed
2705 DALI_TEST_CHECK(actor.GetRendererCount() == 2u);
2706 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL2); // TEST_VISUAL2 no longer requires the texture as release policy DESTROYED
2707 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
2708 application.SendNotification();
2709 application.Render();
2711 // Test texture was not deleted as TEST_VISUAL release policy is NEVER so it is still required.
2712 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
2714 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
2715 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2716 application.SendNotification();
2717 application.Render();
2719 tet_infoline("Ensure a texture is not deleted as second visual used the NEVER release policy");
2720 // Test texture was not deleted as TEST_VISUAL release policy is NEVER so it is still required.
2721 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
2726 int UtcDaliImageVisualReleasePolicy05(void)
2728 ToolkitTestApplication application;
2729 tet_infoline("UtcDaliImageVisualReleasePolicy05 Testing settung by string currents correct enum");
2731 VisualFactory factory = VisualFactory::Get();
2733 Property::Map propertyMapNeverReleasePolicy;
2734 propertyMapNeverReleasePolicy.Insert(Visual::Property::TYPE, Visual::IMAGE);
2735 propertyMapNeverReleasePolicy.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
2736 propertyMapNeverReleasePolicy.Insert(ImageVisual::Property::DESIRED_WIDTH, 20);
2737 propertyMapNeverReleasePolicy.Insert(ImageVisual::Property::DESIRED_HEIGHT, 30);
2738 propertyMapNeverReleasePolicy.Insert("releasePolicy", "never");
2740 Visual::Base imageVisualNever = factory.CreateVisual(propertyMapNeverReleasePolicy);
2742 Property::Map resultMap;
2743 imageVisualNever.CreatePropertyMap(resultMap);
2744 DALI_TEST_CHECK(!resultMap.Empty());
2746 DALI_TEST_EQUALS((resultMap.Find(ImageVisual::Property::RELEASE_POLICY))->Get<int>(), (int)ImageVisual::ReleasePolicy::NEVER, TEST_LOCATION);
2751 int UtcDaliImageVisualReleasePolicy06(void)
2753 ToolkitTestApplication application;
2754 tet_infoline("UtcDaliImageVisualReleasePolicy06 Never Policy, texture should not be affected by Disabling and Enabling visual");
2756 Visual::Base imageVisual = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
2757 DALI_TEST_CHECK(imageVisual);
2759 TestGlAbstraction& gl = application.GetGlAbstraction();
2760 TraceCallStack& textureTrace = gl.GetTextureTrace();
2761 textureTrace.Enable(true);
2763 tet_infoline("Register visual with control and ensure it has the only handle");
2764 DummyControl actor = DummyControl::New(true);
2765 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2766 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
2767 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
2769 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2771 application.SendNotification();
2772 application.Render(0);
2773 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2774 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2776 application.GetScene().Add(actor);
2778 // Wait for image to load
2779 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2781 application.SendNotification();
2782 application.Render(0);
2783 // Test renderer and texture created
2784 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2785 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
2786 textureTrace.Reset();
2788 tet_infoline("Disable Visual and check texture not affected");
2789 dummyImpl.EnableVisual(DummyControl::Property::TEST_VISUAL, false);
2790 application.SendNotification();
2791 application.Render(0);
2792 tet_infoline("Check renderer is destroyed when visual off stage");
2793 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2794 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
2795 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2796 textureTrace.Reset();
2798 tet_infoline("Re-enable Visual and check texture not affected");
2799 dummyImpl.EnableVisual(DummyControl::Property::TEST_VISUAL, true);
2800 application.SendNotification();
2801 application.Render(0);
2802 tet_infoline("Check texture not affected and renderer is destroyed when visual off stage");
2803 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
2804 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
2805 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2810 int UtcDaliImageVisualReleasePolicy07(void)
2812 ToolkitTestApplication application;
2813 tet_infoline("UtcDaliImageVisualReleasePolicy07 Two visuals with different policies sharing a texture DETACHED and DESTROYED");
2815 tet_infoline("Create first visual with DESTROYED release policy");
2816 Visual::Base imageVisualDestroyed = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DESTROYED);
2818 tet_infoline("Create second visual with DETACHED release policy");
2819 Visual::Base imageVisualDetached = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DETACHED);
2821 // Set up trace debug
2822 TestGlAbstraction& gl = application.GetGlAbstraction();
2823 TraceCallStack& textureTrace = gl.GetTextureTrace();
2824 textureTrace.Enable(true);
2826 tet_infoline("Register visuals with control and ensure it has the only handles");
2827 DummyControl actor = DummyControl::New(true);
2828 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2829 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisualDestroyed);
2830 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL2, imageVisualDetached);
2831 imageVisualDestroyed.Reset(); // reduce ref count so only the control keeps the visual alive.
2832 imageVisualDetached.Reset(); // reduce ref count so only the control keeps the visual alive.
2834 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2836 // Test initially zero renderers
2837 application.SendNotification();
2838 application.Render(0);
2839 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2840 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2842 application.GetScene().Add(actor);
2844 // Wait for image to load
2845 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2847 application.SendNotification();
2848 application.Render(0);
2849 tet_infoline("Ensure a texture is created, shared amongst both visuals. Each visual has its own renderer");
2850 DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION);
2851 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
2853 // Test renderer removed when visual destroyed
2854 DALI_TEST_CHECK(actor.GetRendererCount() == 2u);
2855 dummyImpl.EnableVisual(DummyControl::Property::TEST_VISUAL2, false); // TEST_VISUAL2 no longer requires the texture as release policy DETACHED
2856 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
2857 application.SendNotification();
2858 application.Render();
2860 // Test texture was not deleted as TEST_VISUAL release policy is DESTROYED and is still required.
2861 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
2863 dummyImpl.EnableVisual(DummyControl::Property::TEST_VISUAL, false);
2864 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2865 application.SendNotification();
2866 application.Render();
2868 tet_infoline("Ensure a texture is not deleted as second visual used the DESTROYED release policy");
2869 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
2874 int UtcDaliImageVisualReleasePolicy08(void)
2876 ToolkitTestApplication application;
2877 tet_infoline("UtcDaliImageVisualReleasePolicy08 Ensure TextureSet is same after detach/attach on stage when texture used the DESTROYED release policy");
2879 tet_infoline("Create first visual with DESTROYED release policy");
2880 Visual::Base imageVisualDestroyed = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DESTROYED);
2882 // Set up trace debug
2883 TestGlAbstraction& gl = application.GetGlAbstraction();
2884 TraceCallStack& textureTrace = gl.GetTextureTrace();
2885 textureTrace.Enable(true);
2887 tet_infoline("Register visuals with control and ensure it has the only handles");
2888 DummyControl actor = DummyControl::New(true);
2889 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2890 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisualDestroyed);
2891 imageVisualDestroyed.Reset(); // reduce ref count so only the control keeps the visual alive.
2893 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2895 // Test initially zero renderers
2896 application.SendNotification();
2897 application.Render(0);
2898 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2899 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2900 textureTrace.Reset();
2902 application.GetScene().Add(actor);
2904 // Wait for image to load
2905 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2907 application.SendNotification();
2908 application.Render(0);
2909 tet_infoline("Ensure a texture is created");
2910 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2911 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
2912 textureTrace.Reset();
2914 // Ensure Texture is same after detach/attach on stage when texture used the DESTROYED release policy
2916 Texture textureBefore = actor.GetRendererAt(0u).GetTextures().GetTexture(0u);
2918 // 2.Remove actor from stage. In this case, renderer also is deleted.
2919 tet_infoline("Remove actor from stage");
2920 application.GetScene().Remove(actor);
2921 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2922 application.SendNotification();
2923 application.Render();
2925 tet_infoline("Ensure a texture is not deleted as visual used the DESTROYED release policy");
2926 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
2927 textureTrace.Reset();
2929 // 3.Add actor in stage. In this case, renderer is created.
2930 tet_infoline("Add actor in stage");
2931 application.GetScene().Add(actor);
2932 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
2933 application.SendNotification();
2934 application.Render();
2935 tet_infoline("Ensure a texture is not created again");
2936 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION);
2937 textureTrace.Reset();
2939 // 4.Compare Texture with before and after. texture need to be same because release policy is the DESTROYED.
2940 tet_infoline("Ensure a texture is not deleted because it is used the DESTROYED release policy");
2941 Texture textureAfter = actor.GetRendererAt(0u).GetTextures().GetTexture(0u);
2942 DALI_TEST_CHECK(textureBefore == textureAfter);
2943 textureBefore.Reset();
2944 textureAfter.Reset();
2946 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
2947 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2948 application.SendNotification();
2949 application.Render();
2950 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION);
2955 int UtcDaliImageVisualReleasePolicy09(void)
2957 ToolkitTestApplication application;
2958 tet_infoline("UtcDaliImageVisualReleasePolicy09 Destroyed Policy with N-Patch, Texture should be deleted when visual destroyed");
2960 Property::Map propertyMapNPatchReleasePolicy;
2961 propertyMapNPatchReleasePolicy.Insert(Visual::Property::TYPE, Visual::N_PATCH);
2962 propertyMapNPatchReleasePolicy.Insert(ImageVisual::Property::URL, TEST_N_PATCH_IMAGE_FILE_NAME);
2963 propertyMapNPatchReleasePolicy.Insert(DevelImageVisual::Property::AUXILIARY_IMAGE, TEST_MASK_IMAGE_FILE_NAME);
2964 propertyMapNPatchReleasePolicy.Insert(DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA, 0.9f);
2965 propertyMapNPatchReleasePolicy.Insert(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DESTROYED);
2967 VisualFactory factory = VisualFactory::Get();
2968 Visual::Base imageVisual = factory.CreateVisual(propertyMapNPatchReleasePolicy);
2969 DALI_TEST_CHECK(imageVisual);
2971 // Setup debug trace
2972 TestGlAbstraction& gl = application.GetGlAbstraction();
2973 TraceCallStack& textureTrace = gl.GetTextureTrace();
2974 textureTrace.Enable(true);
2976 tet_infoline("Register visual with control and ensure it has the only handle");
2977 DummyControl actor = DummyControl::New(true);
2978 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2979 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
2980 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
2982 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2984 application.SendNotification();
2985 application.Render(0);
2986 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2987 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2989 application.GetScene().Add(actor);
2991 // Wait for image to load
2992 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2994 application.SendNotification();
2995 application.Render(0);
2996 // Test renderer and texture created
2997 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2998 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
3000 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
3001 tet_infoline("Destroy visual by UnRegistering visual with control, check renderer is destroyed");
3002 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
3003 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
3004 application.SendNotification();
3005 application.Render();
3007 // Test texture removed after visual destroyed.
3008 tet_infoline("Ensure texture is deleted after visual destroyed");
3009 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 2, TEST_LOCATION);
3014 int UtcDaliImageVisualLoadPolicy01(void)
3016 ToolkitTestApplication application;
3017 tet_infoline("UtcDaliImageVisualLoadPolicy01 Load a visual image before attaching to stage");
3019 // Set up trace debug
3020 TestGlAbstraction& gl = application.GetGlAbstraction();
3021 TraceCallStack& textureTrace = gl.GetTextureTrace();
3022 textureTrace.Enable(true);
3024 tet_infoline("Create visual with IMMEDIATE load policy");
3025 VisualFactory factory = VisualFactory::Get();
3027 Property::Map propertyMap;
3028 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
3029 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
3030 propertyMap.Insert(ImageVisual::Property::DESIRED_WIDTH, 20);
3031 propertyMap.Insert(ImageVisual::Property::DESIRED_HEIGHT, 30);
3032 propertyMap.Insert("loadPolicy", ImageVisual::LoadPolicy::IMMEDIATE);
3034 Visual::Base imageVisual = factory.CreateVisual(propertyMap);
3036 Property::Map resultMap;
3037 imageVisual.CreatePropertyMap(resultMap);
3038 DALI_TEST_CHECK(!resultMap.Empty());
3039 DALI_TEST_EQUALS((resultMap.Find(ImageVisual::Property::LOAD_POLICY))->Get<int>(), (int)ImageVisual::LoadPolicy::IMMEDIATE, TEST_LOCATION);
3041 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3043 // Ensure texture has been uploaded
3044 application.SendNotification();
3045 application.Render();
3047 tet_infoline("Ensure texture loading starts after visual created");
3048 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
3049 textureTrace.Reset();
3051 tet_infoline("Register visuals with control and ensure it has the only handles");
3052 DummyControl actor = DummyControl::New(true);
3053 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
3054 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
3055 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
3057 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3058 application.GetScene().Add(actor);
3059 tet_infoline("Ensure nothing triggers another load as texure already loaded");
3060 const unsigned int TIME_OUT_3_SECONDS = 3;
3061 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, TIME_OUT_3_SECONDS), false, TEST_LOCATION);
3063 application.SendNotification();
3064 application.Render();
3066 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3067 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
3069 // Ensure texture is deleted when no longer needed (ref count was correct )
3070 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
3072 application.SendNotification();
3073 application.Render();
3075 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3076 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION);
3081 int UtcDaliImageVisualLoadPolicy02(void)
3083 ToolkitTestApplication application;
3084 tet_infoline("UtcDaliImageVisualLoadPolicy01 Load a visual image only after attached to stage");
3086 // Set up trace debug
3087 TestGlAbstraction& gl = application.GetGlAbstraction();
3088 TraceCallStack& textureTrace = gl.GetTextureTrace();
3089 textureTrace.Enable(true);
3091 tet_infoline("Create visual with IMMEDIATE load policy");
3092 Visual::Base imageVisual = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::ATTACHED);
3094 const unsigned int TIME_OUT_3_SECONDS = 3;
3095 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, TIME_OUT_3_SECONDS), false, TEST_LOCATION);
3097 // Act on meeage queue even although nothing expected to load
3098 application.SendNotification();
3099 application.Render();
3101 tet_infoline("Ensure texture is not generated yet");
3102 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
3103 textureTrace.Reset();
3105 tet_infoline("Register visuals with control and ensure it has the only handles");
3106 DummyControl actor = DummyControl::New(true);
3107 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
3108 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
3109 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
3111 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3112 application.GetScene().Add(actor);
3113 tet_infoline("Allow image time to load");
3114 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3116 application.SendNotification();
3117 application.Render();
3119 tet_infoline("Ensure texture generated and renderer created");
3120 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3121 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
3123 // Ensure texture is delete when no longer needed
3124 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
3126 application.SendNotification();
3127 application.Render();
3129 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3130 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION);
3135 int UtcDaliImageVisualLoadPolicy03(void)
3137 ToolkitTestApplication application;
3138 tet_infoline("UtcDaliImageVisualLoadPolicy03 Load a visual image and receive ResourceReady Signal when loaded");
3140 const bool VISUAL_NOT_ENABLED(false); // Instead of just passing 'false' into an API.
3142 // Set up trace debug
3143 TestGlAbstraction& gl = application.GetGlAbstraction();
3144 TraceCallStack& textureTrace = gl.GetTextureTrace();
3145 textureTrace.Enable(true);
3147 tet_infoline("Create a control and connect to resource ready signal without adding to stage");
3148 DummyControl actor = DummyControl::New(true);
3149 actor.ResourceReadySignal().Connect(&ResourceReadySignal);
3150 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
3151 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3153 tet_infoline("Create visual with IMMEDIATE load policy");
3154 Visual::Base imageVisual = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE);
3156 tet_infoline("Registering visual allows control to get a signal once loaded even if visual not enabled( not staged )");
3157 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual, VISUAL_NOT_ENABLED);
3158 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
3160 tet_infoline("Allow image time to load resource");
3161 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3162 application.SendNotification();
3163 application.Render();
3165 // Ensure texture has been uploaded
3166 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
3167 DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
3172 int UtcDaliImageVisualLoadPolicy04(void)
3174 ToolkitTestApplication application;
3175 tet_infoline("UtcDaliImageVisualLoadPolicy04 First part Load a visual image before attaching to stage");
3176 tet_infoline("Second part, Reuse the same image in aonther control and check resource ready signal fired");
3178 const bool VISUAL_NOT_ENABLED(false); // Instead of just passing false into an API.
3180 // Set up trace debug
3181 TestGlAbstraction& gl = application.GetGlAbstraction();
3182 TraceCallStack& textureTrace = gl.GetTextureTrace();
3183 textureTrace.Enable(true);
3185 tet_infoline("Create a control and connect to resource ready signal");
3186 DummyControl actor = DummyControl::New(true);
3187 actor.ResourceReadySignal().Connect(&ResourceReadySignal);
3188 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
3189 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3191 tet_infoline("Create visual with IMMEDIATE load policy");
3192 Visual::Base imageVisual = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE);
3194 tet_infoline("Registering visual allows control to get a signal once loaded even if visual not enabled( staged )");
3195 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual, VISUAL_NOT_ENABLED);
3196 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
3198 tet_infoline("Allow image time to load");
3199 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3200 application.SendNotification();
3201 application.Render();
3203 tet_infoline("Testing texture is loaded and resource ready signal fired");
3204 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
3205 DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
3207 tet_infoline("Original control correctly signalled, now testing for signal with new Control reusing the image");
3209 gResourceReadySignalFired = false; // Reset signal check ready for testing next Control
3210 Visual::Base imageVisual2 = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE);
3211 DummyControl actor2 = DummyControl::New(true);
3212 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(actor.GetImplementation());
3213 actor2.ResourceReadySignal().Connect(&ResourceReadySignal);
3215 tet_infoline("Registering visual this should trigger the loading signal as is already image loaded for previous control");
3216 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual2);
3217 imageVisual2.Reset(); // reduce ref count so only the control keeps the visual alive.
3218 actor2.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3219 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(0), true, TEST_LOCATION); // Not expecting any further loading as texture is being reused.
3220 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3225 int UtcDaliImageVisualLoadPolicy05(void)
3227 ToolkitTestApplication application;
3228 tet_infoline("UtcDaliImageVisualLoadPolicy05 LoadPolicy::ATTACHED (default) First part Load a visual image before attaching to stage");
3229 tet_infoline("Second part, Reuse the same image in aonther control and check resource ready signal fired");
3230 // Set up trace debug
3231 TestGlAbstraction& gl = application.GetGlAbstraction();
3232 TraceCallStack& textureTrace = gl.GetTextureTrace();
3233 textureTrace.Enable(true);
3235 tet_infoline("Create a control and connect to resource ready signal");
3236 DummyControl actor = DummyControl::New(true);
3237 actor.ResourceReadySignal().Connect(&ResourceReadySignal);
3238 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
3239 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3240 application.GetScene().Add(actor);
3242 tet_infoline("Create visual with ATTACHED load policy");
3243 Visual::Base imageVisual = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::ATTACHED);
3245 tet_infoline("Registering visual allows control to get a signal once loaded");
3246 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
3247 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
3249 tet_infoline("Allow image time to load");
3250 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3251 application.SendNotification();
3252 application.Render();
3254 tet_infoline("Testing texture is loaded and resource ready signal fired");
3255 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
3256 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3258 tet_infoline("Original control correctly signalled, now testing for signal with new Control reusing the image");
3260 gResourceReadySignalFired = false; // Reset signal check ready for testing next Control
3261 Visual::Base imageVisual2 = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::ATTACHED);
3262 DummyControl actor2 = DummyControl::New(true);
3263 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(actor.GetImplementation());
3264 actor2.ResourceReadySignal().Connect(&ResourceReadySignal);
3266 tet_infoline("Registering visual this should trigger the loading signal as is already image loaded for previous control");
3267 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual2);
3268 imageVisual2.Reset(); // reduce ref count so only the control keeps the visual alive.
3269 actor2.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3270 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(0), true, TEST_LOCATION); // Not expecting any further loading as texture is being reused.
3271 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3276 int UtcDaliImageVisualOrientationCorrection(void)
3278 ToolkitTestApplication application;
3279 tet_infoline("UtcDaliImageVisualOrientationCorrection Enabling OrientationCorrection should rotate an image with exif (90deg) orientation data with requested");
3281 VisualFactory factory = VisualFactory::Get();
3282 tet_infoline("Create visual with Orientation correction set OFF");
3283 Property::Map propertyMap;
3284 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
3285 propertyMap.Insert(ImageVisual::Property::URL, TEST_ROTATED_IMAGE);
3286 propertyMap.Insert("orientationCorrection", false);
3287 Visual::Base imageVisual = factory.CreateVisual(propertyMap);
3289 tet_infoline("Create control for visual, need to loaded it");
3290 DummyControl actor = DummyControl::New(true);
3291 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
3292 application.GetScene().Add(actor);
3294 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
3295 // Wait for image to load
3296 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3298 Vector2 originalImageSize;
3299 tet_infoline("Get size of original visual to compare later with rotated image");
3300 imageVisual.GetNaturalSize(originalImageSize);
3301 DALI_TEST_GREATER(originalImageSize.width, originalImageSize.height, TEST_LOCATION); // Width and Height must be different for this test.
3302 imageVisual.Reset(); // remove handle so can unregister it and remove from cache
3303 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
3304 application.SendNotification();
3305 application.Render();
3307 tet_infoline("Create visual with Orientation correction set ON ");
3308 propertyMap.Clear();
3309 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
3310 propertyMap.Insert(ImageVisual::Property::URL, TEST_ROTATED_IMAGE);
3311 propertyMap.Insert(ImageVisual::Property::ORIENTATION_CORRECTION, true);
3312 imageVisual = factory.CreateVisual(propertyMap);
3314 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
3315 // Wait for image to load
3316 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3318 Vector2 rotatedImageSize;
3319 imageVisual.GetNaturalSize(rotatedImageSize);
3320 tet_infoline("Confirm that visual has rotated");
3321 DALI_TEST_EQUALS(originalImageSize.width, rotatedImageSize.height, TEST_LOCATION);
3322 DALI_TEST_EQUALS(originalImageSize.height, rotatedImageSize.width, TEST_LOCATION);
3324 Property::Map resultMap;
3325 imageVisual.CreatePropertyMap(resultMap);
3327 // check the Property::ORIENTATION_CORRECTION value from the returned map
3328 Property::Value* typeValue = resultMap.Find(ImageVisual::Property::ORIENTATION_CORRECTION, Property::BOOLEAN);
3329 DALI_TEST_EQUALS(typeValue->Get<bool>(), true, TEST_LOCATION);
3334 int UtcDaliImageVisualCustomShader(void)
3336 ToolkitTestApplication application;
3337 tet_infoline("UtcDaliImageVisualCustomShader Test custom shader");
3339 VisualFactory factory = VisualFactory::Get();
3340 Property::Map properties;
3341 Property::Map shader;
3342 const std::string vertexShader = "Foobar";
3343 const std::string fragmentShader = "Foobar";
3344 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
3345 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
3347 properties[Visual::Property::TYPE] = Visual::IMAGE;
3348 properties[Visual::Property::SHADER] = shader;
3349 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
3351 Visual::Base visual = factory.CreateVisual(properties);
3353 // trigger creation through setting on stage
3354 DummyControl dummy = DummyControl::New(true);
3355 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
3356 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
3358 dummy.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3359 dummy.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3360 application.GetScene().Add(dummy);
3362 application.SendNotification();
3363 application.Render();
3365 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3367 Renderer renderer = dummy.GetRendererAt(0);
3368 Shader shader2 = renderer.GetShader();
3369 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
3370 Property::Map* map = value.GetMap();
3371 DALI_TEST_CHECK(map);
3373 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
3374 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
3376 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
3377 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
3381 shader[Visual::Shader::Property::HINTS] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
3382 properties[Visual::Property::SHADER] = shader;
3384 Visual::Base visual1 = factory.CreateVisual(properties);
3386 // trigger creation through setting on stage
3387 DummyControl dummy1 = DummyControl::New(true);
3388 Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummy1.GetImplementation());
3389 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual1);
3390 dummy1.SetProperty(Actor::Property::SIZE, Vector2(200, 200));
3391 dummy1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3392 application.GetScene().Add(dummy1);
3394 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3395 glAbstraction.EnableEnableDisableCallTrace(true);
3397 application.SendNotification();
3398 application.Render();
3400 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
3401 std::ostringstream blendStr;
3402 blendStr << std::hex << GL_BLEND;
3403 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str()));
3408 void ResourceReadyLoadNext(Control control)
3410 static int callNumber = 0;
3412 gResourceReadySignalFired = true;
3413 gReadyIds.push_back(control.GetProperty<int>(Actor::Property::ID));
3417 DALI_TEST_EQUALS(control.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL), Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
3419 tet_infoline("Create visual with loaded image from within the signal handler");
3420 VisualFactory factory = VisualFactory::Get();
3421 Visual::Base imageVisual = factory.CreateVisual(TEST_IMAGE_FILE_NAME, ImageDimensions{20, 30});
3423 Impl::DummyControl& controlImpl = static_cast<Impl::DummyControl&>(control.GetImplementation());
3424 controlImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual); // This should trigger another signal.
3429 tet_infoline("3rd signal called");
3430 DALI_TEST_CHECK(true);
3434 int UtcDaliImageVisualLoadReady01(void)
3436 ToolkitTestApplication application;
3437 tet_infoline("UtcDaliImageVisualLoadReady01");
3438 tet_infoline("First part: Load an image visual for one resource, then another image visual for a second resource.");
3439 tet_infoline("Second part, In the ready signal for the second image visual, add a 3rd visual with the first URL");
3440 tet_infoline("Should get a ready signal for all three visuals");
3444 tet_infoline("Create a control and connect to resource ready signal");
3445 DummyControl actor = DummyControl::New(true);
3446 int actor1Id = actor.GetProperty<int>(Actor::Property::ID);
3447 actor.ResourceReadySignal().Connect(&ResourceReadySignal);
3448 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
3449 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3450 application.GetScene().Add(actor);
3452 tet_infoline("Create visual with IMMEDIATE load policy");
3453 Visual::Base imageVisual1 = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE);
3455 tet_infoline("Registering visual allows control to get a signal once loaded even if visual not enabled( staged )");
3456 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual1);
3458 tet_infoline("Allow image time to load");
3459 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3460 application.SendNotification();
3461 application.Render();
3463 tet_infoline("Testing texture is loaded and resource ready signal fired");
3464 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3465 DALI_TEST_EQUALS(gReadyIds[0], actor1Id, TEST_LOCATION);
3467 tet_infoline("Original control correctly signalled, now testing failing image");
3469 gResourceReadySignalFired = false; // Reset signal check ready for testing next Control
3472 Visual::Base imageVisual2 = CreateVisualWithPolicy(TEST_BROKEN_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE);
3474 DummyControl actor2 = DummyControl::New(true);
3475 int actor2Id = actor2.GetProperty<int>(Actor::Property::ID);
3476 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(actor2.GetImplementation());
3477 actor2.ResourceReadySignal().Connect(&ResourceReadyLoadNext);
3479 tet_infoline("Registering visual this should trigger the ready signal when the image fails to load");
3480 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual2);
3482 actor2.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3483 application.GetScene().Add(actor2);
3485 tet_infoline("Wait for loading thread to finish");
3486 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3487 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3489 DALI_TEST_EQUALS(gReadyIds[0], actor2Id, TEST_LOCATION);
3491 tet_infoline("Check for 3rd signal");
3492 application.SendNotification();
3493 DALI_TEST_EQUALS(gReadyIds.size(), 2, TEST_LOCATION);
3494 DALI_TEST_EQUALS(gReadyIds[1], actor2Id, TEST_LOCATION);
3499 int UtcDaliImageVisualLoadImagePlanes01(void)
3501 EnvironmentVariable::SetTestEnvironmentVariable(LOAD_IMAGE_YUV_PLANES_ENV, "1");
3502 EnvironmentVariable::SetTestEnvironmentVariable(ENABLE_DECODE_JPEG_TO_YUV_420_ENV, "1");
3504 ToolkitTestApplication application;
3506 VisualFactory factory = VisualFactory::Get();
3507 DALI_TEST_CHECK(factory);
3509 Property::Map propertyMap;
3510 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
3511 propertyMap.Insert(ImageVisual::Property::URL, TEST_YUV420_IMAGE_FILE_NAME);
3513 Visual::Base visual = factory.CreateVisual(propertyMap);
3514 DALI_TEST_CHECK(visual);
3516 DummyControl actor = DummyControl::New();
3517 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
3518 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
3519 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3520 application.GetScene().Add(actor);
3522 application.SendNotification();
3523 application.Render();
3525 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3527 TestGlAbstraction& gl = application.GetGlAbstraction();
3528 TraceCallStack& textureTrace = gl.GetTextureTrace();
3529 textureTrace.Enable(true);
3531 application.SendNotification();
3532 application.Render();
3534 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3535 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
3536 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 3, TEST_LOCATION);
3538 Renderer renderer = actor.GetRendererAt(0);
3539 auto preMultipliedAlpha = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
3540 DALI_TEST_EQUALS(preMultipliedAlpha, false, TEST_LOCATION);
3545 int UtcDaliImageVisualLoadImagePlanes02(void)
3547 EnvironmentVariable::SetTestEnvironmentVariable(LOAD_IMAGE_YUV_PLANES_ENV, "1");
3548 EnvironmentVariable::SetTestEnvironmentVariable(ENABLE_DECODE_JPEG_TO_YUV_420_ENV, "1");
3550 ToolkitTestApplication application;
3552 VisualFactory factory = VisualFactory::Get();
3553 DALI_TEST_CHECK(factory);
3555 // Alpha masking case - not support yuv planes
3556 Property::Map propertyMap;
3557 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
3558 propertyMap.Insert(ImageVisual::Property::URL, TEST_YUV420_IMAGE_FILE_NAME);
3559 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
3561 Visual::Base visual = factory.CreateVisual(propertyMap);
3562 DALI_TEST_CHECK(visual);
3564 DummyControl actor = DummyControl::New();
3565 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
3566 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
3567 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3568 application.GetScene().Add(actor);
3570 application.SendNotification();
3571 application.Render();
3573 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
3575 TestGlAbstraction& gl = application.GetGlAbstraction();
3576 TraceCallStack& textureTrace = gl.GetTextureTrace();
3577 textureTrace.Enable(true);
3579 application.SendNotification();
3580 application.Render();
3582 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3583 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
3584 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 1, TEST_LOCATION);
3589 int UtcDaliImageVisualLoadImagePlanes03(void)
3591 EnvironmentVariable::SetTestEnvironmentVariable(LOAD_IMAGE_YUV_PLANES_ENV, "1");
3592 EnvironmentVariable::SetTestEnvironmentVariable(ENABLE_DECODE_JPEG_TO_YUV_420_ENV, "1");
3594 ToolkitTestApplication application;
3596 VisualFactory factory = VisualFactory::Get();
3597 DALI_TEST_CHECK(factory);
3599 TestGlAbstraction& gl = application.GetGlAbstraction();
3600 TraceCallStack& textureTrace = gl.GetTextureTrace();
3601 textureTrace.Enable(true);
3603 Property::Map propertyMap;
3604 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
3605 propertyMap.Insert(ImageVisual::Property::URL, TEST_YUV420_IMAGE_FILE_NAME);
3606 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
3608 Visual::Base visual = factory.CreateVisual(propertyMap);
3609 DALI_TEST_CHECK(visual);
3611 DummyControl actor = DummyControl::New();
3612 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
3613 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
3614 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3615 application.GetScene().Add(actor);
3617 application.SendNotification();
3618 application.Render();
3620 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3621 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
3622 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 3, TEST_LOCATION);
3627 int UtcDaliImageVisualLoadFastTrackImage01(void)
3629 tet_infoline("Test worker thread uploading with Local URL");
3630 ToolkitTestApplication application;
3632 Test::TextureUploadManager::InitalizeGraphicsController(application.GetGraphicsController());
3634 VisualFactory factory = VisualFactory::Get();
3635 DALI_TEST_CHECK(factory);
3637 // Pair of filename - expect GenTextures count.
3638 std::vector<std::pair<std::string, int>> testCases = {
3639 {TEST_IMAGE_FILE_NAME, 1},
3640 {TEST_REMOTE_IMAGE_FILE_NAME, 1},
3641 {TEST_INVALID_FILE_NAME, 0},
3644 for(auto&& tc : testCases)
3646 auto& filename = tc.first;
3647 auto& expectValue = tc.second;
3649 tet_printf("Test %s\n", filename.c_str());
3651 Property::Map propertyMap;
3652 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
3653 propertyMap.Insert(ImageVisual::Property::URL, filename.c_str());
3654 propertyMap.Insert(DevelImageVisual::Property::FAST_TRACK_UPLOADING, true);
3656 Visual::Base visual = factory.CreateVisual(propertyMap);
3657 DALI_TEST_CHECK(visual);
3659 DummyControl actor = DummyControl::New();
3660 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
3661 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
3662 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3664 TestGlAbstraction& gl = application.GetGlAbstraction();
3665 TraceCallStack& textureTrace = gl.GetTextureTrace();
3666 textureTrace.Enable(true);
3668 application.GetScene().Add(actor);
3670 application.SendNotification();
3671 application.Render();
3673 // EventThread without callback
3674 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 30, false), true, TEST_LOCATION);
3676 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION);
3679 // TODO : There is no way to flush TextureUploadManager in test-application's Render() now.
3680 // How can we make it? Should it be integration-api?
3681 auto textureUploadManager = Dali::Devel::TextureUploadManager::Get();
3682 DALI_TEST_EQUALS(textureUploadManager.ResourceUpload(), expectValue > 0, TEST_LOCATION);
3684 // Render only without SendNotification(). And check whether glTexImage2D called or not.
3685 application.Render();
3687 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), expectValue, TEST_LOCATION);
3689 application.SendNotification();
3690 application.Render();
3692 textureTrace.Reset();
3698 int UtcDaliImageVisualLoadFastTrackImage02(void)
3700 tet_infoline("Test worker thread uploading with Local URL");
3701 ToolkitTestApplication application;
3703 Test::TextureUploadManager::InitalizeGraphicsController(application.GetGraphicsController());
3705 VisualFactory factory = VisualFactory::Get();
3706 DALI_TEST_CHECK(factory);
3709 auto filename = std::string(TEST_IMAGE_FILE_NAME);
3710 auto expectValue = 1;
3712 tet_printf("Test %s\n", filename.c_str());
3714 Property::Map propertyMap;
3715 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
3716 propertyMap.Insert(ImageVisual::Property::URL, filename.c_str());
3717 propertyMap.Insert("fastTrackUploading", true);
3719 Visual::Base visual = factory.CreateVisual(propertyMap);
3720 DALI_TEST_CHECK(visual);
3722 DummyControl actor = DummyControl::New();
3723 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
3724 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
3725 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3727 TestGlAbstraction& gl = application.GetGlAbstraction();
3728 TraceCallStack& textureTrace = gl.GetTextureTrace();
3729 textureTrace.Enable(true);
3731 application.GetScene().Add(actor);
3733 application.SendNotification();
3734 application.Render();
3736 // EventThread without callback
3737 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 30, false), true, TEST_LOCATION);
3739 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION);
3742 // TODO : There is no way to flush TextureUploadManager in test-application's Render() now.
3743 // How can we make it? Should it be integration-api?
3744 auto textureUploadManager = Dali::Devel::TextureUploadManager::Get();
3745 DALI_TEST_EQUALS(textureUploadManager.ResourceUpload(), expectValue > 0, TEST_LOCATION);
3747 // Render only without SendNotification(). And check whether glTexImage2D called or not.
3748 application.Render();
3750 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), expectValue, TEST_LOCATION);
3752 application.SendNotification();
3753 application.Render();
3755 textureTrace.Reset();
3761 int UtcDaliImageVisualLoadFastTrackImageResourceReady(void)
3763 tet_infoline("Test worker thread uploading with Local URL");
3764 ToolkitTestApplication application;
3766 VisualFactory factory = VisualFactory::Get();
3767 DALI_TEST_CHECK(factory);
3769 Property::Map propertyMap;
3770 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
3771 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
3772 propertyMap.Insert(DevelImageVisual::Property::FAST_TRACK_UPLOADING, true);
3774 Visual::Base visual = factory.CreateVisual(propertyMap);
3775 DALI_TEST_CHECK(visual);
3777 DummyControl actor = DummyControl::New();
3778 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
3779 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
3780 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3782 TestGlAbstraction& gl = application.GetGlAbstraction();
3783 TraceCallStack& textureTrace = gl.GetTextureTrace();
3784 textureTrace.Enable(true);
3786 application.GetScene().Add(actor);
3788 application.SendNotification();
3789 application.Render();
3791 // EventThread with callback
3792 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3794 // Check resource ready comes after
3795 application.SendNotification();
3796 application.Render();
3798 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3799 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
3804 int UtcDaliImageVisualLoadFastTrackImageReload(void)
3806 tet_infoline("Test worker thread uploading with Local URL");
3807 ToolkitTestApplication application;
3809 Test::TextureUploadManager::InitalizeGraphicsController(application.GetGraphicsController());
3811 VisualFactory factory = VisualFactory::Get();
3812 DALI_TEST_CHECK(factory);
3814 Property::Map propertyMap;
3815 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
3816 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
3817 propertyMap.Insert(DevelImageVisual::Property::FAST_TRACK_UPLOADING, true);
3819 Visual::Base visual = factory.CreateVisual(propertyMap);
3820 DALI_TEST_CHECK(visual);
3822 DummyControl actor = DummyControl::New();
3823 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
3824 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
3825 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3827 TestGlAbstraction& gl = application.GetGlAbstraction();
3828 TraceCallStack& textureTrace = gl.GetTextureTrace();
3829 textureTrace.Enable(true);
3831 application.GetScene().Add(actor);
3833 application.SendNotification();
3834 application.Render();
3836 // EventThread without callback
3837 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 30, false), true, TEST_LOCATION);
3839 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION);
3842 // TODO : There is no way to flush TextureUploadManager in test-application's Render() now.
3843 // How can we make it? Should it be integration-api?
3844 auto textureUploadManager = Dali::Devel::TextureUploadManager::Get();
3845 DALI_TEST_EQUALS(textureUploadManager.ResourceUpload(), true, TEST_LOCATION);
3847 // Render only without SendNotification(). And check whether glTexImage2D called or not.
3848 application.Render();
3850 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 1, TEST_LOCATION);
3853 Property::Map attributes;
3854 DevelControl::DoAction(actor, Control::CONTROL_PROPERTY_END_INDEX + 1, DevelImageVisual::Action::RELOAD, attributes);
3856 // EventThread with callback
3857 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3859 // Check resource ready comes after
3860 application.SendNotification();
3861 application.Render();
3863 // Check whether renderer count is 1 or not.
3864 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3865 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
3870 int UtcDaliImageVisualLoadFastTrackImagePlanes01(void)
3872 EnvironmentVariable::SetTestEnvironmentVariable(LOAD_IMAGE_YUV_PLANES_ENV, "1");
3873 EnvironmentVariable::SetTestEnvironmentVariable(ENABLE_DECODE_JPEG_TO_YUV_420_ENV, "1");
3875 ToolkitTestApplication application;
3877 Test::TextureUploadManager::InitalizeGraphicsController(application.GetGraphicsController());
3879 VisualFactory factory = VisualFactory::Get();
3880 DALI_TEST_CHECK(factory);
3882 Property::Map propertyMap;
3883 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
3884 propertyMap.Insert(ImageVisual::Property::URL, TEST_YUV420_IMAGE_FILE_NAME);
3885 propertyMap.Insert(DevelImageVisual::Property::FAST_TRACK_UPLOADING, true);
3887 Visual::Base visual = factory.CreateVisual(propertyMap);
3888 DALI_TEST_CHECK(visual);
3890 DummyControl actor = DummyControl::New();
3891 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
3892 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
3893 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3895 TestGlAbstraction& gl = application.GetGlAbstraction();
3896 TraceCallStack& textureTrace = gl.GetTextureTrace();
3897 textureTrace.Enable(true);
3899 application.GetScene().Add(actor);
3901 application.SendNotification();
3902 application.Render();
3904 // EventThread without callback
3905 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 30, false), true, TEST_LOCATION);
3907 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION);
3910 // TODO : There is no way to flush TextureUploadManager in test-application's Render() now.
3911 // How can we make it? Should it be integration-api?
3912 auto textureUploadManager = Dali::Devel::TextureUploadManager::Get();
3913 textureUploadManager.ResourceUpload();
3914 application.Render();
3916 // Render only without SendNotification(). And check whether glTexImage2D called or not.
3917 application.Render();
3919 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 3, TEST_LOCATION);
3921 application.SendNotification();
3922 application.Render();
3927 int UtcDaliImageVisualLoadFastTrackImagePlanes02(void)
3929 EnvironmentVariable::SetTestEnvironmentVariable(LOAD_IMAGE_YUV_PLANES_ENV, "1");
3930 EnvironmentVariable::SetTestEnvironmentVariable(ENABLE_DECODE_JPEG_TO_YUV_420_ENV, "1");
3932 ToolkitTestApplication application;
3934 Test::TextureUploadManager::InitalizeGraphicsController(application.GetGraphicsController());
3936 VisualFactory factory = VisualFactory::Get();
3937 DALI_TEST_CHECK(factory);
3939 Property::Map propertyMap;
3940 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
3941 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
3942 propertyMap.Insert(DevelImageVisual::Property::FAST_TRACK_UPLOADING, true);
3944 Visual::Base visual = factory.CreateVisual(propertyMap);
3945 DALI_TEST_CHECK(visual);
3947 DummyControl actor = DummyControl::New();
3948 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
3949 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
3950 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3952 TestGlAbstraction& gl = application.GetGlAbstraction();
3953 TraceCallStack& textureTrace = gl.GetTextureTrace();
3954 textureTrace.Enable(true);
3956 application.GetScene().Add(actor);
3958 application.SendNotification();
3959 application.Render();
3961 // EventThread without callback
3962 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 30, false), true, TEST_LOCATION);
3964 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION);
3967 // TODO : There is no way to flush TextureUploadManager in test-application's Render() now.
3968 // How can we make it? Should it be integration-api?
3969 auto textureUploadManager = Dali::Devel::TextureUploadManager::Get();
3970 textureUploadManager.ResourceUpload();
3971 application.Render();
3973 // Render only without SendNotification(). And check whether glTexImage2D called or not.
3974 application.Render();
3976 DALI_TEST_GREATER(textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION);
3978 application.SendNotification();
3979 application.Render();