Home | History | Annotate | Download | only in debugger
      1 
      2 /*
      3  * Copyright 2012 Google Inc.
      4  *
      5  * Use of this source code is governed by a BSD-style license that can be
      6  * found in the LICENSE file.
      7  */
      8 
      9 
     10 #ifndef SKDEBUGGER_H_
     11 #define SKDEBUGGER_H_
     12 
     13 #include "SkDebugCanvas.h"
     14 #include "SkPicture.h"
     15 #include "SkTArray.h"
     16 
     17 class SkString;
     18 
     19 class SkDebugger {
     20 public:
     21     SkDebugger();
     22 
     23     ~SkDebugger();
     24 
     25     void setIndex(int index) {
     26         fIndex = index;
     27     }
     28     void draw(SkCanvas* canvas) {
     29         if (fIndex > 0) {
     30             fDebugCanvas->drawTo(canvas, fIndex);
     31         }
     32     }
     33 
     34     void step();
     35     void stepBack();
     36     void play();
     37     void rewind();
     38 
     39     bool isCommandVisible(int index) {
     40         return fDebugCanvas->getDrawCommandVisibilityAt(index);
     41     }
     42 
     43     void setCommandVisible(int index, bool isVisible) {
     44         fDebugCanvas->toggleCommand(index, isVisible);
     45     }
     46 
     47     SkTArray<SkString>* getDrawCommandsAsStrings() {
     48         return fDebugCanvas->getDrawCommandsAsStrings();
     49     }
     50 
     51     SkTDArray<size_t>* getDrawCommandOffsets() {
     52         return fDebugCanvas->getDrawCommandOffsets();
     53     }
     54 
     55     const SkTDArray<SkDrawCommand*>& getDrawCommands() const {
     56         return fDebugCanvas->getDrawCommands();
     57     }
     58 
     59     void highlightCurrentCommand(bool on) {
     60         fDebugCanvas->toggleFilter(on);
     61     }
     62 
     63     void setWindowSize(int width, int height) { fDebugCanvas->setWindowSize(width, height); }
     64 
     65     void loadPicture(SkPicture* picture);
     66 
     67     SkPicture* copyPicture();
     68 
     69     int getSize() {
     70         return fDebugCanvas->getSize();
     71     }
     72 
     73     void setUserMatrix(SkMatrix userMatrix) {
     74         // Should this live in debugger instead?
     75         fDebugCanvas->setUserMatrix(userMatrix);
     76     }
     77 
     78     int getCommandAtPoint(int x, int y, int index) {
     79         return fDebugCanvas->getCommandAtPoint(x, y, index);
     80     }
     81 
     82     SkTDArray<SkString*>* getCommandInfo(int index) {
     83         return fDebugCanvas->getCommandInfo(index);
     84     }
     85 
     86     const SkMatrix& getCurrentMatrix() {
     87         return fDebugCanvas->getCurrentMatrix();
     88     }
     89 
     90     const SkIRect& getCurrentClip() {
     91         return fDebugCanvas->getCurrentClip();
     92     }
     93 
     94     SkRect pictureCull() const   {
     95         return NULL == fPicture ? SkRect::MakeEmpty() : fPicture->cullRect();
     96     }
     97 
     98     int index() {
     99         return fIndex;
    100     }
    101 
    102     void setOverdrawViz(bool overDrawViz) {
    103         if (fDebugCanvas) {
    104             fDebugCanvas->setOverdrawViz(overDrawViz);
    105         }
    106     }
    107 
    108     void setPathOps(bool pathOps) {
    109         if (fDebugCanvas) {
    110             fDebugCanvas->setAllowSimplifyClip(pathOps);
    111         }
    112     }
    113 
    114     void setMegaViz(bool megaViz) {
    115         if (fDebugCanvas) {
    116             fDebugCanvas->setMegaVizMode(megaViz);
    117         }
    118     }
    119 
    120     void setTexFilterOverride(bool texFilterOverride, SkPaint::FilterLevel level) {
    121         if (fDebugCanvas) {
    122             fDebugCanvas->overrideTexFiltering(texFilterOverride, level);
    123         }
    124     }
    125 
    126     void getOverviewText(const SkTDArray<double>* typeTimes, double totTime,
    127                          SkString* overview, int numRuns);
    128 
    129     void getClipStackText(SkString* clipStack);
    130 
    131 private:
    132     SkDebugCanvas* fDebugCanvas;
    133     SkPicture* fPicture;
    134 
    135     int fIndex;
    136 };
    137 
    138 
    139 #endif /* SKDEBUGGER_H_ */
    140