41 static skiagm::GMRegistry SK_MACRO_APPEND_COUNTER(REG_)( \
42 []() { return std::unique_ptr<skiagm::GM>([]() { CODE; }()); });
50#define DEF_SIMPLE_GM(NAME, CANVAS, W, H) \
51 DEF_SIMPLE_GM_BG_NAME(NAME, CANVAS, W, H, SK_ColorWHITE, SkString(#NAME))
52#define DEF_SIMPLE_GM_BG(NAME, CANVAS, W, H, BGCOLOR) \
53 DEF_SIMPLE_GM_BG_NAME(NAME, CANVAS, W, H, BGCOLOR, SkString(#NAME))
54#define DEF_SIMPLE_GM_BG_NAME(NAME, CANVAS, W, H, BGCOLOR, NAME_STR) \
55 static void SK_MACRO_CONCAT(NAME,_GM_inner)(SkCanvas*); \
56 DEF_SIMPLE_GM_BG_NAME_CAN_FAIL(NAME, CANVAS,, W, H, BGCOLOR, NAME_STR) { \
57 SK_MACRO_CONCAT(NAME,_GM_inner)(CANVAS); \
58 return skiagm::DrawResult::kOk; \
60 void SK_MACRO_CONCAT(NAME,_GM_inner)(SkCanvas* CANVAS)
62#define DEF_SIMPLE_GM_CAN_FAIL(NAME, CANVAS, ERR_MSG, W, H) \
63 DEF_SIMPLE_GM_BG_NAME_CAN_FAIL(NAME, CANVAS, ERR_MSG, W, H, SK_ColorWHITE, SkString(#NAME))
64#define DEF_SIMPLE_GM_BG_CAN_FAIL(NAME, CANVAS, ERR_MSG, W, H, BGCOLOR) \
65 DEF_SIMPLE_GM_BG_NAME_CAN_FAIL(NAME, CANVAS, ERR_MSG, W, H, BGCOLOR, SkString(#NAME))
66#define DEF_SIMPLE_GM_BG_NAME_CAN_FAIL(NAME, CANVAS, ERR_MSG, W, H, BGCOLOR, NAME_STR) \
67 static skiagm::DrawResult SK_MACRO_CONCAT(NAME,_GM)(SkCanvas*, SkString*); \
68 DEF_GM(return new skiagm::SimpleGM(BGCOLOR, NAME_STR, {W,H}, SK_MACRO_CONCAT(NAME,_GM));) \
69 skiagm::DrawResult SK_MACRO_CONCAT(NAME,_GM)(SkCanvas* CANVAS, SkString* ERR_MSG)
73#define DEF_GM_REGISTERER_FN(FN) \
74 static skiagm::GMRegistererFnRegistry SK_MACRO_APPEND_COUNTER(REG_)(FN)
79#define DEF_SIMPLE_GPU_GM(NAME, GR_CONTEXT, CANVAS, W, H) \
80 DEF_SIMPLE_GPU_GM_BG(NAME, GR_CONTEXT, CANVAS, W, H, SK_ColorWHITE)
82#define DEF_SIMPLE_GPU_GM_BG(NAME, GR_CONTEXT, CANVAS, W, H, BGCOLOR) \
83 static void SK_MACRO_CONCAT(NAME,_GM_inner)(GrRecordingContext*, SkCanvas*); \
84 DEF_SIMPLE_GPU_GM_BG_CAN_FAIL(NAME, GR_CONTEXT, CANVAS, , W, H, BGCOLOR) { \
85 SK_MACRO_CONCAT(NAME,_GM_inner)(GR_CONTEXT, CANVAS); \
86 return skiagm::DrawResult::kOk; \
88 void SK_MACRO_CONCAT(NAME,_GM_inner)(GrRecordingContext* GR_CONTEXT, SkCanvas* CANVAS)
90#define DEF_SIMPLE_GPU_GM_CAN_FAIL(NAME, GR_CONTEXT, CANVAS, ERR_MSG, W, H) \
91 DEF_SIMPLE_GPU_GM_BG_CAN_FAIL(NAME, GR_CONTEXT, CANVAS, ERR_MSG, W, H, SK_ColorWHITE)
93#define DEF_SIMPLE_GPU_GM_BG_CAN_FAIL(NAME, GR_CONTEXT, CANVAS, ERR_MSG, W, H, BGCOLOR) \
94 static skiagm::DrawResult SK_MACRO_CONCAT(NAME,_GM)( \
95 GrRecordingContext*, SkCanvas*, SkString*); \
96 DEF_GM(return new skiagm::SimpleGpuGM(BGCOLOR, SkString(#NAME), {W,H}, \
97 SK_MACRO_CONCAT(NAME,_GM));) \
98 skiagm::DrawResult SK_MACRO_CONCAT(NAME,_GM)( \
99 GrRecordingContext* GR_CONTEXT, SkCanvas* CANVAS, SkString* ERR_MSG)
128 "This test is for GPU configs only.";
134 if (!fHaveCalledOnceBeforeDraw) {
135 fHaveCalledOnceBeforeDraw =
true;
142 return this->
draw(canvas, &errorMsg);
208 return std::map<std::string, std::string>{
210 {
"source_type",
"gm"},
233 bool fHaveCalledOnceBeforeDraw =
false;
234 bool fGpuSetup =
false;
239 using GMFactory = std::function<std::unique_ptr<skiagm::GM>()>;
257#if defined(SK_GANESH)
261 class GpuGM :
public GM {
294#if defined(SK_GANESH)
295 class SimpleGpuGM :
public GpuGM {
const char *(* DrawProc)(const BezierRec *, int)
static const SkColor bgColor
constexpr SkColor SK_ColorWHITE
const char * c_str() const
DrawResult gpuSetup(SkCanvas *, SkString *errorMsg, GraphiteTestContext *=nullptr)
virtual void onGpuTeardown()
GM(SkColor backgroundColor=SK_ColorWHITE)
DrawResult drawContent(SkCanvas *canvas)
static constexpr char kErrorMsg_DrawSkippedGpuOnly[]
virtual bool onChar(SkUnichar)
virtual SkISize getISize()=0
virtual std::map< std::string, std::string > getGoldKeys() const
virtual void modifyGraphiteContextOptions(skgpu::graphite::ContextOptions *) const
virtual void onSetControls(const SkMetaData &)
virtual void onOnceBeforeDraw()
void drawSizeBounds(SkCanvas *, SkColor)
GraphiteTestContext * graphiteTestContext() const
bool getControls(SkMetaData *controls)
SkColor getBGColor() const
void setControls(const SkMetaData &controls)
virtual bool runAsBench() const
skiagm::DrawResult DrawResult
virtual DrawResult onGpuSetup(SkCanvas *, SkString *, GraphiteTestContext *)
virtual SkString getName() const =0
virtual bool isBazelOnly() const
skiatest::graphite::GraphiteTestContext GraphiteTestContext
virtual bool onAnimate(double)
DrawResult draw(SkCanvas *canvas)
virtual bool onGetControls(SkMetaData *)
virtual void modifyGrContextOptions(GrContextOptions *)
virtual DrawResult onDraw(SkCanvas *, SkString *errorMsg)
void drawBackground(SkCanvas *)
SimpleGM(SkColor bgColor, const SkString &name, const SkISize &size, DrawProc drawProc)
SkISize getISize() override
DrawResult(*)(SkCanvas *, SkString *) DrawProc
SkString getName() const override
Dart_NativeFunction function
void MarkGMBad(SkCanvas *, SkScalar x, SkScalar y)
void MarkGMGood(SkCanvas *, SkScalar x, SkScalar y)
DEF_SWITCHES_START aot vmservice shared library name
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
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 keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
std::function< std::unique_ptr< skiagm::GM >()> GMFactory
std::function< std::string()> GMRegistererFn
void Register(skiagm::GM *gm)