add property for disable broken image.
it is for placeholder image visual
Change-Id: I3c2609aed11a5e880207b616243c2b110815d71b
END_TEST;
}
+int UtcDaliImageVisualSetInvalidImageWithDisabledBroken(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("Request image visual with invalid images - should draw broken.png");
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK(factory);
+
+ // Load invalid file
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, "InvalidImage.png");
+
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
+
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+
+ application.GetScene().Add(actor);
+
+ application.SendNotification();
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+
+ application.GetScene().Remove(actor);
+ DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
+ textureTrace.Reset();
+
+ // Load invalid file with disabled broken
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, "InvalidImage.png");
+ propertyMap.Insert(Toolkit::DevelImageVisual::Property::ENABLE_BROKEN_IMAGE, false);
+
+ visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ actor = DummyControl::New();
+ DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl2.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
+
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+
+ application.GetScene().Add(actor);
+
+ application.SendNotification();
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), false, TEST_LOCATION);
+
+ application.GetScene().Remove(actor);
+ DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
+
+ END_TEST;
+}
+
int UtcDaliImageVisualAlphaMask01(void)
{
ToolkitTestApplication application;
* So we change its value to MASKING_ON_RENDERING even if the visual sets the MASKING_TYPE as MASKING_ON_LOADING when it uses external texture.
* @note It is used in the ImageVisual and AnimatedImageVisual. The default is MASKING_ON_LOADING.
*/
- MASKING_TYPE = ORIENTATION_CORRECTION + 12
+ MASKING_TYPE = ORIENTATION_CORRECTION + 12,
+
+ /**
+ * @brief Whether to enable broken image in image visual.
+ * Some of visual don't need to show broken image(ex. placeholder)
+ * Disable broken image for these visuals.
+ * default is true.
+ */
+ ENABLE_BROKEN_IMAGE = ORIENTATION_CORRECTION + 14
};
} //namespace Property
propertyMap.Insert(Toolkit::ImageVisual::Property::URL, mPlaceholderUrl);
//propertyMap.Insert(Toolkit::ImageVisual::Property::LOAD_POLICY, Toolkit::ImageVisual::LoadPolicy::IMMEDIATE); // TODO: need to enable this property
propertyMap.Insert(Toolkit::ImageVisual::Property::RELEASE_POLICY, Toolkit::ImageVisual::ReleasePolicy::DESTROYED);
+ propertyMap.Insert(Toolkit::DevelImageVisual::Property::ENABLE_BROKEN_IMAGE, false);
mPlaceholderVisual = Toolkit::VisualFactory::Get().CreateVisual(propertyMap);
if(mPlaceholderVisual)
{
mAtlasRectSize(0, 0),
mLoadState(TextureManager::LoadState::NOT_STARTED),
mAttemptAtlasing(false),
- mOrientationCorrection(true)
+ mOrientationCorrection(true),
+ mEnableBrokenImage(true)
{
EnablePreMultipliedAlpha(mFactoryCache.GetPreMultiplyOnLoad());
}
{
DoSetProperty(Toolkit::DevelImageVisual::Property::MASKING_TYPE, keyValue.second);
}
+ else if(keyValue.first == ENABLE_BROKEN_IMAGE)
+ {
+ DoSetProperty(Toolkit::DevelImageVisual::Property::ENABLE_BROKEN_IMAGE, keyValue.second);
+ }
else if(keyValue.first == LOAD_POLICY_NAME)
{
DoSetProperty(Toolkit::ImageVisual::Property::LOAD_POLICY, keyValue.second);
break;
}
+ case Toolkit::DevelImageVisual::Property::ENABLE_BROKEN_IMAGE:
+ {
+ bool enableBrokenImage(mEnableBrokenImage);
+ if(value.Get(enableBrokenImage))
+ {
+ mEnableBrokenImage = enableBrokenImage;
+ }
+ break;
+ }
+
case Toolkit::ImageVisual::Property::RELEASE_POLICY:
{
int releasePolicy = 0;
}
else if(mLoadState == TextureManager::LoadState::LOAD_FAILED)
{
- Vector2 imageSize = Vector2::ZERO;
- if(actor)
- {
- imageSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector2>();
- mPlacementActorSize = imageSize;
- }
-
- mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize);
- actor.AddRenderer(mImpl->mRenderer);
- mPlacementActor.Reset();
-
+ ShowBrokenImage();
ResourceReady(Toolkit::Visual::ResourceStatus::FAILED);
}
}
actor.RemoveRenderer(mImpl->mRenderer);
if(mReleasePolicy == Toolkit::ImageVisual::ReleasePolicy::DETACHED)
{
- RemoveTexture(); // If INVALID_TEXTURE_ID then removal will be attempted on atlas
- mImpl->mResourceStatus = Toolkit::Visual::ResourceStatus::PREPARING;
-
- TextureSet textureSet = TextureSet::New();
- mImpl->mRenderer.SetTextures(textureSet);
- ComputeTextureSize();
-
- mLoadState = TextureManager::LoadState::NOT_STARTED;
+ ResetRenderer();
}
mPlacementActor.Reset();
Actor actor = mPlacementActor.GetHandle();
if(!loadingSuccess)
{
- Vector2 imageSize = Vector2::ZERO;
- if(actor)
- {
- imageSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector2>();
- mPlacementActorSize = imageSize;
- }
- else
- {
- imageSize = mPlacementActorSize;
- }
-
- mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize);
+ ShowBrokenImage();
textureInformation.textureSet = mImpl->mRenderer.GetTextures();
}
else
UpdateShader();
}
}
- }
- if(actor)
- {
- actor.AddRenderer(mImpl->mRenderer);
- // reset the weak handle so that the renderer only get added to actor once
- mPlacementActor.Reset();
+ if(actor)
+ {
+ actor.AddRenderer(mImpl->mRenderer);
+ // reset the weak handle so that the renderer only get added to actor once
+ mPlacementActor.Reset();
+ }
}
}
}
}
+void ImageVisual::ResetRenderer()
+{
+ RemoveTexture(); // If INVALID_TEXTURE_ID then removal will be attempted on atlas
+ mImpl->mResourceStatus = Toolkit::Visual::ResourceStatus::PREPARING;
+
+ TextureSet textureSet = TextureSet::New();
+ mImpl->mRenderer.SetTextures(textureSet);
+ ComputeTextureSize();
+
+ mLoadState = TextureManager::LoadState::NOT_STARTED;
+}
+
+void ImageVisual::ShowBrokenImage()
+{
+ if(mEnableBrokenImage)
+ {
+ Actor actor = mPlacementActor.GetHandle();
+
+ Vector2 imageSize = Vector2::ZERO;
+ if(actor)
+ {
+ imageSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector2>();
+ mPlacementActorSize = imageSize;
+ }
+
+ mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize);
+ if(actor)
+ {
+ actor.AddRenderer(mImpl->mRenderer);
+ mPlacementActor.Reset();
+ }
+ }
+ else
+ {
+ ResetRenderer();
+ }
+}
+
} // namespace Internal
} // namespace Toolkit
*/
void CheckMaskTexture();
+ /**
+ * @brief Reset Renderer using empty texture
+ * For drawing empty visual, reset the renderer.
+ */
+ void ResetRenderer();
+
+ /**
+ * @brief Show broken image when image loading is failed.
+ */
+ void ShowBrokenImage();
+
private:
Vector4 mPixelArea;
WeakHandle<Actor> mPlacementActor;
bool mAttemptAtlasing; ///< If true will attempt atlasing, otherwise create unique texture
bool mOrientationCorrection; ///< true if the image will have it's orientation corrected.
bool mNeedYuvToRgb{false}; ///< true if we need to convert yuv to rgb.
+ bool mEnableBrokenImage;
};
} // namespace Internal
const char* const REDRAW_IN_SCALING_DOWN_NAME("redrawInScalingDown");
const char* const MASKING_TYPE_NAME("maskingType");
const char* const MASK_TEXTURE_RATIO_NAME("maskTextureRatio");
+const char* const ENABLE_BROKEN_IMAGE("enableBrokenImage");
// Text visual
const char* const TEXT_PROPERTY("text");
extern const char* const REDRAW_IN_SCALING_DOWN_NAME;
extern const char* const MASKING_TYPE_NAME;
extern const char* const MASK_TEXTURE_RATIO_NAME;
+extern const char* const ENABLE_BROKEN_IMAGE;
// Text visual
extern const char* const TEXT_PROPERTY;