// Setup properties, signals and actions using the type-registry.
DALI_TYPE_REGISTRATION_BEGIN(Scene3D::SceneView, Toolkit::Control, Create);
+
+DALI_PROPERTY_REGISTRATION(Scene3D, SceneView, "AlphaMaskUrl", STRING, ALPHA_MASK_URL)
+DALI_PROPERTY_REGISTRATION(Scene3D, SceneView, "MaskContentScale", FLOAT, MASK_CONTENT_SCALE)
+DALI_PROPERTY_REGISTRATION(Scene3D, SceneView, "CropToMask", BOOLEAN, CROP_TO_MASK)
DALI_TYPE_REGISTRATION_END()
Property::Index RENDERING_BUFFER = Dali::Toolkit::Control::CONTROL_PROPERTY_END_INDEX + 1;
mShaderManager->UpdateShadowUniform(light);
}
+void SceneView::SetAlphaMaskUrl(std::string& alphaMaskUrl)
+{
+ if(mAlphaMaskUrl != alphaMaskUrl)
+ {
+ mAlphaMaskUrl = alphaMaskUrl;
+ mMaskingPropertyChanged = true;
+ UpdateRenderTask();
+ }
+}
+
+std::string SceneView::GetAlphaMaskUrl()
+{
+ return mAlphaMaskUrl;
+}
+
+void SceneView::SetMaskContentScaleFactor(float maskContentScaleFactor)
+{
+ if(mMaskContentScaleFactor != maskContentScaleFactor)
+ {
+ mMaskContentScaleFactor = maskContentScaleFactor;
+ mMaskingPropertyChanged = true;
+ UpdateRenderTask();
+ }
+}
+
+float SceneView::GetMaskContentScaleFactor()
+{
+ return mMaskContentScaleFactor;
+}
+
+void SceneView::EnableCropToMask(bool enableCropToMask)
+{
+ if(mCropToMask != enableCropToMask)
+ {
+ mCropToMask = enableCropToMask;
+ mMaskingPropertyChanged = true;
+ UpdateRenderTask();
+ }
+}
+
+bool SceneView::IsEnabledCropToMask()
+{
+ return mCropToMask;
+}
+
+void SceneView::SetProperty(BaseObject* object, Property::Index index, const Property::Value& value)
+{
+ Scene3D::SceneView sceneView = Scene3D::SceneView::DownCast(Dali::BaseHandle(object));
+
+ if(sceneView)
+ {
+ SceneView& sceneViewImpl(GetImpl(sceneView));
+
+ switch(index)
+ {
+ case Scene3D::SceneView::Property::ALPHA_MASK_URL:
+ {
+ std::string alphaMaskUrl = value.Get<std::string>();
+ sceneViewImpl.SetAlphaMaskUrl(alphaMaskUrl);
+ break;
+ }
+ case Scene3D::SceneView::Property::MASK_CONTENT_SCALE:
+ {
+ sceneViewImpl.SetMaskContentScaleFactor(value.Get<float>());
+ break;
+ }
+ case Scene3D::SceneView::Property::CROP_TO_MASK:
+ {
+ sceneViewImpl.EnableCropToMask(value.Get<bool>());
+ break;
+ }
+ }
+ }
+}
+
+Property::Value SceneView::GetProperty(BaseObject* object, Property::Index index)
+{
+ Property::Value value;
+
+ Scene3D::SceneView sceneView = Scene3D::SceneView::DownCast(Dali::BaseHandle(object));
+
+ if(sceneView)
+ {
+ SceneView& sceneViewImpl(GetImpl(sceneView));
+
+ switch(index)
+ {
+ case Scene3D::SceneView::Property::ALPHA_MASK_URL:
+ {
+ value = sceneViewImpl.GetAlphaMaskUrl();
+ break;
+ }
+ case Scene3D::SceneView::Property::MASK_CONTENT_SCALE:
+ {
+ value = sceneViewImpl.GetMaskContentScaleFactor();
+ break;
+ }
+ case Scene3D::SceneView::Property::CROP_TO_MASK:
+ {
+ value = sceneViewImpl.IsEnabledCropToMask();
+ break;
+ }
+ }
+ }
+ return value;
+}
+
///////////////////////////////////////////////////////////
//
// Private methods
Dali::FrameBuffer currentFrameBuffer = mRenderTask.GetFrameBuffer();
if(!currentFrameBuffer ||
!Dali::Equals(currentFrameBuffer.GetColorTexture().GetWidth(), size.width) ||
- !Dali::Equals(currentFrameBuffer.GetColorTexture().GetHeight(), size.height))
+ !Dali::Equals(currentFrameBuffer.GetColorTexture().GetHeight(), size.height) ||
+ mMaskingPropertyChanged)
{
mRootLayer.SetProperty(Dali::Actor::Property::COLOR_MODE, ColorMode::USE_OWN_COLOR);
mRenderTask.ResetViewportGuideActor();
imagePropertyMap.Insert(Toolkit::ImageVisual::Property::URL, imageUrl.GetUrl());
// To flip rendered scene without CameraActor::SetInvertYAxis() to avoid backface culling.
imagePropertyMap.Insert(Toolkit::ImageVisual::Property::PIXEL_AREA, Vector4(0.0f, 1.0f, 1.0f, -1.0f));
+ imagePropertyMap.Insert(Toolkit::ImageVisual::Property::ALPHA_MASK_URL, mAlphaMaskUrl);
+ if(!mAlphaMaskUrl.empty())
+ {
+ imagePropertyMap.Insert(Toolkit::ImageVisual::Property::MASK_CONTENT_SCALE, mMaskContentScaleFactor);
+ imagePropertyMap.Insert(Toolkit::ImageVisual::Property::CROP_TO_MASK, mCropToMask);
+ imagePropertyMap.Insert(Toolkit::DevelImageVisual::Property::MASKING_TYPE, Toolkit::DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
+ }
+ mMaskingPropertyChanged = false;
mVisual = Toolkit::VisualFactory::Get().CreateVisual(imagePropertyMap);
Toolkit::DevelControl::RegisterVisual(*this, RENDERING_BUFFER, mVisual);
Dali::Scene3D::Loader::ShaderManagerPtr GetShaderManager() const;
/**
- * @brief Update shader uniforms about shadow.
+ * @brief Updates shader uniforms about shadow.
* @param[in] light Light that makes shadow.
*/
void UpdateShadowUniform(Scene3D::Light light);
+ /**
+ * @brief Sets alpha mask url
+ * @param[in] alphaMaskUrl Url for alpha mask.
+ */
+ void SetAlphaMaskUrl(std::string& alphaMaskUrl);
+
+ /**
+ * @brief Retrieves alpha mask url
+ * @return Alpha mask url.
+ */
+ std::string GetAlphaMaskUrl();
+
+ /**
+ * @brief Sets mask content scale factor
+ * @param[in] maskContentScaleFactor Scale factor for mask content.
+ */
+ void SetMaskContentScaleFactor(float maskContentScaleFactor);
+
+ /**
+ * @brief Retrieves mask content scale factor
+ * @return Scale factor for mask content.
+ */
+ float GetMaskContentScaleFactor();
+
+ /**
+ * @brief Sets whether the rendered result will be crop to mask or not.
+ * @param[in] enableCropToMask True for crop rendered result to mask.
+ */
+ void EnableCropToMask(bool enableCropToMask);
+
+ /**
+ * @brief Retrieves whether the crop to mask is enabled or not.
+ * @return True when rendered result is cropped to mask.
+ */
+ bool IsEnabledCropToMask();
+
+ // Properties
+
+ /**
+ * Called when a property of an object of this type is set.
+ * @param[in] object The object whose property is set.
+ * @param[in] index The property index.
+ * @param[in] value The new property value.
+ */
+ static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value);
+
+ /**
+ * Called to retrieve a property of an object of this type.
+ * @param[in] object The object whose property is to be retrieved.
+ * @param[in] index The property index.
+ * @return The current value of the property.
+ */
+ static Property::Value GetProperty(BaseObject* object, Property::Index index);
+
protected:
/**
* @brief Constructs a new SceneView.
float mSkyboxIntensity{1.0f};
uint8_t mFrameBufferMultiSamplingLevel{4u};
+ // Masking
+ std::string mAlphaMaskUrl;
+ float mMaskContentScaleFactor{1.0f};
+ bool mCropToMask{true};
+ bool mMaskingPropertyChanged{false};
+
// Shader Factory
Dali::Scene3D::Loader::ShaderManagerPtr mShaderManager;
{
public:
/**
+ * @brief The start and end property ranges for this control.
+ * @SINCE_1_1.4
+ */
+ enum PropertyRange
+ {
+ PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
+ PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000
+ };
+
+ struct Property
+ {
+ enum
+ {
+ /**
+ * @brief URL of a masking image
+ * @details Name "alphaMaskUrl", type Property::STRING, URL of image to apply as
+ * a mask after SceneView is drawn.
+ * @note Alpha masking is only available when framebuffer is used.
+ * @note Optional.
+ */
+ ALPHA_MASK_URL = PROPERTY_START_INDEX,
+
+ /**
+ * @brief The scale factor to apply to the content image before masking
+ * @details Name "maskContentScale", type Property::FLOAT, The scale factor
+ * to apply to the content before masking. Note, scaled result is cropped to
+ * the same size as the alpha mask.
+ * @note Optional.
+ */
+ MASK_CONTENT_SCALE,
+
+ /**
+ * @brief Whether to crop rendered result to mask or scale mask to fit result
+ * @details Name "cropToMask", type Property::BOOLEAN, True if the rendered result should
+ * be cropped to match the mask size, or false if the result should remain the same size.
+ * @note Optional, Default true
+ * @note If this is false, then the mask is scaled to fit the rendered result before being applied.
+ */
+ CROP_TO_MASK,
+ };
+ };
+
+public:
+ /**
* @brief Create an initialized SceneView.
*
* @SINCE_2_1.38