OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColor.h" | 10 #include "SkColor.h" |
11 #include "SkPaint.h" | 11 #include "SkPaint.h" |
12 #include "SkPoint.h" | 12 #include "SkPoint.h" |
13 #include "SkRect.h" | 13 #include "SkRect.h" |
| 14 #include "SkSurface.h" |
14 #include "SkTypes.h" | 15 #include "SkTypes.h" |
15 #include "Test.h" | 16 #include "Test.h" |
| 17 #include <math.h> |
16 | 18 |
17 static const SkColor bgColor = SK_ColorWHITE; | 19 static const SkColor bgColor = SK_ColorWHITE; |
18 | 20 |
19 static void create(SkBitmap* bm, SkIRect bound) { | 21 static void create(SkBitmap* bm, SkIRect bound) { |
20 bm->allocN32Pixels(bound.width(), bound.height()); | 22 bm->allocN32Pixels(bound.width(), bound.height()); |
21 } | 23 } |
22 | 24 |
23 static void drawBG(SkCanvas* canvas) { | 25 static void drawBG(SkCanvas* canvas) { |
24 canvas->drawColor(bgColor); | 26 canvas->drawColor(bgColor); |
25 } | 27 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 106 |
105 REPORTER_ASSERT(reporter, | 107 REPORTER_ASSERT(reporter, |
106 compare(drawTextBitmap, drawTextRect, | 108 compare(drawTextBitmap, drawTextRect, |
107 drawPosTextBitmap, drawPosTextRe
ct)); | 109 drawPosTextBitmap, drawPosTextRe
ct)); |
108 } | 110 } |
109 } | 111 } |
110 } | 112 } |
111 } | 113 } |
112 } | 114 } |
113 } | 115 } |
| 116 |
| 117 // Test drawing text at some unusual coordinates. |
| 118 // We measure success by not crashing or asserting. |
| 119 DEF_TEST(DrawText_weirdCoordinates, r) { |
| 120 auto surface = SkSurface::MakeRasterN32Premul(10,10); |
| 121 auto canvas = surface->getCanvas(); |
| 122 |
| 123 SkScalar oddballs[] = { 0.0f, (float)INFINITY, (float)NAN, 34359738368.0f }; |
| 124 |
| 125 for (auto x : oddballs) { |
| 126 canvas->drawText("a", 1, +x, 0.0f, SkPaint()); |
| 127 canvas->drawText("a", 1, -x, 0.0f, SkPaint()); |
| 128 } |
| 129 for (auto y : oddballs) { |
| 130 canvas->drawText("a", 1, 0.0f, +y, SkPaint()); |
| 131 canvas->drawText("a", 1, 0.0f, -y, SkPaint()); |
| 132 } |
| 133 } |
OLD | NEW |