Flutter Engine
The Flutter Engine
Classes | Typedefs | Functions | Variables
DM Namespace Reference

Classes

class  AndroidCodecSrc
 
class  BisectSrc
 
class  CodecSrc
 
class  ColorCodecSrc
 
class  DebugSink
 
class  GMSrc
 
class  GPUDDLSink
 
class  GPUPersistentCacheTestingSink
 
class  GPUPrecompileTestingSink
 
class  GPURemoteSlugSink
 
class  GPUSerializeSlugSink
 
class  GPUSink
 
class  GPUSlugSink
 
class  ImageGenSrc
 
struct  ImplicitString
 
class  JsonWriter
 
class  MSKPSrc
 
class  NullSink
 
class  PDFSink
 
class  RasterSink
 
class  Result
 
struct  Sink
 
struct  SinkFlags
 
class  SKPSink
 
class  SKPSrc
 
struct  Src
 
class  SVGSink
 
class  Via
 
class  ViaMatrix
 
class  ViaPicture
 
class  ViaRuntimeBlend
 
class  ViaSerialization
 
class  ViaSVG
 
class  ViaUpright
 
class  XPSSink
 

Typedefs

using DrawToCanvasFn = std::function< DM::Result(SkCanvas *, Src::GraphiteTestContext *)>
 
typedef ImplicitString Name
 
typedef ImplicitString Path
 

Functions

static SkMutex & bitmap_result_mutex ()
 
static SkString get_scaled_name (const Path &path, float scale)
 
static bool serial_from_path_name (const SkString &path)
 
static void swap_rb_if_necessary (SkBitmap &bitmap, CodecSrc::DstColorType dstColorType)
 
static bool get_decode_info (SkImageInfo *decodeInfo, SkColorType canvasColorType, CodecSrc::DstColorType dstColorType, SkAlphaType dstAlphaType)
 
static void draw_to_canvas (SkCanvas *canvas, const SkImageInfo &info, void *pixels, size_t rowBytes, CodecSrc::DstColorType dstColorType, SkScalar left=0, SkScalar top=0)
 
static void set_bitmap_color_space (SkImageInfo *info)
 
static DEFINE_int (skpViewportSize, 1000, "Width & height of the viewport used to crop skp rendering.")
 
static SkRect get_cull_rect_for_skp (const char *path)
 
static Result compare_bitmaps (const SkBitmap &reference, const SkBitmap &bitmap)
 
static DEFINE_bool (gpuStats, false, "Append GPU stats to the log for each GPU task?")
 
static DEFINE_bool (preAbandonGpuContext, false, "Test abandoning the GrContext before running the test.")
 
static DEFINE_bool (abandonGpuContext, false, "Test abandoning the GrContext after running each test.")
 
static DEFINE_bool (releaseAndAbandonGpuContext, false, "Test releasing all gpu resources and abandoning the GrContext " "after running each test")
 
static DEFINE_bool (drawOpClip, false, "Clip each GrDrawOp to its device bounds for testing.")
 
static DEFINE_bool (programBinaryCache, true, "Use in-memory program binary cache")
 
static Result draw_skdocument (const Src &src, SkDocument *doc, SkWStream *dst)
 
static SkSerialProcs serial_procs_using_png ()
 
static Result draw_to_canvas (Sink *sink, SkBitmap *bitmap, SkWStream *stream, SkString *log, SkISize size, const DrawToCanvasFn &draw)
 
static DEFINE_bool (check, true, "If true, have most Via- modes fail if they affect the output.")
 
static Result check_against_reference (const SkBitmap *bitmap, const Src &src, Sink *sink)
 
static SkISize auto_compute_translate (SkMatrix *matrix, int srcW, int srcH)
 

Variables

TArray< JsonWriter::BitmapResultgBitmapResults
 

Typedef Documentation

◆ DrawToCanvasFn

Definition at line 2425 of file DMSrcSink.cpp.

◆ Name

Definition at line 38 of file DMSrcSink.h.

◆ Path

Definition at line 39 of file DMSrcSink.h.

Function Documentation

◆ auto_compute_translate()

static SkISize DM::auto_compute_translate ( SkMatrix matrix,
int  srcW,
int  srcH 
)
static

Definition at line 2469 of file DMSrcSink.cpp.

2469 {
2470 SkRect bounds = SkRect::MakeIWH(srcW, srcH);
2471 matrix->mapRect(&bounds);
2472 matrix->postTranslate(-bounds.x(), -bounds.y());
2473 return {SkScalarRoundToInt(bounds.width()), SkScalarRoundToInt(bounds.height())};
2474}
#define SkScalarRoundToInt(x)
Definition: SkScalar.h:37
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
Optional< SkRect > bounds
Definition: SkRecords.h:189
static SkRect MakeIWH(int w, int h)
Definition: SkRect.h:623

◆ bitmap_result_mutex()

static SkMutex & DM::bitmap_result_mutex ( )
static

Definition at line 25 of file DMJsonWriter.cpp.

25 {
26 static SkMutex& mutex = *(new SkMutex);
27 return mutex;
28}

◆ check_against_reference()

static Result DM::check_against_reference ( const SkBitmap bitmap,
const Src src,
Sink sink 
)
static

Definition at line 2449 of file DMSrcSink.cpp.

2449 {
2450 // We can only check raster outputs.
2451 // (Non-raster outputs like .pdf, .skp, .svg may differ but still draw identically.)
2452 if (FLAGS_check && bitmap) {
2453 SkBitmap reference;
2454 SkString log;
2455 SkDynamicMemoryWStream wStream;
2456 Result result = sink->draw(src, &reference, &wStream, &log);
2457 // If we can draw into this Sink via some pipeline, we should be able to draw directly.
2458 SkASSERT(result.isOk());
2459 if (!result.isOk()) {
2460 return result;
2461 }
2462 return compare_bitmaps(reference, *bitmap);
2463 }
2464 return Result::Ok();
2465}
#define SkASSERT(cond)
Definition: SkAssert.h:116
GAsyncResult * result
static Result compare_bitmaps(const SkBitmap &reference, const SkBitmap &bitmap)
Definition: DMSrcSink.cpp:1481
Definition: bitmap.py:1
virtual Result draw(const Src &, SkBitmap *, SkWStream *, SkString *log) const =0

◆ compare_bitmaps()

static Result DM::compare_bitmaps ( const SkBitmap reference,
const SkBitmap bitmap 
)
static

Definition at line 1481 of file DMSrcSink.cpp.

1481 {
1482 // The dimensions are a property of the Src only, and so should be identical.
1483 SkASSERT(reference.computeByteSize() == bitmap.computeByteSize());
1484 if (reference.computeByteSize() != bitmap.computeByteSize()) {
1485 return Result::Fatal("Dimensions don't match reference");
1486 }
1487 // All SkBitmaps in DM are tight, so this comparison is easy.
1488 if (0 != memcmp(reference.getPixels(), bitmap.getPixels(), reference.computeByteSize())) {
1489 SkString encoded;
1490 SkString errString("Pixels don't match reference");
1491 if (ToolUtils::BitmapToBase64DataURI(reference, &encoded)) {
1492 errString.append("\nExpected: ");
1493 errString.append(encoded);
1494 } else {
1495 errString.append("\nExpected image failed to encode: ");
1496 errString.append(encoded);
1497 }
1499 errString.append("\nActual: ");
1500 errString.append(encoded);
1501 } else {
1502 errString.append("\nActual image failed to encode: ");
1503 errString.append(encoded);
1504 }
1505 return Result(Result::Status::Fatal, errString);
1506 }
1507 return Result::Ok();
1508}
size_t computeByteSize() const
Definition: SkBitmap.h:293
void * getPixels() const
Definition: SkBitmap.h:283
bool BitmapToBase64DataURI(const SkBitmap &bitmap, SkString *dst)
Definition: EncodeUtils.cpp:25
void Fatal(char const *file, int line, char const *error)

◆ DEFINE_bool() [1/7]

static DM::DEFINE_bool ( abandonGpuContext  ,
false  ,
"Test abandoning the GrContext after running each test."   
)
static

◆ DEFINE_bool() [2/7]

static DM::DEFINE_bool ( check  ,
true  ,
"If  true,
have most Via- modes fail if they affect the output."   
)
static

◆ DEFINE_bool() [3/7]

static DM::DEFINE_bool ( drawOpClip  ,
false  ,
"Clip each GrDrawOp to its device bounds for testing."   
)
static

◆ DEFINE_bool() [4/7]

static DM::DEFINE_bool ( gpuStats  ,
false  ,
"Append GPU stats to the log for each GPU task?"   
)
static

◆ DEFINE_bool() [5/7]

static DM::DEFINE_bool ( preAbandonGpuContext  ,
false  ,
"Test abandoning the GrContext before running the test."   
)
static

◆ DEFINE_bool() [6/7]

static DM::DEFINE_bool ( programBinaryCache  ,
true  ,
"Use in-memory program binary cache"   
)
static

◆ DEFINE_bool() [7/7]

static DM::DEFINE_bool ( releaseAndAbandonGpuContext  ,
false  ,
"Test releasing all gpu resources and abandoning the GrContext " "after running each test  
)
static

◆ DEFINE_int()

static DM::DEFINE_int ( skpViewportSize  ,
1000  ,
"Width & height of the viewport used to crop skp rendering."   
)
static

◆ draw_skdocument()

static Result DM::draw_skdocument ( const Src src,
SkDocument doc,
SkWStream dst 
)
static

Definition at line 1972 of file DMSrcSink.cpp.

1972 {
1973 if (src.size().isEmpty()) {
1974 return Result::Fatal("Source has empty dimensions");
1975 }
1976 SkASSERT(doc);
1977 int pageCount = src.pageCount();
1978 for (int i = 0; i < pageCount; ++i) {
1979 int width = src.size(i).width(), height = src.size(i).height();
1980 SkCanvas* canvas =
1982 if (!canvas) {
1983 return Result::Fatal("SkDocument::beginPage(w,h) returned nullptr");
1984 }
1985 Result result = src.draw(i, canvas, /*GraphiteTestContext=*/nullptr);
1986 if (!result.isOk()) {
1987 return result;
1988 }
1989 doc->endPage();
1990 }
1991 doc->close();
1992 dst->flush();
1993 return Result::Ok();
1994}
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void close()
Definition: SkDocument.cpp:52
SkCanvas * beginPage(SkScalar width, SkScalar height, const SkRect *content=nullptr)
Definition: SkDocument.cpp:32
void endPage()
Definition: SkDocument.cpp:45
dst
Definition: cp.py:12
int32_t height
int32_t width

◆ draw_to_canvas() [1/2]

static Result DM::draw_to_canvas ( Sink sink,
SkBitmap bitmap,
SkWStream stream,
SkString log,
SkISize  size,
const DrawToCanvasFn draw 
)
static

Definition at line 2427 of file DMSrcSink.cpp.

2428 {
2429 class ProxySrc : public Src {
2430 public:
2431 ProxySrc(SkISize size, const DrawToCanvasFn& draw) : fSize(size), fDraw(draw) {}
2432 Result draw(SkCanvas* canvas, GraphiteTestContext* testContext) const override {
2433 return fDraw(canvas, testContext);
2434 }
2435 Name name() const override { return "ProxySrc"; }
2436 SkISize size() const override { return fSize; }
2437 private:
2438 SkISize fSize;
2439 const DrawToCanvasFn& fDraw;
2440 };
2441 return sink->draw(ProxySrc(size, draw), bitmap, stream, log);
2442}
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
ImplicitString Name
Definition: DMSrcSink.h:38
std::function< DM::Result(SkCanvas *, Src::GraphiteTestContext *)> DrawToCanvasFn
Definition: DMSrcSink.cpp:2425
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
virtual Name name() const =0
virtual Result draw(SkCanvas *canvas, GraphiteTestContext *) const =0
virtual SkISize size() const =0
Definition: SkSize.h:16

◆ draw_to_canvas() [2/2]

static void DM::draw_to_canvas ( SkCanvas canvas,
const SkImageInfo info,
void *  pixels,
size_t  rowBytes,
CodecSrc::DstColorType  dstColorType,
SkScalar  left = 0,
SkScalar  top = 0 
)
static

Definition at line 456 of file DMSrcSink.cpp.

458 {
460 bitmap.installPixels(info, pixels, rowBytes);
461 swap_rb_if_necessary(bitmap, dstColorType);
462 canvas->drawImage(bitmap.asImage(), left, top);
463}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
static bool left(const SkPoint &p0, const SkPoint &p1)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static void swap_rb_if_necessary(SkBitmap &bitmap, CodecSrc::DstColorType dstColorType)
Definition: DMSrcSink.cpp:411

◆ get_cull_rect_for_skp()

static SkRect DM::get_cull_rect_for_skp ( const char *  path)
static

Definition at line 1189 of file DMSrcSink.cpp.

1189 {
1190 std::unique_ptr<SkStream> stream = SkStream::MakeFromFile(path);
1191 if (!stream) {
1192 return SkRect::MakeEmpty();
1193 }
1195 if (!SkPicture_StreamIsSKP(stream.get(), &info)) {
1196 return SkRect::MakeEmpty();
1197 }
1198
1199 return info.fCullRect;
1200}
bool SkPicture_StreamIsSKP(SkStream *stream, SkPictInfo *pInfo)
Definition: SkPicture.cpp:109
static std::unique_ptr< SkStreamAsset > MakeFromFile(const char path[])
Definition: SkStream.cpp:922
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
static constexpr SkRect MakeEmpty()
Definition: SkRect.h:595

◆ get_decode_info()

static bool DM::get_decode_info ( SkImageInfo decodeInfo,
SkColorType  canvasColorType,
CodecSrc::DstColorType  dstColorType,
SkAlphaType  dstAlphaType 
)
static

Definition at line 422 of file DMSrcSink.cpp.

423 {
424 switch (dstColorType) {
425 case CodecSrc::kGrayscale_Always_DstColorType:
426 if (kRGB_565_SkColorType == canvasColorType) {
427 return false;
428 }
429 *decodeInfo = decodeInfo->makeColorType(kGray_8_SkColorType);
430 break;
431 case CodecSrc::kNonNative8888_Always_DstColorType:
432 if (kRGB_565_SkColorType == canvasColorType
433 || kRGBA_F16_SkColorType == canvasColorType) {
434 return false;
435 }
436#ifdef SK_PMCOLOR_IS_RGBA
437 *decodeInfo = decodeInfo->makeColorType(kBGRA_8888_SkColorType);
438#else
439 *decodeInfo = decodeInfo->makeColorType(kRGBA_8888_SkColorType);
440#endif
441 break;
442 default:
443 if (kRGB_565_SkColorType == canvasColorType &&
444 kOpaque_SkAlphaType != decodeInfo->alphaType()) {
445 return false;
446 }
447
448 *decodeInfo = decodeInfo->makeColorType(canvasColorType);
449 break;
450 }
451
452 *decodeInfo = decodeInfo->makeAlphaType(dstAlphaType);
453 return true;
454}
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition: SkColorType.h:26
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition: SkColorType.h:38
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
Definition: SkColorType.h:35
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition: SkColorType.h:22
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const
Definition: SkImageInfo.h:466
SkAlphaType alphaType() const
Definition: SkImageInfo.h:375
SkImageInfo makeColorType(SkColorType newColorType) const
Definition: SkImageInfo.h:475

◆ get_scaled_name()

static SkString DM::get_scaled_name ( const Path path,
float  scale 
)
static

Definition at line 199 of file DMSrcSink.cpp.

199 {
200 return SkStringPrintf("%s_%.3f", SkOSPath::Basename(path.c_str()).c_str(), scale);
201}
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
static SkString Basename(const char *fullPath)
Definition: SkOSPath.cpp:23
const char * c_str() const
Definition: SkString.h:133
const Scalar scale

◆ serial_from_path_name()

static bool DM::serial_from_path_name ( const SkString path)
static

Definition at line 376 of file DMSrcSink.cpp.

376 {
377 if (!FLAGS_RAW_threading) {
378 static const char* const exts[] = {
379 "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw",
380 "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW",
381 };
382 const char* actualExt = strrchr(path.c_str(), '.');
383 if (actualExt) {
384 actualExt++;
385 for (auto* ext : exts) {
386 if (0 == strcmp(ext, actualExt)) {
387 return true;
388 }
389 }
390 }
391 }
392 return false;
393}

◆ serial_procs_using_png()

static SkSerialProcs DM::serial_procs_using_png ( )
static

Definition at line 2050 of file DMSrcSink.cpp.

2050 {
2051 static SkSerialProcs procs;
2052 procs.fImageProc = [](SkImage* img, void*) -> sk_sp<SkData> {
2053 return SkPngEncoder::Encode(as_IB(img)->directContext(), img, SkPngEncoder::Options{});
2054 };
2055 return procs;
2056}
static SkImage_Base * as_IB(SkImage *image)
Definition: SkImage_Base.h:201
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
SkSerialImageProc fImageProc
Definition: SkSerialProcs.h:90

◆ set_bitmap_color_space()

static void DM::set_bitmap_color_space ( SkImageInfo info)
static

Definition at line 470 of file DMSrcSink.cpp.

470 {
471 *info = info->makeColorSpace(SkColorSpace::MakeSRGB());
472}
static sk_sp< SkColorSpace > MakeSRGB()

◆ swap_rb_if_necessary()

static void DM::swap_rb_if_necessary ( SkBitmap bitmap,
CodecSrc::DstColorType  dstColorType 
)
static

Definition at line 411 of file DMSrcSink.cpp.

411 {
412 if (CodecSrc::kNonNative8888_Always_DstColorType != dstColorType) {
413 return;
414 }
415
416 for (int y = 0; y < bitmap.height(); y++) {
417 uint32_t* row = (uint32_t*) bitmap.getAddr(0, y);
418 SkOpts::RGBA_to_BGRA(row, row, bitmap.width());
419 }
420}
double y
Swizzle_8888_u32 RGBA_to_BGRA

Variable Documentation

◆ gBitmapResults

TArray<JsonWriter::BitmapResult> DM::gBitmapResults

Definition at line 24 of file DMJsonWriter.cpp.