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

Public Member Functions

 EmbossGM ()
 
- 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 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 36 of file emboss.cpp.

Constructor & Destructor Documentation

◆ EmbossGM()

EmbossGM::EmbossGM ( )
inline

Definition at line 38 of file emboss.cpp.

38 {
39 }

Member Function Documentation

◆ getISize()

SkISize EmbossGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 44 of file emboss.cpp.

44{ return SkISize::Make(600, 120); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString EmbossGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 42 of file emboss.cpp.

42{ return SkString("emboss"); }

◆ onDraw()

void EmbossGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 46 of file emboss.cpp.

46 {
48 auto img = make_bm();
49 canvas->drawImage(img, 10, 10);
50 canvas->translate(img->width() + SkIntToScalar(10), 0);
51
52 paint.setMaskFilter(SkEmbossMaskFilter::Make(
54 { { SK_Scalar1, SK_Scalar1, SK_Scalar1 }, 0, 128, 16*2 }));
55 canvas->drawImage(img, 10, 10, SkSamplingOptions(), &paint);
56 canvas->translate(img->width() + SkIntToScalar(10), 0);
57
58 // this combination of emboss+colorfilter used to crash -- so we exercise it to
59 // confirm that we have a fix.
60 paint.setColorFilter(SkColorFilters::Blend(0xFFFF0000, SkBlendMode::kSrcATop));
61 canvas->drawImage(img, 10, 10, SkSamplingOptions(), &paint);
62 canvas->translate(img->width() + SkIntToScalar(10), 0);
63
64 paint.setAntiAlias(true);
66 paint.setStrokeWidth(SkIntToScalar(10));
67 paint.setMaskFilter(SkEmbossMaskFilter::Make(
69 { { SK_Scalar1, SK_Scalar1, SK_Scalar1 }, 0, 128, 16*2 }));
70 paint.setColorFilter(nullptr);
72 paint.setDither(true);
73 canvas->drawCircle(SkIntToScalar(50), SkIntToScalar(50),
74 SkIntToScalar(30), paint);
75 canvas->translate(SkIntToScalar(100), 0);
76
79 canvas->drawString("Hello", 0, 50, font, paint);
80
81 paint.setShader(nullptr);
82 paint.setColor(SK_ColorGREEN);
83 canvas->drawString("World", 0, 100, font, paint);
84 }
@ kSrcATop
r = s*da + d*(1-sa)
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
#define SK_Scalar1
Definition: SkScalar.h:18
#define SkIntToScalar(x)
Definition: SkScalar.h:57
static SkScalar SK_SPI ConvertRadiusToSigma(SkScalar radius)
Definition: SkBlurMask.cpp:39
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
Definition: SkCanvas.cpp:2707
static sk_sp< SkColorFilter > Blend(const SkColor4f &c, sk_sp< SkColorSpace >, SkBlendMode mode)
static sk_sp< SkMaskFilter > Make(SkScalar blurSigma, const Light &light)
Definition: SkFont.h:35
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
const Paint & paint
Definition: color_source.cc:38
static sk_sp< SkImage > make_bm()
Definition: emboss.cpp:27
SK_API sk_sp< SkShader > Color(SkColor)
sk_sp< SkTypeface > DefaultPortableTypeface()
font
Font Metadata and Metrics.
SkSamplingOptions(SkFilterMode::kLinear))

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