DEF_TEST(SkRecordingAccuracyXfermode, reporter) { #define FINEGRAIN 0 const Drawer drawer; BitmapBackedCanvasStrategy golden(drawer.imageInfo()); PictureStrategy picture(drawer.imageInfo()); #if !FINEGRAIN unsigned numErrors = 0; SkString errors; #endif for (int iMode = 0; iMode < int(SkBlendMode::kLastMode); iMode++) { const SkRect& clip = SkRect::MakeXYWH(100, 0, 100, 100); SkBlendMode mode = SkBlendMode(iMode); const SkBitmap& goldenBM = golden.recordAndReplay(drawer, clip, mode); const SkBitmap& pictureBM = picture.recordAndReplay(drawer, clip, mode); size_t pixelsSize = goldenBM.computeByteSize(); REPORTER_ASSERT(reporter, pixelsSize == pictureBM.computeByteSize()); // The pixel arrays should match. #if FINEGRAIN REPORTER_ASSERT(reporter, 0 == memcmp(goldenBM.getPixels(), pictureBM.getPixels(), pixelsSize)); #else if (memcmp(goldenBM.getPixels(), pictureBM.getPixels(), pixelsSize)) { numErrors++; errors.appendf("For SkXfermode %d %s: SkPictureRecorder bitmap is wrong\n", iMode, SkBlendMode_Name(mode)); } #endif } #if !FINEGRAIN REPORTER_ASSERT(reporter, 0 == numErrors, errors.c_str()); #endif }
sk_sp<GrXPFactory> GrPorterDuffXPFactory::TestCreate(GrProcessorTestData* d) { SkBlendMode mode = SkBlendMode(d->fRandom->nextULessThan((int)SkBlendMode::kLastCoeffMode)); return GrPorterDuffXPFactory::Make(mode); }