Move ShaderData from integration api to internal 70/43970/2
authorAndrew Cox <andrew.cox@partner.samsung.com>
Wed, 15 Jul 2015 12:56:39 +0000 (13:56 +0100)
committerAndrew Cox <andrew.cox@partner.samsung.com>
Thu, 16 Jul 2015 10:52:43 +0000 (11:52 +0100)
Change-Id: Ibd3cae2fe9c4c08a78e3f99ce3b81f9dfbb2c8f1
Signed-off-by: Andrew Cox <andrew.cox@partner.samsung.com>
18 files changed:
dali/integration-api/file.list
dali/integration-api/shader-data.cpp [deleted file]
dali/internal/common/shader-data.h [moved from dali/integration-api/shader-data.h with 90% similarity]
dali/internal/common/shader-saver.h
dali/internal/event/effects/shader-effect-impl.cpp
dali/internal/event/effects/shader-factory.cpp
dali/internal/event/effects/shader-factory.h
dali/internal/event/rendering/shader-impl.cpp
dali/internal/render/renderers/scene-graph-renderer-debug.cpp
dali/internal/render/shaders/program-cache.h
dali/internal/render/shaders/program-controller.cpp
dali/internal/render/shaders/program-controller.h
dali/internal/render/shaders/program.cpp
dali/internal/render/shaders/program.h
dali/internal/render/shaders/scene-graph-shader.cpp
dali/internal/render/shaders/scene-graph-shader.h
dali/internal/update/manager/update-manager.cpp
dali/internal/update/manager/update-manager.h

index 5c03098..ec83f66 100644 (file)
@@ -7,7 +7,6 @@ platform_abstraction_src_files = \
    $(platform_abstraction_src_dir)/debug.cpp \
    $(platform_abstraction_src_dir)/profiling.cpp \
    $(platform_abstraction_src_dir)/input-options.cpp \
-   $(platform_abstraction_src_dir)/shader-data.cpp \
    $(platform_abstraction_src_dir)/system-overlay.cpp \
    $(platform_abstraction_src_dir)/lockless-buffer.cpp \
    $(platform_abstraction_src_dir)/events/event.cpp \
@@ -42,7 +41,6 @@ platform_abstraction_header_files = \
    $(platform_abstraction_src_dir)/gesture-manager.h \
    $(platform_abstraction_src_dir)/render-controller.h \
    $(platform_abstraction_src_dir)/platform-abstraction.h \
-   $(platform_abstraction_src_dir)/shader-data.h \
    $(platform_abstraction_src_dir)/system-overlay.h \
    $(platform_abstraction_src_dir)/lockless-buffer.h
 
diff --git a/dali/integration-api/shader-data.cpp b/dali/integration-api/shader-data.cpp
deleted file mode 100644 (file)
index 6bab886..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/integration-api/shader-data.h>
-
-namespace Dali
-{
-
-namespace Integration
-{
-
-const size_t ShaderData::UNINITIALISED_HASH_VALUE = size_t(0) - 1;
-
-}
-}
similarity index 90%
rename from dali/integration-api/shader-data.h
rename to dali/internal/common/shader-data.h
index b047650..797568d 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __DALI_INTEGRATION_SHADER_DATA_H__
-#define __DALI_INTEGRATION_SHADER_DATA_H__
+#ifndef __DALI_INTERNAL_SHADER_DATA_H__
+#define __DALI_INTERNAL_SHADER_DATA_H__
 
 /*
  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
 // INTERNAL INCLUDES
 #include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/common/dali-vector.h>
-#include <dali/integration-api/resource-declarations.h>
 
 namespace Dali
 {
 
-namespace Integration
+namespace Internal
 {
 
 class ShaderData;
-
 typedef IntrusivePtr<ShaderData> ShaderDataPtr;
 
 /**
@@ -44,15 +42,13 @@ class ShaderData : public Dali::RefObject
 {
 public:
 
-  static const size_t UNINITIALISED_HASH_VALUE;
-
   /**
    * Constructor
    * @param[in] vertexSource   Source code for vertex program
    * @param[in] fragmentSource Source code for fragment program
    */
   ShaderData(const std::string& vertexSource, const std::string& fragmentSource)
-  : mShaderHash( UNINITIALISED_HASH_VALUE ),
+  : mShaderHash( -1 ),
     mVertexShader(vertexSource),
     mFragmentShader(fragmentSource)
   { }
@@ -75,7 +71,7 @@ public: // API
    */
   void SetHashValue(size_t shaderHash)
   {
-    DALI_ASSERT_DEBUG( shaderHash != 0 );
+    DALI_ASSERT_DEBUG( shaderHash != size_t(-1) );
     mShaderHash = shaderHash;
   }
 
@@ -85,7 +81,7 @@ public: // API
    */
   size_t GetHashValue() const
   {
-    DALI_ASSERT_DEBUG( mShaderHash != UNINITIALISED_HASH_VALUE );
+    DALI_ASSERT_DEBUG( mShaderHash != size_t(-1) );
     return mShaderHash;
   }
 
@@ -168,4 +164,4 @@ private: // Data
 
 } // namespace Dali
 
-#endif // __DALI_INTEGRATION_SHADER_DATA_H__
+#endif // __DALI_INTERNAL_SHADER_DATA_H__
index 1083282..580cab6 100644 (file)
 namespace Dali
 {
 
-namespace Integration
+namespace Internal
 {
 class ShaderData;
 typedef IntrusivePtr<ShaderData> ShaderDataPtr;
-}
-
-namespace Internal
-{
 
 /**
  * Abstract interface for passing a ShaderData object towards being saved.
@@ -47,7 +43,7 @@ public:
    * A function saving the binary from a ShaderDataPtr or passing it on to where it can be saved.
    * @param[in] shaderData A smart pointer to a ShaderData for which the program binary should be saved.
    */
-  virtual void SaveBinary( Integration::ShaderDataPtr shaderData ) = 0;
+  virtual void SaveBinary( Internal::ShaderDataPtr shaderData ) = 0;
 
 protected:
   /**
index f659a21..a038ef6 100644 (file)
@@ -292,7 +292,7 @@ void ShaderEffect::SendProgramMessage( const string& vertexSource, const string&
   ShaderFactory& shaderFactory = tls.GetShaderFactory();
   size_t shaderHash;
 
-  Integration::ShaderDataPtr shaderData = shaderFactory.Load( vertexSource, fragmentSource, shaderHash );
+  Internal::ShaderDataPtr shaderData = shaderFactory.Load( vertexSource, fragmentSource, shaderHash );
   DALI_ASSERT_DEBUG( shaderHash != 0U );
 
   // Add shader program to scene-object using a message to the UpdateManager
index 88ef6ed..64100a0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
@@ -28,7 +28,6 @@
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/platform-abstraction.h>
 #include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/resources/resource-client.h>
 #include <dali/internal/event/effects/shader-effect-impl.h>
 #include <dali/internal/event/effects/shader-declarations.h>
 
@@ -41,13 +40,6 @@ const char* VERSION_SEPARATOR = "-";
 const char* SHADER_SUFFIX = ".dali-bin";
 }
 
-// Use pre-compiler constants in order to utilize string concatenation
-#define SHADER_DEF_USE_BONES    "#define USE_BONES\n"
-#define SHADER_DEF_USE_COLOR    "#define USE_COLOR\n"
-#define SHADER_DEF_USE_GRADIENT "#define USE_GRADIENT\n"
-
-using namespace Dali::Integration;
-
 namespace Dali
 {
 
@@ -137,7 +129,7 @@ ShaderDataPtr ShaderFactory::Load( const std::string& vertexSource, const std::s
   return shaderData;
 }
 
-void ShaderFactory::SaveBinary( Integration::ShaderDataPtr shaderData )
+void ShaderFactory::SaveBinary( Internal::ShaderDataPtr shaderData )
 {
   // Save the binary to the file system:
   std::string binaryShaderFilename;
index 29fd221..17a4204 100644 (file)
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-vector.h>
-#include <dali/internal/event/resources/resource-ticket.h>
 #include <dali/internal/event/effects/shader-declarations.h>
 #include <dali/internal/common/message.h>
 #include <dali/internal/common/shader-saver.h>
 
 namespace Dali
 {
-namespace Integration
-{
-
-class ShaderData;
-typedef IntrusivePtr<ShaderData> ShaderDataPtr;
-
-}
 
 namespace Internal
 {
 
-class ResourceClient;
-class MessageController;
+class ShaderData;
+typedef IntrusivePtr<ShaderData> ShaderDataPtr;
 
 /**
  * ShaderFactory is an object which manages shader binary resource load requests,
@@ -75,7 +67,7 @@ public:
    *                            a compiled shader program binary if one could be found, else an
    *                            empty binary buffer cleared to size zero.
    */
-  Integration::ShaderDataPtr Load( const std::string& vertexSource, const std::string& fragmentSource, size_t& shaderHash );
+  Internal::ShaderDataPtr Load( const std::string& vertexSource, const std::string& fragmentSource, size_t& shaderHash );
 
   /**
    * @brief Saves shader to memory cache and filesystem.
@@ -84,7 +76,7 @@ public:
    * @param[in] shader The data to be saved.
    * @sa Load
    */
-  virtual void SaveBinary( Integration::ShaderDataPtr shader );
+  virtual void SaveBinary( Internal::ShaderDataPtr shader );
 
   /**
    * Called during Core initialization to load the default shader.
@@ -93,7 +85,7 @@ public:
 
 private:
 
-  void MemoryCacheInsert( Integration::ShaderData& shaderData );
+  void MemoryCacheInsert( Internal::ShaderData& shaderData );
 
   // Undefined
   ShaderFactory( const ShaderFactory& );
@@ -103,13 +95,13 @@ private:
 
 private:
   ShaderEffectPtr                           mDefaultShader;
-  Dali::Vector< Integration::ShaderData* > mShaderBinaryCache; ///< Cache of pre-compiled shaders.
+  Dali::Vector< Internal::ShaderData* > mShaderBinaryCache; ///< Cache of pre-compiled shaders.
 
 }; // class ShaderFactory
 
-inline MessageBase* ShaderCompiledMessage( ShaderSaver& factory, Integration::ShaderDataPtr shaderData )
+inline MessageBase* ShaderCompiledMessage( ShaderSaver& factory, Internal::ShaderDataPtr shaderData )
 {
-  return new MessageValue1< ShaderSaver, Integration::ShaderDataPtr >( &factory,
+  return new MessageValue1< ShaderSaver, Internal::ShaderDataPtr >( &factory,
                                                             &ShaderSaver::SaveBinary,
                                                             shaderData );
 }
index 12b218e..1ff7b5e 100644 (file)
@@ -281,7 +281,7 @@ void Shader::Initialize(
   ThreadLocalStorage& tls = ThreadLocalStorage::Get();
   ShaderFactory& shaderFactory = tls.GetShaderFactory();
   size_t shaderHash;
-  Integration::ShaderDataPtr shaderData = shaderFactory.Load( vertexSource, fragmentSource, shaderHash );
+  Internal::ShaderDataPtr shaderData = shaderFactory.Load( vertexSource, fragmentSource, shaderHash );
 
   // Add shader program to scene-object using a message to the UpdateManager
   SetShaderProgramMessage( updateManager, *mSceneObject, shaderData, (hints & Dali::Shader::HINT_MODIFIES_GEOMETRY) != 0x0 );
index 2059fd4..433cc30 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 #include "scene-graph-renderer-debug.h"
-#include <dali/integration-api/shader-data.h>
+#include <dali/internal/common/shader-data.h>
 #include <dali/integration-api/resource-declarations.h>
 #include <dali/internal/render/shaders/program.h>
 #include <dali/internal/render/gl-resources/context.h>
@@ -62,7 +62,7 @@ void DebugBoundingBox(Context& context, Rect<float> boundingBox, const Matrix& m
 #if defined ( DEBUG_ENABLED )
   if( gDebugProgram == NULL )
   {
-    Integration::ShaderDataPtr shaderData( new Integration::ShaderData( DEBUG_DRAW_VERTEX_SHADER, DEBUG_DRAW_FRAGMENT_SHADER ) );
+    Internal::ShaderDataPtr shaderData( new Internal::ShaderData( DEBUG_DRAW_VERTEX_SHADER, DEBUG_DRAW_FRAGMENT_SHADER ) );
     gDebugProgram = Program::New( shaderData.Get(), context, true );
   }
 
index 1f28969..7c40a01 100644 (file)
@@ -94,7 +94,7 @@ public: // API
   /**
    * @param programData to store/save
    */
-  virtual void StoreBinary( Integration::ShaderDataPtr programData ) = 0;
+  virtual void StoreBinary( Internal::ShaderDataPtr programData ) = 0;
 
 private: // not implemented as non-copyable
 
index e4163db..0958710 100644 (file)
@@ -141,10 +141,9 @@ unsigned int ProgramController::ProgramBinaryFormat()
   return mProgramBinaryFormat;
 }
 
-void ProgramController::StoreBinary( Integration::ShaderDataPtr programData )
+void ProgramController::StoreBinary( Internal::ShaderDataPtr programData )
 {
   DALI_ASSERT_DEBUG( programData->GetBufferSize() > 0 );
-  DALI_ASSERT_DEBUG( programData->GetHashValue() != 0 );
   DALI_ASSERT_DEBUG( mShaderSaver && "SetShaderSaver() should have been called during startup." );
 
   if( mShaderSaver != NULL )
index 8dedd95..3ceb2a9 100644 (file)
@@ -163,7 +163,7 @@ private: // From ProgramCache
   /**
    * @copydoc ProgramCache::StoreBinary
    */
-  virtual void StoreBinary( Integration::ShaderDataPtr programData );
+  virtual void StoreBinary( Internal::ShaderDataPtr programData );
 
 private: // not implemented as non-copyable
 
index 6957698..0c5ba69 100644 (file)
@@ -26,7 +26,7 @@
 #include <dali/public-api/common/dali-vector.h>
 #include <dali/public-api/common/constants.h>
 #include <dali/integration-api/debug.h>
-#include <dali/integration-api/shader-data.h>
+#include <dali/internal/common/shader-data.h>
 #include <dali/integration-api/gl-defines.h>
 #include <dali/internal/render/common/performance-monitor.h>
 #include <dali/internal/render/shaders/program-cache.h>
@@ -110,7 +110,7 @@ const char* gStdUniforms[ Program::UNIFORM_TYPE_LAST ] =
 
 // IMPLEMENTATION
 
-Program* Program::New( ProgramCache& cache, Integration::ShaderDataPtr shaderData, bool modifiesGeometry )
+Program* Program::New( ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry )
 {
   size_t shaderHash = shaderData->GetHashValue();
   Program* program = cache.GetProgram( shaderHash );
@@ -448,7 +448,7 @@ bool Program::ModifiesGeometry()
   return mModifiesGeometry;
 }
 
-Program::Program( ProgramCache& cache, Integration::ShaderDataPtr shaderData, bool modifiesGeometry )
+Program::Program( ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry )
 : mCache( cache ),
   mGlAbstraction( mCache.GetGlAbstraction() ),
   mProjectionMatrix( NULL ),
index 9bfb90b..50d02d6 100644 (file)
@@ -25,7 +25,7 @@
 #include <dali/public-api/common/vector-wrapper.h>
 #include <dali/public-api/object/ref-object.h>
 #include <dali/integration-api/gl-abstraction.h>
-#include <dali/integration-api/shader-data.h>
+#include <dali/internal/common/shader-data.h>
 
 namespace Dali
 {
@@ -118,7 +118,7 @@ public:
    * @param[in] modifiesGeometry True if the shader modifies geometry
    * @return pointer to the program
    */
-  static Program* New( ProgramCache& cache, Integration::ShaderDataPtr shaderData, bool modifiesGeometry );
+  static Program* New( ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
 
   /**
    * Takes this program into use
@@ -293,7 +293,7 @@ private: // Implementation
    * @param[in] shaderData A smart pointer to a data structure containing the program source and binary
    * @param[in] modifiesGeometry True if the vertex shader changes geometry
    */
-  Program( ProgramCache& cache, Integration::ShaderDataPtr shaderData, bool modifiesGeometry );
+  Program( ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
 
 public:
 
@@ -353,7 +353,7 @@ private:  // Data
   GLuint mVertexShaderId;                     ///< GL identifier for vertex shader
   GLuint mFragmentShaderId;                   ///< GL identifier for fragment shader
   GLuint mProgramId;                          ///< GL identifier for program
-  Integration::ShaderDataPtr mProgramData;    ///< Shader program source and binary (when compiled & linked or loaded)
+  Internal::ShaderDataPtr mProgramData;    ///< Shader program source and binary (when compiled & linked or loaded)
 
   // location caches
   std::vector< std::pair< std::string, GLint > > mAttributeLocations; ///< attribute location cache
index 3a078ce..913a071 100644 (file)
@@ -203,7 +203,7 @@ void Shader::SetCoordinateTypeInRender( unsigned int index, Dali::ShaderEffect::
   mUniformMetadata[ index ]->SetCoordinateType( type );
 }
 
-void Shader::SetProgram( Integration::ShaderDataPtr shaderData,
+void Shader::SetProgram( Internal::ShaderDataPtr shaderData,
                          ProgramCache* programCache,
                          bool modifiesGeometry )
 {
index 1dcb0e0..198b557 100644 (file)
@@ -22,7 +22,7 @@
 #include <dali/public-api/common/dali-vector.h>
 #include <dali/public-api/shader-effects/shader-effect.h>
 
-#include <dali/integration-api/shader-data.h>
+#include <dali/internal/common/shader-data.h>
 
 #include <dali/internal/common/buffer-index.h>
 #include <dali/internal/common/type-abstraction-enums.h>
@@ -243,7 +243,7 @@ public:
    * @param[in] modifiesGeometry  True if the vertex shader changes the positions of vertexes such that
    * they might exceed the bounding box of vertexes passing through the default transformation.
    */
-  void SetProgram( Integration::ShaderDataPtr shaderData,
+  void SetProgram( Internal::ShaderDataPtr shaderData,
                    ProgramCache* programCache,
                    bool modifiesGeometry );
 
index bdae788..5afcf94 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <dali/integration-api/core.h>
 #include <dali/integration-api/render-controller.h>
-#include <dali/integration-api/shader-data.h>
+#include <dali/internal/common/shader-data.h>
 #include <dali/integration-api/debug.h>
 
 #include <dali/internal/common/core-impl.h>
@@ -131,7 +131,7 @@ typedef OwnerContainer< Shader* >              ShaderContainer;
 typedef ShaderContainer::Iterator              ShaderIter;
 typedef ShaderContainer::ConstIterator         ShaderConstIter;
 
-typedef std::vector<Integration::ShaderDataPtr> ShaderDataBatchedQueue;
+typedef std::vector<Internal::ShaderDataPtr> ShaderDataBatchedQueue;
 typedef ShaderDataBatchedQueue::iterator        ShaderDataBatchedQueueIterator;
 
 typedef OwnerContainer<PanGesture*>            GestureContainer;
@@ -610,12 +610,12 @@ void UpdateManager::RemoveShader( Shader* shader )
 }
 
 void UpdateManager::SetShaderProgram( Shader* shader,
-                                      Integration::ShaderDataPtr shaderData, bool modifiesGeometry )
+                                      Internal::ShaderDataPtr shaderData, bool modifiesGeometry )
 {
   if( shaderData )
   {
 
-    typedef MessageValue3< Shader, Integration::ShaderDataPtr, ProgramCache*, bool> DerivedType;
+    typedef MessageValue3< Shader, Internal::ShaderDataPtr, ProgramCache*, bool> DerivedType;
 
     // Reserve some memory inside the render queue
     unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
@@ -625,7 +625,7 @@ void UpdateManager::SetShaderProgram( Shader* shader,
   }
 }
 
-void UpdateManager::SaveBinary( Integration::ShaderDataPtr shaderData )
+void UpdateManager::SaveBinary( Internal::ShaderDataPtr shaderData )
 {
   DALI_ASSERT_DEBUG( shaderData && "No NULL shader data pointers please." );
   DALI_ASSERT_DEBUG( shaderData->GetBufferSize() > 0 && "Shader binary empty so nothing to save." );
index 10bbfcf..5c23c9f 100644 (file)
@@ -309,13 +309,13 @@ public:
    * @param[in] shaderData    Source code, hash over source, and optional compiled binary for the shader program
    * @param[in] modifiesGeometry True if the vertex shader modifies geometry
    */
-  void SetShaderProgram( Shader* shader, Integration::ShaderDataPtr shaderData, bool modifiesGeometry );
+  void SetShaderProgram( Shader* shader, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
 
   /**
    * @brief Accept compiled shaders passed back on render thread for saving.
    * @param[in] shaderData Source code, hash over source, and corresponding compiled binary to be saved.
    */
-  virtual void SaveBinary( Integration::ShaderDataPtr shaderData );
+  virtual void SaveBinary( Internal::ShaderDataPtr shaderData );
 
   /**
    * @brief Set the destination for compiled shader binaries to be passed on to.
@@ -724,10 +724,10 @@ inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader )
 
 inline void SetShaderProgramMessage( UpdateManager& manager,
                                      Shader& shader,
-                                     Integration::ShaderDataPtr shaderData,
+                                     Internal::ShaderDataPtr shaderData,
                                      bool modifiesGeometry )
 {
-  typedef MessageValue3< UpdateManager, Shader*, Integration::ShaderDataPtr, bool > LocalType;
+  typedef MessageValue3< UpdateManager, Shader*, Internal::ShaderDataPtr, bool > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );