Klockwork fixes: Distance field iteration 83/29883/1
authorKingsley Stephens <k.stephens@partner.samsung.com>
Tue, 4 Nov 2014 11:34:38 +0000 (11:34 +0000)
committerKingsley Stephens <k.stephens@partner.samsung.com>
Wed, 5 Nov 2014 13:21:30 +0000 (13:21 +0000)
                 Checking for null pointers
                 Initialising member variables

Change-Id: I9a33b28759ceea74ba90507472de54affdcb0632

19 files changed:
dali/integration-api/glyph-set.cpp
dali/internal/event/actor-attachments/light-attachment-impl.cpp
dali/internal/event/actor-attachments/mesh-attachment-impl.cpp
dali/internal/event/actor-attachments/text-attachment-impl.cpp
dali/internal/event/events/actor-observer.cpp
dali/internal/event/modeling/model-archive.cpp
dali/internal/event/text/atlas/glyph-atlas-manager.cpp
dali/internal/event/text/font-layout.cpp
dali/internal/event/text/resource/glyph-resource-request.cpp
dali/internal/event/text/resource/glyph-resource-request.h
dali/internal/event/text/text-request-helper.cpp
dali/internal/render/common/render-manager.cpp
dali/internal/render/gl-resources/context.cpp
dali/internal/update/render-tasks/scene-graph-render-task-list.cpp
dali/internal/update/resources/resource-manager.cpp
dali/public-api/common/dali-common.cpp
dali/public-api/events/key-event.cpp
dali/public-api/images/distance-field.cpp
dali/public-api/signals/callback.cpp

index 9c9b4cd..33d3e47 100644 (file)
@@ -31,7 +31,8 @@ GlyphSet::GlyphSet()
   mUnitsPerEM(0.0f),
   mUnderlinePosition(0.0f),
   mUnderlineThickness(0.0f),
-  mPadAdjust(0.0f)
+  mPadAdjust(0.0f),
+  mAtlasId( 0 )
 {
 }
 
index 5b44c03..6f6f87b 100644 (file)
@@ -47,7 +47,8 @@ LightAttachmentPtr LightAttachment::New( const SceneGraph::Node& parentNode )
 }
 
 LightAttachment::LightAttachment( Stage& stage )
-: ActorAttachment( stage )
+: ActorAttachment( stage ),
+  mSceneObject( NULL )
 {
   mCachedLight = new Internal::Light( "Unnamed" );
 }
index f2a81d6..90ac633 100644 (file)
@@ -54,6 +54,7 @@ MeshAttachmentPtr MeshAttachment::New( const SceneGraph::Node& parentNode )
 
 MeshAttachment::MeshAttachment( Stage& stage )
 : RenderableAttachment( stage ),
+  mSceneObject( NULL ),
   mAffectedByLighting( true )
 {
 }
index 454bfee..97ee7ad 100644 (file)
@@ -57,6 +57,7 @@ TextAttachmentPtr TextAttachment::New( const SceneGraph::Node& parentNode, const
 
 TextAttachment::TextAttachment( Stage& stage )
 : RenderableAttachment( stage ),
+  mSceneObject( NULL ),
   mTextRequestHelper( *this ),
   mTextColor( NULL ),
   mTextChanged( true ),
@@ -599,25 +600,28 @@ const SceneGraph::RenderableAttachment& TextAttachment::GetSceneObject() const
 
 void TextAttachment::SetTextChanges()
 {
-  // record the natural size of the text
-  mTextSize = mVertexBuffer->mVertexMax;
+  if( mVertexBuffer )
+  {
+    // record the natural size of the text
+    mTextSize = mVertexBuffer->mVertexMax;
 
-  // remember the texture id, so we can detect atlas resizes / splits
-  mTextureId = mVertexBuffer->mTextureId;
+    // remember the texture id, so we can detect atlas resizes / splits
+    mTextureId = mVertexBuffer->mTextureId;
 
-  EventToUpdate& eventToUpdate(  mStage->GetUpdateInterface() );
-  const SceneGraph::TextAttachment& attachment( *mSceneObject );
+    EventToUpdate& eventToUpdate(  mStage->GetUpdateInterface() );
+    const SceneGraph::TextAttachment& attachment( *mSceneObject );
 
-  if( mTextChanged  || mFontChanged )
-  {
-    DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "TextAttachment::SetTextChanges() Sending VertexBuffer to attachment:%p  textureId:%d\n", &attachment, mVertexBuffer->mTextureId);
+    if( mTextChanged  || mFontChanged )
+    {
+      DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "TextAttachment::SetTextChanges() Sending VertexBuffer to attachment:%p  textureId:%d\n", &attachment, mVertexBuffer->mTextureId);
 
-    // release the vertex buffer to pass  ownership to the scene-graph-text-attachment
-    SetTextVertexBufferMessage( eventToUpdate, attachment, *mVertexBuffer.Release() );
+      // release the vertex buffer to pass  ownership to the scene-graph-text-attachment
+      SetTextVertexBufferMessage( eventToUpdate, attachment, *mVertexBuffer.Release() );
 
-    if( mFontChanged )
-    {
-      SetTextFontSizeMessage( eventToUpdate, attachment, mFont->GetPixelSize() );
+      if( mFontChanged )
+      {
+        SetTextFontSizeMessage( eventToUpdate, attachment, mFont->GetPixelSize() );
+      }
     }
   }
 }
index 51c33a0..ff1ce2d 100644 (file)
@@ -16,9 +16,9 @@
  */
 
 // CLASS HEADER
+#include <dali/internal/event/events/actor-observer.h>
 #include <dali/integration-api/debug.h>
 #include <dali/internal/event/actors/actor-impl.h>
-#include <dali/internal/event/events/actor-observer.h>
 
 namespace Dali
 {
@@ -33,25 +33,25 @@ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACT
 #endif // defined(DEBUG_ENABLED)
 }
 
-ActorObserver::ActorObserver::ActorObserver()
+ActorObserver::ActorObserver()
 : mActor ( NULL ),
   mActorDisconnected(false)
 {
   DALI_LOG_TRACE_METHOD( gLogFilter );
 }
 
-ActorObserver::ActorObserver::~ActorObserver()
+ActorObserver::~ActorObserver()
 {
   DALI_LOG_TRACE_METHOD( gLogFilter );
   SetActor( NULL );
 }
 
-Actor* ActorObserver::ActorObserver::GetActor()
+Actor* ActorObserver::GetActor()
 {
   return mActorDisconnected ? NULL : mActor;
 }
 
-void ActorObserver::ActorObserver::SetActor( Actor* actor )
+void ActorObserver::SetActor( Actor* actor )
 {
   DALI_LOG_TRACE_METHOD( gLogFilter );
 
@@ -72,7 +72,7 @@ void ActorObserver::ActorObserver::SetActor( Actor* actor )
   mActorDisconnected = false;
 }
 
-void ActorObserver::ActorObserver::ResetActor()
+void ActorObserver::ResetActor()
 {
   if ( mActor )
   {
@@ -83,7 +83,7 @@ void ActorObserver::ActorObserver::ResetActor()
   }
 }
 
-void ActorObserver::ActorObserver::SceneObjectRemoved( ProxyObject& proxy )
+void ActorObserver::SceneObjectRemoved( ProxyObject& proxy )
 {
   DALI_LOG_TRACE_METHOD( gLogFilter );
 
@@ -94,7 +94,7 @@ void ActorObserver::ActorObserver::SceneObjectRemoved( ProxyObject& proxy )
   }
 }
 
-void ActorObserver::ActorObserver::ProxyDestroyed(ProxyObject& proxy)
+void ActorObserver::ProxyDestroyed(ProxyObject& proxy)
 {
   DALI_LOG_TRACE_METHOD( gLogFilter );
 
index 86a3f80..e630764 100644 (file)
@@ -450,53 +450,76 @@ Archive& operator<< (Archive& ar, const Dali::EntityAnimatorMap& t)
   ar << t.GetEntityName();
   ar << t.GetDuration();
 
+  unsigned int count = 0;
+
   const KeyFrameVector3* positionKeyFrames = NULL;
   GetSpecialization(GetImplementation(t.GetPositionKeyFrames()), positionKeyFrames);
-  unsigned int count = positionKeyFrames->GetNumberOfKeyFrames();
-  ar << count;
-  if( count )
+  if( positionKeyFrames )
   {
-    for( unsigned int i = 0; i < count; ++i)
+    count = positionKeyFrames->GetNumberOfKeyFrames();
+    ar << count;
+    if( count )
     {
-      float progress;
-      Vector3 position;
-      positionKeyFrames->GetKeyFrame(i, progress, position);
+      for( unsigned int i = 0; i < count; ++i)
+      {
+        float progress;
+        Vector3 position;
+        positionKeyFrames->GetKeyFrame(i, progress, position);
 
-      ar << progress << position;
+        ar << progress << position;
+      }
     }
   }
+  else
+  {
+    ar << 0;
+  }
 
   const KeyFrameVector3* scaleKeyFrames = NULL;
   GetSpecialization(GetImplementation(t.GetScaleKeyFrames()), scaleKeyFrames);
-  count = scaleKeyFrames->GetNumberOfKeyFrames();
-  ar << count;
-  if( count )
+  if( scaleKeyFrames )
   {
-    for( unsigned int i = 0; i < count; ++i)
+    count = scaleKeyFrames->GetNumberOfKeyFrames();
+    ar << count;
+    if( count )
     {
-      float progress;
-      Vector3 scale;
-      scaleKeyFrames->GetKeyFrame(i, progress, scale);
+      for( unsigned int i = 0; i < count; ++i)
+      {
+        float progress;
+        Vector3 scale;
+        scaleKeyFrames->GetKeyFrame(i, progress, scale);
 
-      ar << progress << scale;
+        ar << progress << scale;
+      }
     }
   }
+  else
+  {
+    ar << 0;
+  }
 
   const KeyFrameQuaternion* rotationKeyFrames = NULL;
   GetSpecialization(GetImplementation(t.GetRotationKeyFrames()), rotationKeyFrames);
-  count = rotationKeyFrames->GetNumberOfKeyFrames();
-  ar << count;
-  if( count )
+  if( rotationKeyFrames )
   {
-    for( unsigned int i = 0; i < count; ++i)
+    count = rotationKeyFrames->GetNumberOfKeyFrames();
+    ar << count;
+    if( count )
     {
-      float progress;
-      Quaternion rotation;
-      rotationKeyFrames->GetKeyFrame(i, progress, rotation);
+      for( unsigned int i = 0; i < count; ++i)
+      {
+        float progress;
+        Quaternion rotation;
+        rotationKeyFrames->GetKeyFrame(i, progress, rotation);
 
-      ar << progress << rotation;
+        ar << progress << rotation;
+      }
     }
   }
+  else
+  {
+    ar << 0;
+  }
 
   ar.CloseChunk(); // EANI
   return ar;
index eabda31..f7011e9 100644 (file)
@@ -55,15 +55,21 @@ TextVertexBuffer* GlyphAtlasManager::TextRequired( const Integration::TextArray&
   GlyphAtlas* atlas  = FindAtlas( text, format, fontId, bestRank);
 
   DALI_ASSERT_DEBUG( atlas && "Find atlas should always return a valid atlas." );
+  if( atlas )
+  {
+    // if the atlas is full, create a new larger one
+    if( bestRank.GetSpaceStatus() == AtlasRanking::FULL_CAN_BE_RESIZED )
+    {
+      atlas = CreateLargerAtlas( atlas );
+    }
 
-  // if the atlas is full, create a new larger one
-  if( bestRank.GetSpaceStatus() == AtlasRanking::FULL_CAN_BE_RESIZED )
+    // assign the text to it
+    return atlas->AssignText( text, format, fontId, metrics );
+  }
+  else
   {
-    atlas = CreateLargerAtlas( atlas );
+    return NULL;
   }
-
-  // assign the text to it
-  return atlas->AssignText( text, format, fontId, metrics );
 }
 
 void GlyphAtlasManager::TextNotRequired( const Integration::TextArray& text,
index 4af96fd..14aed15 100644 (file)
@@ -35,6 +35,7 @@ const float POINT_TO_INCHES( 1.f / INCH_TO_POINTS );
 }
 
 FontLayout::FontLayout()
+  :mUnitsPerEM(0.0f)
 {
 }
 
index 5c98e29..ea8c65e 100644 (file)
@@ -26,6 +26,12 @@ namespace Internal
 
 using Integration::TextResourceType;
 
+GlyphResourceRequest::GlyphResourceRequest()
+:mFontId( 0 ),
+ mQuality( LOW_QUALITY )
+{
+
+}
 
 GlyphResourceRequest::GlyphResourceRequest( FontId fontId, GlyphQuality quality )
 :mFontId( fontId ),
index a0d0c10..3b01f7c 100644 (file)
@@ -102,9 +102,7 @@ private:
   /**
    * constructor
    */
-  GlyphResourceRequest()
-  {
-  }
+  GlyphResourceRequest();
 
   FontId mFontId;                  ///< font id
   GlyphQuality mQuality;           ///< quality
index e0de39d..692a102 100644 (file)
@@ -99,11 +99,13 @@ TextVertexBuffer* TextRequestHelper::TextRequired( const TextFormat& format )
 
     // get the vertex buffer required to display the text
     TextVertexBuffer* buffer =  mFont->TextRequired( mText, format );
+    if( buffer )
+    {
+      // keep track of the texture id, ( texture id == atlas id)
+      mTextureId = buffer->mTextureId;
 
-    // keep track of the texture id, ( texture id == atlas id)
-    mTextureId = buffer->mTextureId;
-
-    return buffer;
+      return buffer;
+    }
   }
   else if( 0u == mText.Count()  )
   {
index 641441f..eb84e29 100644 (file)
@@ -93,6 +93,8 @@ struct RenderManager::Impl
     resourcePostProcessQueue( resourcePostProcessQ ),
     instructions(),
     backgroundColor( Dali::Stage::DEFAULT_BACKGROUND_COLOR ),
+    frameTime( 0.0f ),
+    lastFrameTime( 0.0f ),
     frameCount( 0 ),
     renderBufferIndex( SceneGraphBuffers::INITIAL_UPDATE_BUFFER_INDEX ),
     defaultSurfaceRect(),
index f664268..8aaa865 100644 (file)
@@ -105,7 +105,10 @@ Context::Context(Integration::GlAbstraction& glAbstraction)
   mClearColor(Color::WHITE),    // initial color, never used until it's been set by the user
   mCullFaceMode(CullNone),
   mViewPort( 0, 0, 0, 0 ),
-  mCurrentProgram( NULL )
+  mCurrentProgram( NULL ),
+  mFrameCount( 0 ),
+  mCulledCount( 0 ),
+  mRendererCount( 0 )
 {
 }
 
index ba1a682..618c01e 100644 (file)
@@ -32,7 +32,8 @@ namespace SceneGraph
 {
 
 RenderTaskList::RenderTaskList(CompleteStatusManager& completeStatusManager)
-: mCompleteStatusManager( completeStatusManager )
+: mNotificationObject( NULL ),
+  mCompleteStatusManager( completeStatusManager )
 {
 }
 
index c56833a..65e4f8c 100644 (file)
@@ -105,7 +105,8 @@ struct ResourceManager::ResourceManagerImpl
     mPostProcessResourceDispatcher(postProcessResourceDispatcher),
     mDiscardQueue(discardQueue),
     mRenderQueue(renderQueue),
-    mNotificationCount(0)
+    mNotificationCount(0),
+    cacheUpdated(false)
   {
   }
 
index 88109f2..b080a33 100644 (file)
@@ -71,23 +71,26 @@ std::string Demangle(const char* symbol)
 
       // Allocate space for symbol
       char *mangledSymbol = (char*)malloc(tokenLength+1u);
-      strncpy(mangledSymbol, startOfToken, tokenLength);
-      mangledSymbol[tokenLength] = '\0';
-
-      size_t size;
-      int    status;
-      char*  demangled=NULL;
-      demangled = abi::__cxa_demangle( mangledSymbol, NULL, &size, &status );
-      if( demangled != NULL )
+      if(mangledSymbol != NULL)
       {
-        result = demangled;
-        free(demangled); // demangle() allocates returned string, so free it
+        strncpy(mangledSymbol, startOfToken, tokenLength);
+        mangledSymbol[tokenLength] = '\0';
+
+        size_t size;
+        int    status;
+        char*  demangled=NULL;
+        demangled = abi::__cxa_demangle( mangledSymbol, NULL, &size, &status );
+        if( demangled != NULL )
+        {
+          result = demangled;
+          free(demangled); // demangle() allocates returned string, so free it
+        }
+        else
+        {
+          result = symbol;
+        }
+        free(mangledSymbol);
       }
-      else
-      {
-        result = symbol;
-      }
-      free(mangledSymbol);
     }
   }
 
index f88946e..1919e79 100644 (file)
@@ -35,6 +35,7 @@ KeyEvent::KeyEvent()
   keyPressed(""),
   keyCode(KEY_INVALID_CODE),
   keyModifier(0),
+  time(0),
   state(KeyEvent::Down)
 {
 }
index fc89a4a..d9fc27c 100644 (file)
@@ -96,7 +96,7 @@ void DistanceTransform( float *source, float* dest, unsigned int length )
     const float initialDistance( source[i] + SQUARE( i ) );
     int parabola = parabolas[rightmost];
     float newDistance( (initialDistance - (source[parabola] + SQUARE( parabola ))) / (2 * i - 2 * parabola) );
-    while( newDistance <= edge[rightmost] )
+    while( rightmost > 0 && newDistance <= edge[rightmost] )
     {
       rightmost--;
       parabola = parabolas[rightmost];
index 6965864..ca9044d 100644 (file)
@@ -82,7 +82,8 @@ void CallbackBase::Reset()
 
 CallbackBase::Impl::Impl()
 : mObjectPointer( NULL ),
-  mMemberFunctionDispatcher( NULL )
+  mMemberFunctionDispatcher( NULL ),
+  mDestructorDispatcher( NULL )
 {
 }