blob: d807cdeaba21125344aa31395e05c88535f9bb29 [file] [log] [blame]
Hal Canaryac7f23c2018-11-26 14:07:41 -05001/*
2 * Copyright 2018 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#ifndef skqp_model_DEFINED
8#define skqp_model_DEFINED
9
10#include <cstdint>
11#include <string>
12
13#include "SkBitmap.h"
14
15#include "skqp.h"
16
17class SkQPAssetManager;
18class SkStreamAsset;
19
20namespace skqp {
21
22/** Prefered colortype for comparing test outcomes. */
23constexpr SkColorType kColorType = kRGBA_8888_SkColorType;
24
25/** Prefered alphatype for comparing test outcomes. */
26constexpr SkAlphaType kAlphaType = kUnpremul_SkAlphaType;
27
28/** Where to find the maximum and minimum of the model. */
29constexpr char kMaxPngPath[] = "max.png";
30constexpr char kMinPngPath[] = "min.png";
31
32struct ModelResult {
33 SkBitmap fErrors; // Correct pixels are white, failing pixels scale from black
34 // (1 value off) to red (255 off in some channel).
35 sk_sp<SkData> fMinPng; // original model data, PNG encoded image.
36 sk_sp<SkData> fMaxPng; // original model data, PNG encoded image.
37 SkQP::RenderOutcome fOutcome;
38 std::string fErrorString; // if non-empty, an error occured.
39};
40
41SkQP::RenderOutcome Check(const SkPixmap& minImg,
42 const SkPixmap& maxImg,
43 const SkPixmap& img,
44 unsigned tolerance,
45 SkBitmap* errorOut);
46
47/** Check if the given test image matches the expected results.
48
49 @param name the name of the rendering test that produced the image
50 @param image the image to be tested. Should be kRGBA_8888_SkColorType
51 and kUnpremul_SkAlphaType.
52 @param assetManager provides model data files
53*/
54
55ModelResult CheckAgainstModel(const char* name, const SkPixmap& image,
56 SkQPAssetManager* assetManager);
57}
58#endif // skqp_model_DEFINED