• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 class SkQPAssetManager;
18 class SkStreamAsset;
19 
20 namespace skqp {
21 
22 /** Prefered colortype for comparing test outcomes. */
23 constexpr SkColorType kColorType = kRGBA_8888_SkColorType;
24 
25 /** Prefered alphatype for comparing test outcomes. */
26 constexpr SkAlphaType kAlphaType = kUnpremul_SkAlphaType;
27 
28 /** Where to find the maximum and minimum of the model. */
29 constexpr char kMaxPngPath[] = "max.png";
30 constexpr char kMinPngPath[] = "min.png";
31 
32 struct 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 
41 SkQP::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 
55 ModelResult CheckAgainstModel(const char* name, const SkPixmap& image,
56                               SkQPAssetManager* assetManager);
57 }
58 #endif  // skqp_model_DEFINED
59