Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Private Member Functions | List of all members
skiagm::DistantClipGM Class Reference
Inheritance diagram for skiagm::DistantClipGM:
skiagm::GM

Private Member Functions

SkString getName () const override
 
SkISize getISize () override
 
void onDraw (SkCanvas *canvas) override
 

Additional Inherited Members

- Public Types inherited from skiagm::GM
enum  Mode { kGM_Mode , kSample_Mode , kBench_Mode }
 
using DrawResult = skiagm::DrawResult
 
using GraphiteTestContext = skiatest::graphite::GraphiteTestContext
 
- Public Member Functions inherited from skiagm::GM
 GM (SkColor backgroundColor=SK_ColorWHITE)
 
virtual ~GM ()
 
void setMode (Mode mode)
 
Mode getMode () const
 
DrawResult gpuSetup (SkCanvas *, SkString *errorMsg, GraphiteTestContext *=nullptr)
 
void gpuTeardown ()
 
void onceBeforeDraw ()
 
DrawResult draw (SkCanvas *canvas)
 
DrawResult draw (SkCanvas *, SkString *errorMsg)
 
void drawBackground (SkCanvas *)
 
DrawResult drawContent (SkCanvas *canvas)
 
DrawResult drawContent (SkCanvas *, SkString *errorMsg)
 
virtual bool runAsBench () const
 
SkScalar width ()
 
SkScalar height ()
 
SkColor getBGColor () const
 
void setBGColor (SkColor)
 
void drawSizeBounds (SkCanvas *, SkColor)
 
bool animate (double)
 
virtual bool onChar (SkUnichar)
 
bool getControls (SkMetaData *controls)
 
void setControls (const SkMetaData &controls)
 
virtual void modifyGrContextOptions (GrContextOptions *)
 
virtual void modifyGraphiteContextOptions (skgpu::graphite::ContextOptions *) const
 
virtual bool isBazelOnly () const
 
virtual std::map< std::string, std::string > getGoldKeys () const
 
- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 
- Protected Member Functions inherited from skiagm::GM
virtual DrawResult onGpuSetup (SkCanvas *, SkString *, GraphiteTestContext *)
 
virtual void onGpuTeardown ()
 
virtual void onOnceBeforeDraw ()
 
virtual DrawResult onDraw (SkCanvas *, SkString *errorMsg)
 
virtual bool onAnimate (double)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
GraphiteTestContextgraphiteTestContext () const
 

Detailed Description

Definition at line 23 of file distantclip.cpp.

Member Function Documentation

◆ getISize()

SkISize skiagm::DistantClipGM::getISize ( )
inlineoverrideprivatevirtual

Implements skiagm::GM.

Definition at line 26 of file distantclip.cpp.

26{ return {100, 100}; }

◆ getName()

SkString skiagm::DistantClipGM::getName ( ) const
inlineoverrideprivatevirtual

Implements skiagm::GM.

Definition at line 24 of file distantclip.cpp.

24{ return SkString("distantclip"); }

◆ onDraw()

void skiagm::DistantClipGM::onDraw ( SkCanvas canvas)
inlineoverrideprivatevirtual

Reimplemented from skiagm::GM.

Definition at line 28 of file distantclip.cpp.

28 {
29 constexpr SkScalar kOffset = 35000.0f;
30 constexpr SkScalar kExtents = 1000.0f;
31
32 SkPictureRecorder recorder;
33 // We record a picture of huge vertical extents in which we clear the canvas to red, create
34 // a 'extents' by 'extents' round rect clip at a vertical offset of 'offset', then draw
35 // green into that.
36 SkCanvas* rec = recorder.beginRecording(kExtents, kOffset + kExtents);
38 rec->save();
39 SkRect r = SkRect::MakeXYWH(-kExtents, kOffset - kExtents, 2 * kExtents, 2 * kExtents);
40 rec->clipPath(SkPath::RRect(r, 5, 5), true);
42 rec->restore();
44
45 // Next we play that picture into another picture of the same size.
46 pict->playback(recorder.beginRecording(pict->cullRect().width(),
47 pict->cullRect().height()));
49
50 // Finally we play the part of that second picture that should be green into the canvas.
51 canvas->save();
52 canvas->translate(kExtents / 2, -(kOffset - kExtents / 2));
53 pict2->playback(canvas);
54 canvas->restore();
55
56 // If the image is red, we erroneously decided the clipPath was empty and didn't record
57 // the green drawColor, if it's green we're all good.
58 }
static constexpr uint64_t kOffset
Definition DrawPass.cpp:54
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition SkColor.h:131
void restore()
Definition SkCanvas.cpp:465
void translate(SkScalar dx, SkScalar dy)
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition SkCanvas.h:1182
void clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)
int save()
Definition SkCanvas.cpp:451
static SkPath RRect(const SkRRect &, SkPathDirection dir=SkPathDirection::kCW)
Definition SkPath.cpp:3534
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
float SkScalar
Definition extension.cpp:12
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659

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