Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
scaledrects.cpp
Go to the documentation of this file.
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"
11#include "include/core/SkRect.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:
23 this->setBGColor(0xFFCCCCCC);
24 }
25
26protected:
27 SkString getName() const override { return SkString("scaledrects"); }
28
29 SkISize getISize() override { return SkISize::Make(128, 64); }
30
31 void onDraw(SkCanvas* canvas) override {
32 canvas->clipRect(SkRect::MakeXYWH(10, 50, 100, 10));
33
34 {
35 SkPaint blue;
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;
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
@ kPlus
r = min(s + d, 1)
constexpr SkColor SK_ColorBLUE
Definition SkColor.h:135
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
void drawRect(const SkRect &rect, const SkPaint &paint)
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void setMatrix(const SkM44 &matrix)
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
Definition SkMatrix.h:179
void setColor(SkColor color)
Definition SkPaint.cpp:119
void setBlendMode(SkBlendMode mode)
Definition SkPaint.cpp:151
void setBGColor(SkColor)
Definition gm.cpp:159
SkISize getISize() override
void onDraw(SkCanvas *canvas) override
SkString getName() const override
#define DEF_GM(CODE)
Definition gm.h:40
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659