71d8cbafae63e87a8b1a13e49296b3a3876e7d55
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / npatch / npatch-visual.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include "npatch-visual.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/devel-api/adaptor-framework/image-loading.h>
23 #include <dali/devel-api/common/stage.h>
24 #include <dali/devel-api/rendering/renderer-devel.h>
25 #include <dali/integration-api/debug.h>
26
27 // INTERNAL INCLUDES
28 #include <dali-toolkit/devel-api/utility/npatch-helper.h>
29 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
30 #include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
31 #include <dali-toolkit/internal/visuals/image-visual-shader-factory.h>
32 #include <dali-toolkit/internal/visuals/npatch-loader.h>
33 #include <dali-toolkit/internal/visuals/rendering-addon.h>
34 #include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
35 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
36 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
37 #include <dali-toolkit/internal/visuals/visual-factory-impl.h>
38 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
39 #include <dali-toolkit/public-api/visuals/visual-properties.h>
40
41 namespace Dali
42 {
43 namespace Toolkit
44 {
45 namespace Internal
46 {
47 namespace
48 {
49 const int CUSTOM_PROPERTY_COUNT(5); // fixed(3),stretch,aux
50 }
51
52 /////////////////NPatchVisual////////////////
53
54 NPatchVisualPtr NPatchVisual::New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, const Property::Map& properties)
55 {
56   NPatchVisualPtr nPatchVisual(new NPatchVisual(factoryCache, shaderFactory));
57   nPatchVisual->mImageUrl = imageUrl;
58   nPatchVisual->SetProperties(properties);
59   nPatchVisual->Initialize();
60   return nPatchVisual;
61 }
62
63 NPatchVisualPtr NPatchVisual::New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl)
64 {
65   NPatchVisualPtr nPatchVisual(new NPatchVisual(factoryCache, shaderFactory));
66   nPatchVisual->mImageUrl = imageUrl;
67   nPatchVisual->Initialize();
68   return nPatchVisual;
69 }
70
71 void NPatchVisual::LoadImages()
72 {
73   TextureManager& textureManager     = mFactoryCache.GetTextureManager();
74   bool            synchronousLoading = mImpl->mFlags & Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
75
76   if(mId == NPatchData::INVALID_NPATCH_DATA_ID && (mImageUrl.IsLocalResource() || mImageUrl.IsBufferResource()))
77   {
78     bool preMultiplyOnLoad = IsPreMultipliedAlphaEnabled() && !mImpl->mCustomShader ? true : false;
79     mId                    = mLoader.Load(textureManager, this, mImageUrl, mBorder, preMultiplyOnLoad, synchronousLoading);
80
81     const NPatchData* data;
82     if(mLoader.GetNPatchData(mId, data) && data->GetLoadingState() == NPatchData::LoadingState::LOAD_COMPLETE)
83     {
84       EnablePreMultipliedAlpha(data->IsPreMultiplied());
85     }
86   }
87
88   if(!mAuxiliaryPixelBuffer && mAuxiliaryUrl.IsValid() && (mAuxiliaryUrl.IsLocalResource() || mAuxiliaryUrl.IsBufferResource()))
89   {
90     // Load the auxiliary image
91     auto preMultiplyOnLoading = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
92     mAuxiliaryPixelBuffer     = textureManager.LoadPixelBuffer(mAuxiliaryUrl, Dali::ImageDimensions(), FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, synchronousLoading, this, true, preMultiplyOnLoading);
93   }
94 }
95
96 void NPatchVisual::GetNaturalSize(Vector2& naturalSize)
97 {
98   naturalSize.x = 0u;
99   naturalSize.y = 0u;
100
101   // load now if not already loaded
102   const NPatchData* data;
103   if(mLoader.GetNPatchData(mId, data) && data->GetLoadingState() != NPatchData::LoadingState::LOADING)
104   {
105     naturalSize.x = data->GetCroppedWidth();
106     naturalSize.y = data->GetCroppedHeight();
107   }
108   else
109   {
110     if(mImageUrl.IsValid())
111     {
112       ImageDimensions dimensions = Dali::GetOriginalImageSize(mImageUrl.GetUrl());
113       if(dimensions != ImageDimensions(0, 0))
114       {
115         naturalSize.x = dimensions.GetWidth();
116         naturalSize.y = dimensions.GetHeight();
117       }
118     }
119   }
120
121   if(mAuxiliaryPixelBuffer)
122   {
123     naturalSize.x = std::max(naturalSize.x, float(mAuxiliaryPixelBuffer.GetWidth()));
124     naturalSize.y = std::max(naturalSize.y, float(mAuxiliaryPixelBuffer.GetHeight()));
125   }
126 }
127
128 void NPatchVisual::DoSetProperties(const Property::Map& propertyMap)
129 {
130   // URL is already passed in via constructor
131
132   Property::Value* borderOnlyValue = propertyMap.Find(Toolkit::ImageVisual::Property::BORDER_ONLY, BORDER_ONLY);
133   if(borderOnlyValue)
134   {
135     borderOnlyValue->Get(mBorderOnly);
136   }
137
138   Property::Value* borderValue = propertyMap.Find(Toolkit::ImageVisual::Property::BORDER, BORDER);
139   if(borderValue && !borderValue->Get(mBorder)) // If value exists and is rect, just set mBorder
140   {
141     // Not a rect so try vector4
142     Vector4 border;
143     if(borderValue->Get(border))
144     {
145       mBorder.left   = static_cast<int>(border.x);
146       mBorder.right  = static_cast<int>(border.y);
147       mBorder.bottom = static_cast<int>(border.z);
148       mBorder.top    = static_cast<int>(border.w);
149     }
150   }
151
152   Property::Value* auxImage = propertyMap.Find(Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE, AUXILIARY_IMAGE_NAME);
153   if(auxImage)
154   {
155     std::string url;
156     if(auxImage->Get(url))
157     {
158       mAuxiliaryUrl = url;
159     }
160   }
161
162   Property::Value* auxImageAlpha = propertyMap.Find(Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA, AUXILIARY_IMAGE_ALPHA_NAME);
163   if(auxImageAlpha)
164   {
165     auxImageAlpha->Get(mAuxiliaryImageAlpha);
166   }
167
168   Property::Value* synchronousLoading = propertyMap.Find(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, SYNCHRONOUS_LOADING);
169   if(synchronousLoading)
170   {
171     bool sync = false;
172     synchronousLoading->Get(sync);
173     if(sync)
174     {
175       mImpl->mFlags |= Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
176     }
177     else
178     {
179       mImpl->mFlags &= ~Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
180     }
181   }
182
183   Property::Value* releasePolicy = propertyMap.Find(Toolkit::ImageVisual::Property::RELEASE_POLICY, RELEASE_POLICY_NAME);
184   if(releasePolicy)
185   {
186     releasePolicy->Get(mReleasePolicy);
187   }
188 }
189
190 void NPatchVisual::DoSetOnScene(Actor& actor)
191 {
192   // load when first go on stage
193   LoadImages();
194
195   const NPatchData* data;
196   if(mLoader.GetNPatchData(mId, data))
197   {
198     Geometry geometry = CreateGeometry();
199     Shader   shader   = CreateShader();
200
201     mImpl->mRenderer.SetGeometry(geometry);
202     mImpl->mRenderer.SetShader(shader);
203
204     mPlacementActor = actor;
205     if(data->GetLoadingState() != NPatchData::LoadingState::LOADING)
206     {
207       if(RenderingAddOn::Get().IsValid())
208       {
209         RenderingAddOn::Get().SubmitRenderTask(mImpl->mRenderer, data->GetRenderingMap());
210       }
211
212       ApplyTextureAndUniforms();
213       actor.AddRenderer(mImpl->mRenderer);
214       mPlacementActor.Reset();
215
216       // npatch loaded and ready to display
217       ResourceReady(Toolkit::Visual::ResourceStatus::READY);
218     }
219   }
220 }
221
222 void NPatchVisual::DoSetOffScene(Actor& actor)
223 {
224   if((mId != NPatchData::INVALID_NPATCH_DATA_ID) && mReleasePolicy == Toolkit::ImageVisual::ReleasePolicy::DETACHED)
225   {
226     mLoader.Remove(mId, this);
227     mImpl->mResourceStatus = Toolkit::Visual::ResourceStatus::PREPARING;
228     mId                    = NPatchData::INVALID_NPATCH_DATA_ID;
229   }
230
231   actor.RemoveRenderer(mImpl->mRenderer);
232   mPlacementActor.Reset();
233 }
234
235 void NPatchVisual::OnSetTransform()
236 {
237   if(mImpl->mRenderer)
238   {
239     mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
240   }
241 }
242
243 void NPatchVisual::DoCreatePropertyMap(Property::Map& map) const
244 {
245   map.Clear();
246   bool sync = IsSynchronousLoadingRequired();
247   map.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, sync);
248   map.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::N_PATCH);
249   map.Insert(Toolkit::ImageVisual::Property::URL, mImageUrl.GetUrl());
250   map.Insert(Toolkit::ImageVisual::Property::BORDER_ONLY, mBorderOnly);
251   map.Insert(Toolkit::ImageVisual::Property::BORDER, mBorder);
252   map.Insert(Toolkit::ImageVisual::Property::RELEASE_POLICY, mReleasePolicy);
253
254   if(mAuxiliaryUrl.IsValid())
255   {
256     map.Insert(Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE, mAuxiliaryUrl.GetUrl());
257     map.Insert(Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA, mAuxiliaryImageAlpha);
258   }
259 }
260
261 void NPatchVisual::DoCreateInstancePropertyMap(Property::Map& map) const
262 {
263   if(mAuxiliaryUrl.IsValid())
264   {
265     map.Insert(Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE, mAuxiliaryUrl.GetUrl());
266     map.Insert(Toolkit::DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA, mAuxiliaryImageAlpha);
267   }
268 }
269
270 NPatchVisual::NPatchVisual(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory)
271 : Visual::Base(factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::N_PATCH),
272   mPlacementActor(),
273   mLoader(factoryCache.GetNPatchLoader()),
274   mImageVisualShaderFactory(shaderFactory),
275   mImageUrl(),
276   mAuxiliaryUrl(),
277   mId(NPatchData::INVALID_NPATCH_DATA_ID),
278   mBorderOnly(false),
279   mBorder(),
280   mAuxiliaryImageAlpha(0.0f),
281   mReleasePolicy(Toolkit::ImageVisual::ReleasePolicy::DETACHED)
282 {
283   EnablePreMultipliedAlpha(mFactoryCache.GetPreMultiplyOnLoad());
284 }
285
286 NPatchVisual::~NPatchVisual()
287 {
288   if(Stage::IsInstalled() && (mId != NPatchData::INVALID_NPATCH_DATA_ID) && (mReleasePolicy != Toolkit::ImageVisual::ReleasePolicy::NEVER))
289   {
290     mLoader.Remove(mId, this);
291     mId = NPatchData::INVALID_NPATCH_DATA_ID;
292   }
293 }
294
295 void NPatchVisual::OnInitialize()
296 {
297   // Get basic geometry and shader
298   Geometry geometry = mFactoryCache.GetGeometry(VisualFactoryCache::QUAD_GEOMETRY);
299   Shader   shader   = mImageVisualShaderFactory.GetShader(
300     mFactoryCache,
301     ImageVisualShaderFeature::FeatureBuilder());
302
303   mImpl->mRenderer = VisualRenderer::New(geometry, shader);
304   mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT);
305
306   //Register transform properties
307   mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
308 }
309
310 Geometry NPatchVisual::CreateGeometry()
311 {
312   Geometry          geometry;
313   const NPatchData* data;
314   if(mLoader.GetNPatchData(mId, data) && data->GetLoadingState() == NPatchData::LoadingState::LOAD_COMPLETE)
315   {
316     if(data->GetStretchPixelsX().Size() == 1 && data->GetStretchPixelsY().Size() == 1)
317     {
318       if(DALI_UNLIKELY(mBorderOnly))
319       {
320         geometry = GetNinePatchGeometry(VisualFactoryCache::NINE_PATCH_BORDER_GEOMETRY);
321       }
322       else
323       {
324         if(data->GetRenderingMap())
325         {
326           uint32_t elementCount[2];
327           geometry = RenderingAddOn::Get().CreateGeometryGrid(data->GetRenderingMap(), Uint16Pair(3, 3), elementCount);
328           if(mImpl->mRenderer)
329           {
330             RenderingAddOn::Get().SubmitRenderTask(mImpl->mRenderer, data->GetRenderingMap());
331           }
332         }
333         else
334         {
335           geometry = GetNinePatchGeometry(VisualFactoryCache::NINE_PATCH_GEOMETRY);
336         }
337       }
338     }
339     else if(data->GetStretchPixelsX().Size() > 0 || data->GetStretchPixelsY().Size() > 0)
340     {
341       Uint16Pair gridSize(2 * data->GetStretchPixelsX().Size() + 1, 2 * data->GetStretchPixelsY().Size() + 1);
342       if(!data->GetRenderingMap())
343       {
344         geometry = !mBorderOnly ? NPatchHelper::CreateGridGeometry(gridSize) : NPatchHelper::CreateBorderGeometry(gridSize);
345       }
346       else
347       {
348         uint32_t elementCount[2];
349         geometry = !mBorderOnly ? RenderingAddOn::Get().CreateGeometryGrid(data->GetRenderingMap(), gridSize, elementCount) : NPatchHelper::CreateBorderGeometry(gridSize);
350         if(mImpl->mRenderer)
351         {
352           RenderingAddOn::Get().SubmitRenderTask(mImpl->mRenderer, data->GetRenderingMap());
353         }
354       }
355     }
356   }
357   else
358   {
359     // no N patch data so use default geometry
360     geometry = GetNinePatchGeometry(VisualFactoryCache::NINE_PATCH_GEOMETRY);
361   }
362   return geometry;
363 }
364
365 Shader NPatchVisual::CreateShader()
366 {
367   Shader            shader;
368   const NPatchData* data;
369   // 0 is either no data (load failed?) or no stretch regions on image
370   // for both cases we use the default shader
371   NPatchUtility::StretchRanges::SizeType xStretchCount = 0;
372   NPatchUtility::StretchRanges::SizeType yStretchCount = 0;
373
374   auto fragmentShader = mAuxiliaryPixelBuffer ? SHADER_NPATCH_VISUAL_MASK_SHADER_FRAG
375                                               : SHADER_NPATCH_VISUAL_SHADER_FRAG;
376   auto shaderType = mAuxiliaryPixelBuffer ? VisualFactoryCache::NINE_PATCH_MASK_SHADER
377                                           : VisualFactoryCache::NINE_PATCH_SHADER;
378
379   // ask loader for the regions
380   if(mLoader.GetNPatchData(mId, data))
381   {
382     xStretchCount = data->GetStretchPixelsX().Count();
383     yStretchCount = data->GetStretchPixelsY().Count();
384   }
385
386   if(DALI_LIKELY(!mImpl->mCustomShader))
387   {
388     if(DALI_LIKELY((xStretchCount == 1 && yStretchCount == 1) ||
389                    (xStretchCount == 0 && yStretchCount == 0)))
390     {
391       shader = mFactoryCache.GetShader(shaderType);
392       if(DALI_UNLIKELY(!shader))
393       {
394         shader = Shader::New(SHADER_NPATCH_VISUAL_3X3_SHADER_VERT, fragmentShader);
395         // Only cache vanilla 9 patch shaders
396         mFactoryCache.SaveShader(shaderType, shader);
397       }
398     }
399     else if(xStretchCount > 0 || yStretchCount > 0)
400     {
401       std::stringstream vertexShader;
402       vertexShader << "#define FACTOR_SIZE_X " << xStretchCount + 2 << "\n"
403                    << "#define FACTOR_SIZE_Y " << yStretchCount + 2 << "\n"
404                    << SHADER_NPATCH_VISUAL_SHADER_VERT;
405
406       shader = Shader::New(vertexShader.str(), fragmentShader);
407     }
408   }
409   else
410   {
411     Dali::Shader::Hint::Value hints = Dali::Shader::Hint::NONE;
412
413     if(!mImpl->mCustomShader->mFragmentShader.empty())
414     {
415       fragmentShader = mImpl->mCustomShader->mFragmentShader.c_str();
416     }
417     hints = mImpl->mCustomShader->mHints;
418
419     /* Apply Custom Vertex Shader only if image is 9-patch */
420     if((xStretchCount == 1 && yStretchCount == 1) ||
421        (xStretchCount == 0 && yStretchCount == 0))
422     {
423       const char* vertexShader = SHADER_NPATCH_VISUAL_3X3_SHADER_VERT.data();
424
425       if(!mImpl->mCustomShader->mVertexShader.empty())
426       {
427         vertexShader = mImpl->mCustomShader->mVertexShader.c_str();
428       }
429       shader = Shader::New(vertexShader, fragmentShader, hints);
430     }
431     else if(xStretchCount > 0 || yStretchCount > 0)
432     {
433       std::stringstream vertexShader;
434       vertexShader << "#define FACTOR_SIZE_X " << xStretchCount + 2 << "\n"
435                    << "#define FACTOR_SIZE_Y " << yStretchCount + 2 << "\n"
436                    << SHADER_NPATCH_VISUAL_SHADER_VERT;
437
438       shader = Shader::New(vertexShader.str(), fragmentShader, hints);
439     }
440   }
441
442   return shader;
443 }
444
445 void NPatchVisual::ApplyTextureAndUniforms()
446 {
447   const NPatchData* data;
448   TextureSet        textureSet;
449
450   if(mLoader.GetNPatchData(mId, data) && data->GetLoadingState() == NPatchData::LoadingState::LOAD_COMPLETE)
451   {
452     textureSet = data->GetTextures();
453     NPatchHelper::ApplyTextureAndUniforms(mImpl->mRenderer, data);
454   }
455   else
456   {
457     DALI_LOG_ERROR("The N patch image '%s' is not a valid N patch image\n", mImageUrl.GetUrl().c_str());
458     textureSet = TextureSet::New();
459
460     Actor   actor     = mPlacementActor.GetHandle();
461     Vector2 imageSize = Vector2::ZERO;
462     if(actor)
463     {
464       imageSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector2>();
465     }
466     mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize);
467   }
468
469   if(mAuxiliaryPixelBuffer)
470   {
471     // If the auxiliary image is smaller than the un-stretched NPatch, use CPU resizing to enlarge it to the
472     // same size as the unstretched NPatch. This will give slightly higher quality results than just relying
473     // on GL interpolation alone.
474     if(mAuxiliaryPixelBuffer.GetWidth() < data->GetCroppedWidth() &&
475        mAuxiliaryPixelBuffer.GetHeight() < data->GetCroppedHeight())
476     {
477       mAuxiliaryPixelBuffer.Resize(data->GetCroppedWidth(), data->GetCroppedHeight());
478     }
479
480     // Note, this resets mAuxiliaryPixelBuffer handle
481     auto auxiliaryPixelData = Devel::PixelBuffer::Convert(mAuxiliaryPixelBuffer);
482
483     auto texture = Texture::New(TextureType::TEXTURE_2D,
484                                 auxiliaryPixelData.GetPixelFormat(),
485                                 auxiliaryPixelData.GetWidth(),
486                                 auxiliaryPixelData.GetHeight());
487     texture.Upload(auxiliaryPixelData);
488     textureSet.SetTexture(1, texture);
489     mImpl->mRenderer.RegisterProperty(DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA,
490                                       AUXILIARY_IMAGE_ALPHA_NAME,
491                                       mAuxiliaryImageAlpha);
492   }
493   mImpl->mRenderer.SetTextures(textureSet);
494
495   // Register transform properties
496   mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
497 }
498
499 Geometry NPatchVisual::GetNinePatchGeometry(VisualFactoryCache::GeometryType subType)
500 {
501   Geometry geometry = mFactoryCache.GetGeometry(subType);
502   if(!geometry)
503   {
504     if(DALI_LIKELY(VisualFactoryCache::NINE_PATCH_GEOMETRY == subType))
505     {
506       geometry = NPatchHelper::CreateGridGeometry(Uint16Pair(3, 3));
507     }
508     else if(VisualFactoryCache::NINE_PATCH_BORDER_GEOMETRY == subType)
509     {
510       geometry = NPatchHelper::CreateBorderGeometry(Uint16Pair(3, 3));
511     }
512     mFactoryCache.SaveGeometry(subType, geometry);
513   }
514   return geometry;
515 }
516
517 void NPatchVisual::SetResource()
518 {
519   const NPatchData* data;
520   if(mImpl->mRenderer && mLoader.GetNPatchData(mId, data))
521   {
522     Geometry geometry = CreateGeometry();
523     Shader   shader   = CreateShader();
524
525     mImpl->mRenderer.SetGeometry(geometry);
526     mImpl->mRenderer.SetShader(shader);
527
528     Actor actor = mPlacementActor.GetHandle();
529     if(actor)
530     {
531       ApplyTextureAndUniforms();
532       actor.AddRenderer(mImpl->mRenderer);
533       mPlacementActor.Reset();
534
535       // npatch loaded and ready to display
536       ResourceReady(Toolkit::Visual::ResourceStatus::READY);
537     }
538   }
539 }
540
541 void NPatchVisual::LoadComplete(bool loadSuccess, TextureInformation textureInformation)
542 {
543   if(textureInformation.returnType == TextureUploadObserver::ReturnType::TEXTURE)
544   {
545     EnablePreMultipliedAlpha(textureInformation.preMultiplied);
546     if(!loadSuccess)
547     {
548       // Image loaded and ready to display
549       ResourceReady(Toolkit::Visual::ResourceStatus::FAILED);
550     }
551
552     if(mAuxiliaryPixelBuffer || !mAuxiliaryUrl.IsValid())
553     {
554       SetResource();
555     }
556   }
557   else // for the ReturnType::PIXEL_BUFFER
558   {
559     if(loadSuccess && textureInformation.url == mAuxiliaryUrl.GetUrl())
560     {
561       mAuxiliaryPixelBuffer = textureInformation.pixelBuffer;
562       SetResource();
563     }
564     else
565     {
566       // Image loaded and ready to display
567       ResourceReady(Toolkit::Visual::ResourceStatus::FAILED);
568     }
569   }
570 }
571
572 } // namespace Internal
573
574 } // namespace Toolkit
575
576 } // namespace Dali