Home | History | Annotate | Download | only in skqp
      1 /*
      2  * Copyright 2017 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 gm_knowledge_DEFINED
      8 #define gm_knowledge_DEFINED
      9 
     10 #include <cstdint>
     11 
     12 namespace skqp {
     13 class AssetManager;
     14 }
     15 
     16 namespace gmkb {
     17 
     18 enum class Error {
     19     kNone,     /**< No error. */
     20     kBadInput, /**< Error with the given image data. */
     21     kBadData,  /**< Error with the given gmkb data directory. */
     22 };
     23 
     24 /**
     25 Check if the given test image matches the expected results.
     26 
     27 Each pixel is an un-pre-multiplied RGBA color:
     28     uint32_t make_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
     29         return (r << 0) | (g << 8) | (b << 16) | (a << 24);
     30     }
     31 
     32 The image's rowBytes is width*sizeof(uint32_t):
     33     uint32_t* get_pixel_addr(uint32_t* pixels, int width, int height, int x, int y) {
     34         assert(x >= 0 && x < width);
     35         assert(y >= 0 && y < height);
     36         return &pixels[x + (width * y)];
     37     }
     38 
     39 @param pixels, width, height  the image
     40 @param gm_name                the name of the rendering test that produced the image
     41 @param backend                (optional) name of the backend
     42 @param asset_manager          GM KnowledgeBase data files
     43 @param report_directory_path  (optional) locatation to write report to.
     44 @param error_out              (optional) error return code.
     45 
     46 @return 0 if the test passes, otherwise a positive number representing how
     47          badly it failed.  Return FLT_MAX on error.
     48  */
     49 
     50 float Check(const uint32_t* pixels,
     51             int width,
     52             int height,
     53             const char* name,
     54             const char* backend,
     55             skqp::AssetManager* asset_manager,
     56             const char* report_directory_path,
     57             Error* error_out);
     58 
     59 /**
     60 Call this after running all checks.
     61 
     62 @param report_directory_path  locatation to write report to.
     63 */
     64 bool MakeReport(const char* report_directory_path);
     65 }  // namespace gmkb
     66 
     67 #endif  // gm_knowledge_DEFINED
     68