David's final changes: more profiler features, fixes.
[ipdf/code.git] / src / debugscript.cpp
index 2784406..434743d 100644 (file)
@@ -1,4 +1,5 @@
 #include "debugscript.h"
+#include "profiler.h"
 
 #include <string>
 
@@ -185,6 +186,16 @@ void DebugScript::ParseAction(View * view, Screen * scr)
        {
                currentAction.type = AT_PrintBounds;
        }
+       else if (actionType == "profileon")
+       {
+               currentAction.type = AT_ProfileDisplay;
+               currentAction.iz = 1;
+       }
+       else if (actionType == "profileoff")
+       {
+               currentAction.type = AT_ProfileDisplay;
+               currentAction.iz = 0;
+       }
        else
                Fatal("Unknown action %s", actionType.c_str());
 
@@ -240,12 +251,21 @@ bool DebugScript::Execute(View *view, Screen *scr)
                break;
        case AT_LoadSVG:
        {
+#ifndef QUADTREE_DISABLED
+               view->Doc().SetQuadtreeInsertNode(view->GetCurrentQuadtreeNode());
+#endif
                #ifdef TRANSFORM_OBJECTS_NOT_VIEW
                        view->Doc().LoadSVG(currentAction.textargs, Rect(Real(1)/Real(2),Real(1)/Real(2),Real(1)/Real(800),Real(1)/Real(600))); 
                #else
                        const Rect & bounds = view->GetBounds();
                        view->Doc().LoadSVG(currentAction.textargs, Rect(bounds.x+bounds.w/Real(2),bounds.y+bounds.h/Real(2),bounds.w/Real(800),bounds.h/Real(600)));
                #endif
+#ifndef QUADTREE_DISABLED
+               view->Doc().PropagateQuadChanges(view->GetCurrentQuadtreeNode());
+               view->Doc().PropagateQuadChanges(view->Doc().GetQuadTree().GetNeighbour(view->GetCurrentQuadtreeNode(), 0, 1, 0));
+               view->Doc().PropagateQuadChanges(view->Doc().GetQuadTree().GetNeighbour(view->GetCurrentQuadtreeNode(), 1, 0, 0));
+               view->Doc().PropagateQuadChanges(view->Doc().GetQuadTree().GetNeighbour(view->GetCurrentQuadtreeNode(), 1, 1, 0));
+#endif
                currentAction.type = AT_WaitFrame;
                view->ForceRenderDirty();
                view->ForceBufferDirty();
@@ -401,6 +421,11 @@ bool DebugScript::Execute(View *view, Screen *scr)
                printf("%s\t%s\t%s\t%s\t%s\t%s\n", Str(view->GetBounds().x).c_str(), Str(view->GetBounds().y).c_str(), Str(view->GetBounds().w).c_str(), Str(view->GetBounds().h).c_str(), Str(Log10(view->GetBounds().w)).c_str(), Str(Log10(view->GetBounds().h)).c_str());
                break;
        }
+       case AT_ProfileDisplay:
+       {
+               g_profiler.Enable(currentAction.iz);
+               break;
+       }
        default:
                Fatal("Unknown script command in queue.");
        }
@@ -424,14 +449,15 @@ void DebugScript::PrintPerformance(View * view, Screen * scr)
        now.view_bounds = view->GetBounds();
 
        // object_count  clock  delta_clock  x  Log10(x)  y  Log10(y)  w  Log10(w)  Size(w)
-       #ifdef QUADTREE_DISABLED
+       //#ifdef QUADTREE_DISABLED
        printf("%d\t%llu\t%llu\t%s\t%s\t%s\t%s\t%s\t%s\t%u\n",
                now.object_count, (long long unsigned)now.clock,
                (long long unsigned)(now.clock - m_perf_last.clock),
-               Str(now.view_bounds.x).c_str(), Str(Log10(Abs(now.view_bounds.x))).c_str(),
+               "", "", "", "", "", "", 0);
+               /*Str(now.view_bounds.x).c_str(), Str(Log10(Abs(now.view_bounds.x))).c_str(),
                Str(now.view_bounds.y).c_str(), Str(Log10(Abs(now.view_bounds.y))).c_str(),
                Str(now.view_bounds.w).c_str(), Str(Log10(now.view_bounds.w)).c_str(),
-               (unsigned)Size(now.view_bounds.w));
-       #endif
+               (unsigned)Size(now.view_bounds.w));*/
+       //#endif
        m_perf_last = now;
 }

UCC git Repository :: git.ucc.asn.au