Add DALI_LOG_RELEASE_INFO for debug
[platform/core/uifw/dali-core.git] / dali / integration-api / debug.h
index 696b611..8e59859 100644 (file)
@@ -1,25 +1,30 @@
 #ifndef __DALI_INTEGRATION_DEBUG_H__
 #define __DALI_INTEGRATION_DEBUG_H__
 
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.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://floralicense.org/license/
-//
-// 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.
-//
+/*
+ * Copyright (c) 2014 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.
+ *
+ */
 
 // EXTERNAL INCLUDES
 #include <string>
+#include <sstream>
 #include <list>
+#include <stdint.h>
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/object/property-map.h>
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-common.h>
@@ -38,17 +43,31 @@ class Matrix3;
 class Matrix;
 class Quaternion;
 
+#if defined(DEBUG_ENABLED)
+
+// Less opaque types for debugger
+typedef std::vector<Dali::Property::Value> DebugPropertyValueArray;
+typedef std::pair< Property::Index, Property::Value > DebugIndexValuePair;
+typedef std::vector<Dali::StringValuePair> DebugStringValueContainer;
+typedef std::vector< DebugIndexValuePair > DebugIndexValueContainer;
+
+struct DebugPropertyValueMap
+{
+  DebugStringValueContainer stringValues;
+  DebugIndexValueContainer  intValues;
+};
+
+// Fake globals for gdb typedefs
+extern Dali::DebugPropertyValueArray gValueArray;
+extern Dali::DebugPropertyValueMap   gValueMap;
+
+#endif
+
 namespace Integration
 {
 namespace Log
 {
 
-// environment variable for enabling/disabling fps tracking
-#define DALI_ENV_FPS_TRACKING "DALI_FPS_TRACKING"
-
-// environment variable for enabling/disabling fps tracking
-#define DALI_ENV_UPDATE_STATUS_INTERVAL "DALI_UPDATE_STATUS_INTERVAL"
-
 enum DebugPriority
 {
   DebugInfo,
@@ -94,6 +113,8 @@ DALI_IMPORT_API void UninstallLogFunction();
 
 #define DALI_LOG_ERROR_NOFN(format, args...)     Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugError, format, ## args)
 
+#define DALI_LOG_WARNING_NOFN(format, args...)     Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugWarning, format, ## args)
+
 /**
  * Provides unfiltered logging for fps monitor
  */
@@ -109,6 +130,11 @@ DALI_IMPORT_API void UninstallLogFunction();
  */
 #define DALI_LOG_RENDER_INFO(format, args...)     Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ## args)
 
+/**
+ * Provides unfiltered logging for release
+ */
+#define DALI_LOG_RELEASE_INFO(format, args...)     Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ## args)
+
 #ifdef DEBUG_ENABLED
 
 /**
@@ -255,7 +281,6 @@ public:
   static Filter *gElement;
   static Filter *gActor;
   static Filter *gShader;
-  static Filter *gDynamics;
 
 private:
   LogLevel mLoggingLevel;
@@ -350,6 +375,19 @@ public: \
   std::string mDebugString;
 
 /**
+ * Print all the actor tree names
+ **/
+#define DALI_LOG_ACTOR_TREE( node ) { \
+  std::stringstream branch; \
+  Node* tempNode = node; \
+  while( tempNode ) { \
+    branch << "<" << tempNode->mDebugString << ">::"; \
+    tempNode = tempNode->GetParent(); \
+  } \
+  DALI_LOG_ERROR_NOFN("Actor tree: %s\n", branch.str().c_str()); \
+}
+
+/**
  * Allows one object to set another object's debug string
  */
 #define DALI_LOG_SET_OBJECT_STRING(object, string) (object->mDebugString = string)
@@ -378,6 +416,7 @@ public: \
 #else // DEBUG_ENABLED
 
 #define DALI_LOG_OBJECT_STRING_DECLARATION
+#define DALI_LOG_ACTOR_TREE(node)
 #define DALI_LOG_SET_OBJECT_STRING(object, string)
 #define DALI_LOG_FMT_OBJECT_STRING(object, fmt, args...)
 #define DALI_LOG_GET_OBJECT_STRING(object)
@@ -474,7 +513,33 @@ DALI_IMPORT_API std::string MatrixToString(const Matrix& m, size_t precision=3,
 
 #endif
 
-}}} // Dali/Integration/Debug namespaces
+/********************************************************************************
+ *                            Time instrumentation                              *
+ ********************************************************************************/
+
+#if defined(DEBUG_ENABLED)
+
+void GetNanoseconds( uint64_t& timeInNanoseconds );
+
+#define DALI_LOG_TIMER_START( timeVariable )      \
+  uint64_t timeVariable##1; \
+  Debug::GetNanoseconds( timeVariable##1 );
+
+#define DALI_LOG_TIMER_END( timeVariable, filter, level, preString)  \
+  uint64_t timeVariable##2; \
+  Debug::GetNanoseconds( timeVariable##2 );                             \
+  DALI_LOG_INFO( filter, level, preString " %ld uSec\n", ((timeVariable##2-timeVariable##1)/1000));
+
+#else // DEBUG_ENABLED
+
+#define DALI_LOG_TIMER_START( timeVariable )
+#define DALI_LOG_TIMER_END( timeVariable, filter, level, preString)
+
+#endif
+
+} // Debug
+} // Integration
+} // Dali
 
 
 #endif // __DALI_INTEGRATION_DEBUG_H__