blob: d31e8260fcd59b0428f838fd06496d5c0a1e43f8 [file] [log] [blame]
Robert Phillipse153f682023-05-25 10:54:41 -04001/*
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
14namespace 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.
20class ScaledRectsGM : public GM {
21public:
22 ScaledRectsGM() {
23 this->setBGColor(0xFFCCCCCC);
24 }
25
26protected:
Leandro Lovisolo24fa2112023-08-15 19:05:17 +000027 SkString getName() const override { return SkString("scaledrects"); }
Robert Phillipse153f682023-05-25 10:54:41 -040028
Leandro Lovisolo8f023882023-08-15 21:13:52 +000029 SkISize getISize() override { return SkISize::Make(128, 64); }
Robert Phillipse153f682023-05-25 10:54:41 -040030
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
61DEF_GM(return new ScaledRectsGM;)
62
63} // namespace skiagm