Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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

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

Definition at line 2424 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 2468 of file DMSrcSink.cpp.

2468 {
2469 SkRect bounds = SkRect::MakeIWH(srcW, srcH);
2470 matrix->mapRect(&bounds);
2471 matrix->postTranslate(-bounds.x(), -bounds.y());
2472 return {SkScalarRoundToInt(bounds.width()), SkScalarRoundToInt(bounds.height())};
2473}
#define SkScalarRoundToInt(x)
Definition SkScalar.h:37
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 2448 of file DMSrcSink.cpp.

2448 {
2449 // We can only check raster outputs.
2450 // (Non-raster outputs like .pdf, .skp, .svg may differ but still draw identically.)
2451 if (FLAGS_check && bitmap) {
2452 SkBitmap reference;
2453 SkString log;
2454 SkDynamicMemoryWStream wStream;
2455 Result result = sink->draw(src, &reference, &wStream, &log);
2456 // If we can draw into this Sink via some pipeline, we should be able to draw directly.
2457 SkASSERT(result.isOk());
2458 if (!result.isOk()) {
2459 return result;
2460 }
2461 return compare_bitmaps(reference, *bitmap);
2462 }
2463 return Result::Ok();
2464}
static bool compare_bitmaps(skiatest::Reporter *r, const char *file, int expectedFrame, const SkBitmap &expectedBm, const SkBitmap &actualBm)
#define SkASSERT(cond)
Definition SkAssert.h:116
GAsyncResult * result
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)

◆ 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()
SkCanvas * beginPage(SkScalar width, SkScalar height, const SkRect *content=nullptr)
void endPage()
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 2426 of file DMSrcSink.cpp.

2427 {
2428 class ProxySrc : public Src {
2429 public:
2430 ProxySrc(SkISize size, const DrawToCanvasFn& draw) : fSize(size), fDraw(draw) {}
2431 Result draw(SkCanvas* canvas, GraphiteTestContext* testContext) const override {
2432 return fDraw(canvas, testContext);
2433 }
2434 Name name() const override { return "ProxySrc"; }
2435 SkISize size() const override { return fSize; }
2436 private:
2437 SkISize fSize;
2438 const DrawToCanvasFn& fDraw;
2439 };
2440 return sink->draw(ProxySrc(size, draw), bitmap, stream, log);
2441}
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
virtual Name name() const =0
virtual Result draw(SkCanvas *canvas, GraphiteTestContext *) const =0
virtual SkISize size() const =0

◆ 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)

◆ 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)
static std::unique_ptr< SkStreamAsset > MakeFromFile(const char path[])
Definition SkStream.cpp:922
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
SkAlphaType alphaType() const
SkImageInfo makeColorType(SkColorType newColorType) const

◆ 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 static SkString SkStringPrintf()
Definition SkString.h:287
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 2049 of file DMSrcSink.cpp.

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

◆ 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.