Merge "More Text related logging & clean-up" into tizen
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 5 May 2015 14:24:48 +0000 (07:24 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Tue, 5 May 2015 14:24:48 +0000 (07:24 -0700)
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/text/character-set-conversion.cpp
dali-toolkit/internal/text/character-set-conversion.h
dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp
dali-toolkit/internal/text/rendering/basic/text-basic-renderer.cpp
dali-toolkit/internal/text/segmentation.cpp
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/text-controller.cpp

index abefb7f..ec6f12d 100644 (file)
@@ -987,7 +987,7 @@ bool TextField::OnKeyEvent( const KeyEvent& event )
 
 ImfManager::ImfCallbackData TextField::OnImfEvent( Dali::ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
 {
-  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnImfEvent %p eventName %d\n", imfEvent.eventName );
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnImfEvent %p eventName %d\n", mController.Get(), imfEvent.eventName );
 
   bool update( false );
 
@@ -1080,7 +1080,7 @@ void TextField::EnableClipping( bool clipping, const Vector2& size )
 
 void TextField::KeyboardStatusChanged(bool keyboardShown)
 {
-  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::KeyboardStatusChanged %p keyboardShown %d\n", keyboardShown );
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::KeyboardStatusChanged %p keyboardShown %d\n", mController.Get(), keyboardShown );
 
   // Just hide the grab handle when keyboard is hidden.
   if (!keyboardShown )
index 3afecbb..b1b9993 100644 (file)
@@ -211,6 +211,17 @@ uint32_t Utf32ToUtf8( const uint32_t* const utf32, uint32_t numberOfCharacters,
   return utf8 - utf8Begin;
 }
 
+void Utf32ToUtf8( const uint32_t* const utf32, uint32_t numberOfCharacters, std::string& utf8 )
+{
+  utf8.clear();
+
+  uint32_t numberOfBytes = GetNumberOfUtf8Bytes( &utf32[0], numberOfCharacters );
+  utf8.resize( numberOfBytes );
+
+  // This is a bit horrible but std::string returns a (signed) char*
+  Utf32ToUtf8( utf32, numberOfCharacters, reinterpret_cast<uint8_t*>(&utf8[0]) );
+}
+
 } // namespace Toolkit
 
 } // namespace Dali
index 7a62498..19784fb 100644 (file)
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <stdint.h>
+#include <string>
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-common.h>
@@ -76,6 +77,15 @@ uint32_t Utf8ToUtf32( const uint8_t* const utf8, uint32_t length, uint32_t* utf3
  */
 uint32_t Utf32ToUtf8( const uint32_t* const utf32, uint32_t numberOfCharacters, uint8_t* utf8 );
 
+/**
+ * @brief Converts a text array encoded in UTF32 into a text array encoded in UTF8.
+ *
+ * @param[in] utf32 The pointer to the UTF32 array.
+ * @param[in] numberOfCharacters The number of characters of the UTF32 array.
+ * @param[out] utf8 The UTF8 characters will be stored here.
+ */
+void Utf32ToUtf8( const uint32_t* const utf32, uint32_t numberOfCharacters, std::string& utf8 );
+
 } // namespace Toolkit
 
 } // namespace Dali
index 6453f9a..9e8a3fa 100644 (file)
@@ -29,9 +29,6 @@
 #include <dali-toolkit/internal/text/rendering/shaders/text-basic-shader.h>
 #include <dali-toolkit/internal/text/rendering/shaders/text-bgra-shader.h>
 #include <dali-toolkit/internal/text/rendering/shaders/text-basic-shadow-shader.h>
-#if defined(DEBUG_ENABLED)
-Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_ATLAS_RENDERER");
-#endif
 
 using namespace Dali;
 using namespace Dali::Toolkit;
@@ -39,6 +36,10 @@ using namespace Dali::Toolkit::Text;
 
 namespace
 {
+#if defined(DEBUG_ENABLED)
+  Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_RENDERING");
+#endif
+
   const float ZERO( 0.0f );
   const float HALF( 0.5f );
   const float ONE( 1.0f );
@@ -684,6 +685,8 @@ struct AtlasRenderer::Impl : public ConnectionTracker
 
 Text::RendererPtr AtlasRenderer::New()
 {
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Text::AtlasRenderer::New()\n" );
+
   return Text::RendererPtr( new AtlasRenderer() );
 }
 
index dc6ec3e..68ba70c 100644 (file)
 // CLASS HEADER
 #include <dali-toolkit/internal/text/rendering/basic/text-basic-renderer.h>
 
-// INTERNAL INCLUDES
+// EXTERNAL INCLUDES
 #include <dali/public-api/text-abstraction/font-client.h>
 #include <dali/public-api/actors/image-actor.h>
 #include <dali/public-api/actors/mesh-actor.h>
 #include <dali/public-api/images/atlas.h>
 #include <dali/public-api/geometry/mesh.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/rendering/shaders/text-basic-shader.h>
 #include <dali-toolkit/internal/text/rendering/shaders/text-bgra-shader.h>
 
@@ -35,6 +38,10 @@ using namespace Dali::Toolkit::Text;
 namespace
 {
 
+#if defined(DEBUG_ENABLED)
+  Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_RENDERING");
+#endif
+
 const std::size_t PADDING = 2; //< To avoid GL filtering artefacts
 
 struct TextureCoordinates
@@ -330,6 +337,8 @@ struct BasicRenderer::Impl
 
 Text::RendererPtr BasicRenderer::New()
 {
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Text::BasicRenderer::New()\n" );
+
   return Text::RendererPtr( new BasicRenderer() );
 }
 
index efac834..d89a935 100644 (file)
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/text-abstraction/segmentation.h>
+#ifdef DEBUG_ENABLED
+#include <string>
+#include <dali/integration-api/debug.h>
+#endif
+
+// INTERNAL INCLUDES
+#ifdef DEBUG_ENABLED
+#include <dali-toolkit/internal/text/character-set-conversion.h>
+#endif
+
+namespace
+{
+
+#if defined(DEBUG_ENABLED)
+  Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_SEGMENTATION");
+#endif
+
+} // namespace
+
 
 namespace Dali
 {
@@ -46,6 +65,23 @@ void SetLineBreakInfo( const Vector<Character>& text,
   TextAbstraction::Segmentation::Get().GetLineBreakPositions( text.Begin(),
                                                               numberOfCharacters,
                                                               lineBreakInfo.Begin() );
+#ifdef DEBUG_ENABLED
+  if( gLogFilter->IsEnabledFor(Debug::Verbose) )
+  {
+    std::string utf8;
+    Utf32ToUtf8( text.Begin(), numberOfCharacters, utf8 );
+
+    std::string info;
+    info.reserve( numberOfCharacters );
+    for( unsigned int i=0; i<lineBreakInfo.Count(); ++i )
+    {
+      info.push_back( static_cast<char>('0' + lineBreakInfo[i]) );
+    }
+
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SetLineBreakInfo Characters: %s\n", utf8.c_str() );
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SetLineBreakInfo Break info: %s\n", info.c_str() );
+  }
+#endif
 }
 
 void ReplaceLineBreakInfo( LogicalModel& model,
@@ -71,6 +107,23 @@ void SetWordBreakInfo( const Vector<Character>& text,
   TextAbstraction::Segmentation::Get().GetWordBreakPositions( text.Begin(),
                                                               numberOfCharacters,
                                                               wordBreakInfo.Begin() );
+#ifdef DEBUG_ENABLED
+  if( gLogFilter->IsEnabledFor(Debug::Verbose) )
+  {
+    std::string utf8;
+    Utf32ToUtf8( text.Begin(), numberOfCharacters, utf8 );
+
+    std::string info;
+    info.reserve( numberOfCharacters );
+    for( unsigned int i=0; i<wordBreakInfo.Count(); ++i )
+    {
+      info.push_back( static_cast<char>('0' + wordBreakInfo[i]) );
+    }
+
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SetWordBreakInfo Characters: %s\n", utf8.c_str() );
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SetWordBreakInfo Break info: %s\n", info.c_str() );
+  }
+#endif
 }
 
 void ReplaceWordBreakInfo( LogicalModel& model,
index 00c666e..c50b753 100644 (file)
@@ -245,7 +245,7 @@ void Controller::Impl::UpdateModel( OperationsMask operationsRequired )
 
   Vector<Character>& utf32Characters = mLogicalModel->mText;
 
-  const Length numberOfCharacters = mLogicalModel->GetNumberOfCharacters();
+  const Length numberOfCharacters = utf32Characters.Count();
 
   Vector<LineBreakInfo>& lineBreakInfo = mLogicalModel->mLineBreakInfo;
   if( GET_LINE_BREAKS & operations )
index 99bed83..61ca6e0 100644 (file)
@@ -128,12 +128,7 @@ void Controller::GetText( std::string& text ) const
 
     if( 0u != utf32Characters.Count() )
     {
-      uint32_t numberOfBytes = GetNumberOfUtf8Bytes( &utf32Characters[0], utf32Characters.Count() );
-
-      text.resize( numberOfBytes );
-
-      // This is a bit horrible but std::string returns a (signed) char*
-      Utf32ToUtf8( &utf32Characters[0], utf32Characters.Count(), reinterpret_cast<uint8_t*>(&text[0]) );
+      Utf32ToUtf8( &utf32Characters[0], utf32Characters.Count(), text );
     }
   }
   else
@@ -464,6 +459,8 @@ Vector3 Controller::GetNaturalSize()
 
   if( mImpl->mRecalculateNaturalSize )
   {
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::GetNaturalSize\n" );
+
     // Operations that can be done only once until the text changes.
     const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32  |
                                                                            GET_SCRIPTS       |
@@ -497,10 +494,14 @@ Vector3 Controller::GetNaturalSize()
     mImpl->mVisualModel->SetNaturalSize( naturalSize.GetVectorXY() );
 
     mImpl->mRecalculateNaturalSize = false;
+
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize calculated %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
   }
   else
   {
     naturalSize = mImpl->mVisualModel->GetNaturalSize();
+
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::GetNaturalSize cached %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
   }
 
   return naturalSize;
@@ -552,7 +553,7 @@ float Controller::GetHeightForWidth( float width )
 
 bool Controller::Relayout( const Size& size )
 {
-  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::Relayout %p --> size %f,%f\n", this, size.width, size.height );
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::Relayout %p size %f,%f\n", this, size.width, size.height );
 
   if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) )
   {
@@ -563,7 +564,7 @@ bool Controller::Relayout( const Size& size )
       glyphsRemoved = true;
     }
     // Not worth to relayout if width or height is equal to zero.
-    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::Relayout <-- (skipped)\n" );
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::Relayout (skipped)\n" );
     return glyphsRemoved;
   }
 
@@ -602,7 +603,7 @@ bool Controller::Relayout( const Size& size )
     updated = mImpl->ProcessInputEvents() || updated;
   }
 
-  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::Relayout <--\n" );
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::Relayout\n" );
   return updated;
 }