| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
| 9 #include "SkView.h" | 9 #include "SkView.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| 11 #include "SkPaint.h" | 11 #include "SkPaint.h" |
| 12 #include "SkRandom.h" | 12 #include "SkRandom.h" |
| 13 #include "SkString.h" |
| 13 | 14 |
| 14 class EmptyPathView : public SampleView { | 15 class EmptyPathView : public SampleView { |
| 15 public: | 16 public: |
| 16 EmptyPathView() {} | 17 EmptyPathView() {} |
| 17 | 18 |
| 18 protected: | 19 protected: |
| 19 // overrides from SkEventSink | 20 // overrides from SkEventSink |
| 20 virtual bool onQuery(SkEvent* evt) { | 21 virtual bool onQuery(SkEvent* evt) { |
| 21 if (SampleCode::TitleQ(*evt)) { | 22 if (SampleCode::TitleQ(*evt)) { |
| 22 SampleCode::TitleR(evt, "EmptyPath"); | 23 SampleCode::TitleR(evt, "EmptyPath"); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 this->drawEmpty(canvas, color, rect, | 97 this->drawEmpty(canvas, color, rect, |
| 97 gStyles[style].fStyle, gFills[fill].fFill); | 98 gStyles[style].fStyle, gFills[fill].fFill); |
| 98 | 99 |
| 99 SkPaint rectPaint; | 100 SkPaint rectPaint; |
| 100 rectPaint.setColor(SK_ColorBLACK); | 101 rectPaint.setColor(SK_ColorBLACK); |
| 101 rectPaint.setStyle(SkPaint::kStroke_Style); | 102 rectPaint.setStyle(SkPaint::kStroke_Style); |
| 102 rectPaint.setStrokeWidth(-1); | 103 rectPaint.setStrokeWidth(-1); |
| 103 rectPaint.setAntiAlias(true); | 104 rectPaint.setAntiAlias(true); |
| 104 canvas->drawRect(rect, rectPaint); | 105 canvas->drawRect(rect, rectPaint); |
| 105 | 106 |
| 106 char label[1024]; | 107 SkString label; |
| 107 sprintf(label, "%s, %s", gStyles[style].fName, | 108 label.appendf("%s, %s", gStyles[style].fName, gFills[fill].fName
); |
| 108 gFills[fill].fName); | 109 |
| 109 SkPaint labelPaint; | 110 SkPaint labelPaint; |
| 110 labelPaint.setColor(color); | 111 labelPaint.setColor(color); |
| 111 labelPaint.setAntiAlias(true); | 112 labelPaint.setAntiAlias(true); |
| 112 labelPaint.setLCDRenderText(true); | 113 labelPaint.setLCDRenderText(true); |
| 113 canvas->drawText(label, strlen(label), | 114 canvas->drawText(label.c_str(), label.size(), |
| 114 0, rect.height() + 15 * SK_Scalar1, | 115 0, rect.height() + 15 * SK_Scalar1, |
| 115 labelPaint); | 116 labelPaint); |
| 116 } | 117 } |
| 117 } | 118 } |
| 118 canvas->restore(); | 119 canvas->restore(); |
| 119 canvas->restore(); | 120 canvas->restore(); |
| 120 } | 121 } |
| 121 | 122 |
| 122 private: | 123 private: |
| 123 typedef SampleView INHERITED; | 124 typedef SampleView INHERITED; |
| 124 }; | 125 }; |
| 125 | 126 |
| 126 ////////////////////////////////////////////////////////////////////////////// | 127 ////////////////////////////////////////////////////////////////////////////// |
| 127 | 128 |
| 128 static SkView* MyFactory() { return new EmptyPathView; } | 129 static SkView* MyFactory() { return new EmptyPathView; } |
| 129 static SkViewRegister reg(MyFactory); | 130 static SkViewRegister reg(MyFactory); |
| OLD | NEW |