Changes to support stereoscopic 3D 55/19455/1
authorJavon Prince <javon.prince@samsung.com>
Wed, 19 Mar 2014 16:13:26 +0000 (16:13 +0000)
committerVictor Cebollada <v.cebollada@samsung.com>
Fri, 11 Apr 2014 14:44:36 +0000 (15:44 +0100)
[Issue#] (N/A)
[Problem]
[Cause]
[Solution]

Change-Id: I23d627756284ee19a2778528616919c72be923c2
Signed-off-by: Javon Prince <javon.prince@samsung.com>
adaptors/tizen/internal/application-impl.cpp
adaptors/tizen/internal/application-impl.h
adaptors/tizen/internal/command-line-options.cpp
adaptors/tizen/internal/command-line-options.h
adaptors/tizen/internal/common/adaptor-impl.cpp
adaptors/tizen/internal/common/adaptor-impl.h
adaptors/tizen/public-api/adaptor-framework/application.cpp
adaptors/tizen/public-api/adaptor-framework/application.h

index 353d086..810cbb0 100644 (file)
@@ -183,6 +183,17 @@ void Application::OnInit()
     Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).DisableVSync();
   }
 
+  Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetStereoBase( mCommandLineOptions->stereoBase );
+  if( mCommandLineOptions->viewMode != 0 )
+  {
+    ViewMode viewMode = MONO;
+    if( mCommandLineOptions->viewMode <= STEREO_INTERLACED )
+    {
+      viewMode = static_cast<ViewMode>( mCommandLineOptions->viewMode );
+    }
+    Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetViewMode( viewMode );
+  }
+
   mInitialized = true;
 
   Dali::Application application(this);
@@ -269,6 +280,28 @@ void Application::SetTheme(const std::string& themeFilePath)
   return Dali::StyleMonitor::Get().SetTheme(themeFilePath);
 }
 
+// Stereoscopy
+
+void Application::SetViewMode( ViewMode viewMode )
+{
+  Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetViewMode( viewMode );
+}
+
+ViewMode Application::GetViewMode() const
+{
+  return Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).GetViewMode();
+}
+
+void Application::SetStereoBase( float stereoBase )
+{
+  Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetStereoBase( stereoBase );
+}
+
+float Application::GetStereoBase() const
+{
+  return Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).GetStereoBase();
+}
+
 } // namespace Adaptor
 
 } // namespace Internal
index e87f141..1a36300 100644 (file)
@@ -122,6 +122,28 @@ public:
    */
   void SetTheme(const std::string& themeFilePath);
 
+public: // Stereoscopy
+
+  /**
+   * @copydoc Dali::Application::SetViewMode()
+   */
+  void SetViewMode( ViewMode viewMode );
+
+  /**
+   * @copydoc Dali::Application::GetViewMode()
+   */
+  ViewMode GetViewMode() const;
+
+  /**
+   * @copydoc Dali::Application::SetStereoBase()
+   */
+  void SetStereoBase( float stereoBase );
+
+  /**
+   * @copydoc Dali::Application::GetStereoBase()
+   */
+  float GetStereoBase() const;
+
 public: // From Framework::Observer
 
   /**
index 40079ce..a84c6f2 100644 (file)
@@ -43,7 +43,7 @@ struct Argument
   void Print()
   {
     std::cout << std::left << "  --";
-    std::cout.width( 15 );
+    std::cout.width( 18 );
     std::cout << opt;
     std::cout << optDescription;
     std::cout << std::endl;
@@ -52,13 +52,14 @@ struct Argument
 
 Argument EXPECTED_ARGS[] =
 {
-  { "no-vsync", "Disable VSync on Render" },
-  { "width",    "Stage Width"             },
-  { "height",   "Stage Height"            },
-  { "dpi",      "Emulated DPI"            },
-  { "help",     "Help"                    },
-
-  { NULL,       NULL                      }
+  { "no-vsync",    "Disable VSync on Render" },
+  { "width",       "Stage Width"             },
+  { "height",      "Stage Height"            },
+  { "dpi",         "Emulated DPI"            },
+  { "view",        "Stereocopic 3D view mode ([0]=MONO, 1=STEREO_HORZ, 2=STEREO_VERT, 3=STEREO_INTERLACED)" },
+  { "stereo-base", "Distance in millimeters between left/right cameras [65.0]" },
+  { "help",        "Help"                    },
+  { NULL,          NULL                      }
 };
 
 enum Option
@@ -67,16 +68,31 @@ enum Option
   OPTION_STAGE_WIDTH,
   OPTION_STAGE_HEIGHT,
   OPTION_DPI,
+  OPTION_STEREO_MODE,
+  OPTION_STEREO_BASE,
   OPTION_HELP
 };
 
 typedef std::vector< int > UnhandledContainer;
 
+void ShowHelp()
+{
+  std::cout << "Available options:" << std::endl;
+  Argument* arg = EXPECTED_ARGS;
+  while ( arg->opt )
+  {
+    arg->Print();
+    ++arg;
+  }
+}
+
 } // unnamed namespace
 
 CommandLineOptions::CommandLineOptions(int *argc, char **argv[])
 : noVSyncOnRender(0),
-  stageWidth(0), stageHeight(0)
+  stageWidth(0), stageHeight(0),
+  viewMode(0),
+  stereoBase(65)
 {
   if ( *argc > 1 )
   {
@@ -92,14 +108,16 @@ CommandLineOptions::CommandLineOptions(int *argc, char **argv[])
       { EXPECTED_ARGS[OPTION_STAGE_WIDTH].opt,  required_argument, NULL,             'w' },  // "--width"
       { EXPECTED_ARGS[OPTION_STAGE_HEIGHT].opt, required_argument, NULL,             'h' },  // "--height"
       { EXPECTED_ARGS[OPTION_DPI].opt,          required_argument, NULL,             'd' },  // "--dpi"
-      { EXPECTED_ARGS[OPTION_HELP].opt,         no_argument,       &help,            1   },  // "--help"
+      { EXPECTED_ARGS[OPTION_STEREO_MODE].opt,  required_argument, NULL,             'v' },  // "--view"
+      { EXPECTED_ARGS[OPTION_STEREO_BASE].opt,  required_argument, NULL,             's' },  // "--stereo-base"
+      { EXPECTED_ARGS[OPTION_HELP].opt,         no_argument,       &help,            '?' },  // "--help"
       { 0, 0, 0, 0 } // end of options
     };
 
     int shortOption( 0 );
     int optionIndex( 0 );
 
-    const char* optString = "-w:h:d:"; // The '-' ensures that argv is NOT permuted
+    const char* optString = "-w:h:d:v:s:?"; // The '-' ensures that argv is NOT permuted
     bool optionProcessed( false );
 
     UnhandledContainer unhandledOptions; // We store indices of options we do not handle here
@@ -115,13 +133,7 @@ CommandLineOptions::CommandLineOptions(int *argc, char **argv[])
           // Check if we want help
           if ( help )
           {
-            std::cout << "Available options:" << std::endl;
-            Argument* arg = EXPECTED_ARGS;
-            while ( arg->opt )
-            {
-              arg->Print();
-              ++arg;
-            }
+            ShowHelp();
             optionProcessed = true;
           }
           break;
@@ -157,6 +169,32 @@ CommandLineOptions::CommandLineOptions(int *argc, char **argv[])
           break;
         }
 
+        case 'v':
+        {
+          if ( optarg )
+          {
+            viewMode = atoi(optarg);
+            optionProcessed = true;
+          }
+          break;
+        }
+
+        case 's':
+        {
+          if ( optarg )
+          {
+            stereoBase = atoi(optarg);
+            optionProcessed = true;
+          }
+          break;
+        }
+
+        case '?':
+        {
+           ShowHelp();
+           optionProcessed = true;
+           break;
+        }
         case -1:
         {
           // All command-line options have been parsed.
index a0d4ba8..bd1def7 100644 (file)
@@ -64,9 +64,11 @@ public:
 
 public: // Command line parsed values
 
-  int noVSyncOnRender; ///< If 1, then the user does not want VSync on Render
-  int stageWidth; ///< The width of the stage required.  0 if not set.
-  int stageHeight; ///< The height of the stage required.   0 if not set.
+  int noVSyncOnRender;  ///< If 1, then the user does not want VSync on Render
+  int stageWidth;       ///< The width of the stage required.  0 if not set.
+  int stageHeight;      ///< The height of the stage required.   0 if not set.
+  int viewMode;         ///< Stereocopic 3D view mode (0=MONO, 1=STEREO_HORZ, 2=STEREO_VERT, 3=STEREO_INTERLACED)
+  int stereoBase;       ///< The distance in millimeters between left/right cameras
   std::string stageDPI; ///< DPI stored as hxv, where h is horizontal DPI and v is vertical DPI
 };
 
index 143173d..ceb5b0e 100644 (file)
@@ -797,6 +797,28 @@ Adaptor::Adaptor(Dali::Adaptor& adaptor, RenderSurface* surface, const DeviceLay
   gThreadLocalAdaptor.reset(this);
 }
 
+// Stereoscopy
+
+void Adaptor::SetViewMode( ViewMode viewMode )
+{
+  mCore->SetViewMode( viewMode );
+}
+
+ViewMode Adaptor::GetViewMode() const
+{
+  return mCore->GetViewMode();
+}
+
+void Adaptor::SetStereoBase( float stereoBase )
+{
+  mCore->SetStereoBase( stereoBase );
+}
+
+float Adaptor::GetStereoBase() const
+{
+  return mCore->GetStereoBase();
+}
+
 } // namespace Adaptor
 
 } // namespace Internal
index 39e48ca..b36c866 100644 (file)
@@ -24,6 +24,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/common/view-mode.h>
 #include <dali/public-api/math/rect.h>
 #include <dali/integration-api/render-controller.h>
 
@@ -34,7 +35,6 @@
 #include <dali/public-api/adaptor-framework/common/device-layout.h>
 #include <dali/public-api/adaptor-framework/common/clipboard.h>
 
-
 #include <slp-platform-abstraction.h>
 #include <base/interfaces/adaptor-internal-services.h>
 #include <base/log-options.h>
@@ -337,6 +337,28 @@ public:  //AdaptorInternalServices
    */
   virtual KernelTraceInterface& GetKernelTraceInterface();
 
+public: // Stereoscopy
+
+  /**
+   * @copydoc Dali::Integration::Core::SetViewMode()
+   */
+  DALI_IMPORT_API void SetViewMode( ViewMode viewMode );
+
+  /**
+   * @copydoc Dali::Integration::Core::GetViewMode()
+   */
+  DALI_IMPORT_API ViewMode GetViewMode() const;
+
+  /**
+   * @copydoc Dali::Integration::Core::SetStereoBase()
+   */
+  DALI_IMPORT_API void SetStereoBase( float stereoBase );
+
+  /**
+   * @copydoc Dali::Integration::Core::GetStereoBase()
+   */
+  DALI_IMPORT_API float GetStereoBase() const;
+
 public: // Signals
 
   /**
index e0d2891..a1c4625 100644 (file)
@@ -110,6 +110,26 @@ Application Application::Get()
   return Internal::Adaptor::Application::Get();
 }
 
+void Application::SetViewMode( ViewMode viewMode )
+{
+  Internal::Adaptor::GetImplementation(*this).SetViewMode( viewMode );
+}
+
+ViewMode Application::GetViewMode() const
+{
+  return Internal::Adaptor::GetImplementation(*this).GetViewMode();
+}
+
+void Application::SetStereoBase( float stereoBase )
+{
+  Internal::Adaptor::GetImplementation(*this).SetStereoBase( stereoBase );
+}
+
+float Application::GetStereoBase() const
+{
+  return Internal::Adaptor::GetImplementation(*this).GetStereoBase();
+}
+
 Application::AppSignalV2& Application::InitSignal()
 {
   return Internal::Adaptor::GetImplementation(*this).InitSignal();
index 1dcbb3d..9942093 100644 (file)
@@ -21,6 +21,7 @@
 #include <boost/function.hpp>
 #include <string>
 #include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/common/view-mode.h>
 
 #include <dali/public-api/adaptor-framework/common/style-monitor.h>
 #include <dali/public-api/adaptor-framework/common/device-layout.h>
@@ -210,6 +211,32 @@ public:
    */
   static Application Get();
 
+public: // Stereoscopy
+
+  /**
+   * Set the stereoscopic 3D viewing mode for the application
+   * @param[in] viewMode The new viewing mode
+   */
+  void SetViewMode( ViewMode viewMode );
+
+  /**
+   * Get the current stereoscopic 3D viewing mode.
+   * @return The current stereoscopic 3D viewing mode.
+   */
+  ViewMode GetViewMode() const;
+
+  /**
+   * Set the stereo base (eye seperation) for stereoscopic 3D
+   * @param[in] stereoBase The stereo base (eye seperation) for stereoscopic 3D
+   */
+  void SetStereoBase( float stereoBase );
+
+  /**
+   * Get the stereo base (eye seperation) for stereoscopic 3D
+   * @return The stereo base (eye seperation) for stereoscopic 3D
+   */
+  float GetStereoBase() const;
+
 public:  // Signals
 
   /**