Flutter Engine
The Flutter Engine
Macros | Functions
RecordingXfermodeTest.cpp File Reference
#include "include/core/SkBBHFactory.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkImage.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPicture.h"
#include "include/core/SkPictureRecorder.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSamplingOptions.h"
#include "include/core/SkScalar.h"
#include "include/core/SkString.h"
#include "include/core/SkSurface.h"
#include "tests/Test.h"
#include <cstring>

Go to the source code of this file.

Macros

#define FINEGRAIN   0
 

Functions

 DEF_TEST (SkRecordingAccuracyXfermode, reporter)
 

Macro Definition Documentation

◆ FINEGRAIN

#define FINEGRAIN   0

Function Documentation

◆ DEF_TEST()

DEF_TEST ( SkRecordingAccuracyXfermode  ,
reporter   
)

Definition at line 144 of file RecordingXfermodeTest.cpp.

144 {
145#define FINEGRAIN 0
146 const Drawer drawer;
147
148 BitmapBackedCanvasStrategy golden(drawer.imageInfo());
149 PictureStrategy picture(drawer.imageInfo());
150
151#if !FINEGRAIN
152 unsigned numErrors = 0;
154#endif
155
156 for (int iMode = 0; iMode < kSkBlendModeCount; iMode++) {
157 const SkRect& clip = SkRect::MakeXYWH(100, 0, 100, 100);
159
160 const SkBitmap& goldenBM = golden.recordAndReplay(drawer, clip, mode);
161 const SkBitmap& pictureBM = picture.recordAndReplay(drawer, clip, mode);
162
163 size_t pixelsSize = goldenBM.computeByteSize();
164 REPORTER_ASSERT(reporter, pixelsSize == pictureBM.computeByteSize());
165
166 // The pixel arrays should match.
167#if FINEGRAIN
169 0 == memcmp(goldenBM.getPixels(), pictureBM.getPixels(), pixelsSize));
170#else
171 if (0 != memcmp(goldenBM.getPixels(), pictureBM.getPixels(), pixelsSize)) {
172 numErrors++;
173 errors.appendf("For SkBlendMode %d %s: SkPictureRecorder bitmap is wrong\n",
174 iMode, SkBlendMode_Name(mode));
175 }
176#endif
177 }
178
179#if !FINEGRAIN
180 REPORTER_ASSERT(reporter, 0 == numErrors, "%s", errors.c_str());
181#endif
182}
reporter
Definition: FontMgrTest.cpp:39
SK_API const char * SkBlendMode_Name(SkBlendMode blendMode)
static constexpr int kSkBlendModeCount
Definition: SkBlendMode.h:76
SkBlendMode
Definition: SkBlendMode.h:38
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
size_t computeByteSize() const
Definition: SkBitmap.h:293
void * getPixels() const
Definition: SkBitmap.h:283
sk_sp< const SkPicture > picture
Definition: SkRecords.h:299
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 mode
Definition: switches.h:228
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659