Debian Codegraph @

tools/HashAndEncode.h

raw
1 // Copyright 2019 Google LLC.
2 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3
4 #pragma once
5
6 #include "include/core/SkBitmap.h"
7 #include "include/core/SkStream.h"
8 #include "tools/flags/CommandLineFlags.h"
9
10 // HashAndEncode transforms any SkBitmap into a standard format, currently
11 // 16-bit unpremul RGBA in the Rec. 2020 color space. This lets us compare
12 // images from different backends or configurations, using feedHash() for
13 // direct content-based hashing, or encodePNG() for visual comparison.
14 class HashAndEncode {
15 public:
16 explicit HashAndEncode(const SkBitmap&);
17
18 // Feed uncompressed pixel data into a hash function like MD5.
19 void feedHash(SkWStream*) const;
20
21 // Encode pixels as a PNG in our standard format, with md5 and key/properties as metadata.
22 bool encodePNG(SkWStream*,
23 const char* md5,
24 CommandLineFlags::StringArray key,
25 CommandLineFlags::StringArray properties) const;
26
27 private:
28 const SkISize fSize;
29 std::unique_ptr<uint64_t[]> fPixels; // In our standard format mentioned above.
30 };
31