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

Public Member Functions

 PathOpsInverseGM ()
 
- 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
 

Protected Member Functions

void onOnceBeforeDraw () override
 
SkColor blend (SkColor one, SkColor two)
 
void makePaint (SkPaint *paint, SkColor color)
 
SkString getName () const override
 
SkISize getISize () override
 
void onDraw (SkCanvas *canvas) override
 
- Protected Member Functions inherited from skiagm::GM
virtual DrawResult onGpuSetup (SkCanvas *, SkString *, GraphiteTestContext *)
 
virtual void onGpuTeardown ()
 
virtual DrawResult onDraw (SkCanvas *, SkString *errorMsg)
 
virtual bool onAnimate (double)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
GraphiteTestContextgraphiteTestContext () const
 

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
 
- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

Definition at line 23 of file pathopsinverse.cpp.

Constructor & Destructor Documentation

◆ PathOpsInverseGM()

skiagm::PathOpsInverseGM::PathOpsInverseGM ( )
inline

Definition at line 25 of file pathopsinverse.cpp.

25 {
26 }

Member Function Documentation

◆ blend()

SkColor skiagm::PathOpsInverseGM::blend ( SkColor  one,
SkColor  two 
)
inlineprotected

Definition at line 44 of file pathopsinverse.cpp.

44 {
45 SkBitmap temp;
46 temp.allocN32Pixels(1, 1);
47 SkCanvas canvas(temp);
48 canvas.drawColor(one);
49 canvas.drawColor(two);
50 void* pixels = temp.getPixels();
51 return *(SkColor*) pixels;
52 }
uint32_t SkColor
Definition SkColor.h:37
void * getPixels() const
Definition SkBitmap.h:283
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition SkBitmap.cpp:232

◆ getISize()

SkISize skiagm::PathOpsInverseGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 62 of file pathopsinverse.cpp.

62{ return SkISize::Make(1200, 900); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ getName()

SkString skiagm::PathOpsInverseGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 60 of file pathopsinverse.cpp.

60{ return SkString("pathopsinverse"); }

◆ makePaint()

void skiagm::PathOpsInverseGM::makePaint ( SkPaint paint,
SkColor  color 
)
inlineprotected

Definition at line 54 of file pathopsinverse.cpp.

54 {
55 paint->setAntiAlias(true);
56 paint->setStyle(SkPaint::kFill_Style);
57 paint->setColor(color);
58 }
SkColor4f color
@ kFill_Style
set to fill geometry
Definition SkPaint.h:193
const Paint & paint

◆ onDraw()

void skiagm::PathOpsInverseGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 64 of file pathopsinverse.cpp.

64 {
65 SkPath one, two;
66 int yPos = 0;
67 for (int oneFill = 0; oneFill <= 1; ++oneFill) {
70 for (int twoFill = 0; twoFill <= 1; ++twoFill) {
73 one.reset();
74 one.setFillType(oneF);
75 one.addRect(10, 10, 70, 70);
76 two.reset();
77 two.setFillType(twoF);
78 two.addRect(40, 40, 100, 100);
79 canvas->save();
80 canvas->translate(0, SkIntToScalar(yPos));
81 canvas->clipRect(SkRect::MakeWH(110, 110), true);
82 canvas->drawPath(one, fOnePaint);
83 canvas->drawPath(one, fOutlinePaint);
84 canvas->drawPath(two, fTwoPaint);
85 canvas->drawPath(two, fOutlinePaint);
86 canvas->restore();
87 int xPos = 150;
88 for (int op = kDifference_SkPathOp; op <= kReverseDifference_SkPathOp; ++op) {
90 Op(one, two, (SkPathOp) op, &result);
91 canvas->save();
92 canvas->translate(SkIntToScalar(xPos), SkIntToScalar(yPos));
93 canvas->clipRect(SkRect::MakeWH(110, 110), true);
94 canvas->drawPath(result, fOpPaint[op]);
95 canvas->drawPath(result, fOutlinePaint);
96 canvas->restore();
97 xPos += 150;
98 }
99 yPos += 150;
100 }
101 }
102 }
SkPathOp
Definition SkPathOps.h:22
@ kReverseDifference_SkPathOp
subtract the first path from the op path
Definition SkPathOps.h:27
@ kDifference_SkPathOp
subtract the op path from the first path
Definition SkPathOps.h:23
SkPathFillType
Definition SkPathTypes.h:11
#define SkIntToScalar(x)
Definition SkScalar.h:57
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void restore()
Definition SkCanvas.cpp:465
void translate(SkScalar dx, SkScalar dy)
int save()
Definition SkCanvas.cpp:451
void drawPath(const SkPath &path, const SkPaint &paint)
void setFillType(SkPathFillType ft)
Definition SkPath.h:235
SkPath & reset()
Definition SkPath.cpp:360
SkPath & addRect(const SkRect &rect, SkPathDirection dir, unsigned start)
Definition SkPath.cpp:854
GAsyncResult * result
static constexpr SkRect MakeWH(float w, float h)
Definition SkRect.h:609

◆ onOnceBeforeDraw()

void skiagm::PathOpsInverseGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 29 of file pathopsinverse.cpp.

29 {
30 const unsigned oneColor = ToolUtils::color_to_565(0xFF8080FF);
31 const unsigned twoColor = 0x807F1f1f;
32 SkColor blendColor = blend(oneColor, twoColor);
33 makePaint(&fOnePaint, oneColor);
34 makePaint(&fTwoPaint, twoColor);
35 makePaint(&fOpPaint[kDifference_SkPathOp], oneColor);
36 makePaint(&fOpPaint[kIntersect_SkPathOp], blendColor);
37 makePaint(&fOpPaint[kUnion_SkPathOp], ToolUtils::color_to_565(0xFFc0FFc0));
38 makePaint(&fOpPaint[kReverseDifference_SkPathOp], twoColor);
39 makePaint(&fOpPaint[kXOR_SkPathOp], ToolUtils::color_to_565(0xFFa0FFe0));
40 makePaint(&fOutlinePaint, 0xFF000000);
41 fOutlinePaint.setStyle(SkPaint::kStroke_Style);
42 }
@ kIntersect_SkPathOp
intersect the two paths
Definition SkPathOps.h:24
@ kUnion_SkPathOp
union (inclusive-or) the two paths
Definition SkPathOps.h:25
@ kXOR_SkPathOp
exclusive-or the two paths
Definition SkPathOps.h:26
void setStyle(Style style)
Definition SkPaint.cpp:105
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
void makePaint(SkPaint *paint, SkColor color)
SkColor blend(SkColor one, SkColor two)
SkColor color_to_565(SkColor color)

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