1 /* 2 * Copyright 2015 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 8 #ifndef SK_COMMON_FLAGS_CONFIG_H 9 #define SK_COMMON_FLAGS_CONFIG_H 10 11 #include "SkCommandLineFlags.h" 12 13 #if SK_SUPPORT_GPU 14 #include "GrContextFactory.h" 15 #endif 16 17 DECLARE_string(config); 18 19 #if SK_SUPPORT_GPU 20 class SkCommandLineConfigGpu; 21 #endif 22 23 // SkCommandLineConfig represents a Skia rendering configuration string. 24 // The string has following form: 25 // tag: 26 // [via-]*backend 27 // where 'backend' consists of chars excluding hyphen or "angle-gl" 28 // and each 'via' consists of chars excluding hyphen. 29 class SkCommandLineConfig { 30 public: 31 SkCommandLineConfig(const SkString& tag, const SkString& backend, 32 const SkTArray<SkString>& viaParts); 33 virtual ~SkCommandLineConfig(); 34 #if SK_SUPPORT_GPU asConfigGpu()35 virtual const SkCommandLineConfigGpu* asConfigGpu() const { return nullptr; } 36 #endif getTag()37 const SkString& getTag() const { return fTag; } getBackend()38 const SkString& getBackend() const { return fBackend; } getViaParts()39 const SkTArray<SkString>& getViaParts() const { return fViaParts; } 40 private: 41 SkString fTag; 42 SkString fBackend; 43 SkTArray<SkString> fViaParts; 44 }; 45 46 #if SK_SUPPORT_GPU 47 // SkCommandLineConfigGpu is a SkCommandLineConfig that extracts information out of the backend 48 // part of the tag. It is constructed tags that have: 49 // * backends of form "gpu(option=value,option2=value,...)" 50 // * backends that represent a shorthand of above (such as "msaa16" representing "gpu(samples=16)") 51 class SkCommandLineConfigGpu : public SkCommandLineConfig { 52 public: 53 typedef GrContextFactory::GLContextType ContextType; 54 SkCommandLineConfigGpu(const SkString& tag, const SkTArray<SkString>& viaParts, 55 ContextType contextType, bool useNVPR, bool useDIText, int samples); asConfigGpu()56 const SkCommandLineConfigGpu* asConfigGpu() const override { return this; } getContextType()57 ContextType getContextType() const { return fContextType; } getUseNVPR()58 bool getUseNVPR() const { return fUseNVPR; } getUseDIText()59 bool getUseDIText() const { return fUseDIText; } getSamples()60 int getSamples() const { return fSamples; } 61 62 private: 63 ContextType fContextType; 64 bool fUseNVPR; 65 bool fUseDIText; 66 int fSamples; 67 }; 68 #endif 69 70 typedef SkTArray<SkAutoTDelete<SkCommandLineConfig>, true> SkCommandLineConfigArray; 71 void ParseConfigs(const SkCommandLineFlags::StringArray& configList, 72 SkCommandLineConfigArray* outResult); 73 74 #endif 75