Index: gm/bigrect.cpp |
diff --git a/gm/bigrect.cpp b/gm/bigrect.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8bc418e817734ea446762c24bbd19bf930d921ed |
--- /dev/null |
+++ b/gm/bigrect.cpp |
@@ -0,0 +1,114 @@ |
+/* |
+ * Copyright 2016 Google Inc. |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
+#include "gm.h" |
+ |
+namespace skiagm { |
mtklein
2016/03/07 14:32:12
Generally no need for this. I guess it's fine if
dogben
2016/03/07 16:12:48
Removed.
|
+ |
+// This GM exercises drawing rects with coordinates outside the range of int32. |
+class BigRectGM : public GM { |
mtklein
2016/03/07 14:32:12
I think this can use DEF_SIMPLE_GM or DEF_SIMPLE_G
dogben
2016/03/07 16:12:48
Done.
|
+public: |
+ BigRectGM() { |
+ this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD)); |
+ } |
+ |
+protected: |
+ SkString onShortName() override { |
+ return SkString("bigrect"); |
+ } |
+ |
+ SkISize onISize() override { |
+ return SkISize::Make(kWidth, kHeight); |
+ } |
+ |
+ void onDraw(SkCanvas* canvas) override { |
+ static const SkScalar kBig = SkFloatToScalar(5e10f); |
+ |
+ SkPaint outlinePaint; |
+ outlinePaint.setColor(SK_ColorBLUE); |
+ outlinePaint.setStyle(SkPaint::kStroke_Style); |
+ outlinePaint.setStrokeWidth(0); |
+ |
+ SkPaint outOfBoundsPaint; |
+ outOfBoundsPaint.setColor(SK_ColorRED); |
+ outOfBoundsPaint.setStyle(SkPaint::kStroke_Style); |
+ outOfBoundsPaint.setStrokeWidth(0); |
+ |
+ // Looks like this: |
+ // +-+-+--+-+------+ |
+ // | | | | | +---+ |
+ // | +-+ | | +---+ |
+ // | | | | |
+ // +------+-+------+ |
+ // +------+-+------+ |
+ // | | | | |
+ // +---+ | | +-+ | |
+ // +---+ | | | | | |
+ // +------+-+--+-+-+ |
+ |
+ SkRect tl = SkRect::MakeLTRB(SkIntToScalar(5), |
+ -kBig, |
+ SkIntToScalar(10), |
+ SkIntToScalar(10)); |
+ canvas->drawRect(tl, outlinePaint); |
+ |
+ SkRect tr = SkRect::MakeLTRB(SkIntToScalar(25), |
+ SkIntToScalar(5), |
+ kBig, |
+ SkIntToScalar(10)); |
+ canvas->drawRect(tr, outlinePaint); |
+ |
+ SkRect br = SkRect::MakeLTRB(SkIntToScalar(25), |
+ SkIntToScalar(25), |
+ SkIntToScalar(30), |
+ kBig); |
+ canvas->drawRect(br, outlinePaint); |
+ |
+ SkRect bl = SkRect::MakeLTRB(-kBig, |
+ SkIntToScalar(25), |
+ SkIntToScalar(10), |
+ SkIntToScalar(30)); |
+ canvas->drawRect(bl, outlinePaint); |
+ |
+ SkRect horiz = SkRect::MakeLTRB(-kBig, |
+ SkIntToScalar(15), |
+ kBig, |
+ SkIntToScalar(20)); |
+ canvas->drawRect(horiz, outlinePaint); |
+ |
+ SkRect vert = SkRect::MakeLTRB(SkIntToScalar(15), |
+ -kBig, |
+ SkIntToScalar(20), |
+ kBig); |
+ canvas->drawRect(vert, outlinePaint); |
+ |
+ SkRect leftBorder = SkRect::MakeLTRB(-2, -1, 0, 35); |
+ canvas->drawRect(leftBorder, outlinePaint); |
+ |
+ SkRect topBorder = SkRect::MakeLTRB(-1, -2, 35, 0); |
+ canvas->drawRect(topBorder, outlinePaint); |
+ |
+ SkRect rightBorder = SkRect::MakeLTRB(34, -1, 36, 35); |
+ canvas->drawRect(rightBorder, outlinePaint); |
+ |
+ SkRect bottomBorder = SkRect::MakeLTRB(-1, 34, 35, 36); |
+ canvas->drawRect(bottomBorder, outlinePaint); |
+ |
+ SkRect outOfBounds = SkRect::MakeLTRB(-1, -1, 35, 35); |
+ canvas->drawRect(outOfBounds, outOfBoundsPaint); |
+ } |
+ |
+private: |
+ static const int kWidth = 35; |
+ static const int kHeight = 35; |
+ |
+ typedef GM INHERITED; |
+}; |
+ |
+// Disabled pending skia:5060. |
+// DEF_GM(return new BigRectGM;) |
mtklein
2016/03/07 14:32:12
Let's land it on?
dogben
2016/03/07 16:12:48
Sure, I'll add an ignore rule to gold instead.
|
+} |