Stop using raw matrix pointers directly in render thread as that can cause matrix... 05/24105/1
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Mon, 7 Jul 2014 12:58:15 +0000 (13:58 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 8 Jul 2014 13:19:39 +0000 (14:19 +0100)
Change-Id: Ie956986f048786657cc6055b87f39113bb55a54d
Signed-off-by: Adeel Kazmi <adeel.kazmi@samsung.com>
dali/internal/render/common/render-algorithms.cpp
dali/internal/render/common/render-debug.cpp
dali/internal/render/common/render-debug.h
dali/internal/render/common/render-instruction.cpp
dali/internal/render/common/render-instruction.h
dali/internal/update/render-tasks/scene-graph-render-task.cpp
dali/internal/update/render-tasks/scene-graph-render-task.h

index e18e9e2..0821279 100644 (file)
@@ -125,10 +125,10 @@ void ProcessRenderInstruction( const RenderInstruction& instruction,
                                BufferIndex bufferIndex,
                                float frameTime )
 {
-  DALI_PRINT_RENDER_INSTRUCTION( instruction );
+  DALI_PRINT_RENDER_INSTRUCTION( instruction, bufferIndex );
 
-  const Matrix* viewMatrix       = instruction.mViewMatrix;
-  const Matrix* projectionMatrix = instruction.mProjectionMatrix;
+  const Matrix* viewMatrix       = instruction.GetViewMatrix( bufferIndex );
+  const Matrix* projectionMatrix = instruction.GetProjectionMatrix( bufferIndex );
 
   DALI_ASSERT_DEBUG( NULL != viewMatrix );
   DALI_ASSERT_DEBUG( NULL != projectionMatrix );
index f2e5637..d5995d4 100644 (file)
@@ -48,12 +48,12 @@ void PrintFrameEnd()
   DALI_LOG_RENDER_INFO( "RENDER END\n\n" );
 }
 
-void PrintRenderInstruction( const SceneGraph::RenderInstruction& instruction )
+void PrintRenderInstruction( const SceneGraph::RenderInstruction& instruction, BufferIndex index )
 {
   const char* target = (0 != instruction.mOffscreenTextureId) ? "FrameBuffer" : "Screen";
 
   std::stringstream debugStream;
-  debugStream << "Rendering to " << target << ", View: " << *(instruction.mViewMatrix) << " Projection: " << *(instruction.mProjectionMatrix);
+  debugStream << "Rendering to " << target << ", View: " << *(instruction.GetViewMatrix(index)) << " Projection: " << *(instruction.GetProjectionMatrix(index));
 
   if( instruction.mIsViewportSet )
   {
index d37deaf..59dbf66 100644 (file)
@@ -28,7 +28,7 @@
 
 #define DALI_PRINT_RENDER_START(x) Render::PrintFrameStart(x);
 #define DALI_PRINT_RENDER_END() Render::PrintFrameEnd();
-#define DALI_PRINT_RENDER_INSTRUCTION(x) Render::PrintRenderInstruction(x);
+#define DALI_PRINT_RENDER_INSTRUCTION(x,index) Render::PrintRenderInstruction(x,index);
 #define DALI_PRINT_RENDER_LIST(x) Render::PrintRenderList(x);
 #define DALI_PRINT_RENDER_ITEM(x) Render::PrintRenderItem(x);
 
@@ -36,7 +36,7 @@
 
 #define DALI_PRINT_RENDER_START(x)
 #define DALI_PRINT_RENDER_END()
-#define DALI_PRINT_RENDER_INSTRUCTION(x)
+#define DALI_PRINT_RENDER_INSTRUCTION(x,index)
 #define DALI_PRINT_RENDER_LIST(x)
 #define DALI_PRINT_RENDER_ITEM(x)
 
@@ -88,8 +88,9 @@ void PrintFrameEnd();
 /**
  * Print some information about a render-instruction.
  * @param[in] instruction The render-instruction.
+ * @param[in] index to use
  */
-void PrintRenderInstruction( const SceneGraph::RenderInstruction& instruction );
+void PrintRenderInstruction( const SceneGraph::RenderInstruction& instruction, BufferIndex index );
 
 /**
  * Print some information about a render-list.
index 714177e..5e38169 100644 (file)
@@ -32,14 +32,13 @@ namespace SceneGraph
 {
 
 RenderInstruction::RenderInstruction()
-: mViewMatrix( 0 ),
-  mProjectionMatrix( 0 ),
-  mRenderTracker( NULL ),
+: mRenderTracker( NULL ),
   mClearColor(),
   mIsViewportSet( false ),
   mIsClearColorSet( false ),
   mCullMode(false),
   mOffscreenTextureId( 0 ),
+  mCameraAttachment( 0 ),
   mNextFreeRenderList( 0 )
 {
   // reserve 6 lists, which is enough for three layers with opaque and transparent things on
@@ -98,14 +97,12 @@ const RenderList* RenderInstruction::GetRenderList( RenderListContainer::SizeTyp
   return mRenderLists[ index ];
 }
 
-void RenderInstruction::Reset( const Matrix*   viewMatrix,
-                               const Matrix*   projectionMatrix,
-                               unsigned int    offscreenTextureId,
-                               const Viewport* viewport,
-                               const Vector4*  clearColor)
+void RenderInstruction::Reset( CameraAttachment* cameraAttachment,
+                               unsigned int      offscreenTextureId,
+                               const Viewport*   viewport,
+                               const Vector4*    clearColor )
 {
-  mViewMatrix = viewMatrix;
-  mProjectionMatrix = projectionMatrix;
+  mCameraAttachment = cameraAttachment;
   mViewport = viewport ? *viewport : Viewport();
   mIsViewportSet = NULL != viewport;
   mClearColor = clearColor ? *clearColor : Color::BLACK;
index a1ce9ee..e0c2c12 100644 (file)
@@ -21,6 +21,7 @@
 // INTERNAL INCLUDES
 #include <dali/public-api/math/matrix.h>
 #include <dali/public-api/math/viewport.h>
+#include <dali/internal/update/node-attachments/scene-graph-camera-attachment.h>
 #include <dali/internal/render/common/render-list.h>
 
 namespace Dali
@@ -32,6 +33,7 @@ namespace Internal
 namespace SceneGraph
 {
 class RenderTracker;
+class CameraAttachment;
 
 /**
  * A set of rendering instructions consisting of:
@@ -86,18 +88,38 @@ public:
    * render-lists are cleared but not released, while matrices and other settings reset in
    * preparation for building a set of instructions for the renderer.
    *
-   * @param[in] viewMatrix The view matrix.
-   * @param[in] projectionMatrix The projection matrix.
+   * @param[in] cameraAttachment to use to get view and projection matrices.
    * @param[in] offscreenId A resource Id of an off-screen render target, or 0
    * @param[in] viewport A pointer to a viewport, of NULL.
    * @param[in] clearColor A pointer to a color to clear with, or NULL if no clear is required.
    */
-  void Reset( const Matrix* viewMatrix,
-              const Matrix* projectionMatrix,
+  void Reset( CameraAttachment* cameraAttachment,
               unsigned int offscreenId,
               const Viewport* viewport,
               const Vector4* clearColor );
 
+  /**
+   * Get the view matrix for rendering
+   * @param index of the rendering side
+   * @return the view matrix
+   */
+  const Matrix* GetViewMatrix( BufferIndex index ) const
+  {
+    // inlined as this is called once per frame per render instruction
+    return &mCameraAttachment->GetViewMatrix( index );
+  }
+
+  /**
+   * Get the projection matrix for rendering
+   * @param index of the rendering side
+   * @return the projection matrix
+   */
+  const Matrix* GetProjectionMatrix( BufferIndex index ) const
+  {
+    // inlined as this is called once per frame per render instruction
+    return &mCameraAttachment->GetProjectionMatrix( index );
+  }
+
 private:
 
   // Undefined
@@ -107,8 +129,6 @@ private:
 
 public: // Data, TODO hide these
 
-  const Matrix* mViewMatrix;            ///< Pointer to a View Matrix (owned by camera)
-  const Matrix* mProjectionMatrix;      ///< Pointer to a Projection Matrix (owned by camera)
   RenderTracker* mRenderTracker;        ///< Pointer to an optional tracker object (not owned)
 
   Viewport mViewport;                   ///< Optional viewport
@@ -121,6 +141,7 @@ public: // Data, TODO hide these
 
 private: // Data
 
+  CameraAttachment* mCameraAttachment;  ///< camera that is used
   RenderListContainer mRenderLists;     ///< container of all render lists
   RenderListContainer::SizeType mNextFreeRenderList;     ///< index for the next free render list
 
index 77ca4bf..27acf09 100644 (file)
@@ -123,11 +123,6 @@ void RenderTask::SetCameraNode( Node* cameraNode )
   }
 }
 
-Node* RenderTask::GetCameraNode() const
-{
-  return mCameraNode;
-}
-
 void RenderTask::SetFrameBufferId( unsigned int resourceId )
 {
   if ( mFrameBufferResourceId != resourceId )
@@ -421,13 +416,14 @@ const Matrix& RenderTask::GetProjectionMatrix( BufferIndex bufferIndex ) const
 
 void RenderTask::PrepareRenderInstruction( RenderInstruction& instruction, BufferIndex updateBufferIndex )
 {
+  DALI_ASSERT_DEBUG( NULL != mCameraAttachment );
+
   TASK_LOG(Debug::General);
 
   Viewport viewport;
   bool viewportSet = QueryViewport( updateBufferIndex, viewport );
 
-  instruction.Reset( &GetViewMatrix( updateBufferIndex ),
-                     &GetProjectionMatrix( updateBufferIndex ),
+  instruction.Reset( mCameraAttachment,
                      GetFrameBufferId(),
                      viewportSet ? &viewport : NULL,
                      mClearEnabled ? &GetClearColor( updateBufferIndex ) : NULL );
index 6b9e162..3cdf32a 100644 (file)
@@ -97,12 +97,6 @@ public:
   void SetCameraNode( Node* node );
 
   /**
-   * Retrieve the camera node.
-   * @return The scene is viewed from the perspective of this node.
-   */
-  Node* GetCameraNode() const;
-
-  /**
    * Set the frame-buffer used as a render target.
    * @param[in] resourceId The resource ID of the frame-buffer, or zero if not rendering off-screen.
    */