Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2016 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #include "gm.h" | |
| 9 | |
| 10 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.
| |
| 11 | |
| 12 // This GM exercises drawing rects with coordinates outside the range of int32. | |
| 13 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.
| |
| 14 public: | |
| 15 BigRectGM() { | |
| 16 this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD)); | |
| 17 } | |
| 18 | |
| 19 protected: | |
| 20 SkString onShortName() override { | |
| 21 return SkString("bigrect"); | |
| 22 } | |
| 23 | |
| 24 SkISize onISize() override { | |
| 25 return SkISize::Make(kWidth, kHeight); | |
| 26 } | |
| 27 | |
| 28 void onDraw(SkCanvas* canvas) override { | |
| 29 static const SkScalar kBig = SkFloatToScalar(5e10f); | |
| 30 | |
| 31 SkPaint outlinePaint; | |
| 32 outlinePaint.setColor(SK_ColorBLUE); | |
| 33 outlinePaint.setStyle(SkPaint::kStroke_Style); | |
| 34 outlinePaint.setStrokeWidth(0); | |
| 35 | |
| 36 SkPaint outOfBoundsPaint; | |
| 37 outOfBoundsPaint.setColor(SK_ColorRED); | |
| 38 outOfBoundsPaint.setStyle(SkPaint::kStroke_Style); | |
| 39 outOfBoundsPaint.setStrokeWidth(0); | |
| 40 | |
| 41 // Looks like this: | |
| 42 // +-+-+--+-+------+ | |
| 43 // | | | | | +---+ | |
| 44 // | +-+ | | +---+ | |
| 45 // | | | | | |
| 46 // +------+-+------+ | |
| 47 // +------+-+------+ | |
| 48 // | | | | | |
| 49 // +---+ | | +-+ | | |
| 50 // +---+ | | | | | | |
| 51 // +------+-+--+-+-+ | |
| 52 | |
| 53 SkRect tl = SkRect::MakeLTRB(SkIntToScalar(5), | |
| 54 -kBig, | |
| 55 SkIntToScalar(10), | |
| 56 SkIntToScalar(10)); | |
| 57 canvas->drawRect(tl, outlinePaint); | |
| 58 | |
| 59 SkRect tr = SkRect::MakeLTRB(SkIntToScalar(25), | |
| 60 SkIntToScalar(5), | |
| 61 kBig, | |
| 62 SkIntToScalar(10)); | |
| 63 canvas->drawRect(tr, outlinePaint); | |
| 64 | |
| 65 SkRect br = SkRect::MakeLTRB(SkIntToScalar(25), | |
| 66 SkIntToScalar(25), | |
| 67 SkIntToScalar(30), | |
| 68 kBig); | |
| 69 canvas->drawRect(br, outlinePaint); | |
| 70 | |
| 71 SkRect bl = SkRect::MakeLTRB(-kBig, | |
| 72 SkIntToScalar(25), | |
| 73 SkIntToScalar(10), | |
| 74 SkIntToScalar(30)); | |
| 75 canvas->drawRect(bl, outlinePaint); | |
| 76 | |
| 77 SkRect horiz = SkRect::MakeLTRB(-kBig, | |
| 78 SkIntToScalar(15), | |
| 79 kBig, | |
| 80 SkIntToScalar(20)); | |
| 81 canvas->drawRect(horiz, outlinePaint); | |
| 82 | |
| 83 SkRect vert = SkRect::MakeLTRB(SkIntToScalar(15), | |
| 84 -kBig, | |
| 85 SkIntToScalar(20), | |
| 86 kBig); | |
| 87 canvas->drawRect(vert, outlinePaint); | |
| 88 | |
| 89 SkRect leftBorder = SkRect::MakeLTRB(-2, -1, 0, 35); | |
| 90 canvas->drawRect(leftBorder, outlinePaint); | |
| 91 | |
| 92 SkRect topBorder = SkRect::MakeLTRB(-1, -2, 35, 0); | |
| 93 canvas->drawRect(topBorder, outlinePaint); | |
| 94 | |
| 95 SkRect rightBorder = SkRect::MakeLTRB(34, -1, 36, 35); | |
| 96 canvas->drawRect(rightBorder, outlinePaint); | |
| 97 | |
| 98 SkRect bottomBorder = SkRect::MakeLTRB(-1, 34, 35, 36); | |
| 99 canvas->drawRect(bottomBorder, outlinePaint); | |
| 100 | |
| 101 SkRect outOfBounds = SkRect::MakeLTRB(-1, -1, 35, 35); | |
| 102 canvas->drawRect(outOfBounds, outOfBoundsPaint); | |
| 103 } | |
| 104 | |
| 105 private: | |
| 106 static const int kWidth = 35; | |
| 107 static const int kHeight = 35; | |
| 108 | |
| 109 typedef GM INHERITED; | |
| 110 }; | |
| 111 | |
| 112 // Disabled pending skia:5060. | |
| 113 // 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.
| |
| 114 } | |
| OLD | NEW |