SkDebugger.h revision e8cc6e8071935339a06548b13a0668b56a7540f5
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 17class SkDebugger { 18public: 19 SkDebugger(); 20 21 ~SkDebugger(); 22 23 void setIndex(int index) { 24 fIndex = index; 25 } 26 void draw(SkCanvas* canvas) { 27 if (fIndex > 0) { 28 fDebugCanvas->drawTo(canvas, fIndex); 29 } 30 } 31 32 void step(); 33 void stepBack(); 34 void play(); 35 void rewind(); 36 37 bool isCommandVisible(int index) { 38 return fDebugCanvas->getDrawCommandVisibilityAt(index); 39 } 40 41 void setCommandVisible(int index, bool isVisible) { 42 fDebugCanvas->toggleCommand(index, isVisible); 43 } 44 45 SkTArray<SkString>* getDrawCommandsAsStrings() { 46 return fDebugCanvas->getDrawCommandsAsStrings(); 47 } 48 49 const SkTDArray<SkDrawCommand*>& getDrawCommands() const { 50 return fDebugCanvas->getDrawCommands(); 51 } 52 53 void highlightCurrentCommand(bool on) { 54 fDebugCanvas->toggleFilter(on); 55 } 56 57 void resize(int width, int height) { 58 fDebugCanvas->setBounds(width, height); 59 } 60 61 void loadPicture(SkPicture* picture); 62 63 SkPicture* makePicture(); 64 65 int getSize() { 66 return fDebugCanvas->getSize(); 67 } 68 69 void setUserMatrix(SkMatrix userMatrix) { 70 // Should this live in debugger instead? 71 fDebugCanvas->setUserMatrix(userMatrix); 72 } 73 74 int getCommandAtPoint(int x, int y, int index) { 75 return fDebugCanvas->getCommandAtPoint(x, y, index); 76 } 77 78 SkTDArray<SkString*>* getCommandInfo(int index) { 79 return fDebugCanvas->getCommandInfo(index); 80 } 81 82 const SkMatrix& getCurrentMatrix() { 83 return fDebugCanvas->getCurrentMatrix(); 84 } 85 86 const SkIRect& getCurrentClip() { 87 return fDebugCanvas->getCurrentClip(); 88 } 89 90 int pictureHeight() { 91 return fPictureHeight; 92 } 93 94 int pictureWidth() { 95 return fPictureWidth; 96 } 97 98 int index() { 99 return fIndex; 100 } 101 102private: 103 SkDebugCanvas* fDebugCanvas; 104 SkPicture* fPicture; 105 106 int fPictureWidth; 107 int fPictureHeight; 108 int fIndex; 109}; 110 111 112#endif /* SKDEBUGGER_H_ */ 113