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: ScaledRectsGM()22 ScaledRectsGM() { 23 this->setBGColor(0xFFCCCCCC); 24 } 25 26 protected: getName() const27 SkString getName() const override { return SkString("scaledrects"); } 28 getISize()29 SkISize getISize() override { return SkISize::Make(128, 64); } 30 onDraw(SkCanvas * canvas)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 64