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

Public Member Functions

 AndroidBlendModesGM ()
 
- 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 SkISize getISize ()=0
 
virtual SkString getName () const =0
 
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

SkString getName () const override
 
SkISize getISize () override
 
void onOnceBeforeDraw () override
 
void drawTile (SkCanvas *canvas, int xOffset, int yOffset, SkBlendMode mode)
 
void onDraw (SkCanvas *canvas) override
 
- 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 void onDraw (SkCanvas *)
 
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 29 of file androidblendmodes.cpp.

Constructor & Destructor Documentation

◆ AndroidBlendModesGM()

skiagm::AndroidBlendModesGM::AndroidBlendModesGM ( )
inline

Definition at line 31 of file androidblendmodes.cpp.

31 {
33 }
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
void setBGColor(SkColor)
Definition: gm.cpp:159

Member Function Documentation

◆ drawTile()

void skiagm::AndroidBlendModesGM::drawTile ( SkCanvas canvas,
int  xOffset,
int  yOffset,
SkBlendMode  mode 
)
inlineprotected

Definition at line 65 of file androidblendmodes.cpp.

65 {
66 canvas->translate(xOffset, yOffset);
67
68 canvas->clipRect(SkRect::MakeXYWH(0, 0, 256, 256));
69
70 canvas->saveLayer(nullptr, nullptr);
71
72 SkPaint p;
73 canvas->drawImage(fCompositeDst.asImage(), 0, 0, SkSamplingOptions(), &p);
74 p.setBlendMode(mode);
75 canvas->drawImage(fCompositeSrc.asImage(), 0, 0, SkSamplingOptions(), &p);
76 }
sk_sp< SkImage > asImage() const
Definition: SkBitmap.cpp:645
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition: SkCanvas.cpp:496
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
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 mode
Definition: switches.h:228
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ getISize()

SkISize skiagm::AndroidBlendModesGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 38 of file androidblendmodes.cpp.

38 {
39 return SkISize::Make(kNumCols * kBitmapSize, kNumRows * kBitmapSize);
40 }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 36 of file androidblendmodes.cpp.

36{ return SkString("androidblendmodes"); }

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 78 of file androidblendmodes.cpp.

78 {
80
81 ToolUtils::draw_checkerboard(canvas, kWhite, kGrey, 32);
82
83 int xOffset = 0, yOffset = 0;
84
85 // Android doesn't expose all the blend modes
86 // Note that the Android documentation calls:
87 // Skia's kPlus, add
88 // Skia's kModulate, multiply
98
99 int saveCount = canvas->save();
100 this->drawTile(canvas, xOffset, yOffset, mode);
101 canvas->restoreToCount(saveCount);
102
104 xOffset + kBitmapSize/2.0f,
105 yOffset + kBitmapSize,
107
108 xOffset += 256;
109 if (xOffset >= 1024) {
110 xOffset = 0;
111 yOffset += 256;
112 }
113 }
114 }
SK_API const char * SkBlendMode_Name(SkBlendMode blendMode)
SkBlendMode
Definition: SkBlendMode.h:38
@ kSrcOut
r = s * (1-da)
@ kPlus
r = min(s + d, 1)
@ kLighten
rc = s + d - min(s*da, d*sa), ra = kSrcOver
@ kDstIn
r = d * sa
@ kModulate
r = s*d
@ kScreen
r = s + d - s*d
@ kSrcOver
r = s + (1-sa)*d
@ kXor
r = s*(1-da) + d*(1-sa)
@ kOverlay
multiply or screen, depending on destination
@ kSrcATop
r = s*da + d*(1-sa)
@ kDstATop
r = d*sa + s*(1-da)
@ kDstOver
r = d + (1-da)*s
@ kDstOut
r = d * (1-sa)
@ kDarken
rc = s + d - max(s*da, d*sa), ra = kSrcOver
@ kSrcIn
r = s * da
@ kClear
r = 0
void restoreToCount(int saveCount)
Definition: SkCanvas.cpp:478
int save()
Definition: SkCanvas.cpp:447
Definition: SkFont.h:35
static void DrawString(SkCanvas *canvas, const char text[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint, Align align=kLeft_Align)
Definition: SkTextUtils.h:34
void drawTile(SkCanvas *canvas, int xOffset, int yOffset, SkBlendMode mode)
void draw_checkerboard(SkCanvas *canvas, SkColor c1, SkColor c2, int size)
Definition: ToolUtils.cpp:174
SkFont DefaultPortableFont()
font
Font Metadata and Metrics.

◆ onOnceBeforeDraw()

void skiagm::AndroidBlendModesGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 42 of file androidblendmodes.cpp.

42 {
43 SkImageInfo ii = SkImageInfo::MakeN32Premul(kBitmapSize, kBitmapSize);
44 {
45 fCompositeSrc.allocPixels(ii);
46 SkCanvas tmp(fCompositeSrc);
47 tmp.clear(SK_ColorTRANSPARENT);
48 SkPaint p;
49 p.setAntiAlias(true);
50 p.setColor(ToolUtils::color_to_565(kBlue));
51 tmp.drawRect(SkRect::MakeLTRB(16, 96, 160, 240), p);
52 }
53
54 {
55 fCompositeDst.allocPixels(ii);
56 SkCanvas tmp(fCompositeDst);
57 tmp.clear(SK_ColorTRANSPARENT);
58 SkPaint p;
59 p.setAntiAlias(true);
60 p.setColor(ToolUtils::color_to_565(kRed));
61 tmp.drawCircle(160, 95, 80, p);
62 }
63 }
constexpr SkColor SK_ColorTRANSPARENT
Definition: SkColor.h:99
void allocPixels(const SkImageInfo &info, size_t rowBytes)
Definition: SkBitmap.cpp:258
SkColor color_to_565(SkColor color)
Definition: ToolUtils.cpp:139
static SkImageInfo MakeN32Premul(int width, int height)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646

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