| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
| 9 #include "SampleCode.h" | 9 #include "SampleCode.h" |
| 10 #include "SkView.h" | 10 #include "SkView.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 break; | 69 break; |
| 70 default: | 70 default: |
| 71 break; | 71 break; |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 if (count > 0) { | 74 if (count > 0) { |
| 75 contourCounts->push_back(count); | 75 contourCounts->push_back(count); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 static void erase(SkSurface* surface) { | 79 static void erase(const sk_sp<SkSurface>& surface) { |
| 80 SkCanvas* canvas = surface->getCanvas(); | 80 SkCanvas* canvas = surface->getCanvas(); |
| 81 if (canvas) { | 81 if (canvas) { |
| 82 canvas->clear(SK_ColorTRANSPARENT); | 82 canvas->clear(SK_ColorTRANSPARENT); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 struct StrokeTypeButton { | 86 struct StrokeTypeButton { |
| 87 SkRect fBounds; | 87 SkRect fBounds; |
| 88 char fLabel; | 88 char fLabel; |
| 89 bool fEnabled; | 89 bool fEnabled; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 103 kCount = 18 | 103 kCount = 18 |
| 104 }; | 104 }; |
| 105 SkPoint fPts[kCount]; | 105 SkPoint fPts[kCount]; |
| 106 SkRect fWeightControl; | 106 SkRect fWeightControl; |
| 107 SkRect fRadiusControl; | 107 SkRect fRadiusControl; |
| 108 SkRect fErrorControl; | 108 SkRect fErrorControl; |
| 109 SkRect fWidthControl; | 109 SkRect fWidthControl; |
| 110 SkRect fBounds; | 110 SkRect fBounds; |
| 111 SkMatrix fMatrix, fInverse; | 111 SkMatrix fMatrix, fInverse; |
| 112 sk_sp<SkShader> fShader; | 112 sk_sp<SkShader> fShader; |
| 113 SkAutoTUnref<SkSurface> fMinSurface; | 113 sk_sp<SkSurface> fMinSurface; |
| 114 SkAutoTUnref<SkSurface> fMaxSurface; | 114 sk_sp<SkSurface> fMaxSurface; |
| 115 StrokeTypeButton fCubicButton; | 115 StrokeTypeButton fCubicButton; |
| 116 StrokeTypeButton fConicButton; | 116 StrokeTypeButton fConicButton; |
| 117 StrokeTypeButton fQuadButton; | 117 StrokeTypeButton fQuadButton; |
| 118 StrokeTypeButton fArcButton; | 118 StrokeTypeButton fArcButton; |
| 119 StrokeTypeButton fRRectButton; | 119 StrokeTypeButton fRRectButton; |
| 120 CircleTypeButton fCircleButton; | 120 CircleTypeButton fCircleButton; |
| 121 StrokeTypeButton fTextButton; | 121 StrokeTypeButton fTextButton; |
| 122 SkString fText; | 122 SkString fText; |
| 123 SkScalar fTextSize; | 123 SkScalar fTextSize; |
| 124 SkScalar fWeight; | 124 SkScalar fWeight; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 } | 260 } |
| 261 | 261 |
| 262 void setWHZ(int width, int height, int zoom) { | 262 void setWHZ(int width, int height, int zoom) { |
| 263 fZoom = zoom; | 263 fZoom = zoom; |
| 264 fBounds.set(0, 0, SkIntToScalar(width * zoom), SkIntToScalar(height * zo
om)); | 264 fBounds.set(0, 0, SkIntToScalar(width * zoom), SkIntToScalar(height * zo
om)); |
| 265 fMatrix.setScale(SkIntToScalar(zoom), SkIntToScalar(zoom)); | 265 fMatrix.setScale(SkIntToScalar(zoom), SkIntToScalar(zoom)); |
| 266 fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom); | 266 fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom); |
| 267 fShader = sk_tool_utils::create_checkerboard_shader(0xFFCCCCCC, 0xFFFFFF
FF, zoom); | 267 fShader = sk_tool_utils::create_checkerboard_shader(0xFFCCCCCC, 0xFFFFFF
FF, zoom); |
| 268 | 268 |
| 269 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); | 269 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); |
| 270 fMinSurface.reset(SkSurface::NewRaster(info)); | 270 fMinSurface = SkSurface::MakeRaster(info); |
| 271 info = info.makeWH(width * zoom, height * zoom); | 271 info = info.makeWH(width * zoom, height * zoom); |
| 272 fMaxSurface.reset(SkSurface::NewRaster(info)); | 272 fMaxSurface = SkSurface::MakeRaster(info); |
| 273 } | 273 } |
| 274 | 274 |
| 275 void draw_points(SkCanvas* canvas, const SkPath& path, SkColor color, | 275 void draw_points(SkCanvas* canvas, const SkPath& path, SkColor color, |
| 276 bool show_lines) { | 276 bool show_lines) { |
| 277 SkPaint paint; | 277 SkPaint paint; |
| 278 paint.setColor(color); | 278 paint.setColor(color); |
| 279 paint.setAlpha(0x80); | 279 paint.setAlpha(0x80); |
| 280 paint.setAntiAlias(true); | 280 paint.setAntiAlias(true); |
| 281 int n = path.countPoints(); | 281 int n = path.countPoints(); |
| 282 SkAutoSTArray<32, SkPoint> pts(n); | 282 SkAutoSTArray<32, SkPoint> pts(n); |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 } | 792 } |
| 793 | 793 |
| 794 private: | 794 private: |
| 795 typedef SkView INHERITED; | 795 typedef SkView INHERITED; |
| 796 }; | 796 }; |
| 797 | 797 |
| 798 /////////////////////////////////////////////////////////////////////////////// | 798 /////////////////////////////////////////////////////////////////////////////// |
| 799 | 799 |
| 800 static SkView* F2() { return new QuadStrokerView; } | 800 static SkView* F2() { return new QuadStrokerView; } |
| 801 static SkViewRegister gR2(F2); | 801 static SkViewRegister gR2(F2); |
| OLD | NEW |