49#if defined(SK_GRAPHITE)
63#include <initializer_list>
67#if defined(SK_GANESH) && defined(GR_TEST_UTILS)
68extern int gOverrideMaxTextureSizeGanesh;
69extern std::atomic<int> gNumTilesDrawnGanesh;
72#if defined(SK_GRAPHITE) && defined(GRAPHITE_TEST_UTILS)
73extern int gOverrideMaxTextureSizeGraphite;
74extern std::atomic<int> gNumTilesDrawnGraphite;
81 void draw(
SkCanvas* canvas,
int imgSize,
int whiteBandWidth,
82 int desiredLineWidth,
int desiredDepth) {
83 const int kPad = desiredLineWidth;
92 int desiredDrawSize = imgSize - 2 *
kPad - 2 * whiteBandWidth;
100sk_sp<SkImage> make_big_bitmap_image(
int imgSize,
int whiteBandWidth,
101 int desiredLineWidth,
int desiredDepth) {
107 draw(&canvas, imgSize, whiteBandWidth, desiredLineWidth, desiredDepth);
113sk_sp<SkImage> make_big_picture_image(
int imgSize,
int whiteBandWidth,
114 int desiredLineWidth,
int desiredDepth) {
120 draw(canvas, imgSize, whiteBandWidth, desiredLineWidth, desiredDepth);
125 { imgSize, imgSize },
148 const char* generator,
155 label.
appendf(
"%s-%s-%s-%d-%d-%s-%d",
156 dContext ?
"ganesh" :
"graphite",
166void potentially_write_to_png(
const char* directory,
169 constexpr bool kWriteOutImages =
false;
171 if constexpr(kWriteOutImages) {
173 filename.
appendf(
"//%s//%s.png", directory, label.
c_str());
187 static const float kTols[4] = { 0.008f, 0.008f, 0.008f, 0.008f };
188 static const float kRotTols[4] = { 0.024f, 0.024f, 0.024f, 0.024f };
190 auto error = std::function<ComparePixmapsErrorReporter>(
191 [&](
int x,
int y,
const float diffs[4]) {
194 label.
c_str(),
x,
y, diffs[0], diffs[1], diffs[2], diffs[3]);
205 switch (numDesiredTiles) {
256 return scale > 1 || rot > 0;
270 static const int kOverrideMaxTextureSize = 1024;
272#if defined(SK_GANESH)
279#if defined(SK_GRAPHITE)
288 static const int kWhiteBandWidth = 4;
292 using GeneratorT =
sk_sp<SkImage>(*)(
int imgSize,
int whiteBandWidth,
293 int desiredLineWidth,
int desiredDepth);
295 static const struct {
298 } kGenerators[] = { { make_big_bitmap_image,
"BM" },
299 { make_big_picture_image,
"Picture" } };
309 int numClippedTiles = 9;
310 for (
auto gen : kGenerators) {
311 if (recorder && !strcmp(
gen.fTag,
"Picture")) {
326 numClippedTiles = (numClippedTiles == 9) ? 4 : 9;
328 for (
int scale : { 1, 4, 8 }) {
329 for (
int rot : { 0, 45 }) {
330 for (
int numDesiredTiles : { numClippedTiles, 16 }) {
335 SkIRect rotatedRect =
m.mapRect(destRect).roundOut();
351#if defined(SK_GANESH)
359#if defined(SK_GRAPHITE)
365 for (
auto sampling : kSamplingOptions) {
373 constraint, numDesiredTiles);
389#if defined(SK_GANESH) && defined(GR_TEST_UTILS)
390 gOverrideMaxTextureSizeGanesh = 0;
392#if defined(SK_GRAPHITE) && defined(GRAPHITE_TEST_UTILS)
393 gOverrideMaxTextureSizeGraphite = 0;
403#if defined(SK_GANESH) && defined(GR_TEST_UTILS)
405 gNumTilesDrawnGanesh.load(std::memory_order_acquire);
408#if defined(SK_GRAPHITE) && defined(GRAPHITE_TEST_UTILS)
409 int actualNumTiles2 =
410 gNumTilesDrawnGraphite.load(std::memory_order_acquire);
416#if defined(SK_GANESH) && defined(GR_TEST_UTILS)
417 gOverrideMaxTextureSizeGanesh = kOverrideMaxTextureSize;
419#if defined(SK_GRAPHITE) && defined(GRAPHITE_TEST_UTILS)
420 gOverrideMaxTextureSizeGraphite = kOverrideMaxTextureSize;
431#if defined(SK_GANESH) && defined(GR_TEST_UTILS)
434 gNumTilesDrawnGanesh.load(std::memory_order_acquire);
436 numDesiredTiles == actualNumTiles,
437 "mismatch expected: %d actual: %d\n",
442#if defined(SK_GRAPHITE) && defined(GRAPHITE_TEST_UTILS)
445 gNumTilesDrawnGraphite.load(std::memory_order_acquire);
447 numDesiredTiles == actualNumTiles2,
448 "mismatch expected: %d actual: %d\n",
459 potentially_write_to_png(
"expected", label, expected);
460 potentially_write_to_png(
"actual", label, actual);
468#if defined(SK_GANESH) && defined(GR_TEST_UTILS)
469 gOverrideMaxTextureSizeGanesh = 0;
471#if defined(SK_GRAPHITE) && defined(GRAPHITE_TEST_UTILS)
472 gOverrideMaxTextureSizeGraphite = 0;
482 static const int kOverrideMaxTextureSize = 1024;
483 static const SkISize kExpectedTileSize { kOverrideMaxTextureSize, kOverrideMaxTextureSize };
499#if defined(SK_GANESH)
505#if defined(SK_GRAPHITE)
517#if defined(SK_GANESH) && defined(GR_TEST_UTILS)
518 gOverrideMaxTextureSizeGanesh = kOverrideMaxTextureSize;
520#if defined(SK_GRAPHITE) && defined(GRAPHITE_TEST_UTILS)
521 gOverrideMaxTextureSizeGraphite = kOverrideMaxTextureSize;
523 for (
int i = 0;
i < 2; ++
i) {
536#if defined(SK_GANESH)
542 if (tex && tex->
dimensions() == kExpectedTileSize) {
549#if defined(SK_GRAPHITE)
564#if defined(SK_GANESH) && defined(GR_TEST_UTILS)
565 gOverrideMaxTextureSizeGanesh = 0;
567#if defined(SK_GRAPHITE) && defined(GRAPHITE_TEST_UTILS)
568 gOverrideMaxTextureSizeGraphite = 0;
574#if defined(SK_GANESH)
581 auto dContext = ctxInfo.directContext();
583 tiling_comparison_test(dContext,
nullptr,
reporter);
591 auto dContext = ctxInfo.directContext();
593 tiled_image_caching_test(dContext,
nullptr,
reporter);
598#if defined(SK_GRAPHITE)
605 std::unique_ptr<skgpu::graphite::Recorder> recorder =
606 context->makeRecorder(ToolUtils::CreateTestingRecorderOptions());
608 tiling_comparison_test(
nullptr, recorder.get(),
reporter);
615 std::unique_ptr<skgpu::graphite::Recorder> recorder =
616 context->makeRecorder(ToolUtils::CreateTestingRecorderOptions());
618 tiled_image_caching_test(
nullptr, recorder.get(),
reporter);
static void readback(const SkBitmap &src, int *result, int resultCount)
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
bool check_pixels(skiatest::Reporter *reporter, GrDirectContext *dContext, const GrBackendTexture &tex, const SkImageInfo &info, SkColor expectedColor)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorWHITE
constexpr SkColor SK_ColorDKGRAY
static constexpr int kBicubicFilterTexelPad
#define SK_ScalarRoot2Over2
bool ComparePixels(const GrCPixmap &a, const GrCPixmap &b, const float tolRGBA[4], std::function< ComparePixmapsErrorReporter > &error)
#define REPORTER_ASSERT(r, cond,...)
#define DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS(name, reporter, graphite_context, ctsEnforcement)
#define DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(name, reporter, context_info, ctsEnforcement)
static SkScalar center(float pos0, float pos1)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
GrResourceCache * getResourceCache()
SK_API int maxTextureSize() const
GrDirectContextPriv priv()
SkISize dimensions() const
virtual GrTexture * asTexture()
void allocPixels(const SkImageInfo &info, size_t rowBytes)
sk_sp< SkImage > asImage() const
const SkPixmap & pixmap() const
void allocN32Pixels(int width, int height, bool isOpaque=false)
void drawRect(const SkRect &rect, const SkPaint &paint)
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void translate(SkScalar dx, SkScalar dy)
virtual GrRecordingContext * recordingContext() const
virtual skgpu::graphite::Recorder * recorder() const
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
@ kFast_SrcRectConstraint
sample outside bounds; faster
void clear(SkColor color)
void concat(const SkMatrix &matrix)
static sk_sp< SkColorSpace > MakeSRGB()
static SkMatrix RotateDeg(SkScalar deg)
void setColor(SkColor color)
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
const char * c_str() const
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
int maxTextureSize() const
const Caps * caps() const
SkISize dimensions() const
const uint8_t uint32_t uint32_t GError ** error
static const int kImageSize
SK_API sk_sp< SkImage > DeferredFromPicture(sk_sp< SkPicture > picture, const SkISize &dimensions, const SkMatrix *matrix, const SkPaint *paint, BitDepth bitDepth, sk_sp< SkColorSpace > colorSpace, SkSurfaceProps props)
@ kU8
uses 8-bit unsigned int per color component
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
clipRect(r.rect, r.opAA.op(), r.opAA.aa())) template<> void Draw
SkSamplingOptions sampling
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
void DrawImage(SkCanvas *canvas, const SkImage *image, SkScalar x, SkScalar y, const SkSamplingOptions &sampling={}, const SkPaint *paint=nullptr, SkCanvas::SrcRectConstraint constraint=SkCanvas::kFast_SrcRectConstraint)
SK_API void DrawImageRect(SkCanvas *canvas, const SkImage *image, const SkRect &src, const SkRect &dst, const SkSamplingOptions &sampling={}, const SkPaint *paint=nullptr, SkCanvas::SrcRectConstraint constraint=SkCanvas::kFast_SrcRectConstraint)
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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
SkSamplingOptions(SkFilterMode::kLinear))
static constexpr SkCubicResampler CatmullRom()
constexpr int32_t height() const
int32_t fTop
smaller y-axis bounds
constexpr int32_t width() const
int32_t fLeft
smaller x-axis bounds
void outset(int32_t dx, int32_t dy)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
SkScalar fLeft
smaller x-axis bounds
static SkRect MakeIWH(int w, int h)
void outset(float dx, float dy)
SkRect makeInset(float dx, float dy) const
constexpr float height() const
constexpr float width() const
constexpr SkPoint center() const
static constexpr SkRect MakeWH(float w, float h)
SkScalar fTop
smaller y-axis bounds
const SkFilterMode filter
const SkMipmapMode mipmap