diff options
author | halcanary <halcanary@google.com> | 2016-08-03 15:30:37 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-03 15:30:37 -0700 |
commit | ef59974708dade6fa72fb0218d4f8a9590175c47 (patch) | |
tree | 4aa9e35661de6345a5d05f38f08e981c84fd308e /src | |
parent | 19a9720978700a24efed8dda7e0935ea2b7338c4 (diff) |
SkRTConf: reduce functionality to what we use, increase simplicity
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2212473002
DOCS_PREVIEW= https://skia.org/?cl=2212473002
CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
[mtklein]
TBR=reed@google.com
Only removing unused public API.
Review-Url: https://codereview.chromium.org/2212473002
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkGraphics.cpp | 10 | ||||
-rw-r--r-- | src/effects/SkBlurMaskFilter.cpp | 9 | ||||
-rw-r--r-- | src/gpu/batches/GrAADistanceFieldPathRenderer.cpp | 1 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpuProgramCache.cpp | 5 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.cpp | 1 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLShaderStringBuilder.cpp | 5 | ||||
-rw-r--r-- | src/gpu/vk/GrVkPipelineStateCache.cpp | 1 | ||||
-rw-r--r-- | src/images/SkJPEGImageEncoder.cpp | 1 | ||||
-rw-r--r-- | src/images/SkPNGImageEncoder.cpp | 9 | ||||
-rw-r--r-- | src/opts/opts_check_x86.cpp | 1 | ||||
-rw-r--r-- | src/utils/SkRTConf.cpp | 325 |
11 files changed, 12 insertions, 356 deletions
diff --git a/src/core/SkGraphics.cpp b/src/core/SkGraphics.cpp index d7022b770b..01b1432ef0 100644 --- a/src/core/SkGraphics.cpp +++ b/src/core/SkGraphics.cpp @@ -22,7 +22,6 @@ #include "SkPixelRef.h" #include "SkRefCnt.h" #include "SkResourceCache.h" -#include "SkRTConf.h" #include "SkScalerContext.h" #include "SkShader.h" #include "SkStream.h" @@ -49,15 +48,6 @@ void SkGraphics::Init() { // SkGraphics::Init() must be thread-safe and idempotent. SkCpu::CacheRuntimeFeatures(); SkOpts::Init(); - -#ifdef SK_DEBUG - skRTConfRegistry().possiblyDumpFile(); - skRTConfRegistry().validate(); - if (skRTConfRegistry().hasNonDefault()) { - SkDebugf("Non-default runtime configuration options:\n"); - skRTConfRegistry().printNonDefault(); - } -#endif } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index 9e0315f2b7..38b5313be3 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -12,7 +12,6 @@ #include "SkWriteBuffer.h" #include "SkMaskFilter.h" #include "SkRRect.h" -#include "SkRTConf.h" #include "SkStringUtils.h" #include "SkStrokeRec.h" @@ -304,9 +303,10 @@ static SkCachedData* add_cached_rects(SkMask* mask, SkScalar sigma, SkBlurStyle } #ifdef SK_IGNORE_FAST_RRECT_BLUR -SK_CONF_DECLARE(bool, c_analyticBlurRRect, "mask.filter.blur.analyticblurrrect", false, "Use the faster analytic blur approach for ninepatch rects"); + // Use the faster analytic blur approach for ninepatch round rects + static const bool c_analyticBlurRRect{false}; #else -SK_CONF_DECLARE(bool, c_analyticBlurRRect, "mask.filter.blur.analyticblurrrect", true, "Use the faster analytic blur approach for ninepatch round rects"); + static const bool c_analyticBlurRRect{true}; #endif SkMaskFilter::FilterReturn @@ -443,7 +443,8 @@ SkBlurMaskFilterImpl::filterRRectToNine(const SkRRect& rrect, const SkMatrix& ma return kTrue_FilterReturn; } -SK_CONF_DECLARE(bool, c_analyticBlurNinepatch, "mask.filter.analyticNinePatch", true, "Use the faster analytic blur approach for ninepatch rects"); +// Use the faster analytic blur approach for ninepatch rects +static const bool c_analyticBlurNinepatch{true}; SkMaskFilter::FilterReturn SkBlurMaskFilterImpl::filterRectsToNine(const SkRect rects[], int count, diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp index a9ba94da40..36a9ff01e7 100644 --- a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp +++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp @@ -20,7 +20,6 @@ #include "effects/GrDistanceFieldGeoProc.h" #include "SkDistanceFieldGen.h" -#include "SkRTConf.h" #define ATLAS_TEXTURE_WIDTH 2048 #define ATLAS_TEXTURE_HEIGHT 2048 diff --git a/src/gpu/gl/GrGLGpuProgramCache.cpp b/src/gpu/gl/GrGLGpuProgramCache.cpp index 4ba0d23ae5..ae93926c79 100644 --- a/src/gpu/gl/GrGLGpuProgramCache.cpp +++ b/src/gpu/gl/GrGLGpuProgramCache.cpp @@ -13,12 +13,11 @@ #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLProgramDataManager.h" #include "glsl/GrGLSLProgramDesc.h" -#include "SkRTConf.h" #include "SkTSearch.h" #ifdef PROGRAM_CACHE_STATS -SK_CONF_DECLARE(bool, c_DisplayCache, "gpu.displayCache", false, - "Display program cache usage."); +// Display program cache usage +static const bool c_DisplayCache{false}; #endif typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index 2d06e434f2..2bbeb42af6 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -12,7 +12,6 @@ #include "GrGLProgramBuilder.h" #include "GrSwizzle.h" #include "GrTexture.h" -#include "SkRTConf.h" #include "SkTraceEvent.h" #include "gl/GrGLGpu.h" #include "gl/GrGLProgram.h" diff --git a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp index b4ce2824e2..296c2beb44 100644 --- a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp +++ b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp @@ -8,14 +8,13 @@ #include "GrGLShaderStringBuilder.h" #include "gl/GrGLGpu.h" #include "gl/GrGLSLPrettyPrint.h" -#include "SkRTConf.h" #include "SkTraceEvent.h" #define GL_CALL(X) GR_GL_CALL(gpu->glInterface(), X) #define GL_CALL_RET(R, X) GR_GL_CALL_RET(gpu->glInterface(), R, X) -SK_CONF_DECLARE(bool, c_PrintShaders, "gpu.printShaders", false, - "Print the source code for all shaders generated."); +// Print the source code for all shaders generated. +static const bool c_PrintShaders{false}; static void print_shader_source(const char** strings, int* lengths, int count); diff --git a/src/gpu/vk/GrVkPipelineStateCache.cpp b/src/gpu/vk/GrVkPipelineStateCache.cpp index b8335e8e44..494f659e9f 100644 --- a/src/gpu/vk/GrVkPipelineStateCache.cpp +++ b/src/gpu/vk/GrVkPipelineStateCache.cpp @@ -11,7 +11,6 @@ #include "GrProcessor.h" #include "GrVkPipelineState.h" #include "GrVkPipelineStateBuilder.h" -#include "SkRTConf.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLProgramDataManager.h" diff --git a/src/images/SkJPEGImageEncoder.cpp b/src/images/SkJPEGImageEncoder.cpp index 1051aec205..66b2440c20 100644 --- a/src/images/SkJPEGImageEncoder.cpp +++ b/src/images/SkJPEGImageEncoder.cpp @@ -13,7 +13,6 @@ #include "SkTemplates.h" #include "SkTime.h" #include "SkUtils.h" -#include "SkRTConf.h" #include "SkRect.h" #include "SkCanvas.h" diff --git a/src/images/SkPNGImageEncoder.cpp b/src/images/SkPNGImageEncoder.cpp index c3df5d10a8..1932e66dc6 100644 --- a/src/images/SkPNGImageEncoder.cpp +++ b/src/images/SkPNGImageEncoder.cpp @@ -10,7 +10,6 @@ #include "SkColorPriv.h" #include "SkDither.h" #include "SkMath.h" -#include "SkRTConf.h" #include "SkStream.h" #include "SkTemplates.h" #include "SkUtils.h" @@ -36,11 +35,9 @@ #endif #define DEFAULT_FOR_SUPPRESS_PNG_IMAGE_DECODER_WARNINGS true -SK_CONF_DECLARE(bool, c_suppressPNGImageDecoderWarnings, - "images.png.suppressDecoderWarnings", - DEFAULT_FOR_SUPPRESS_PNG_IMAGE_DECODER_WARNINGS, - "Suppress most PNG warnings when calling image decode " - "functions."); +// Suppress most PNG warnings when calling image decode functions. +static const bool c_suppressPNGImageDecoderWarnings{ + DEFAULT_FOR_SUPPRESS_PNG_IMAGE_DECODER_WARNINGS}; /////////////////////////////////////////////////////////////////////////////// diff --git a/src/opts/opts_check_x86.cpp b/src/opts/opts_check_x86.cpp index dacb49bc91..a8003a3b0e 100644 --- a/src/opts/opts_check_x86.cpp +++ b/src/opts/opts_check_x86.cpp @@ -13,7 +13,6 @@ #include "SkBlitRow.h" #include "SkBlitRow_opts_SSE2.h" #include "SkCpu.h" -#include "SkRTConf.h" /* diff --git a/src/utils/SkRTConf.cpp b/src/utils/SkRTConf.cpp deleted file mode 100644 index 2dfa47efc7..0000000000 --- a/src/utils/SkRTConf.cpp +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright 2013 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "SkRTConf.h" -#include "SkOSFile.h" - -#include <stdlib.h> - -SkRTConfRegistry::SkRTConfRegistry(): fConfs(100) { - - FILE *fp = sk_fopen(configFileLocation(), kRead_SkFILE_Flag); - - if (!fp) { - return; - } - - char line[1024]; - - while (!sk_feof(fp)) { - - if (!sk_fgets(line, sizeof(line), fp)) { - break; - } - - char *commentptr = strchr(line, '#'); - if (commentptr == line) { - continue; - } - if (commentptr) { - *commentptr = '\0'; - } - - char sep[] = " \t\r\n"; - - char *keyptr = strtok(line, sep); - if (!keyptr) { - continue; - } - - char *valptr = strtok(nullptr, sep); - if (!valptr) { - continue; - } - - SkString *key = new SkString(keyptr); - SkString *val = new SkString(valptr); - - fConfigFileKeys.append(1, &key); - fConfigFileValues.append(1, &val); - } - sk_fclose(fp); -} - -SkRTConfRegistry::~SkRTConfRegistry() { - ConfMap::Iter iter(fConfs); - SkTDArray<SkRTConfBase *> *confArray; - - while (iter.next(&confArray)) { - delete confArray; - } - - for (int i = 0 ; i < fConfigFileKeys.count() ; i++) { - delete fConfigFileKeys[i]; - delete fConfigFileValues[i]; - } -} - -const char *SkRTConfRegistry::configFileLocation() const { - return "skia.conf"; // for now -- should probably do something fancier like home directories or whatever. -} - -// dump all known runtime config options to the file with their default values. -// to trigger this, make a config file of zero size. -void SkRTConfRegistry::possiblyDumpFile() const { - const char *path = configFileLocation(); - FILE *fp = sk_fopen(path, kRead_SkFILE_Flag); - if (!fp) { - return; - } - size_t configFileSize = sk_fgetsize(fp); - if (configFileSize == 0) { - printAll(path); - } - sk_fclose(fp); -} - -// Run through every provided configuration option and print a warning if the user hasn't -// declared a correponding configuration object somewhere. -void SkRTConfRegistry::validate() const { - for (int i = 0 ; i < fConfigFileKeys.count() ; i++) { - if (!fConfs.find(fConfigFileKeys[i]->c_str())) { - SkDebugf("WARNING: You have config value %s in your configuration file, but I've never heard of that.\n", fConfigFileKeys[i]->c_str()); - } - } -} - -void SkRTConfRegistry::printAll(const char *fname) const { - SkWStream *o; - - if (fname) { - o = new SkFILEWStream(fname); - } else { - o = new SkDebugWStream(); - } - - ConfMap::Iter iter(fConfs); - SkTDArray<SkRTConfBase *> *confArray; - - while (iter.next(&confArray)) { - if (confArray->getAt(0)->isDefault()) { - o->writeText("# "); - } - confArray->getAt(0)->print(o); - o->newline(); - } - - delete o; -} - -bool SkRTConfRegistry::hasNonDefault() const { - ConfMap::Iter iter(fConfs); - SkTDArray<SkRTConfBase *> *confArray; - while (iter.next(&confArray)) { - if (!confArray->getAt(0)->isDefault()) { - return true; - } - } - return false; -} - -void SkRTConfRegistry::printNonDefault(const char *fname) const { - SkWStream *o; - - if (fname) { - o = new SkFILEWStream(fname); - } else { - o = new SkDebugWStream(); - } - ConfMap::Iter iter(fConfs); - SkTDArray<SkRTConfBase *> *confArray; - - while (iter.next(&confArray)) { - if (!confArray->getAt(0)->isDefault()) { - confArray->getAt(0)->print(o); - o->newline(); - } - } - - delete o; -} - -// register a configuration variable after its value has been set by the parser. -// we maintain a vector of these things instead of just a single one because the -// user might set the value after initialization time and we need to have -// all the pointers lying around, not just one. -void SkRTConfRegistry::registerConf(SkRTConfBase *conf) { - SkTDArray<SkRTConfBase *> *confArray; - if (fConfs.find(conf->getName(), &confArray)) { - if (!conf->equals(confArray->getAt(0))) { - SkDebugf("WARNING: Skia config \"%s\" was registered more than once in incompatible ways.\n", conf->getName()); - } else { - confArray->append(1, &conf); - } - } else { - confArray = new SkTDArray<SkRTConfBase *>; - confArray->append(1, &conf); - fConfs.set(conf->getName(),confArray); - } -} - -template <typename T> T doParse(const char *, bool *success ) { - SkDebugf("WARNING: Invoked non-specialized doParse function...\n"); - if (success) { - *success = false; - } - return (T) 0; -} - -template<> bool doParse<bool>(const char *s, bool *success) { - if (success) { - *success = true; - } - if (!strcmp(s,"1") || !strcmp(s,"true")) { - return true; - } - if (!strcmp(s,"0") || !strcmp(s,"false")) { - return false; - } - if (success) { - *success = false; - } - return false; -} - -template<> const char * doParse<const char *>(const char * s, bool *success) { - if (success) { - *success = true; - } - return s; -} - -template<> int doParse<int>(const char * s, bool *success) { - if (success) { - *success = true; - } - return atoi(s); -} - -template<> unsigned int doParse<unsigned int>(const char * s, bool *success) { - if (success) { - *success = true; - } - return (unsigned int) atoi(s); -} - -template<> float doParse<float>(const char * s, bool *success) { - if (success) { - *success = true; - } - return (float) atof(s); -} - -template<> double doParse<double>(const char * s, bool *success) { - if (success) { - *success = true; - } - return atof(s); -} - -static inline void str_replace(char *s, char search, char replace) { - for (char *ptr = s ; *ptr ; ptr++) { - if (*ptr == search) { - *ptr = replace; - } - } -} - -template<typename T> bool SkRTConfRegistry::parse(const char *name, T* value) { - const char *str = nullptr; - - for (int i = fConfigFileKeys.count() - 1 ; i >= 0; i--) { - if (fConfigFileKeys[i]->equals(name)) { - str = fConfigFileValues[i]->c_str(); - break; - } - } - - SkString environment_variable("skia."); - environment_variable.append(name); - - const char *environment_value = getenv(environment_variable.c_str()); - if (environment_value) { - str = environment_value; - } else { - // apparently my shell doesn't let me have environment variables that - // have periods in them, so also let the user substitute underscores. - SkAutoTMalloc<char> underscore_name(SkStrDup(environment_variable.c_str())); - str_replace(underscore_name.get(), '.', '_'); - environment_value = getenv(underscore_name.get()); - if (environment_value) { - str = environment_value; - } - } - - if (!str) { - return false; - } - - bool success; - T new_value = doParse<T>(str, &success); - if (success) { - *value = new_value; - } else { - SkDebugf("WARNING: Couldn't parse value \'%s\' for variable \'%s\'\n", - str, name); - } - return success; -} - -// need to explicitly instantiate the parsing function for every config type we might have... - -template bool SkRTConfRegistry::parse(const char *name, bool *value); -template bool SkRTConfRegistry::parse(const char *name, int *value); -template bool SkRTConfRegistry::parse(const char *name, unsigned int *value); -template bool SkRTConfRegistry::parse(const char *name, float *value); -template bool SkRTConfRegistry::parse(const char *name, double *value); -template bool SkRTConfRegistry::parse(const char *name, const char **value); - -template <typename T> void SkRTConfRegistry::set(const char *name, - T value, - bool warnIfNotFound) { - SkTDArray<SkRTConfBase *> *confArray; - if (!fConfs.find(name, &confArray)) { - if (warnIfNotFound) { - SkDebugf("WARNING: Attempting to set configuration value \"%s\"," - " but I've never heard of that.\n", name); - } - return; - } - SkASSERT(confArray != nullptr); - for (SkRTConfBase **confBase = confArray->begin(); confBase != confArray->end(); confBase++) { - // static_cast here is okay because there's only one kind of child class. - SkRTConf<T> *concrete = static_cast<SkRTConf<T> *>(*confBase); - - if (concrete) { - concrete->set(value); - } - } -} - -template void SkRTConfRegistry::set(const char *name, bool value, bool); -template void SkRTConfRegistry::set(const char *name, int value, bool); -template void SkRTConfRegistry::set(const char *name, unsigned int value, bool); -template void SkRTConfRegistry::set(const char *name, float value, bool); -template void SkRTConfRegistry::set(const char *name, double value, bool); -template void SkRTConfRegistry::set(const char *name, char * value, bool); - -SkRTConfRegistry &skRTConfRegistry() { - static SkRTConfRegistry r; - return r; -} |