From: Heeyong Song Date: Tue, 25 May 2021 11:32:27 +0000 (+0900) Subject: Remove DevelColorVisual::Property::RENDER_IF_TRANSPARENT X-Git-Tag: dali_2.0.28~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3c6245ad032678461d6df519db63240016f43ed7;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git Remove DevelColorVisual::Property::RENDER_IF_TRANSPARENT Change-Id: I985ae68c61246dec81360e94c827f236d9e27a4e --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp index 396bab4..221bac0 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -525,22 +525,9 @@ int UtcDaliControlBackgroundColorRendererCount(void) ToolkitTestApplication application; Control control = Control::New(); + control[Actor::Property::SIZE] = Vector2(100.0f, 100.0f); application.GetScene().Add( control ); - tet_infoline( "Set transparent, no renderers should be created" ); - control.SetBackgroundColor( Color::TRANSPARENT ); - application.SendNotification(); - application.Render(); - DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION ); - - tet_infoline( "Set transparent alpha with positive RGB values, no renderers should be created, but returned color should reflect what we set" ); - const Vector4 alphaZero( 1.0f, 0.5f, 0.25f, 0.0f ); - control.SetBackgroundColor( alphaZero ); - application.SendNotification(); - application.Render(); - DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION ); - DALI_TEST_EQUALS( GetControlBackgroundColor( control ), alphaZero, TEST_LOCATION ); - tet_infoline( "Set semi transparent alpha with positive RGB values, 1 renderer should be created, but returned color should reflect what we set" ); const Vector4 semiTransparent( 1.0f, 0.75f, 0.5f, 0.5f ); control.SetBackgroundColor( semiTransparent ); @@ -561,19 +548,29 @@ int UtcDaliControlBackgroundColorRendererCount(void) DALI_TEST_EQUALS( GetControlBackgroundColor( control ), newColor, TEST_LOCATION ); DALI_TEST_EQUALS( renderer, control.GetRendererAt( 0 ), TEST_LOCATION ); - tet_infoline( "Set transparent, ensure no renderers are created" ); + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& drawTrace = gl.GetDrawTrace(); + drawTrace.Enable(true); + + tet_infoline( "Set transparent, 1 renderer should be created, but ensure nothing is drawn" ); control.SetBackgroundColor( Color::TRANSPARENT ); application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION ); + + DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION ); DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION ); + DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION); + + drawTrace.Reset(); tet_infoline( "Set control to clip its children, a renderer should be created which will be transparent" ); control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN ); application.SendNotification(); application.Render(); + DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION ); DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION ); + DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); tet_infoline( "Set a color, only 1 renderer should exist" ); control.SetBackgroundColor( Color::RED ); @@ -595,12 +592,15 @@ int UtcDaliControlBackgroundColorRendererCount(void) DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION ); DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION ); - tet_infoline( "Disable clipping, no renderers" ); + drawTrace.Reset(); + + tet_infoline( "Disable clipping, render nothing" ); control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED ); application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION ); + DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION); END_TEST; } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index 127a611..a0f5334 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -3559,56 +3559,6 @@ int UtcDaliRegisterVisualWithDepthIndex(void) END_TEST; } -int UtcDaliColorVisualRenderIfTransparentProperty(void) -{ - ToolkitTestApplication application; - tet_infoline( "Test the renderIfTransparent property of ColorVisual" ); - - VisualFactory factory = VisualFactory::Get(); - Property::Map propertyMap; - propertyMap.Insert( Visual::Property::TYPE, Visual::COLOR ); - propertyMap.Insert( ColorVisual::Property::MIX_COLOR, Color::BLUE ); - - tet_infoline( "Check default value" ); - { - Visual::Base testVisual = factory.CreateVisual( propertyMap ); - Property::Map returnedMap; - testVisual.CreatePropertyMap( returnedMap ); - - Property::Value* renderIfTransparentProperty = returnedMap.Find( DevelColorVisual::Property::RENDER_IF_TRANSPARENT ); - DALI_TEST_CHECK( renderIfTransparentProperty ); - DALI_TEST_EQUALS( renderIfTransparentProperty->Get< bool >(), false, TEST_LOCATION ); - } - - propertyMap.Insert( DevelColorVisual::Property::RENDER_IF_TRANSPARENT, true ); - - tet_infoline( "Ensure set to value required" ); - { - Visual::Base testVisual = factory.CreateVisual( propertyMap ); - Property::Map returnedMap; - testVisual.CreatePropertyMap( returnedMap ); - - Property::Value* renderIfTransparentProperty = returnedMap.Find( DevelColorVisual::Property::RENDER_IF_TRANSPARENT ); - DALI_TEST_CHECK( renderIfTransparentProperty ); - DALI_TEST_EQUALS( renderIfTransparentProperty->Get< bool >(), true, TEST_LOCATION ); - } - - propertyMap[ DevelColorVisual::Property::RENDER_IF_TRANSPARENT ] = Color::BLUE; - - tet_infoline( "Ensure it returns default value if set to wrong type" ); - { - Visual::Base testVisual = factory.CreateVisual( propertyMap ); - Property::Map returnedMap; - testVisual.CreatePropertyMap( returnedMap ); - - Property::Value* renderIfTransparentProperty = returnedMap.Find( DevelColorVisual::Property::RENDER_IF_TRANSPARENT ); - DALI_TEST_CHECK( renderIfTransparentProperty ); - DALI_TEST_EQUALS( renderIfTransparentProperty->Get< bool >(), false, TEST_LOCATION ); - } - - END_TEST; -} - int UtcDaliSvgVisualCustomShader(void) { ToolkitTestApplication application; @@ -4234,11 +4184,6 @@ int UtcDaliVisualGetVisualProperty01(void) DALI_TEST_CHECK(!property1.object); DALI_TEST_CHECK(property1.propertyIndex == Property::INVALID_INDEX); - // Test not-supported property - Property property2 = DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, DevelColorVisual::Property::RENDER_IF_TRANSPARENT); - DALI_TEST_CHECK(!property2.object); - DALI_TEST_CHECK(property2.propertyIndex == Property::INVALID_INDEX); - // Test unregistered visual Property property3 = DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL2, Visual::Property::MIX_COLOR); DALI_TEST_CHECK(!property3.object); diff --git a/dali-toolkit/devel-api/visuals/color-visual-properties-devel.h b/dali-toolkit/devel-api/visuals/color-visual-properties-devel.h index 448bf88..bae7111 100644 --- a/dali-toolkit/devel-api/visuals/color-visual-properties-devel.h +++ b/dali-toolkit/devel-api/visuals/color-visual-properties-devel.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_COLOR_VISUAL_PROPERTIES_DEVEL_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,14 +40,6 @@ enum MIX_COLOR = Toolkit::ColorVisual::Property::MIX_COLOR, /** - * @brief Whether to render if the MIX_COLOR is transparent. - * @details Name "renderIfTransparent", type Property::BOOLEAN. - * @note Optional. - * @note By default it's false, i.e. ColorVisual will not render if the MIX_COLOR is transparent. - */ - RENDER_IF_TRANSPARENT = MIX_COLOR + 1, - - /** * @brief The blur radius of the visual. * @details Name "blurRadius", type Property::FLOAT, animatable. * If the value is 0, the edge is sharp. Otherwise, the larger the value, the more the edge is blurred. diff --git a/dali-toolkit/internal/visuals/color/color-visual.cpp b/dali-toolkit/internal/visuals/color/color-visual.cpp index 9ce3a29..cf6abd3 100644 --- a/dali-toolkit/internal/visuals/color/color-visual.cpp +++ b/dali-toolkit/internal/visuals/color/color-visual.cpp @@ -51,7 +51,6 @@ ColorVisual::ColorVisual(VisualFactoryCache& factoryCache) : Visual::Base(factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::COLOR), mBlurRadius(0.0f), mBlurRadiusIndex(Property::INVALID_INDEX), - mRenderIfTransparent(false), mNeedBlurRadius(false) { } @@ -87,15 +86,6 @@ void ColorVisual::DoSetProperties(const Property::Map& propertyMap) } } - Property::Value* renderIfTransparentValue = propertyMap.Find(Toolkit::DevelColorVisual::Property::RENDER_IF_TRANSPARENT, RENDER_IF_TRANSPARENT_NAME); - if(renderIfTransparentValue) - { - if(!renderIfTransparentValue->Get(mRenderIfTransparent)) - { - DALI_LOG_ERROR("ColorVisual: renderIfTransparent property has incorrect type: %d\n", renderIfTransparentValue->GetType()); - } - } - Property::Value* blurRadiusValue = propertyMap.Find(Toolkit::DevelColorVisual::Property::BLUR_RADIUS, BLUR_RADIUS_NAME); if(blurRadiusValue) { @@ -108,12 +98,7 @@ void ColorVisual::DoSetProperties(const Property::Map& propertyMap) void ColorVisual::DoSetOnScene(Actor& actor) { - // Only add the renderer if it's not fully transparent - // We cannot avoid creating a renderer as it's used in the base class - if(mRenderIfTransparent || mImpl->mMixColor.a > 0.0f) - { - actor.AddRenderer(mImpl->mRenderer); - } + actor.AddRenderer(mImpl->mRenderer); // Color Visual generated and ready to display ResourceReady(Toolkit::Visual::ResourceStatus::READY); @@ -129,7 +114,6 @@ void ColorVisual::DoCreatePropertyMap(Property::Map& map) const map.Clear(); map.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR); map.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, mImpl->mMixColor); - map.Insert(Toolkit::DevelColorVisual::Property::RENDER_IF_TRANSPARENT, mRenderIfTransparent); if(mImpl->mRenderer && mBlurRadiusIndex != Property::INVALID_INDEX) { diff --git a/dali-toolkit/internal/visuals/color/color-visual.h b/dali-toolkit/internal/visuals/color/color-visual.h index ba9a590..6fe1f43 100644 --- a/dali-toolkit/internal/visuals/color/color-visual.h +++ b/dali-toolkit/internal/visuals/color/color-visual.h @@ -133,10 +133,9 @@ private: ColorVisual& operator=(const ColorVisual& colorRenderer); private: - float mBlurRadius; ///< The blur radius - Property::Index mBlurRadiusIndex; ///< The blur radius property index - bool mRenderIfTransparent; ///< Whether we should render even if the mix-color is transparent. - bool mNeedBlurRadius; ///< Whether we need the blur radius in shader. + float mBlurRadius; ///< The blur radius + Property::Index mBlurRadiusIndex; ///< The blur radius property index + bool mNeedBlurRadius; ///< Whether we need the blur radius in shader. }; } // namespace Internal diff --git a/dali-toolkit/internal/visuals/visual-string-constants.cpp b/dali-toolkit/internal/visuals/visual-string-constants.cpp index 9f1ad0a..9c9ca4b 100644 --- a/dali-toolkit/internal/visuals/visual-string-constants.cpp +++ b/dali-toolkit/internal/visuals/visual-string-constants.cpp @@ -80,7 +80,6 @@ const char* const CORNER_RADIUS("cornerRadius"); const char* const CORNER_RADIUS_POLICY("cornerRadiusPolicy"); // Color visual -const char* const RENDER_IF_TRANSPARENT_NAME("renderIfTransparent"); const char* const BLUR_RADIUS_NAME("blurRadius"); // Image visual diff --git a/dali-toolkit/internal/visuals/visual-string-constants.h b/dali-toolkit/internal/visuals/visual-string-constants.h index 5f7f336..966e51f 100644 --- a/dali-toolkit/internal/visuals/visual-string-constants.h +++ b/dali-toolkit/internal/visuals/visual-string-constants.h @@ -64,7 +64,6 @@ extern const char* const CORNER_RADIUS; extern const char* const CORNER_RADIUS_POLICY; // Color visual -extern const char* const RENDER_IF_TRANSPARENT_NAME; extern const char* const BLUR_RADIUS_NAME; // Image visual diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 781b531..61e67eb 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -64,27 +64,6 @@ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_CON #endif /** - * @brief Replace the background visual if it's a color visual with the renderIfTransparent property set as required. - * @param[in] controlImpl The control implementation - * @param[in] renderIfTransaparent Whether we should render if the color is transparent - */ -void ChangeBackgroundColorVisual(Control& controlImpl, bool renderIfTransparent) -{ - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(controlImpl); - - Toolkit::Visual::Base backgroundVisual = controlDataImpl.GetVisual(Toolkit::Control::Property::BACKGROUND); - if(backgroundVisual && backgroundVisual.GetType() == Toolkit::Visual::COLOR) - { - Property::Map map; - backgroundVisual.CreatePropertyMap(map); - - // Only change it if it's a color visual - map[Toolkit::DevelColorVisual::Property::RENDER_IF_TRANSPARENT] = renderIfTransparent; - controlImpl.SetBackground(map); - } -} - -/** * @brief Creates a clipping renderer if required. * (EG. If no renders exist and clipping is enabled). * @param[in] controlImpl The control implementation. @@ -96,34 +75,11 @@ void CreateClippingRenderer(Control& controlImpl) int clippingMode = ClippingMode::DISABLED; if(self.GetProperty(Actor::Property::CLIPPING_MODE).Get(clippingMode)) { - switch(clippingMode) - { - case ClippingMode::CLIP_CHILDREN: - { - if(self.GetRendererCount() == 0u) - { - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(controlImpl); - if(controlDataImpl.mVisuals.Empty()) - { - controlImpl.SetBackgroundColor(Color::TRANSPARENT); - } - else - { - // We have visuals, check if we've set the background and re-create it to - // render even if transparent (only if it's a color visual) - ChangeBackgroundColorVisual(controlImpl, true); - } - } - break; - } + Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(controlImpl); - case ClippingMode::DISABLED: - case ClippingMode::CLIP_TO_BOUNDING_BOX: - { - // If we have a background visual, check if it's a color visual and remove the render if transparent flag - ChangeBackgroundColorVisual(controlImpl, false); - break; - } + if(clippingMode == ClippingMode::CLIP_CHILDREN && controlDataImpl.mVisuals.Empty() && self.GetRendererCount() == 0u) + { + controlImpl.SetBackgroundColor(Color::TRANSPARENT); } } } @@ -173,33 +129,12 @@ void Control::SetBackgroundColor(const Vector4& color) map[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::COLOR; map[Toolkit::ColorVisual::Property::MIX_COLOR] = color; - bool renderIfTransparent = false; - int clippingMode = ClippingMode::DISABLED; - if((Self().GetProperty(Actor::Property::CLIPPING_MODE).Get(clippingMode)) && - (clippingMode == ClippingMode::CLIP_CHILDREN)) - { - // If clipping-mode is set to CLIP_CHILDREN, then force visual to add the render even if transparent - map[Toolkit::DevelColorVisual::Property::RENDER_IF_TRANSPARENT] = true; - renderIfTransparent = true; - } - Toolkit::Visual::Base visual = mImpl->GetVisual(Toolkit::Control::Property::BACKGROUND); if(visual && visual.GetType() == Toolkit::Visual::COLOR) { - Property::Map visualMap; - visual.CreatePropertyMap(visualMap); - - Property::Value* renderValue = visualMap.Find(Toolkit::DevelColorVisual::Property::RENDER_IF_TRANSPARENT); - Property::Value* colorValue = visualMap.Find(Toolkit::ColorVisual::Property::MIX_COLOR); - if(renderValue && colorValue) - { - if((renderValue->Get() == true || colorValue->Get().a > 0.0f) && (renderIfTransparent || color.a > 0.0f)) - { - // Update background color only - mImpl->DoAction(Toolkit::Control::Property::BACKGROUND, DevelColorVisual::Action::UPDATE_PROPERTY, map); - return; - } - } + // Update background color only + mImpl->DoAction(Toolkit::Control::Property::BACKGROUND, DevelColorVisual::Action::UPDATE_PROPERTY, map); + return; } SetBackground(map);