| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "gm.h" | 8 #include "gm.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkPath.h" | 10 #include "SkPath.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 FakeCloseCorner, // The last point coincides with the first one at a c
orner. | 25 FakeCloseCorner, // The last point coincides with the first one at a c
orner. |
| 26 // The path looks closed, but final rendering has 2 e
nds with cap. | 26 // The path looks closed, but final rendering has 2 e
nds with cap. |
| 27 | 27 |
| 28 FakeCloseMiddle, // The last point coincides with the first one in the
middle of a line. | 28 FakeCloseMiddle, // The last point coincides with the first one in the
middle of a line. |
| 29 // The path looks closed, and the final rendering loo
ks closed too. | 29 // The path looks closed, and the final rendering loo
ks closed too. |
| 30 | 30 |
| 31 kClosureTypeCount | 31 kClosureTypeCount |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 protected: | 34 protected: |
| 35 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 35 uint32_t onGetFlags() const SK_OVERRIDE { |
| 36 return kSkipTiled_Flag; | 36 return kSkipTiled_Flag; |
| 37 } | 37 } |
| 38 | 38 |
| 39 virtual SkString onShortName() SK_OVERRIDE { | 39 SkString onShortName() SK_OVERRIDE { |
| 40 return SkString("nonclosedpaths"); | 40 return SkString("nonclosedpaths"); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // 12 * 18 + 3 cases, every case is 100 * 100 pixels. | 43 // 12 * 18 + 3 cases, every case is 100 * 100 pixels. |
| 44 virtual SkISize onISize() SK_OVERRIDE { | 44 SkISize onISize() SK_OVERRIDE { |
| 45 return SkISize::Make(1220, 1920); | 45 return SkISize::Make(1220, 1920); |
| 46 } | 46 } |
| 47 | 47 |
| 48 // Use rect-like geometry for non-closed path, for right angles make it | 48 // Use rect-like geometry for non-closed path, for right angles make it |
| 49 // easier to show the visual difference of lineCap and lineJoin. | 49 // easier to show the visual difference of lineCap and lineJoin. |
| 50 static void MakePath(SkPath* path, ClosureType type) { | 50 static void MakePath(SkPath* path, ClosureType type) { |
| 51 if (FakeCloseMiddle == type) { | 51 if (FakeCloseMiddle == type) { |
| 52 path->moveTo(30, 50); | 52 path->moveTo(30, 50); |
| 53 path->lineTo(30, 30); | 53 path->lineTo(30, 30); |
| 54 } else { | 54 } else { |
| 55 path->moveTo(30, 30); | 55 path->moveTo(30, 30); |
| 56 } | 56 } |
| 57 path->lineTo(70, 30); | 57 path->lineTo(70, 30); |
| 58 path->lineTo(70, 70); | 58 path->lineTo(70, 70); |
| 59 path->lineTo(30, 70); | 59 path->lineTo(30, 70); |
| 60 path->lineTo(30, 50); | 60 path->lineTo(30, 50); |
| 61 if (FakeCloseCorner == type) { | 61 if (FakeCloseCorner == type) { |
| 62 path->lineTo(30, 30); | 62 path->lineTo(30, 30); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 // Set the location for the current test on the canvas | 66 // Set the location for the current test on the canvas |
| 67 static void SetLocation(SkCanvas* canvas, int counter, int lineNum) { | 67 static void SetLocation(SkCanvas* canvas, int counter, int lineNum) { |
| 68 SkScalar x = SK_Scalar1 * 100 * (counter % lineNum) + 10 + SK_Scalar1 /
4; | 68 SkScalar x = SK_Scalar1 * 100 * (counter % lineNum) + 10 + SK_Scalar1 /
4; |
| 69 SkScalar y = SK_Scalar1 * 100 * (counter / lineNum) + 10 + 3 * SK_Scalar
1 / 4; | 69 SkScalar y = SK_Scalar1 * 100 * (counter / lineNum) + 10 + 3 * SK_Scalar
1 / 4; |
| 70 canvas->translate(x, y); | 70 canvas->translate(x, y); |
| 71 } | 71 } |
| 72 | 72 |
| 73 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 73 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 74 // Stroke widths are: | 74 // Stroke widths are: |
| 75 // 0(may use hairline rendering), 10(common case for stroke-style) | 75 // 0(may use hairline rendering), 10(common case for stroke-style) |
| 76 // 40 and 50(>= geometry width/height, make the contour filled in fact) | 76 // 40 and 50(>= geometry width/height, make the contour filled in fact) |
| 77 static const int kStrokeWidth[] = {0, 10, 40, 50}; | 77 static const int kStrokeWidth[] = {0, 10, 40, 50}; |
| 78 int numWidths = SK_ARRAY_COUNT(kStrokeWidth); | 78 int numWidths = SK_ARRAY_COUNT(kStrokeWidth); |
| 79 | 79 |
| 80 static const SkPaint::Style kStyle[] = { | 80 static const SkPaint::Style kStyle[] = { |
| 81 SkPaint::kStroke_Style, SkPaint::kStrokeAndFill_Style | 81 SkPaint::kStroke_Style, SkPaint::kStrokeAndFill_Style |
| 82 }; | 82 }; |
| 83 | 83 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 private: | 141 private: |
| 142 typedef GM INHERITED; | 142 typedef GM INHERITED; |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 ////////////////////////////////////////////////////////////////////////////// | 145 ////////////////////////////////////////////////////////////////////////////// |
| 146 | 146 |
| 147 DEF_GM(return new NonClosedPathsGM;) | 147 DEF_GM(return new NonClosedPathsGM;) |
| 148 | 148 |
| 149 } | 149 } |
| OLD | NEW |