Robert Phillips | e153f68 | 2023-05-25 10:54:41 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2023 Google LLC |
| 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/gm.h" |
| 9 | #include "include/core/SkCanvas.h" |
| 10 | #include "include/core/SkPaint.h" |
| 11 | #include "include/core/SkRect.h" |
| 12 | #include "include/core/SkString.h" |
| 13 | |
| 14 | namespace skiagm { |
| 15 | |
| 16 | // From crbug.com/1442854. Draws two rects (equivalent in device space) but which vary wildly |
| 17 | // in their sizes and scales. In both cases the clip is what is actually determining the |
| 18 | // final drawn geometry. For the red rectangle case the inverted skews were becoming very small and |
| 19 | // ran afoul of some logic in the DMSAA code that zeroed them out. |
| 20 | class ScaledRectsGM : public GM { |
| 21 | public: |
| 22 | ScaledRectsGM() { |
| 23 | this->setBGColor(0xFFCCCCCC); |
| 24 | } |
| 25 | |
| 26 | protected: |
Leandro Lovisolo | 24fa211 | 2023-08-15 19:05:17 +0000 | [diff] [blame] | 27 | SkString getName() const override { return SkString("scaledrects"); } |
Robert Phillips | e153f68 | 2023-05-25 10:54:41 -0400 | [diff] [blame] | 28 | |
Leandro Lovisolo | 8f02388 | 2023-08-15 21:13:52 +0000 | [diff] [blame] | 29 | SkISize getISize() override { return SkISize::Make(128, 64); } |
Robert Phillips | e153f68 | 2023-05-25 10:54:41 -0400 | [diff] [blame] | 30 | |
| 31 | void onDraw(SkCanvas* canvas) override { |
| 32 | canvas->clipRect(SkRect::MakeXYWH(10, 50, 100, 10)); |
| 33 | |
| 34 | { |
| 35 | SkPaint blue; |
| 36 | blue.setColor(SK_ColorBLUE); |
| 37 | |
| 38 | canvas->setMatrix(SkMatrix::MakeAll( 3.0f, -0.5f, 0.0f, |
| 39 | -0.5f, -3.0f, 0.0f, |
| 40 | 0.0f, 0.0f, 1.0f)); |
| 41 | |
| 42 | canvas->drawRect(SkRect::MakeXYWH(-1000, -1000, 2000, 2000), blue); |
| 43 | } |
| 44 | |
| 45 | { |
| 46 | SkPaint red; |
| 47 | red.setColor(SK_ColorRED); |
| 48 | red.setBlendMode(SkBlendMode::kPlus); |
| 49 | |
| 50 | canvas->setMatrix(SkMatrix::MakeAll(3000.0f, -500.0f, 0.0f, |
| 51 | -500.0f, -3000.0f, 0.0f, |
| 52 | 0.0f, 0.0f, 1.0f)); |
| 53 | |
| 54 | canvas->drawRect(SkRect::MakeXYWH(-1, -1, 2, 2), red); |
| 55 | } |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | ////////////////////////////////////////////////////////////////////////////// |
| 60 | |
| 61 | DEF_GM(return new ScaledRectsGM;) |
| 62 | |
| 63 | } // namespace skiagm |