skia2/experimental/CocoaDebugger/SkDebuggerViews.h
yangsu@google.com a8a42e20f0 Added CocoaDebugger to experimental
git-svn-id: http://skia.googlecode.com/svn/trunk@1622 2bbb7eff-a529-9590-31e7-b0007b416f81
2011-06-16 20:49:55 +00:00

115 lines
2.5 KiB
C++

#include "SkView.h"
#include "SkColor.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkGPipe.h"
#include "SkPaint.h"
#include "SkDebugDumper.h"
#include <deque>
#define SkDebugger_TextSize 14
#define SkDebugger_CommandType "SkDebugger_Command"
#define SkDebugger_StateType "SkDebugger_State"
#define SkDebugger_Atom "SkDebugger_Atom"
#define SkDebugger_Matrix "SkDebugger_Matrix"
#define SkDebugger_Clip "SkDebugger_Clip"
#define SkDebugger_PaintInfo "SkDebugger_PaintInfo"
#define SkDebugger_Paint "SkDebugger_Paint"
/*
* Debugger - Main Content
*/
class SkContentView : public SkView {
public:
SkContentView(SkEventSinkID clID, SkEventSinkID ipID);
~SkContentView();
void init();
void reinit(const char* fileName);
void toggleClip();
void goToAtom(int atom);
protected:
virtual bool onEvent(const SkEvent& evt);
virtual void onDraw(SkCanvas* canvas);
private:
SkColor fBGColor;
int fAtomsToRead;
std::deque<int> fAtomBounds;
std::deque<int> fFrameBounds;
bool fDisplayClip;
SkString fFilePath;
SkDebugDumper fDumper;
typedef SkView INHERITED;
};
/*
* Debugger - Info Panel
*/
class SkInfoPanelView : public SkView {
public:
SkInfoPanelView();
protected:
virtual bool onEvent(const SkEvent& evt);
virtual void onDraw(SkCanvas* canvas);
private:
SkColor fBGColor;
SkPaint fPaint;
SkString fMatrix;
SkString fPaintInfo;
SkString fClip;
typedef SkView INHERITED;
};
/*
* Debugger - Commands List
*/
class SkCommandListView : public SkView {
public:
SkCommandListView();
void reinit();
int nextItem();
int prevItem();
int scrollUp();
int scrollDown();
void highlight(int index);
int selectHighlight(int ypos);
void toggleCentered();
protected:
virtual bool onEvent(const SkEvent& evt);
virtual void onSizeChange();
virtual void onDraw(SkCanvas* canvas);
private:
void init();
void alignCenter();
SkColor fBGColor;
int fTopIndex;
int fHighlight;
SkScalar fSpacing;
int fRange;
bool fCentered;
std::deque<SkString> fList;
typedef SkView INHERITED;
};
static void* PaintProc(void* ptr, bool doRef) {
SkPaint* p = (SkPaint*) ptr;
if (doRef) {
return new SkPaint(*p);
}
else {
delete p;
return NULL;
}
}