Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions
gm.h File Reference
#include "include/core/SkColor.h"
#include "include/core/SkScalar.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkMacros.h"
#include "tools/Registry.h"
#include <functional>
#include <map>
#include <memory>

Go to the source code of this file.

Classes

class  skiagm::GM
 
class  skiagm::SimpleGM
 

Namespaces

namespace  skiagm
 
namespace  skiagm::verifiers
 
namespace  skgpu
 
namespace  skgpu::graphite
 
namespace  skiatest
 
namespace  skiatest::graphite
 

Macros

#define DEF_GM(CODE)
 
#define DEF_SIMPLE_GM(NAME, CANVAS, W, H)    DEF_SIMPLE_GM_BG_NAME(NAME, CANVAS, W, H, SK_ColorWHITE, SkString(#NAME))
 
#define DEF_SIMPLE_GM_BG(NAME, CANVAS, W, H, BGCOLOR)    DEF_SIMPLE_GM_BG_NAME(NAME, CANVAS, W, H, BGCOLOR, SkString(#NAME))
 
#define DEF_SIMPLE_GM_BG_NAME(NAME, CANVAS, W, H, BGCOLOR, NAME_STR)
 
#define DEF_SIMPLE_GM_CAN_FAIL(NAME, CANVAS, ERR_MSG, W, H)    DEF_SIMPLE_GM_BG_NAME_CAN_FAIL(NAME, CANVAS, ERR_MSG, W, H, SK_ColorWHITE, SkString(#NAME))
 
#define DEF_SIMPLE_GM_BG_CAN_FAIL(NAME, CANVAS, ERR_MSG, W, H, BGCOLOR)    DEF_SIMPLE_GM_BG_NAME_CAN_FAIL(NAME, CANVAS, ERR_MSG, W, H, BGCOLOR, SkString(#NAME))
 
#define DEF_SIMPLE_GM_BG_NAME_CAN_FAIL(NAME, CANVAS, ERR_MSG, W, H, BGCOLOR, NAME_STR)
 
#define DEF_GM_REGISTERER_FN(FN)    static skiagm::GMRegistererFnRegistry SK_MACRO_APPEND_COUNTER(REG_)(FN)
 

Typedefs

using skiagm::GMFactory = std::function< std::unique_ptr< skiagm::GM >()>
 
using skiagm::GMRegistry = sk_tools::Registry< GMFactory >
 
using skiagm::GMRegistererFn = std::function< std::string()>
 
using skiagm::GMRegistererFnRegistry = sk_tools::Registry< GMRegistererFn >
 

Enumerations

enum class  skiagm::DrawResult { skiagm::kOk , skiagm::kFail , skiagm::kSkip }
 

Functions

void skiagm::Register (skiagm::GM *gm)
 
void MarkGMGood (SkCanvas *, SkScalar x, SkScalar y)
 
void MarkGMBad (SkCanvas *, SkScalar x, SkScalar y)
 

Macro Definition Documentation

◆ DEF_GM

#define DEF_GM (   CODE )
Value:
[]() { return std::unique_ptr<skiagm::GM>([]() { CODE; }()); });
#define SK_MACRO_APPEND_COUNTER(name)
Definition SkMacros.h:27

Definition at line 40 of file gm.h.

42 { return std::unique_ptr<skiagm::GM>([]() { CODE; }()); });

◆ DEF_GM_REGISTERER_FN

#define DEF_GM_REGISTERER_FN (   FN)     static skiagm::GMRegistererFnRegistry SK_MACRO_APPEND_COUNTER(REG_)(FN)

Definition at line 73 of file gm.h.

◆ DEF_SIMPLE_GM

#define DEF_SIMPLE_GM (   NAME,
  CANVAS,
  W,
  H 
)     DEF_SIMPLE_GM_BG_NAME(NAME, CANVAS, W, H, SK_ColorWHITE, SkString(#NAME))

Definition at line 50 of file gm.h.

◆ DEF_SIMPLE_GM_BG

#define DEF_SIMPLE_GM_BG (   NAME,
  CANVAS,
  W,
  H,
  BGCOLOR 
)     DEF_SIMPLE_GM_BG_NAME(NAME, CANVAS, W, H, BGCOLOR, SkString(#NAME))

Definition at line 52 of file gm.h.

◆ DEF_SIMPLE_GM_BG_CAN_FAIL

#define DEF_SIMPLE_GM_BG_CAN_FAIL (   NAME,
  CANVAS,
  ERR_MSG,
  W,
  H,
  BGCOLOR 
)     DEF_SIMPLE_GM_BG_NAME_CAN_FAIL(NAME, CANVAS, ERR_MSG, W, H, BGCOLOR, SkString(#NAME))

Definition at line 64 of file gm.h.

◆ DEF_SIMPLE_GM_BG_NAME

#define DEF_SIMPLE_GM_BG_NAME (   NAME,
  CANVAS,
  W,
  H,
  BGCOLOR,
  NAME_STR 
)
Value:
static void SK_MACRO_CONCAT(NAME,_GM_inner)(SkCanvas*); \
DEF_SIMPLE_GM_BG_NAME_CAN_FAIL(NAME, CANVAS,, W, H, BGCOLOR, NAME_STR) { \
SK_MACRO_CONCAT(NAME,_GM_inner)(CANVAS); \
} \
void SK_MACRO_CONCAT(NAME,_GM_inner)(SkCanvas* CANVAS)
#define SK_MACRO_CONCAT(X, Y)
Definition SkMacros.h:16
#define W
Definition aaa.cpp:17
Definition SkMD5.cpp:130

Definition at line 54 of file gm.h.

56 { \
57 SK_MACRO_CONCAT(NAME,_GM_inner)(CANVAS); \
59 } \
60 void SK_MACRO_CONCAT(NAME,_GM_inner)(SkCanvas* CANVAS)

◆ DEF_SIMPLE_GM_BG_NAME_CAN_FAIL

#define DEF_SIMPLE_GM_BG_NAME_CAN_FAIL (   NAME,
  CANVAS,
  ERR_MSG,
  W,
  H,
  BGCOLOR,
  NAME_STR 
)
Value:
DEF_GM(return new skiagm::SimpleGM(BGCOLOR, NAME_STR, {W,H}, SK_MACRO_CONCAT(NAME,_GM));) \
skiagm::DrawResult SK_MACRO_CONCAT(NAME,_GM)(SkCanvas* CANVAS, SkString* ERR_MSG)
DrawResult
Definition gm.h:104

Definition at line 66 of file gm.h.

68 {W,H}, SK_MACRO_CONCAT(NAME,_GM));) \
69 skiagm::DrawResult SK_MACRO_CONCAT(NAME,_GM)(SkCanvas* CANVAS, SkString* ERR_MSG)

◆ DEF_SIMPLE_GM_CAN_FAIL

#define DEF_SIMPLE_GM_CAN_FAIL (   NAME,
  CANVAS,
  ERR_MSG,
  W,
  H 
)     DEF_SIMPLE_GM_BG_NAME_CAN_FAIL(NAME, CANVAS, ERR_MSG, W, H, SK_ColorWHITE, SkString(#NAME))

Definition at line 62 of file gm.h.

Function Documentation

◆ MarkGMBad()

void MarkGMBad ( SkCanvas canvas,
SkScalar  x,
SkScalar  y 
)

Definition at line 238 of file gm.cpp.

238 {
239 mark(canvas, x,y, [&] {
240 // A red circle.
241 canvas->drawCircle(0,0, 12, SkPaint(SkColor4f::FromColor(SkColorSetRGB(231, 41, 138))));
242
243 // Cut out an 'X'.
245 paint.setBlendMode(SkBlendMode::kSrc);
246 paint.setStrokeWidth(2);
248 canvas->drawLine(-5,-5,
249 +5,+5, paint);
250 canvas->drawLine(+5,-5,
251 -5,+5, paint);
252 });
253}
#define SkColorSetRGB(r, g, b)
Definition SkColor.h:57
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
const Paint & paint
static void mark(SkCanvas *canvas, SkScalar x, SkScalar y, Fn &&fn)
Definition gm.cpp:211
double y
double x
constexpr SkColor4f kTransparent
Definition SkColor.h:434
static SkRGBA4f FromColor(SkColor color)

◆ MarkGMGood()

void MarkGMGood ( SkCanvas canvas,
SkScalar  x,
SkScalar  y 
)

Definition at line 221 of file gm.cpp.

221 {
222 mark(canvas, x,y, [&]{
223 // A green circle.
224 canvas->drawCircle(0, 0, 12, SkPaint(SkColor4f::FromColor(SkColorSetRGB(27, 158, 119))));
225
226 // Cut out a check mark.
228 paint.setBlendMode(SkBlendMode::kSrc);
229 paint.setStrokeWidth(2);
231 canvas->drawLine(-6, 0,
232 -1, 5, paint);
233 canvas->drawLine(-1, +5,
234 +7, -5, paint);
235 });
236}