Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
skiagm::BigRRectAAEffectGM Class Reference
Inheritance diagram for skiagm::BigRRectAAEffectGM:

Public Member Functions

 BigRRectAAEffectGM (const SkRRect &rrect, const char *name)
 

Protected Member Functions

SkString getName () const override
 
SkISize getISize () override
 
DrawResult onDraw (GrRecordingContext *rContext, SkCanvas *canvas, SkString *errorMsg) override
 

Detailed Description

Definition at line 40 of file bigrrectaaeffect.cpp.

Constructor & Destructor Documentation

◆ BigRRectAAEffectGM()

skiagm::BigRRectAAEffectGM::BigRRectAAEffectGM ( const SkRRect rrect,
const char *  name 
)
inline

Definition at line 42 of file bigrrectaaeffect.cpp.

43 : fRRect(rrect)
44 , fName(name) {
45 this->setBGColor(ToolUtils::color_to_565(SK_ColorBLUE));
46 // Each test case draws the rrect with gaps around it.
47 fTestWidth = SkScalarCeilToInt(rrect.width()) + 2 * kGap;
48 fTestHeight = SkScalarCeilToInt(rrect.height()) + 2 * kGap;
49
50 // Add a pad between test cases.
51 fTestOffsetX = fTestWidth + kPad;
52 fTestOffsetY = fTestHeight + kPad;
53
54 // We draw two tests in x (fill and inv-fill) and pad around
55 // all four sides of the image.
56 fWidth = 2 * fTestOffsetX + kPad;
57 fHeight = fTestOffsetY + kPad;
58 }
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
#define SkScalarCeilToInt(x)
Definition: SkScalar.h:36
constexpr int kPad
SkScalar width() const
Definition: SkRRect.h:95
SkScalar height() const
Definition: SkRRect.h:102
SkRRect rrect
Definition: SkRecords.h:232
SkColor color_to_565(SkColor color)
Definition: ToolUtils.cpp:139
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

Member Function Documentation

◆ getISize()

SkISize skiagm::BigRRectAAEffectGM::getISize ( )
inlineoverrideprotected

Definition at line 67 of file bigrrectaaeffect.cpp.

67{ return SkISize::Make(fWidth, fHeight); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString skiagm::BigRRectAAEffectGM::getName ( ) const
inlineoverrideprotected

Definition at line 61 of file bigrrectaaeffect.cpp.

61 {
63 name.printf("big_rrect_%s_aa_effect", fName);
64 return name;
65 }

◆ onDraw()

DrawResult skiagm::BigRRectAAEffectGM::onDraw ( GrRecordingContext rContext,
SkCanvas canvas,
SkString errorMsg 
)
inlineoverrideprotected

Definition at line 69 of file bigrrectaaeffect.cpp.

69 {
71 if (!sdc) {
72 *errorMsg = kErrorMsg_DrawSkippedGpuOnly;
73 return DrawResult::kSkip;
74 }
75
76 int y = kPad;
77 int x = kPad;
78 constexpr GrClipEdgeType kEdgeTypes[] = {
81 };
82 SkRect testBounds = SkRect::MakeIWH(fTestWidth, fTestHeight);
83 for (size_t et = 0; et < std::size(kEdgeTypes); ++et) {
84 GrClipEdgeType edgeType = kEdgeTypes[et];
85 canvas->save();
87
88 // Draw a background for the test case
90 paint.setColor(SK_ColorWHITE);
91 canvas->drawRect(testBounds, paint);
92
93 SkRRect rrect = fRRect;
94 rrect.offset(SkIntToScalar(x + kGap), SkIntToScalar(y + kGap));
95 const auto& caps = *rContext->priv().caps()->shaderCaps();
96 auto [success, fp] = GrRRectEffect::Make(/*inputFP=*/nullptr, edgeType, rrect,
97 caps);
98 SkASSERT(success);
99 if (success) {
100 SkASSERT(fp);
101 GrPaint grPaint;
102 grPaint.setColor4f({ 0, 0, 0, 1.f });
104 grPaint.setCoverageFragmentProcessor(std::move(fp));
105
106 SkRect bounds = testBounds;
108
110 rContext, std::move(grPaint), SkMatrix::I(), bounds));
111 }
112 canvas->restore();
113 x = x + fTestOffsetX;
114 }
115
116 return DrawResult::kOk;
117 }
GrClipEdgeType
Definition: GrTypesPriv.h:361
#define SkASSERT(cond)
Definition: SkAssert.h:116
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
#define SkIntToScalar(x)
Definition: SkScalar.h:57
const GrCaps * caps() const
const GrShaderCaps * shaderCaps() const
Definition: GrCaps.h:63
void setXPFactory(const GrXPFactory *xpFactory)
Definition: GrPaint.h:53
void setColor4f(const SkPMColor4f &color)
Definition: GrPaint.h:50
void setCoverageFragmentProcessor(std::unique_ptr< GrFragmentProcessor > fp)
Definition: GrPaint.h:75
static const GrXPFactory * Get(SkBlendMode blendMode)
GrRecordingContextPriv priv()
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
static const SkMatrix & I()
Definition: SkMatrix.cpp:1544
void offset(SkScalar dx, SkScalar dy)
Definition: SkRRect.h:387
static GrOp::Owner MakeNonAARect(GrRecordingContext *, GrPaint &&, const SkMatrix &view, const SkRect &, const GrUserStencilSettings *=nullptr)
Definition: FillRectOp.cpp:480
const Paint & paint
Definition: color_source.cc:38
double y
double x
GrFPResult Make(std::unique_ptr< GrFragmentProcessor >, GrClipEdgeType, const SkRRect &, const GrShaderCaps &)
Optional< SkRect > bounds
Definition: SkRecords.h:189
const uint32_t fp
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
SurfaceDrawContext * TopDeviceSurfaceDrawContext(const SkCanvas *canvas)
Definition: GrCanvas.cpp:20
static SkRect MakeIWH(int w, int h)
Definition: SkRect.h:623

The documentation for this class was generated from the following file: