yangsu@google.com | ef7bdfa | 2011-08-12 14:27:47 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2011 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 | #include "SkView.h" |
| 9 | #include "SkColor.h" |
| 10 | #include "SkBitmap.h" |
| 11 | #include "SkCanvas.h" |
| 12 | #include "SkGPipe.h" |
| 13 | #include "SkPaint.h" |
| 14 | |
| 15 | #include "SkDebugDumper.h" |
| 16 | |
| 17 | #define SKDEBUGGER_COMMANDTYPE "SKDEBUGGER_COMMAND" |
| 18 | #define SKDEBUGGER_STATETYPE "SKDEBUGGER_STATE" |
| 19 | |
| 20 | #define SKDEBUGGER_ATOM "SKDEBUGGER_ATOM" |
| 21 | #define SKDEBUGGER_MATRIX "SKDEBUGGER_MATRIX" |
| 22 | #define SKDEBUGGER_CLIP "SKDEBUGGER_CLIP" |
| 23 | #define SKDEBUGGER_PAINTINFO "SKDEBUGGER_PAINTINFO" |
| 24 | #define SKDEBUGGER_PAINT "SKDEBUGGER_PAINT" |
| 25 | |
| 26 | #define SKDEBUGGER_TEXTSIZE 14 |
| 27 | #define CMD_WIDTH 200 |
| 28 | #define INFO_HEIGHT 150.0 |
| 29 | #define SKDEBUGGER_HIGHLIGHTCOLOR 0xFF113399 |
| 30 | #define SKDEBUGGER_TEXTCOLOR 0xFF000000 |
| 31 | #define SKDEBUGGER_RESIZEBARCOLOR 0xFF333333 |
| 32 | #define SKDEBUGGER_RESIZEBARSIZE 5 |
| 33 | |
| 34 | /* |
| 35 | * Debugger - Info Panel |
| 36 | */ |
| 37 | class DebuggerStateView : public SkView { |
| 38 | public: |
| 39 | DebuggerStateView(); |
| 40 | |
| 41 | protected: |
| 42 | virtual bool onEvent(const SkEvent& evt); |
| 43 | virtual void onDraw(SkCanvas* canvas); |
| 44 | private: |
| 45 | SkColor fBGColor; |
| 46 | SkPaint fPaint; |
| 47 | SkString fMatrix; |
| 48 | SkString fPaintInfo; |
| 49 | SkString fClip; |
| 50 | bool fResizing; |
| 51 | typedef SkView INHERITED; |
| 52 | }; |
| 53 | |
| 54 | /* |
| 55 | * Debugger - Commands List |
| 56 | */ |
| 57 | class DebuggerCommandsView : public SkView { |
| 58 | public: |
| 59 | DebuggerCommandsView(); |
| 60 | ~DebuggerCommandsView(); |
| 61 | int nextItem(); |
| 62 | int prevItem(); |
| 63 | int scrollUp(); |
| 64 | int scrollDown(); |
| 65 | void highlight(int index); |
| 66 | int selectHighlight(int ypos); |
| 67 | void toggleCentered(); |
| 68 | |
| 69 | protected: |
| 70 | virtual bool onEvent(const SkEvent& evt); |
| 71 | virtual void onSizeChange(); |
| 72 | virtual void onDraw(SkCanvas* canvas); |
| 73 | private: |
| 74 | void init(); |
| 75 | void alignCenter(); |
| 76 | SkColor fBGColor; |
| 77 | int fTopIndex; |
| 78 | int fHighlight; |
| 79 | SkScalar fSpacing; |
| 80 | int fRange; |
| 81 | bool fResizing; |
| 82 | bool fCentered; |
| 83 | SkTDArray<SkString*> fList; |
| 84 | typedef SkView INHERITED; |
| 85 | }; |
| 86 | |
| 87 | |
| 88 | static void* PaintProc(void* ptr, bool doRef) { |
| 89 | SkPaint* p = (SkPaint*) ptr; |
| 90 | |
| 91 | if (doRef) { |
| 92 | return new SkPaint(*p); |
| 93 | } |
| 94 | else { |
| 95 | delete p; |
| 96 | return NULL; |
| 97 | } |
| 98 | |
| 99 | } |
| 100 | |