Merge "Shader compilation tool for dali-toolkit" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / super-blur-view / super-blur-view-impl.cpp
index 1b55ce8..4cd42a4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -21,7 +21,7 @@
 // EXTERNAL INCLUDES
 #include <cmath>
 #include <dali/public-api/animation/constraint.h>
-#include <dali/public-api/common/stage.h>
+#include <dali/devel-api/common/stage.h>
 #include <dali/public-api/object/property-map.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/type-registry-helper.h>
 // INTERNAL_INCLUDES
 #include <dali-toolkit/public-api/image-loader/sync-image-loader.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 #include <dali-toolkit/internal/controls/control/control-renderers.h>
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
 #include <dali-toolkit/internal/visuals/visual-factory-impl.h>
+#include <dali-toolkit/internal/controls/control/control-data-impl.h>
 
 namespace //Unnamed namespace
 {
@@ -51,18 +53,6 @@ const float GAUSSIAN_BLUR_DOWNSAMPLE_WIDTH_SCALE = 0.5f;
 const float GAUSSIAN_BLUR_DOWNSAMPLE_HEIGHT_SCALE = 0.5f;
 
 const char* ALPHA_UNIFORM_NAME( "uAlpha" );
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
-  varying mediump vec2 vTexCoord;\n
-  uniform sampler2D sTexture;\n
-  uniform lowp vec4 uColor;\n
-  uniform lowp float uAlpha;\n
-  \n
-  void main()\n
-  {\n
-    gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
-    gl_FragColor.a *= uAlpha;
-  }\n
-);
 
 /**
  * The constraint is used to blend the group of blurred images continuously with a unified blur strength property value which ranges from zero to one.
@@ -163,6 +153,11 @@ void SuperBlurView::OnInitialize()
   Actor self( Self() );
 
   mBlurStrengthPropertyIndex = self.RegisterProperty( "blurStrength", 0.f );
+
+  DevelControl::SetAccessibilityConstructor( self, []( Dali::Actor actor ) {
+    return std::unique_ptr< Dali::Accessibility::Accessible >(
+      new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::FILLER ) );
+  } );
 }
 
 void SuperBlurView::SetTexture( Texture texture )
@@ -294,21 +289,21 @@ void SuperBlurView::OnSizeSet( const Vector3& targetSize )
   Control::OnSizeSet( targetSize );
 }
 
-void SuperBlurView::OnStageConnection( int depth )
+void SuperBlurView::OnSceneConnection( int depth )
 {
   if( mTargetSize == Vector2::ZERO )
   {
     return;
   }
 
-  // Exception to the rule, chaining up first ensures visuals have SetOnStage called to create their renderers
-  Control::OnStageConnection( depth );
+  // Exception to the rule, chaining up first ensures visuals have SetOnScene called to create their renderers
+  Control::OnSceneConnection( depth );
 
   Actor self = Self();
 
   for(unsigned int i=0; i<mBlurLevels+1;i++)
   {
-    mRenderers[i] = CreateRenderer( BASIC_VERTEX_SOURCE, FRAGMENT_SHADER );
+    mRenderers[i] = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_SUPER_BLUR_VIEW_FRAG );
     mRenderers[i].SetProperty( Dali::Renderer::Property::DEPTH_INDEX, (int)i );
     self.AddRenderer( mRenderers[i] );
 
@@ -334,7 +329,7 @@ void SuperBlurView::OnStageConnection( int depth )
   }
 }
 
-void SuperBlurView::OnStageDisconnection()
+void SuperBlurView::OnSceneDisconnection()
 {
   for(unsigned int i=0; i<mBlurLevels+1;i++)
   {
@@ -342,7 +337,7 @@ void SuperBlurView::OnStageDisconnection()
     mRenderers[i].Reset();
   }
 
-  Control::OnStageDisconnection();
+  Control::OnSceneDisconnection();
 }
 
 Vector3 SuperBlurView::GetNaturalSize()