Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
TestEffect Class Reference

Public Member Functions

 TestEffect (skiatest::Reporter *r, GrRecordingContext *grContext, const GraphiteInfo *graphite, SkISize size={2, 2})
 
void build (const char *src)
 
SkRuntimeShaderBuilder::BuilderUniform uniform (const char *name)
 
SkRuntimeShaderBuilder::BuilderChild child (const char *name)
 
void test (std::array< GrColor, 4 > expected, PreTestFn preTestCallback=nullptr)
 
std::string trace (const SkIPoint &traceCoord)
 
void test (GrColor expected, PreTestFn preTestCallback=nullptr)
 

Detailed Description

Definition at line 446 of file SkRuntimeEffectTest.cpp.

Constructor & Destructor Documentation

◆ TestEffect()

TestEffect::TestEffect ( skiatest::Reporter r,
GrRecordingContext grContext,
const GraphiteInfo graphite,
SkISize  size = {2, 2} 
)
inline

Definition at line 448 of file SkRuntimeEffectTest.cpp.

451 {2, 2})
452 : fReporter(r), fGrContext(grContext), fGraphite(graphite), fSize(size) {
453 fSurface = make_surface(fGrContext, fGraphite, fSize);
454 }
static sk_sp< SkSurface > make_surface(GrRecordingContext *grContext, const GraphiteInfo *graphite, SkISize size)
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
Definition switches.h:259

Member Function Documentation

◆ build()

void TestEffect::build ( const char *  src)
inline

Definition at line 456 of file SkRuntimeEffectTest.cpp.

456 {
459 auto [effect, errorText] = SkRuntimeEffect::MakeForShader(SkString(src), options);
460 if (!effect) {
461 ERRORF(fReporter, "Effect didn't compile: %s", errorText.c_str());
462 return;
463 }
464 fBuilder.init(std::move(effect));
465 }
const char * options
#define ERRORF(r,...)
Definition Test.h:293
static void AllowPrivateAccess(SkRuntimeEffect::Options *options)
static Result MakeForShader(SkString sksl, const Options &)
T * init(Args &&... args)
Definition SkTLazy.h:45

◆ child()

SkRuntimeShaderBuilder::BuilderChild TestEffect::child ( const char *  name)
inline

Definition at line 471 of file SkRuntimeEffectTest.cpp.

471 {
472 return fBuilder->child(name);
473 }
BuilderChild child(std::string_view name)
const char * name
Definition fuchsia.cc:50

◆ test() [1/2]

void TestEffect::test ( GrColor  expected,
PreTestFn  preTestCallback = nullptr 
)
inline

Definition at line 522 of file SkRuntimeEffectTest.cpp.

522 {
523 this->test({expected, expected, expected, expected}, preTestCallback);
524 }
#define test(name)

◆ test() [2/2]

void TestEffect::test ( std::array< GrColor, 4 >  expected,
PreTestFn  preTestCallback = nullptr 
)
inline

Definition at line 475 of file SkRuntimeEffectTest.cpp.

475 {
476 auto shader = fBuilder->makeShader();
477 if (!shader) {
478 ERRORF(fReporter, "Effect didn't produce a shader");
479 return;
480 }
481
482 SkCanvas* canvas = fSurface->getCanvas();
483
484 // We shouldn't need to clear the canvas, because we are about to paint over the whole thing
485 // with a `source` blend mode. However, there are a few devices where the background can
486 // leak through when we paint with MSAA on. (This seems to be a driver/hardware bug.)
487 // Graphite, at present, uses MSAA to do `drawPaint`. To avoid flakiness in this test on
488 // those devices, we explicitly clear the canvas here. (skia:13761)
489 canvas->clear(SK_ColorBLACK);
490
492 paint.setShader(std::move(shader));
493 paint.setBlendMode(SkBlendMode::kSrc);
494
495 paint_canvas(canvas, &paint, preTestCallback);
496
497 verify_2x2_surface_results(fReporter, fBuilder->effect(), fSurface.get(), expected);
498 }
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
static void verify_2x2_surface_results(skiatest::Reporter *r, const SkRuntimeEffect *effect, SkSurface *surface, std::array< GrColor, 4 > expected)
void paint_canvas(SkCanvas *canvas, SkPaint *paint, const PreTestFn &preTestCallback)
void clear(SkColor color)
Definition SkCanvas.h:1199
const SkRuntimeEffect * effect() const
sk_sp< SkShader > makeShader(const SkMatrix *localMatrix=nullptr) const
SkCanvas * getCanvas()
Definition SkSurface.cpp:82
T * get() const
Definition SkRefCnt.h:303
const Paint & paint

◆ trace()

std::string TestEffect::trace ( const SkIPoint traceCoord)
inline

Definition at line 500 of file SkRuntimeEffectTest.cpp.

500 {
501 sk_sp<SkShader> shader = fBuilder->makeShader();
502 if (!shader) {
503 ERRORF(fReporter, "Effect didn't produce a shader");
504 return {};
505 }
506
507 auto [debugShader, debugTrace] = SkRuntimeEffect::MakeTraced(std::move(shader), traceCoord);
508
509 SkCanvas* canvas = fSurface->getCanvas();
511 paint.setShader(std::move(debugShader));
512 paint.setBlendMode(SkBlendMode::kSrc);
513
514 paint_canvas(canvas, &paint, /*preTestCallback=*/nullptr);
515
517 debugTrace->dump(&wstream);
518 sk_sp<SkData> streamData = wstream.detachAsData();
519 return std::string(static_cast<const char*>(streamData->data()), streamData->size());
520 }
sk_sp< SkData > detachAsData()
Definition SkStream.cpp:707
static TracedShader MakeTraced(sk_sp< SkShader > shader, const SkIPoint &traceCoord)

◆ uniform()

SkRuntimeShaderBuilder::BuilderUniform TestEffect::uniform ( const char *  name)
inline

Definition at line 467 of file SkRuntimeEffectTest.cpp.

467 {
468 return fBuilder->uniform(name);
469 }
BuilderUniform uniform(std::string_view name)

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