diff options
-rw-r--r-- | gyp/tools.gyp | 24 | ||||
-rw-r--r-- | tools/PictureBenchmark.cpp | 124 | ||||
-rw-r--r-- | tools/PictureBenchmark.h | 101 | ||||
-rw-r--r-- | tools/PictureRenderer.cpp | 10 | ||||
-rw-r--r-- | tools/PictureRenderer.h | 11 | ||||
-rw-r--r-- | tools/bench_pictures_main.cpp | 273 | ||||
-rw-r--r-- | tools/picture_utils.cpp | 5 | ||||
-rw-r--r-- | tools/picture_utils.h | 3 | ||||
-rw-r--r-- | tools/render_pictures_main.cpp | 9 |
9 files changed, 322 insertions, 238 deletions
diff --git a/gyp/tools.gyp b/gyp/tools.gyp index 2ab422f1f4..3910b703f0 100644 --- a/gyp/tools.gyp +++ b/gyp/tools.gyp @@ -78,7 +78,7 @@ 'core.gyp:core', 'images.gyp:images', 'ports.gyp:ports', - 'tools.gyp:PictureRenderer', + 'tools.gyp:picture_renderer', 'tools.gyp:picture_utils', ], }, @@ -87,23 +87,37 @@ 'type': 'executable', 'sources': [ '../tools/bench_pictures_main.cpp', - '../src/pipe/utils/SamplePipeControllers.h', - '../src/pipe/utils/SamplePipeControllers.cpp', ], 'include_dirs': [ '../bench', - '../src/pipe/utils/', ], 'dependencies': [ 'core.gyp:core', 'ports.gyp:ports', 'images.gyp:images', 'tools.gyp:picture_utils', + 'tools.gyp:picture_benchmark', 'bench.gyp:bench_timer', ], }, { - 'target_name': 'PictureRenderer', + 'target_name': 'picture_benchmark', + 'type': 'static_library', + 'sources': [ + '../tools/PictureBenchmark.cpp', + ], + 'include_dirs': [ + '../bench', + ], + 'dependencies': [ + 'core.gyp:core', + 'tools.gyp:picture_utils', + 'tools.gyp:picture_renderer', + 'bench.gyp:bench_timer', + ], + }, + { + 'target_name': 'picture_renderer', 'type': 'static_library', 'sources': [ '../tools/PictureRenderer.cpp', diff --git a/tools/PictureBenchmark.cpp b/tools/PictureBenchmark.cpp new file mode 100644 index 0000000000..7a012d9f53 --- /dev/null +++ b/tools/PictureBenchmark.cpp @@ -0,0 +1,124 @@ +/* + * Copyright 2012 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkTypes.h" +#include "BenchTimer.h" +#include "PictureBenchmark.h" +#include "SkCanvas.h" +#include "SkPicture.h" +#include "SkString.h" +#include "picture_utils.h" + +namespace sk_tools { + +void PipePictureBenchmark::run(SkPicture* pict) { + SkBitmap bitmap; + sk_tools::setup_bitmap(&bitmap, pict->width(), pict->height()); + + SkCanvas canvas(bitmap); + + renderer.init(*pict); + + // We throw this away to remove first time effects (such as paging in this + // program) + renderer.render(pict, &canvas); + + BenchTimer timer = BenchTimer(NULL); + timer.start(); + for (int i = 0; i < fRepeats; ++i) { + renderer.render(pict, &canvas); + } + timer.end(); + + SkDebugf("pipe: msecs = %6.2f\n", timer.fWall / fRepeats); +} + +void RecordPictureBenchmark::run(SkPicture* pict) { + BenchTimer timer = BenchTimer(NULL); + double wall_time = 0; + + for (int i = 0; i < fRepeats + 1; ++i) { + SkPicture replayer; + SkCanvas* recorder = replayer.beginRecording(pict->width(), pict->height()); + + timer.start(); + recorder->drawPicture(*pict); + timer.end(); + + // We want to ignore first time effects + if (i > 0) { + wall_time += timer.fWall; + } + } + + SkDebugf("record: msecs = %6.5f\n", wall_time / fRepeats); +} + +void SimplePictureBenchmark::run(SkPicture* pict) { + SkBitmap bitmap; + sk_tools::setup_bitmap(&bitmap, pict->width(), pict->height()); + + SkCanvas canvas(bitmap); + + renderer.init(*pict); + + // We throw this away to remove first time effects (such as paging in this + // program) + renderer.render(pict, &canvas); + + BenchTimer timer = BenchTimer(NULL); + timer.start(); + for (int i = 0; i < fRepeats; ++i) { + renderer.render(pict, &canvas); + } + timer.end(); + + printf("simple: msecs = %6.2f\n", timer.fWall / fRepeats); +} + +void TiledPictureBenchmark::run(SkPicture* pict) { + renderer.init(*pict); + + // We throw this away to remove first time effects (such as paging in this + // program) + renderer.drawTiles(pict); + + BenchTimer timer = BenchTimer(NULL); + timer.start(); + for (int i = 0; i < fRepeats; ++i) { + renderer.drawTiles(pict); + } + timer.end(); + + SkDebugf("%i_tiles_%ix%i: msecs = %6.2f\n", renderer.numTiles(), renderer.getTileWidth(), + renderer.getTileHeight(), timer.fWall / fRepeats); +} + +void UnflattenPictureBenchmark::run(SkPicture* pict) { + BenchTimer timer = BenchTimer(NULL); + double wall_time = 0; + + for (int i = 0; i < fRepeats + 1; ++i) { + SkPicture replayer; + SkCanvas* recorder = replayer.beginRecording(pict->width(), pict->height()); + + recorder->drawPicture(*pict); + + timer.start(); + replayer.endRecording(); + timer.end(); + + // We want to ignore first time effects + if (i > 0) { + wall_time += timer.fWall; + } + } + + SkDebugf("unflatten: msecs = %6.4f\n", wall_time / fRepeats); +} + +} diff --git a/tools/PictureBenchmark.h b/tools/PictureBenchmark.h new file mode 100644 index 0000000000..37487a3e66 --- /dev/null +++ b/tools/PictureBenchmark.h @@ -0,0 +1,101 @@ +/* + * Copyright 2012 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef PictureBenchmark_DEFINED +#define PictureBenchmark_DEFINED +#include "SkTypes.h" +#include "SkRefCnt.h" +#include "PictureRenderer.h" + +class SkPicture; +class SkString; + +namespace sk_tools { + +class PictureBenchmark : public SkRefCnt { +public: + virtual void run(SkPicture* pict) = 0; + + void setRepeats(int repeats) { + fRepeats = repeats; + } + + int getRepeats() const { + return fRepeats; + } + +protected: + int fRepeats; +}; + +class PipePictureBenchmark : public PictureBenchmark { +public: + virtual void run(SkPicture* pict); +private: + PipePictureRenderer renderer; +}; + +class RecordPictureBenchmark : public PictureBenchmark { +public: + virtual void run(SkPicture* pict); +}; + +class SimplePictureBenchmark : public PictureBenchmark { +public: + virtual void run(SkPicture* pict); +private: + SimplePictureRenderer renderer; +}; + +class TiledPictureBenchmark : public PictureBenchmark { +public: + virtual void run(SkPicture* pict); + + void setTileWidth(int width) { + renderer.setTileWidth(width); + } + + int getTileWidth() const { + return renderer.getTileWidth(); + } + + void setTileHeight(int height) { + renderer.setTileHeight(height); + } + + int getTileHeight() const { + return renderer.getTileHeight(); + } + + void setTileWidthPercentage(double percentage) { + renderer.setTileWidthPercentage(percentage); + } + + double getTileWidthPercentage() const { + return renderer.getTileWidthPercentage(); + } + + void setTileHeightPercentage(double percentage) { + renderer.setTileHeightPercentage(percentage); + } + + double getTileHeightPercentage() const { + return renderer.getTileHeightPercentage(); + } + +private: + TiledPictureRenderer renderer; +}; + +class UnflattenPictureBenchmark : public PictureBenchmark { +public: + virtual void run(SkPicture* pict); +}; + +} + +#endif // PictureBenchmark_DEFINED diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp index 5f3496c60f..c6abc1d2f8 100644 --- a/tools/PictureRenderer.cpp +++ b/tools/PictureRenderer.cpp @@ -45,9 +45,7 @@ void TiledPictureRenderer::init(const SkPicture& pict) { } void TiledPictureRenderer::render(SkPicture* pict, SkCanvas* canvas) { - for (int i = 0; i < fTiles.count(); ++i) { - fTiles[i].fCanvas->drawPicture(*pict); - } + drawTiles(pict); copyTilesToCanvas(*pict, canvas); } @@ -92,6 +90,12 @@ void TiledPictureRenderer::deleteTiles() { fTiles.reset(); } +void TiledPictureRenderer::drawTiles(SkPicture* pict) { + for (int i = 0; i < fTiles.count(); ++i) { + fTiles[i].fCanvas->drawPicture(*pict); + } +} + void TiledPictureRenderer::copyTilesToCanvas(const SkPicture& pict, SkCanvas* destination) { int tile_index = 0; for (int tile_y_start = 0; tile_y_start < pict.height(); diff --git a/tools/PictureRenderer.h b/tools/PictureRenderer.h index ebf1891bed..69923737ac 100644 --- a/tools/PictureRenderer.h +++ b/tools/PictureRenderer.h @@ -24,10 +24,12 @@ public: }; class PipePictureRenderer : public PictureRenderer { +public: virtual void render(SkPicture* pict, SkCanvas* canvas); }; class SimplePictureRenderer : public PictureRenderer { +public: virtual void render (SkPicture* pict, SkCanvas* canvas); }; @@ -37,6 +39,7 @@ public: virtual void init(const SkPicture& pict); virtual void render(SkPicture* pict, SkCanvas* canvas); + void drawTiles(SkPicture* pict); void setTileWidth(int width) { fTileWidth = width; @@ -58,7 +61,7 @@ public: fTileWidthPercentage = percentage; } - double getTileWidthPercentage() { + double getTileWidthPercentage() const { return fTileWidthPercentage; } @@ -66,10 +69,14 @@ public: fTileHeightPercentage = percentage; } - double getTileHeightPercentage() { + double getTileHeightPercentage() const { return fTileHeightPercentage; } + int numTiles() const { + return fTiles.count(); + } + ~TiledPictureRenderer(); private: diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp index 5a1b5de025..c595eb54f9 100644 --- a/tools/bench_pictures_main.cpp +++ b/tools/bench_pictures_main.cpp @@ -6,10 +6,8 @@ */ #include "BenchTimer.h" -#include "SamplePipeControllers.h" -#include "SkBitmap.h" +#include "PictureBenchmark.h" #include "SkCanvas.h" -#include "SkGPipe.h" #include "SkOSFile.h" #include "SkPicture.h" #include "SkStream.h" @@ -17,24 +15,6 @@ #include "picture_utils.h" const int DEFAULT_REPEATS = 100; -const int DEFAULT_TILE_WIDTH = 256; -const int DEFAULT_TILE_HEIGHT = 256; - -struct Options; -static void run_simple_benchmark(SkPicture* picture, const Options&); - -struct Options { - int fRepeats; - void (*fBenchmark) (SkPicture*, const Options& options); - int fTileWidth; - int fTileHeight; - double fTileWidthPercentage; - double fTileHeightPercentage; - - Options() : fRepeats(DEFAULT_REPEATS), fBenchmark(run_simple_benchmark), - fTileWidth(DEFAULT_TILE_WIDTH), fTileHeight(DEFAULT_TILE_HEIGHT), - fTileWidthPercentage(0), fTileHeightPercentage(0){} -}; static void usage(const char* argv0) { SkDebugf("SkPicture benchmarking tool\n"); @@ -52,7 +32,7 @@ static void usage(const char* argv0) { "Set to use piping." " Default is to not use piping.\n"); SkDebugf( -" --record : " +" --record : " "Set to do a picture recording benchmark. Default is not to do this.\n"); SkDebugf( " --repeat : " @@ -67,162 +47,8 @@ static void usage(const char* argv0) { "Set to do a picture unflattening benchmark. Default is not to do this.\n"); } -static void run_simple_benchmark(SkPicture* picture, const Options& options) { - SkBitmap bitmap; - sk_tools::setup_bitmap(&bitmap, picture->width(), picture->height()); - - SkCanvas canvas(bitmap); - - // We throw this away to remove first time effects (such as paging in this - // program) - canvas.drawPicture(*picture); - - BenchTimer timer = BenchTimer(NULL); - timer.start(); - for (int i = 0; i < options.fRepeats; ++i) { - canvas.drawPicture(*picture); - } - timer.end(); - - printf("simple: msecs = %6.2f\n", timer.fWall / options.fRepeats); -} - -struct TileInfo { - SkBitmap* fBitmap; - SkCanvas* fCanvas; -}; - -static void clip_tile(SkPicture* picture, const TileInfo& tile) { - SkRect clip = SkRect::MakeWH(SkIntToScalar(picture->width()), - SkIntToScalar(picture->height())); - tile.fCanvas->clipRect(clip); -} - -static void setup_single_tile(SkPicture* picture, const Options& options, - SkTArray<TileInfo>* tiles, int tile_x_start, int tile_y_start) { - TileInfo& tile = tiles->push_back(); - - tile.fBitmap = new SkBitmap(); - sk_tools::setup_bitmap(tile.fBitmap, options.fTileWidth, options.fTileHeight); - - tile.fCanvas = new SkCanvas(*(tile.fBitmap)); - tile.fCanvas->translate(SkIntToScalar(-tile_x_start), SkIntToScalar(-tile_y_start)); - clip_tile(picture, tile); -} - -static void setup_tiles(SkPicture* picture, const Options& options, SkTArray<TileInfo>* tiles) { - for (int tile_y_start = 0; tile_y_start < picture->height(); - tile_y_start += options.fTileHeight) { - for (int tile_x_start = 0; tile_x_start < picture->width(); - tile_x_start += options.fTileWidth) { - setup_single_tile(picture, options, tiles, tile_x_start, tile_y_start); - } - } - -} - -static void run_tile_benchmark(SkPicture* picture, const Options& options) { - SkTArray<TileInfo> tiles; - setup_tiles(picture, options, &tiles); - - // We throw this away to remove first time effects (such as paging in this - // program) - for (int j = 0; j < tiles.count(); ++j) { - tiles[j].fCanvas->drawPicture(*picture); - } - - BenchTimer timer = BenchTimer(NULL); - timer.start(); - for (int i = 0; i < options.fRepeats; ++i) { - for (int j = 0; j < tiles.count(); ++j) { - tiles[j].fCanvas->drawPicture(*picture); - } - } - timer.end(); - - for (int i = 0; i < tiles.count(); ++i) { - delete tiles[i].fCanvas; - delete tiles[i].fBitmap; - } - - printf("%i_tiles_%ix%i: msecs = %6.2f\n", tiles.count(), options.fTileWidth, - options.fTileHeight, timer.fWall / options.fRepeats); -} - -static void pipe_run(SkPicture* picture, SkCanvas* canvas) { - PipeController pipeController(canvas); - SkGPipeWriter writer; - SkCanvas* pipeCanvas = writer.startRecording(&pipeController); - pipeCanvas->drawPicture(*picture); - writer.endRecording(); -} - -static void run_pipe_benchmark(SkPicture* picture, const Options& options) { - SkBitmap bitmap; - sk_tools::setup_bitmap(&bitmap, picture->width(), picture->height()); - - SkCanvas canvas(bitmap); - - // We throw this away to remove first time effects (such as paging in this - // program) - pipe_run(picture, &canvas); - - BenchTimer timer = BenchTimer(NULL); - timer.start(); - for (int i = 0; i < options.fRepeats; ++i) { - pipe_run(picture, &canvas); - } - timer.end(); - - printf("pipe: msecs = %6.2f\n", timer.fWall / options.fRepeats); -} - -static void run_unflatten_benchmark(SkPicture* commands, const Options& options) { - BenchTimer timer = BenchTimer(NULL); - double wall_time = 0; - - for (int i = 0; i < options.fRepeats + 1; ++i) { - SkPicture replayer; - SkCanvas* recorder = replayer.beginRecording(commands->width(), commands->height()); - - recorder->drawPicture(*commands); - - timer.start(); - replayer.endRecording(); - timer.end(); - - // We want to ignore first time effects - if (i > 0) { - wall_time += timer.fWall; - } - } - - printf("unflatten: msecs = %6.4f\n", wall_time / options.fRepeats); -} - -static void run_record_benchmark(SkPicture* commands, const Options& options) { - BenchTimer timer = BenchTimer(NULL); - double wall_time = 0; - - for (int i = 0; i < options.fRepeats + 1; ++i) { - SkPicture replayer; - SkCanvas* recorder = replayer.beginRecording(commands->width(), commands->height()); - - timer.start(); - recorder->drawPicture(*commands); - timer.end(); - - // We want to ignore first time effects - if (i > 0) { - wall_time += timer.fWall; - } - } - - printf("record: msecs = %6.5f\n", wall_time / options.fRepeats); -} - static void run_single_benchmark(const SkString& inputPath, - Options* options) { + sk_tools::PictureBenchmark& benchmark) { SkFILEStream inputStream; inputStream.setPath(inputPath.c_str()); @@ -235,95 +61,92 @@ static void run_single_benchmark(const SkString& inputPath, SkString filename; sk_tools::get_basename(&filename, inputPath); - printf("running bench [%i %i] %s ", picture.width(), picture.height(), + SkDebugf("running bench [%i %i] %s ", picture.width(), picture.height(), filename.c_str()); - if (options->fTileWidthPercentage > 0) { - options->fTileWidth = sk_float_ceil2int( - float(options->fTileWidthPercentage * picture.width() / 100)); - } - if (options->fTileHeightPercentage > 0) { - options->fTileHeight = sk_float_ceil2int( - float(options->fTileHeightPercentage * picture.height() / 100)); - } - - options->fBenchmark(&picture, *options); -} - -static bool is_percentage(char* const string) { - SkString skString(string); - return skString.endsWith("%"); + benchmark.run(&picture); } -static void parse_commandline(int argc, char* const argv[], - SkTArray<SkString>* inputs, Options* options) { +static void parse_commandline(int argc, char* const argv[], SkTArray<SkString>* inputs, + sk_tools::PictureBenchmark*& benchmark) { const char* argv0 = argv[0]; char* const* stop = argv + argc; + int repeats = DEFAULT_REPEATS; + for (++argv; argv < stop; ++argv) { if (0 == strcmp(*argv, "--repeat")) { ++argv; if (argv < stop) { - options->fRepeats = atoi(*argv); - if (options->fRepeats < 1) { + repeats = atoi(*argv); + if (repeats < 1) { + SkDELETE(benchmark); SkDebugf("--repeat must be given a value > 0\n"); exit(-1); } } else { + SkDELETE(benchmark); SkDebugf("Missing arg for --repeat\n"); usage(argv0); exit(-1); } } else if (0 == strcmp(*argv, "--tile")) { - options->fBenchmark = run_tile_benchmark; + sk_tools::TiledPictureBenchmark* tileBenchmark = SkNEW(sk_tools::TiledPictureBenchmark); ++argv; if (argv < stop) { - if (is_percentage(*argv)) { - options->fTileWidthPercentage = atof(*argv); - if (!(options->fTileWidthPercentage > 0)) { + if (sk_tools::is_percentage(*argv)) { + tileBenchmark->setTileWidthPercentage(atof(*argv)); + if (!(tileBenchmark->getTileWidthPercentage() > 0)) { + SkDELETE(tileBenchmark); SkDebugf("--tile must be given a width percentage > 0\n"); exit(-1); } } else { - options->fTileWidth = atoi(*argv); - if (!(options->fTileWidth > 0)) { + tileBenchmark->setTileWidth(atoi(*argv)); + if (!(tileBenchmark->getTileWidth() > 0)) { + SkDELETE(tileBenchmark); SkDebugf("--tile must be given a width > 0\n"); exit(-1); } } } else { + SkDELETE(tileBenchmark); SkDebugf("Missing width for --tile\n"); usage(argv0); exit(-1); } ++argv; if (argv < stop) { - if (is_percentage(*argv)) { - options->fTileHeightPercentage = atof(*argv); - if (!(options->fTileHeightPercentage > 0)) { - SkDebugf( - "--tile must be given a height percentage > 0\n"); + if (sk_tools::is_percentage(*argv)) { + tileBenchmark->setTileHeightPercentage(atof(*argv)); + if (!(tileBenchmark->getTileHeightPercentage() > 0)) { + SkDELETE(tileBenchmark); + SkDebugf("--tile must be given a height percentage > 0\n"); exit(-1); } } else { - options->fTileHeight = atoi(*argv); - if (!(options->fTileHeight > 0)) { + tileBenchmark->setTileHeight(atoi(*argv)); + if (!(tileBenchmark->getTileHeight() > 0)) { + SkDELETE(tileBenchmark); SkDebugf("--tile must be given a height > 0\n"); exit(-1); } } } else { + SkDELETE(tileBenchmark); SkDebugf("Missing height for --tile\n"); usage(argv0); exit(-1); } + benchmark = tileBenchmark; } else if (0 == strcmp(*argv, "--pipe")) { - options->fBenchmark = run_pipe_benchmark; + benchmark = SkNEW(sk_tools::PipePictureBenchmark); } else if (0 == strcmp(*argv, "--record")) { - options->fBenchmark = run_record_benchmark; + benchmark = SkNEW(sk_tools::RecordPictureBenchmark); } else if (0 == strcmp(*argv, "--unflatten")) { - options->fBenchmark = run_unflatten_benchmark; + benchmark = SkNEW(sk_tools::UnflattenPictureBenchmark); } else if (0 == strcmp(*argv, "--help") || 0 == strcmp(*argv, "-h")) { + SkDELETE(benchmark); usage(argv0); exit(0); } else { @@ -332,34 +155,42 @@ static void parse_commandline(int argc, char* const argv[], } if (inputs->count() < 1) { + SkDELETE(benchmark); usage(argv0); exit(-1); } + + if (benchmark == NULL) { + benchmark = SkNEW(sk_tools::SimplePictureBenchmark); + } + + benchmark->setRepeats(repeats); } -static void process_input(const SkString& input, Options* options) { +static void process_input(const SkString& input, sk_tools::PictureBenchmark& benchmark) { SkOSFile::Iter iter(input.c_str(), "skp"); SkString inputFilename; if (iter.next(&inputFilename)) { do { SkString inputPath; - sk_tools::make_filepath(&inputPath, input, - inputFilename); - run_single_benchmark(inputPath, options); + sk_tools::make_filepath(&inputPath, input, inputFilename); + run_single_benchmark(inputPath, benchmark); } while(iter.next(&inputFilename)); } else { - run_single_benchmark(input, options); + run_single_benchmark(input, benchmark); } } int main(int argc, char* const argv[]) { SkTArray<SkString> inputs; - Options options; + sk_tools::PictureBenchmark* benchmark = NULL; - parse_commandline(argc, argv, &inputs, &options); + parse_commandline(argc, argv, &inputs, benchmark); for (int i = 0; i < inputs.count(); ++i) { - process_input(inputs[i], &options); + process_input(inputs[i], *benchmark); } + + SkDELETE(benchmark); } diff --git a/tools/picture_utils.cpp b/tools/picture_utils.cpp index 28e6293d2f..26788ee1ed 100644 --- a/tools/picture_utils.cpp +++ b/tools/picture_utils.cpp @@ -65,6 +65,11 @@ namespace sk_tools { basename->set(path.c_str(), end + 1); } + bool is_percentage(char* const string) { + SkString skString(string); + return skString.endsWith("%"); + } + void setup_bitmap(SkBitmap* bitmap, int width, int height) { bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height); bitmap->allocPixels(); diff --git a/tools/picture_utils.h b/tools/picture_utils.h index aeb625f6e5..2cda45bd40 100644 --- a/tools/picture_utils.h +++ b/tools/picture_utils.h @@ -25,6 +25,9 @@ namespace sk_tools { // only) void get_basename(SkString* basename, const SkString& path); + // Returns true if the string ends with % + bool is_percentage(char* const string); + // Prepares the bitmap so that it can be written. // // Specifically, it configures the bitmap, allocates pixels and then diff --git a/tools/render_pictures_main.cpp b/tools/render_pictures_main.cpp index 6b76c50066..00272c7984 100644 --- a/tools/render_pictures_main.cpp +++ b/tools/render_pictures_main.cpp @@ -114,11 +114,6 @@ static void process_input(const SkString& input, const SkString& outputDir, } } -static bool is_percentage(char* const string) { - SkString skString(string); - return skString.endsWith("%"); -} - static void parse_commandline(int argc, char* const argv[], SkTArray<SkString>* inputs, sk_tools::PictureRenderer*& renderer){ const char* argv0 = argv[0]; @@ -131,7 +126,7 @@ static void parse_commandline(int argc, char* const argv[], SkTArray<SkString>* sk_tools::TiledPictureRenderer* tileRenderer = SkNEW(sk_tools::TiledPictureRenderer); ++argv; if (argv < stop) { - if (is_percentage(*argv)) { + if (sk_tools::is_percentage(*argv)) { tileRenderer->setTileWidthPercentage(atof(*argv)); if (!(tileRenderer->getTileWidthPercentage() > 0)) { SkDELETE(tileRenderer); @@ -154,7 +149,7 @@ static void parse_commandline(int argc, char* const argv[], SkTArray<SkString>* } ++argv; if (argv < stop) { - if (is_percentage(*argv)) { + if (sk_tools::is_percentage(*argv)) { tileRenderer->setTileHeightPercentage(atof(*argv)); if (!(tileRenderer->getTileHeightPercentage() > 0)) { SkDELETE(tileRenderer); |