20 if ((
nullptr == skdata1) || (
nullptr == skdata2)) {
23 if (skdata1->
size() != skdata2->
size()) {
26 return (0 == memcmp(skdata1->
data(), skdata2->
data(), skdata1->
size()));
32 SkDebugf(
"WARNING: could not open file <%s> for reading\n", file_path);
38 bool ignoreColorSpace) {
39 static constexpr const SkCodecs::Decoder decoders[] = {
57 if (!ignoreColorSpace) {
90 for (
int y = 0;
y <
bitmap.height();
y++) {
91 for (
int x = 0;
x <
bitmap.width();
x++) {
99 if (!
copy.tryAllocPixels(
bitmap.info().makeColorType(kN32_SkColorType))) {
108 if (!file.isValid()) {
121 const char oldSubstring[],
const char newSubstring[]) {
123 const char *input_cstr = input.
c_str();
124 const char *first_char = input_cstr;
125 const char *match_char;
126 size_t oldSubstringLen = strlen(oldSubstring);
127 while ((match_char = strstr(first_char, oldSubstring))) {
128 output.append(first_char, (match_char - first_char));
129 output.append(newSubstring);
130 first_char = match_char + oldSubstringLen;
132 output.append(first_char);
138 const char* cstring = diffName.
c_str();
139 size_t dotOffset = strrchr(cstring,
'.') - cstring;
140 diffName.
remove(dotOffset, diffName.
size() - dotOffset);
159 const int colorThreshold,
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
const SkImageInfo & info() const
void allocN32Pixels(int width, int height, bool isOpaque=false)
bool setInfo(const SkImageInfo &imageInfo, size_t rowBytes=0)
bool tryAllocPixels(const SkImageInfo &info, size_t rowBytes)
static std::unique_ptr< SkCodec > MakeFromData(sk_sp< SkData >, SkSpan< const SkCodecs::Decoder > decoders, SkPngChunkReader *=nullptr)
static sk_sp< SkColorSpace > MakeSRGB()
const void * data() const
static sk_sp< SkData > MakeFromFileName(const char path[])
void void void void void void void remove(size_t offset, size_t length)
void append(const char text[])
const char * c_str() const
constexpr SkCodecs::Decoder Decoder()
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
void compute_diff(DiffRecord *dr, DiffMetricProc diffFunction, const int colorThreshold)
SkPMColor(* DiffMetricProc)(SkPMColor, SkPMColor)
Parameterized routine to compute the color of a pixel in a difference image.
SkString filename_to_white_filename(const SkString &filename)
static SkString replace_all(const SkString &input, const char oldSubstring[], const char newSubstring[])
static void force_all_opaque(const SkBitmap &bitmap)
bool are_buffers_equal(SkData *skdata1, SkData *skdata2)
static SkString filename_to_derived_filename(const SkString &filename, const char *suffix)
void create_and_write_diff_image(DiffRecord *drp, DiffMetricProc dmp, const int colorThreshold, const SkString &outputDir, const SkString &filename)
SkString filename_to_diff_filename(const SkString &filename)
sk_sp< SkData > read_file(const char *file_path)
bool write_bitmap(const SkString &path, const SkBitmap &bitmap)
bool get_bitmap(sk_sp< SkData > fileBits, DiffResource &resource, bool sizeOnly, bool ignoreColorSpace)
Result fResult
Which category of diff result.
@ kDifferentPixels_Result
SkImageInfo makeColorSpace(sk_sp< SkColorSpace > cs) const
SkImageInfo makeColorType(SkColorType newColorType) const