Making DALi public API typesafe using guaranteed types; uint8_t, uint32_t
[platform/core/uifw/dali-core.git] / dali / public-api / render-tasks / render-task.cpp
index 36045f8..099a0ad 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/constants.h>
+#include <dali/public-api/rendering/frame-buffer.h>
 #include <dali/internal/event/actors/actor-impl.h>
 #include <dali/internal/event/actors/camera-actor-impl.h>
+#include <dali/internal/event/images/frame-buffer-image-impl.h>
 #include <dali/internal/event/render-tasks/render-task-impl.h>
 
 namespace Dali
@@ -41,12 +43,12 @@ static bool FullScreenFrameBufferFunction( Vector2& coordinates )
 RenderTask::ConstScreenToFrameBufferFunction RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION = DefaultScreenToFrameBufferFunction;
 RenderTask::ConstScreenToFrameBufferFunction RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION        = FullScreenFrameBufferFunction;
 
-const bool         RenderTask::DEFAULT_EXCLUSIVE     = false;
-const bool         RenderTask::DEFAULT_INPUT_ENABLED = true;
-const Vector4      RenderTask::DEFAULT_CLEAR_COLOR   = Vector4( 0.0f, 0.0f, 0.0f, 1.0f ); // cannot use Color::Black because it may or may not be initialized yet
-const bool         RenderTask::DEFAULT_CLEAR_ENABLED = false;
-const bool         RenderTask::DEFAULT_CULL_MODE     = true;
-const unsigned int RenderTask::DEFAULT_REFRESH_RATE  = REFRESH_ALWAYS;
+const bool     RenderTask::DEFAULT_EXCLUSIVE     = false;
+const bool     RenderTask::DEFAULT_INPUT_ENABLED = true;
+const Vector4  RenderTask::DEFAULT_CLEAR_COLOR   = Vector4( 0.0f, 0.0f, 0.0f, 1.0f ); // cannot use Color::Black because it may or may not be initialized yet
+const bool     RenderTask::DEFAULT_CLEAR_ENABLED = false;
+const bool     RenderTask::DEFAULT_CULL_MODE     = true;
+const uint32_t RenderTask::DEFAULT_REFRESH_RATE  = REFRESH_ALWAYS;
 
 RenderTask::RenderTask()
 {
@@ -116,14 +118,38 @@ CameraActor RenderTask::GetCameraActor() const
   return Dali::CameraActor(GetImplementation(*this).GetCameraActor());
 }
 
-void RenderTask::SetTargetFrameBuffer( FrameBufferImage frameBuffer )
+void RenderTask::SetTargetFrameBuffer( Dali::FrameBufferImage frameBuffer )
 {
-  GetImplementation(*this).SetTargetFrameBuffer( frameBuffer );
+  Internal::FrameBufferImage* frameBufferPtr( NULL );
+  if( frameBuffer )
+  {
+    frameBufferPtr = &GetImplementation( frameBuffer );
+  }
+
+  GetImplementation(*this).SetTargetFrameBuffer( frameBufferPtr );
 }
 
 FrameBufferImage RenderTask::GetTargetFrameBuffer() const
 {
-  return GetImplementation(*this).GetTargetFrameBuffer();
+  Internal::FrameBufferImage* frameBufferPtr = GetImplementation(*this).GetTargetFrameBuffer();
+  return Dali::FrameBufferImage( frameBufferPtr );
+}
+
+void RenderTask::SetFrameBuffer( FrameBuffer frameBuffer )
+{
+  Internal::FrameBuffer* frameBufferPtr( NULL );
+  if( frameBuffer )
+  {
+    frameBufferPtr = &GetImplementation( frameBuffer );
+  }
+
+  GetImplementation(*this).SetFrameBuffer( frameBufferPtr );
+}
+
+FrameBuffer RenderTask::GetFrameBuffer() const
+{
+  Internal::FrameBuffer* frameBufferPtr( GetImplementation(*this).GetFrameBuffer() );
+  return FrameBuffer( frameBufferPtr );
 }
 
 void RenderTask::SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction )
@@ -215,12 +241,12 @@ bool RenderTask::GetCullMode() const
   return GetImplementation(*this).GetCullMode();
 }
 
-void RenderTask::SetRefreshRate( unsigned int refreshRate )
+void RenderTask::SetRefreshRate( uint32_t refreshRate )
 {
   GetImplementation(*this).SetRefreshRate( refreshRate );
 }
 
-unsigned int RenderTask::GetRefreshRate() const
+uint32_t RenderTask::GetRefreshRate() const
 {
   return GetImplementation(*this).GetRefreshRate();
 }
@@ -240,6 +266,25 @@ bool RenderTask::GetInputEnabled() const
   return GetImplementation(*this).GetInputEnabled();
 }
 
+bool RenderTask::WorldToViewport(const Vector3 &position, float& viewportX, float& viewportY) const
+{
+  return GetImplementation(*this).WorldToViewport(position, viewportX, viewportY);
+}
+
+bool RenderTask::ViewportToLocal(Actor actor, float viewportX, float viewportY, float &localX, float &localY) const
+{
+  if( actor )
+  {
+    Internal::Actor* actorImpl( &GetImplementation( actor ) );
+    return GetImplementation(*this).ViewportToLocal( actorImpl, viewportX, viewportY, localX, localY );
+  }
+  else
+  {
+    return false;
+  }
+}
+
+
 RenderTask::RenderTask( Internal::RenderTask* internal )
 : Handle(internal)
 {