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

Public Member Functions

 AARectEffect ()
 

Protected Member Functions

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

Detailed Description

This GM directly exercises a GrProcessor that clips against rects.

Definition at line 38 of file aarecteffect.cpp.

Constructor & Destructor Documentation

◆ AARectEffect()

skiagm::AARectEffect::AARectEffect ( )
inline

Definition at line 40 of file aarecteffect.cpp.

40{ this->setBGColor(0xFFFFFFFF); }

Member Function Documentation

◆ getISize()

SkISize skiagm::AARectEffect::getISize ( )
inlineoverrideprotected

Definition at line 45 of file aarecteffect.cpp.

45{ return SkISize::Make(210, 250); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Definition at line 43 of file aarecteffect.cpp.

43{ return SkString("aa_rect_effect"); }

◆ onDraw()

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

Definition at line 49 of file aarecteffect.cpp.

49 {
51 if (!sdc) {
52 *errorMsg = kErrorMsg_DrawSkippedGpuOnly;
53 return DrawResult::kSkip;
54 }
55
56 SkScalar y = 12.f;
57 static constexpr SkScalar kDX = 12.f;
58 static constexpr SkScalar kOutset = 5.f;
59
60 static constexpr SkRect kRects[] = {
61 // integer edges
62 SkRect::MakeLTRB(5.f, 1.f, 30.f, 25.f),
63 // half-integer edges
64 SkRect::MakeLTRB(5.5f, 0.5f, 29.5f, 24.5f),
65 // vertically/horizontally thin rects that cover pixel centers
66 SkRect::MakeLTRB(5.25f, 0.5f, 5.75f, 24.5f),
67 SkRect::MakeLTRB(5.5f, 0.5f, 29.5f, 0.75f),
68 // vertically/horizontally thin rects that don't cover pixel centers
69 SkRect::MakeLTRB(5.55f, 0.5f, 5.75f, 24.5f),
70 SkRect::MakeLTRB(5.5f, .05f, 29.5f, .25f),
71 // small in x and y
72 SkRect::MakeLTRB(5.05f, .55f, 5.45f, .85f),
73 };
74
75 for (auto r : kRects) {
76 SkScalar x = kDX;
77
78 for (int et = 0; et < kGrClipEdgeTypeCnt; ++et) {
79 SkRect rect = r.makeOffset(x, y);
80 GrClipEdgeType edgeType = static_cast<GrClipEdgeType>(et);
81 auto fp = GrFragmentProcessor::Rect(/*inputFP=*/nullptr, edgeType, rect);
82 SkASSERT(fp);
83
84 GrPaint grPaint;
85 grPaint.setColor4f({ 0, 0, 0, 1.f });
87 grPaint.setCoverageFragmentProcessor(std::move(fp));
88 auto drawRect = rect.makeOutset(kOutset, kOutset);
89 auto op = sk_gpu_test::test_ops::MakeRect(rContext, std::move(grPaint), drawRect);
90 sdc->addDrawOp(std::move(op));
91
92 x += SkScalarCeilToScalar(rect.width() + kDX);
93 }
94
95 // Draw rect without and with AA using normal API for reference
96 canvas->save();
97 canvas->translate(x, y);
99 canvas->drawRect(r, paint);
100 x += SkScalarCeilToScalar(r.width() + kDX);
101 paint.setAntiAlias(true);
102 canvas->drawRect(r, paint);
103 canvas->restore();
104
105 y += SkScalarCeilToScalar(r.height() + 20.f);
106 }
107
108 return DrawResult::kOk;
109 }
static const int kGrClipEdgeTypeCnt
Definition: GrTypesPriv.h:369
GrClipEdgeType
Definition: GrTypesPriv.h:361
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define SkScalarCeilToScalar(x)
Definition: SkScalar.h:31
static std::unique_ptr< GrFragmentProcessor > Rect(std::unique_ptr< GrFragmentProcessor >, GrClipEdgeType, SkRect)
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)
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
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
double y
double x
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
const uint32_t fp
GrOp::Owner MakeRect(GrRecordingContext *context, GrPaint &&paint, const SkRect &drawRect, const SkRect &localRect, const SkMatrix &localM)
Definition: TestOps.cpp:227
SurfaceDrawContext * TopDeviceSurfaceDrawContext(const SkCanvas *canvas)
Definition: GrCanvas.cpp:20
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646

◆ onOnceBeforeDraw()

void skiagm::AARectEffect::onOnceBeforeDraw ( )
inlineoverrideprotected

Definition at line 47 of file aarecteffect.cpp.

47{}

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