| 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 | 9 |
| 10 namespace skiagm { | 10 namespace skiagm { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 DrawSquares(canvas, white); | 58 DrawSquares(canvas, white); |
| 59 | 59 |
| 60 canvas->translate(40.0f, 0.0f); | 60 canvas->translate(40.0f, 0.0f); |
| 61 DrawSquares(canvas, green); | 61 DrawSquares(canvas, green); |
| 62 canvas->restore(); | 62 canvas->restore(); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 static void DrawVertRects(SkCanvas* canvas, const SkPaint& p) { | 67 static void DrawVertRects(SkCanvas* canvas, const SkPaint& p) { |
| 68 static const SkRect vertRects[] = { | 68 constexpr SkRect vertRects[] = { |
| 69 { 1, 1, 5.0f, 21 }, // 4 pix wide | 69 { 1, 1, 5.0f, 21 }, // 4 pix wide |
| 70 { 8, 1, 10.0f, 21 }, // 2 pix wide | 70 { 8, 1, 10.0f, 21 }, // 2 pix wide |
| 71 { 13, 1, 14.0f, 21 }, // 1 pix wide | 71 { 13, 1, 14.0f, 21 }, // 1 pix wide |
| 72 { 17, 1, 17.5f, 21 }, // 1/2 pix wide | 72 { 17, 1, 17.5f, 21 }, // 1/2 pix wide |
| 73 { 21, 1, 21.25f, 21 }, // 1/4 pix wide | 73 { 21, 1, 21.25f, 21 }, // 1/4 pix wide |
| 74 { 25, 1, 25.125f, 21 }, // 1/8 pix wide | 74 { 25, 1, 25.125f, 21 }, // 1/8 pix wide |
| 75 { 29, 1, 29.0f, 21 } // 0 pix wide | 75 { 29, 1, 29.0f, 21 } // 0 pix wide |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 for (size_t j = 0; j < SK_ARRAY_COUNT(vertRects); ++j) { | 78 for (size_t j = 0; j < SK_ARRAY_COUNT(vertRects); ++j) { |
| 79 canvas->drawRect(vertRects[j], p); | 79 canvas->drawRect(vertRects[j], p); |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 static void DrawHorizRects(SkCanvas* canvas, const SkPaint& p) { | 83 static void DrawHorizRects(SkCanvas* canvas, const SkPaint& p) { |
| 84 static const SkRect horizRects[] = { | 84 constexpr SkRect horizRects[] = { |
| 85 { 1, 1, 21, 5.0f }, // 4 pix high | 85 { 1, 1, 21, 5.0f }, // 4 pix high |
| 86 { 1, 8, 21, 10.0f }, // 2 pix high | 86 { 1, 8, 21, 10.0f }, // 2 pix high |
| 87 { 1, 13, 21, 14.0f }, // 1 pix high | 87 { 1, 13, 21, 14.0f }, // 1 pix high |
| 88 { 1, 17, 21, 17.5f }, // 1/2 pix high | 88 { 1, 17, 21, 17.5f }, // 1/2 pix high |
| 89 { 1, 21, 21, 21.25f }, // 1/4 pix high | 89 { 1, 21, 21, 21.25f }, // 1/4 pix high |
| 90 { 1, 25, 21, 25.125f }, // 1/8 pix high | 90 { 1, 25, 21, 25.125f }, // 1/8 pix high |
| 91 { 1, 29, 21, 29.0f } // 0 pix high | 91 { 1, 29, 21, 29.0f } // 0 pix high |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 for (size_t j = 0; j < SK_ARRAY_COUNT(horizRects); ++j) { | 94 for (size_t j = 0; j < SK_ARRAY_COUNT(horizRects); ++j) { |
| 95 canvas->drawRect(horizRects[j], p); | 95 canvas->drawRect(horizRects[j], p); |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 static void DrawSquares(SkCanvas* canvas, const SkPaint& p) { | 99 static void DrawSquares(SkCanvas* canvas, const SkPaint& p) { |
| 100 static const SkRect squares[] = { | 100 constexpr SkRect squares[] = { |
| 101 { 1, 1, 5.0f, 5.0f }, // 4 pix | 101 { 1, 1, 5.0f, 5.0f }, // 4 pix |
| 102 { 8, 8, 10.0f, 10.0f }, // 2 pix | 102 { 8, 8, 10.0f, 10.0f }, // 2 pix |
| 103 { 13, 13, 14.0f, 14.0f }, // 1 pix | 103 { 13, 13, 14.0f, 14.0f }, // 1 pix |
| 104 { 17, 17, 17.5f, 17.5f }, // 1/2 pix | 104 { 17, 17, 17.5f, 17.5f }, // 1/2 pix |
| 105 { 21, 21, 21.25f, 21.25f }, // 1/4 pix | 105 { 21, 21, 21.25f, 21.25f }, // 1/4 pix |
| 106 { 25, 25, 25.125f, 25.125f }, // 1/8 pix | 106 { 25, 25, 25.125f, 25.125f }, // 1/8 pix |
| 107 { 29, 29, 29.0f, 29.0f } // 0 pix | 107 { 29, 29, 29.0f, 29.0f } // 0 pix |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 for (size_t j = 0; j < SK_ARRAY_COUNT(squares); ++j) { | 110 for (size_t j = 0; j < SK_ARRAY_COUNT(squares); ++j) { |
| 111 canvas->drawRect(squares[j], p); | 111 canvas->drawRect(squares[j], p); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 typedef GM INHERITED; | 115 typedef GM INHERITED; |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 ////////////////////////////////////////////////////////////////////////////// | 118 ////////////////////////////////////////////////////////////////////////////// |
| 119 | 119 |
| 120 static GM* MyFactory(void*) { return new ThinRectsGM; } | 120 static GM* MyFactory(void*) { return new ThinRectsGM; } |
| 121 static GMRegistry reg(MyFactory); | 121 static GMRegistry reg(MyFactory); |
| 122 | 122 |
| 123 } | 123 } |
| OLD | NEW |