stop passing shader data as raw pointer to make sure ownership transfer is done safely 73/28973/7
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Fri, 17 Oct 2014 16:45:35 +0000 (17:45 +0100)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 23 Oct 2014 16:58:35 +0000 (09:58 -0700)
[Problem] unsafe code
[Cause] ownership is passed through raw pointer
[Solution] use smart pointers

Change-Id: I9b4c3e42ca6c63149783c2929eb7840b82fc8820

dali/internal/render/shaders/program.cpp
dali/internal/render/shaders/program.h
dali/internal/render/shaders/shader.cpp

index 151fb83..b014a48 100644 (file)
@@ -118,7 +118,7 @@ const char* gStdUniforms[ Program::UNIFORM_TYPE_LAST ] =
 
 // IMPLEMENTATION
 
-Program* Program::New( const Integration::ResourceId& resourceId, Integration::ShaderData* shaderData, Context& context, bool modifiesGeometry )
+Program* Program::New( const Integration::ResourceId& resourceId, Integration::ShaderDataPtr shaderData, Context& context, bool modifiesGeometry )
 {
   size_t shaderHash = shaderData->GetHashValue();
   Program* program = context.GetCachedProgram( shaderHash );
@@ -435,7 +435,7 @@ bool Program::ModifiesGeometry()
   return mModifiesGeometry;
 }
 
-Program::Program(Integration::ShaderData* shaderData, Context& context, bool modifiesGeometry )
+Program::Program(Integration::ShaderDataPtr shaderData, Context& context, bool modifiesGeometry )
 : mContext( context ),
   mGlAbstraction( context.GetAbstraction() ),
   mProjectionMatrix( NULL ),
index ab7cc6e..5cd97a3 100644 (file)
@@ -139,7 +139,7 @@ public:
    * @param [in] modifiesGeometry True if the shader modifies geometry
    * @return pointer to the program
    */
-  static Program* New( const Integration::ResourceId& resourceId, Integration::ShaderData* shaderData, Context& context, bool modifiesGeometry );
+  static Program* New( const Integration::ResourceId& resourceId, Integration::ShaderDataPtr shaderData, Context& context, bool modifiesGeometry );
 
   /**
    * Takes this program into use
@@ -296,11 +296,11 @@ private: // Implementation
 
   /**
    * Constructor, private so no direct instantiation
-   * @param[in] shaderData A pointer to a data structure containing the program source and binary
+   * @param[in] shaderData A smart pointer to a data structure containing the program source and binary
    * @param[in] context    The GL context state cache.
    * @param[in] modifiesGeometry True if the vertex shader changes geometry
    */
-  Program( Integration::ShaderData* shaderData, Context& context, bool modifiesGeometry );
+  Program( Integration::ShaderDataPtr shaderData, Context& context, bool modifiesGeometry );
 
 public:
 
index f60dd14..be32605 100644 (file)
@@ -237,7 +237,7 @@ void Shader::SetProgram( GeometryType geometryType,
 
   bool precompiledBinary = shaderData->HasBinary();
 
-  Program* program = Program::New( resourceId, shaderData.Get(), *context, modifiesGeometry );
+  Program* program = Program::New( resourceId, shaderData, *context, modifiesGeometry );
 
   ShaderSubTypes theSubType = subType;
   if( subType == SHADER_SUBTYPE_ALL )