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_runner_DEFINED
      8 #define gm_runner_DEFINED
      9 
     10 #include <memory>
     11 #include <string>
     12 #include <tuple>
     13 #include <vector>
     14 
     15 #include "skqp_asset_manager.h"
     16 
     17 /**
     18 A Skia GM is a single rendering test that can be executed on any Skia backend Canvas.
     19 */
     20 namespace skiagm {
     21 class GM;
     22 }
     23 
     24 namespace skiatest {
     25 struct Test;
     26 }
     27 
     28 namespace gm_runner {
     29 
     30 using GMFactory = skiagm::GM* (*)(void*);
     31 
     32 using UnitTest = const skiatest::Test*;
     33 
     34 enum class SkiaBackend {
     35     kGL,
     36     kGLES,
     37     kVulkan,
     38 };
     39 
     40 enum class Mode {
     41     /** This mode is set when used by Android CTS.  All known tests are executed.  */
     42     kCompatibilityTestMode,
     43     /** This mode is set when used in the test lab.  Some tests are skipped, if
     44         they are known to cause crashes in older devices.  All GMs are evaluated
     45         with stricter requirements. */
     46     kExperimentalMode,
     47 
     48 };
     49 
     50 /**
     51 Initialize Skia
     52 */
     53 void InitSkia(Mode, skqp::AssetManager*);
     54 
     55 std::vector<SkiaBackend> GetSupportedBackends();
     56 
     57 /**
     58 @return a list of all Skia GMs in lexicographic order.
     59 */
     60 std::vector<GMFactory> GetGMFactories(skqp::AssetManager*);
     61 
     62 /**
     63 @return a list of all Skia GPU unit tests in lexicographic order.
     64 */
     65 std::vector<UnitTest> GetUnitTests();
     66 
     67 /**
     68 @return a descriptive name for the GM.
     69 */
     70 std::string GetGMName(GMFactory);
     71 
     72 /**
     73 @return a descriptive name for the unit test.
     74 */
     75 const char* GetUnitTestName(UnitTest);
     76 
     77 /**
     78 @return a descriptive name for the backend.
     79 */
     80 const char* GetBackendName(SkiaBackend);
     81 
     82 enum class Error {
     83     None = 0,
     84     BadSkiaOutput = 1,
     85     BadGMKBData = 2,
     86     SkiaFailure = 3,
     87 };
     88 
     89 const char* GetErrorString(Error);
     90 
     91 /**
     92 @return A non-negative float representing how badly the GM failed (or zero for
     93         success).  Any error running or evaluating the GM will result in a non-zero
     94         error code.
     95 */
     96 std::tuple<float, Error> EvaluateGM(SkiaBackend backend,
     97                                     GMFactory gmFact,
     98                                     skqp::AssetManager* assetManager,
     99                                     const char* reportDirectoryPath);
    100 
    101 /**
    102 @return a (hopefully empty) list of errors produced by this unit test.
    103 */
    104 std::vector<std::string> ExecuteTest(UnitTest);
    105 
    106 }  // namespace gm_runner
    107 
    108 #endif  // gm_runner_DEFINED
    109