2012-06-27 19:33:29 +00:00
|
|
|
/*
|
|
|
|
* 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 "BenchTimer.h"
|
2012-11-07 18:01:46 +00:00
|
|
|
#include "CopyTilesRenderer.h"
|
2012-08-01 17:53:29 +00:00
|
|
|
#include "PictureBenchmark.h"
|
2012-09-07 15:21:18 +00:00
|
|
|
#include "SkBenchLogger.h"
|
2012-06-27 19:33:29 +00:00
|
|
|
#include "SkCanvas.h"
|
2012-09-10 20:29:13 +00:00
|
|
|
#include "SkGraphics.h"
|
Add the ability to provide function pointers to SkPicture serialization
and deserialization for encoding and decoding bitmaps.
Remove kForceFlattenBitmapPixels_Flag, which is no longer used.
When an SkOrderedReadBuffer needs to read a bitmap, if it does not
have an image decoder, use a dummy bitmap.
In GM, add a tolerance option for color differences, used when
testing picture serialization, so it can assume two images are the
same even though PNG encoding/decoding may have resulted in small
differences.
Create dummy implementations for SkImageDecoder and SkImageEncoder
functions in SkImageDecoder_empty so that a project that does not
want to include the images project it can still build.
Allow ports to build without images project.
In Mac's image encoder, copy 4444 to 8888 before encoding.
Add SkWriter32::reservePad, to provide a pointer to write non 4 byte
aligned data, padded with zeroes.
In bench_ and render_ pictures, pass decode function to SkPicture
creation from a stream.
BUG=https://code.google.com/p/skia/issues/detail?id=842
Review URL: https://codereview.appspot.com/6551071
git-svn-id: http://skia.googlecode.com/svn/trunk@5818 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-10-04 21:46:08 +00:00
|
|
|
#include "SkImageDecoder.h"
|
2012-08-23 20:53:25 +00:00
|
|
|
#include "SkMath.h"
|
2012-06-27 19:33:29 +00:00
|
|
|
#include "SkOSFile.h"
|
|
|
|
#include "SkPicture.h"
|
|
|
|
#include "SkStream.h"
|
|
|
|
#include "SkTArray.h"
|
|
|
|
#include "picture_utils.h"
|
|
|
|
|
2012-09-17 21:10:05 +00:00
|
|
|
const int DEFAULT_REPEATS = 1;
|
2012-06-27 19:33:29 +00:00
|
|
|
|
2012-11-06 21:26:13 +00:00
|
|
|
static char const * const gFilterTypes[] = {
|
|
|
|
"paint",
|
|
|
|
"point",
|
|
|
|
"line",
|
|
|
|
"bitmap",
|
|
|
|
"rect",
|
|
|
|
"path",
|
|
|
|
"text",
|
|
|
|
"all",
|
|
|
|
};
|
|
|
|
|
|
|
|
static const size_t kFilterTypesCount = sizeof(gFilterTypes) / sizeof(gFilterTypes[0]);
|
|
|
|
|
|
|
|
static char const * const gFilterFlags[] = {
|
|
|
|
"antiAlias",
|
|
|
|
"filterBitmap",
|
|
|
|
"dither",
|
|
|
|
"underlineText",
|
|
|
|
"strikeThruText",
|
|
|
|
"fakeBoldText",
|
|
|
|
"linearText",
|
|
|
|
"subpixelText",
|
|
|
|
"devKernText",
|
|
|
|
"LCDRenderText",
|
|
|
|
"embeddedBitmapText",
|
|
|
|
"autoHinting",
|
|
|
|
"verticalText",
|
|
|
|
"genA8FromLCD",
|
|
|
|
"blur",
|
|
|
|
"hinting",
|
|
|
|
"slightHinting",
|
2012-11-07 16:42:17 +00:00
|
|
|
"AAClip",
|
2012-11-06 21:26:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const size_t kFilterFlagsCount = sizeof(gFilterFlags) / sizeof(gFilterFlags[0]);
|
|
|
|
|
|
|
|
static SkString filtersName(sk_tools::PictureRenderer::DrawFilterFlags* drawFilters) {
|
|
|
|
int all = drawFilters[0];
|
|
|
|
size_t tIndex;
|
|
|
|
for (tIndex = 1; tIndex < SkDrawFilter::kTypeCount; ++tIndex) {
|
|
|
|
all &= drawFilters[tIndex];
|
|
|
|
}
|
|
|
|
SkString result;
|
|
|
|
for (size_t fIndex = 0; fIndex < kFilterFlagsCount; ++fIndex) {
|
|
|
|
SkString types;
|
|
|
|
if (all & (1 << fIndex)) {
|
|
|
|
types = gFilterTypes[SkDrawFilter::kTypeCount];
|
|
|
|
} else {
|
|
|
|
for (tIndex = 0; tIndex < SkDrawFilter::kTypeCount; ++tIndex) {
|
|
|
|
if (drawFilters[tIndex] & (1 << fIndex)) {
|
|
|
|
types += gFilterTypes[tIndex];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!types.size()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
result += "_";
|
|
|
|
result += types;
|
|
|
|
result += ".";
|
|
|
|
result += gFilterFlags[fIndex];
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static SkString filterTypesUsage() {
|
|
|
|
SkString result;
|
|
|
|
for (size_t index = 0; index < kFilterTypesCount; ++index) {
|
|
|
|
result += gFilterTypes[index];
|
|
|
|
if (index < kFilterTypesCount - 1) {
|
|
|
|
result += " | ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static SkString filterFlagsUsage() {
|
|
|
|
SkString result;
|
|
|
|
size_t len = 0;
|
|
|
|
for (size_t index = 0; index < kFilterFlagsCount; ++index) {
|
|
|
|
result += gFilterFlags[index];
|
|
|
|
if (result.size() - len >= 72) {
|
|
|
|
result += "\n ";
|
|
|
|
len = result.size();
|
|
|
|
}
|
|
|
|
if (index < kFilterFlagsCount - 1) {
|
|
|
|
result += " | ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-06-27 19:33:29 +00:00
|
|
|
static void usage(const char* argv0) {
|
|
|
|
SkDebugf("SkPicture benchmarking tool\n");
|
|
|
|
SkDebugf("\n"
|
|
|
|
"Usage: \n"
|
2012-07-09 18:32:08 +00:00
|
|
|
" %s <inputDir>...\n"
|
2012-09-11 19:15:32 +00:00
|
|
|
" [--logFile filename][--timers [wcgWC]*][--logPerIter 1|0][--min]\n"
|
Provide an option to bench drawing individual tiles in bench_pictures.
Provides output like the following:
running bench [1236 12045] androidpolice.skp
tile_256x256: tile [0,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [1,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [2,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [3,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [4,0] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,1] out of [5,48]: msecs = 2.00
tile_256x256: tile [1,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [2,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [3,1] out of [5,48]: msecs = 6.00
tile_256x256: tile [4,1] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,2] out of [5,48]: msecs = 2.00
BUG=https://code.google.com/p/skia/issues/detail?id=1016
Review URL: https://codereview.appspot.com/6937047
git-svn-id: http://skia.googlecode.com/svn/trunk@6805 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-12-13 22:09:28 +00:00
|
|
|
" [--repeat][--timeIndividualTiles] \n"
|
2012-11-07 18:01:46 +00:00
|
|
|
" [--mode pow2tile minWidth height | record | simple\n"
|
|
|
|
" | tile width height | playbackCreation]\n"
|
2012-08-31 16:15:22 +00:00
|
|
|
" [--pipe]\n"
|
2012-11-02 18:11:49 +00:00
|
|
|
" [--bbh bbhType]\n"
|
2012-09-20 14:42:33 +00:00
|
|
|
" [--multi numThreads]\n"
|
2012-12-17 19:25:54 +00:00
|
|
|
" [--viewport width height][--scale sf]\n"
|
2012-08-20 15:04:04 +00:00
|
|
|
" [--device bitmap"
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
" | gpu"
|
|
|
|
#endif
|
2012-11-06 21:26:13 +00:00
|
|
|
"]\n"
|
|
|
|
" [--filter [%s]:\n [%s]]\n"
|
|
|
|
, argv0, filterTypesUsage().c_str(), filterFlagsUsage().c_str());
|
|
|
|
SkDebugf("\n");
|
2012-06-27 19:33:29 +00:00
|
|
|
SkDebugf(
|
2012-08-02 18:57:53 +00:00
|
|
|
" inputDir: A list of directories and files to use as input. Files are\n"
|
2012-09-07 15:21:18 +00:00
|
|
|
" expected to have the .skp extension.\n\n"
|
|
|
|
" --logFile filename : destination for writing log output, in addition to stdout.\n");
|
2012-09-11 19:15:32 +00:00
|
|
|
SkDebugf(" --logPerIter 1|0 : "
|
|
|
|
"Log each repeat timer instead of mean, default is disabled.\n");
|
|
|
|
SkDebugf(" --min : Print the minimum times (instead of average).\n");
|
|
|
|
SkDebugf(" --timers [wcgWC]* : "
|
|
|
|
"Display wall, cpu, gpu, truncated wall or truncated cpu time for each picture.\n");
|
Provide an option to bench drawing individual tiles in bench_pictures.
Provides output like the following:
running bench [1236 12045] androidpolice.skp
tile_256x256: tile [0,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [1,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [2,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [3,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [4,0] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,1] out of [5,48]: msecs = 2.00
tile_256x256: tile [1,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [2,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [3,1] out of [5,48]: msecs = 6.00
tile_256x256: tile [4,1] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,2] out of [5,48]: msecs = 2.00
BUG=https://code.google.com/p/skia/issues/detail?id=1016
Review URL: https://codereview.appspot.com/6937047
git-svn-id: http://skia.googlecode.com/svn/trunk@6805 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-12-13 22:09:28 +00:00
|
|
|
SkDebugf(" --timeIndividualTiles : Report times for drawing individual tiles, rather than\n"
|
|
|
|
" times for drawing the whole page.\n"
|
|
|
|
" Requires --mode tile\n");
|
2012-06-27 19:33:29 +00:00
|
|
|
SkDebugf(
|
2012-11-07 18:01:46 +00:00
|
|
|
" --mode pow2tile minWidth height | copyTile width height | record | simple\n"
|
|
|
|
" | tile width height | playbackCreation:\n"
|
2012-08-31 16:15:22 +00:00
|
|
|
" Run in the corresponding mode.\n"
|
|
|
|
" Default is simple.\n");
|
2012-07-09 19:37:40 +00:00
|
|
|
SkDebugf(
|
2012-11-07 18:01:46 +00:00
|
|
|
" pow2tile minWidth height, Creates tiles with widths\n"
|
2012-08-31 16:15:22 +00:00
|
|
|
" that are all a power of two\n"
|
|
|
|
" such that they minimize the\n"
|
|
|
|
" amount of wasted tile space.\n"
|
|
|
|
" minWidth is the minimum width\n"
|
|
|
|
" of these tiles and must be a\n"
|
|
|
|
" power of two. Simple\n"
|
|
|
|
" rendering using these tiles\n"
|
2012-09-20 14:42:33 +00:00
|
|
|
" is benchmarked.\n");
|
2012-08-23 20:53:25 +00:00
|
|
|
SkDebugf(
|
2012-08-02 18:57:53 +00:00
|
|
|
" record, Benchmark picture to picture recording.\n");
|
|
|
|
SkDebugf(
|
|
|
|
" simple, Benchmark a simple rendering.\n");
|
|
|
|
SkDebugf(
|
2012-11-07 18:01:46 +00:00
|
|
|
" tile width height, Benchmark simple rendering using\n"
|
|
|
|
" tiles with the given dimensions.\n"
|
|
|
|
" copyTile width height, Draw the picture, then copy it into tiles.\n"
|
|
|
|
" Does not support percentages.\n"
|
|
|
|
" If the picture is large enough, breaks it into\n"
|
|
|
|
" larger tiles (and draws the picture once per\n"
|
|
|
|
" larger tile) to avoid creating a large canvas.\n"
|
|
|
|
" Add --tiles x y to specify the number of tiles\n"
|
|
|
|
" per larger tile in the x and y direction.\n"
|
|
|
|
);
|
2012-06-27 19:33:29 +00:00
|
|
|
SkDebugf(
|
2012-09-07 15:21:18 +00:00
|
|
|
" playbackCreation, Benchmark creation of the SkPicturePlayback.\n");
|
2012-08-02 18:57:53 +00:00
|
|
|
SkDebugf("\n");
|
2012-07-12 19:19:55 +00:00
|
|
|
SkDebugf(
|
2012-09-20 14:42:33 +00:00
|
|
|
" --multi numThreads : Set the number of threads for multi threaded drawing. Must be greater\n"
|
|
|
|
" than 1. Only works with tiled rendering.\n"
|
2012-12-13 21:40:48 +00:00
|
|
|
" --viewport width height : Set the viewport.\n"
|
2012-12-17 19:25:54 +00:00
|
|
|
" --scale sf : Scale drawing by sf.\n"
|
2012-11-02 21:28:12 +00:00
|
|
|
" --pipe: Benchmark SkGPipe rendering. Currently incompatible with \"mode\".\n");
|
2012-08-31 16:15:22 +00:00
|
|
|
SkDebugf(
|
2012-11-06 18:58:43 +00:00
|
|
|
" --bbh bbhType [width height]: Set the bounding box hierarchy type to\n"
|
|
|
|
" be used. Accepted values are: none, rtree, grid. Default\n"
|
|
|
|
" value is none. Not compatible with --pipe. With value\n"
|
|
|
|
" 'grid', width and height must be specified. 'grid' can\n"
|
|
|
|
" only be used with modes tile, record, and\n"
|
|
|
|
" playbackCreation.");
|
2012-11-02 18:11:49 +00:00
|
|
|
SkDebugf(
|
2012-08-20 15:04:04 +00:00
|
|
|
" --device bitmap"
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
" | gpu"
|
|
|
|
#endif
|
|
|
|
": Use the corresponding device. Default is bitmap.\n");
|
|
|
|
SkDebugf(
|
|
|
|
" bitmap, Render to a bitmap.\n");
|
|
|
|
#if SK_SUPPORT_GPU
|
2012-08-20 15:04:12 +00:00
|
|
|
SkDebugf(
|
2012-08-20 15:04:04 +00:00
|
|
|
" gpu, Render to the GPU.\n");
|
|
|
|
#endif
|
|
|
|
SkDebugf("\n");
|
|
|
|
SkDebugf(
|
2012-08-02 18:57:53 +00:00
|
|
|
" --repeat: "
|
|
|
|
"Set the number of times to repeat each test."
|
|
|
|
" Default is %i.\n", DEFAULT_REPEATS);
|
2012-11-06 21:26:13 +00:00
|
|
|
SkDebugf(
|
2012-11-07 16:42:17 +00:00
|
|
|
" --filter type:flag : Enable canvas filtering to disable a paint flag,\n"
|
|
|
|
" use no blur or low quality blur, or use no hinting or\n"
|
|
|
|
" slight hinting. For all flags except AAClip, specify the\n"
|
|
|
|
" type of primitive to effect, or choose all. for AAClip\n"
|
|
|
|
" alone, the filter affects all clips independent of type.\n");
|
2012-06-27 19:33:29 +00:00
|
|
|
}
|
|
|
|
|
2012-09-07 15:21:18 +00:00
|
|
|
SkBenchLogger gLogger;
|
|
|
|
|
2012-09-17 18:26:06 +00:00
|
|
|
static bool run_single_benchmark(const SkString& inputPath,
|
2012-08-01 17:53:29 +00:00
|
|
|
sk_tools::PictureBenchmark& benchmark) {
|
2012-06-27 19:33:29 +00:00
|
|
|
SkFILEStream inputStream;
|
|
|
|
|
|
|
|
inputStream.setPath(inputPath.c_str());
|
|
|
|
if (!inputStream.isValid()) {
|
2012-09-07 15:21:18 +00:00
|
|
|
SkString err;
|
|
|
|
err.printf("Could not open file %s\n", inputPath.c_str());
|
|
|
|
gLogger.logError(err);
|
2012-09-17 18:26:06 +00:00
|
|
|
return false;
|
2012-06-27 19:33:29 +00:00
|
|
|
}
|
|
|
|
|
2012-09-17 18:26:06 +00:00
|
|
|
bool success = false;
|
Add the ability to provide function pointers to SkPicture serialization
and deserialization for encoding and decoding bitmaps.
Remove kForceFlattenBitmapPixels_Flag, which is no longer used.
When an SkOrderedReadBuffer needs to read a bitmap, if it does not
have an image decoder, use a dummy bitmap.
In GM, add a tolerance option for color differences, used when
testing picture serialization, so it can assume two images are the
same even though PNG encoding/decoding may have resulted in small
differences.
Create dummy implementations for SkImageDecoder and SkImageEncoder
functions in SkImageDecoder_empty so that a project that does not
want to include the images project it can still build.
Allow ports to build without images project.
In Mac's image encoder, copy 4444 to 8888 before encoding.
Add SkWriter32::reservePad, to provide a pointer to write non 4 byte
aligned data, padded with zeroes.
In bench_ and render_ pictures, pass decode function to SkPicture
creation from a stream.
BUG=https://code.google.com/p/skia/issues/detail?id=842
Review URL: https://codereview.appspot.com/6551071
git-svn-id: http://skia.googlecode.com/svn/trunk@5818 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-10-04 21:46:08 +00:00
|
|
|
SkPicture picture(&inputStream, &success, &SkImageDecoder::DecodeStream);
|
2012-09-17 18:26:06 +00:00
|
|
|
if (!success) {
|
|
|
|
SkString err;
|
|
|
|
err.printf("Could not read an SkPicture from %s\n", inputPath.c_str());
|
|
|
|
gLogger.logError(err);
|
|
|
|
return false;
|
|
|
|
}
|
2012-06-27 19:33:29 +00:00
|
|
|
|
2012-07-09 18:32:08 +00:00
|
|
|
SkString filename;
|
|
|
|
sk_tools::get_basename(&filename, inputPath);
|
2012-08-21 17:57:59 +00:00
|
|
|
|
|
|
|
SkString result;
|
2012-09-20 18:54:04 +00:00
|
|
|
result.printf("running bench [%i %i] %s ", picture.width(),
|
|
|
|
picture.height(), filename.c_str());
|
2012-09-07 15:21:18 +00:00
|
|
|
gLogger.logProgress(result);
|
2012-07-09 18:32:08 +00:00
|
|
|
|
2012-09-20 18:54:04 +00:00
|
|
|
benchmark.run(&picture);
|
2012-09-17 18:26:06 +00:00
|
|
|
return true;
|
2012-06-27 19:33:29 +00:00
|
|
|
}
|
|
|
|
|
2012-11-02 21:28:12 +00:00
|
|
|
#define PRINT_USAGE_AND_EXIT \
|
|
|
|
do { \
|
|
|
|
usage(argv0); \
|
|
|
|
exit(-1); \
|
|
|
|
} while (0)
|
|
|
|
|
2012-08-01 17:53:29 +00:00
|
|
|
static void parse_commandline(int argc, char* const argv[], SkTArray<SkString>* inputs,
|
2012-09-11 19:15:32 +00:00
|
|
|
sk_tools::PictureBenchmark* benchmark) {
|
2012-06-27 19:33:29 +00:00
|
|
|
const char* argv0 = argv[0];
|
|
|
|
char* const* stop = argv + argc;
|
|
|
|
|
2012-08-01 17:53:29 +00:00
|
|
|
int repeats = DEFAULT_REPEATS;
|
2012-08-20 15:04:04 +00:00
|
|
|
sk_tools::PictureRenderer::SkDeviceTypes deviceType =
|
|
|
|
sk_tools::PictureRenderer::kBitmap_DeviceType;
|
2012-08-01 17:53:29 +00:00
|
|
|
|
2012-11-02 21:28:12 +00:00
|
|
|
SkAutoTUnref<sk_tools::PictureRenderer> renderer(NULL);
|
2012-09-11 19:15:32 +00:00
|
|
|
|
2012-09-07 15:21:18 +00:00
|
|
|
// Create a string to show our current settings.
|
|
|
|
// TODO: Make it prettier. Currently it just repeats the command line.
|
|
|
|
SkString commandLine("bench_pictures:");
|
|
|
|
for (int i = 1; i < argc; i++) {
|
|
|
|
commandLine.appendf(" %s", *(argv+i));
|
|
|
|
}
|
|
|
|
commandLine.append("\n");
|
|
|
|
|
2012-08-31 16:15:22 +00:00
|
|
|
bool usePipe = false;
|
2012-09-20 14:42:33 +00:00
|
|
|
int numThreads = 1;
|
2012-08-31 16:15:22 +00:00
|
|
|
bool useTiles = false;
|
|
|
|
const char* widthString = NULL;
|
|
|
|
const char* heightString = NULL;
|
2012-11-06 18:58:43 +00:00
|
|
|
int gridWidth = 0;
|
|
|
|
int gridHeight = 0;
|
2012-08-31 16:15:22 +00:00
|
|
|
bool isPowerOf2Mode = false;
|
2012-11-07 18:01:46 +00:00
|
|
|
bool isCopyMode = false;
|
|
|
|
const char* xTilesString = NULL;
|
|
|
|
const char* yTilesString = NULL;
|
2012-08-31 16:15:22 +00:00
|
|
|
const char* mode = NULL;
|
2012-11-06 18:58:43 +00:00
|
|
|
bool gridSupported = false;
|
2012-11-06 13:18:25 +00:00
|
|
|
sk_tools::PictureRenderer::BBoxHierarchyType bbhType =
|
2012-11-02 18:11:49 +00:00
|
|
|
sk_tools::PictureRenderer::kNone_BBoxHierarchyType;
|
2012-11-06 21:26:13 +00:00
|
|
|
sk_tools::PictureRenderer::DrawFilterFlags drawFilters[SkDrawFilter::kTypeCount];
|
|
|
|
sk_bzero(drawFilters, sizeof(drawFilters));
|
2012-12-13 21:40:48 +00:00
|
|
|
SkISize viewport;
|
|
|
|
viewport.setEmpty();
|
2012-12-17 19:25:54 +00:00
|
|
|
SkScalar scaleFactor = SK_Scalar1;
|
2012-06-27 19:33:29 +00:00
|
|
|
for (++argv; argv < stop; ++argv) {
|
|
|
|
if (0 == strcmp(*argv, "--repeat")) {
|
|
|
|
++argv;
|
|
|
|
if (argv < stop) {
|
2012-08-01 17:53:29 +00:00
|
|
|
repeats = atoi(*argv);
|
|
|
|
if (repeats < 1) {
|
2012-09-07 15:21:18 +00:00
|
|
|
gLogger.logError("--repeat must be given a value > 0\n");
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-06-27 19:33:29 +00:00
|
|
|
}
|
|
|
|
} else {
|
2012-09-07 15:21:18 +00:00
|
|
|
gLogger.logError("Missing arg for --repeat\n");
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-06-27 19:33:29 +00:00
|
|
|
}
|
2012-08-31 16:15:22 +00:00
|
|
|
} else if (0 == strcmp(*argv, "--pipe")) {
|
|
|
|
usePipe = true;
|
2012-09-07 15:21:18 +00:00
|
|
|
} else if (0 == strcmp(*argv, "--logFile")) {
|
|
|
|
argv++;
|
|
|
|
if (argv < stop) {
|
|
|
|
if (!gLogger.SetLogFile(*argv)) {
|
|
|
|
SkString str;
|
|
|
|
str.printf("Could not open %s for writing.", *argv);
|
|
|
|
gLogger.logError(str);
|
|
|
|
usage(argv0);
|
2012-09-13 18:54:48 +00:00
|
|
|
// TODO(borenet): We're disabling this for now, due to
|
|
|
|
// write-protected Android devices. The very short-term
|
|
|
|
// solution is to ignore the fact that we have no log file.
|
|
|
|
//exit(-1);
|
2012-09-07 15:21:18 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
gLogger.logError("Missing arg for --logFile\n");
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-09-07 15:21:18 +00:00
|
|
|
}
|
2012-09-20 14:42:33 +00:00
|
|
|
} else if (0 == strcmp(*argv, "--multi")) {
|
|
|
|
++argv;
|
|
|
|
if (argv >= stop) {
|
|
|
|
gLogger.logError("Missing arg for --multi\n");
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-09-20 14:42:33 +00:00
|
|
|
}
|
|
|
|
numThreads = atoi(*argv);
|
|
|
|
if (numThreads < 2) {
|
|
|
|
gLogger.logError("Number of threads must be at least 2.\n");
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-09-20 14:42:33 +00:00
|
|
|
}
|
2012-11-02 18:11:49 +00:00
|
|
|
} else if (0 == strcmp(*argv, "--bbh")) {
|
|
|
|
++argv;
|
|
|
|
if (argv >= stop) {
|
|
|
|
gLogger.logError("Missing value for --bbh\n");
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-11-02 18:11:49 +00:00
|
|
|
}
|
|
|
|
if (0 == strcmp(*argv, "none")) {
|
|
|
|
bbhType = sk_tools::PictureRenderer::kNone_BBoxHierarchyType;
|
|
|
|
} else if (0 == strcmp(*argv, "rtree")) {
|
|
|
|
bbhType = sk_tools::PictureRenderer::kRTree_BBoxHierarchyType;
|
2012-11-06 18:58:43 +00:00
|
|
|
} else if (0 == strcmp(*argv, "grid")) {
|
|
|
|
bbhType = sk_tools::PictureRenderer::kTileGrid_BBoxHierarchyType;
|
|
|
|
++argv;
|
|
|
|
if (argv >= stop) {
|
|
|
|
gLogger.logError("Missing width for --bbh grid\n");
|
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
|
|
|
gridWidth = atoi(*argv);
|
|
|
|
++argv;
|
|
|
|
if (argv >= stop) {
|
|
|
|
gLogger.logError("Missing height for --bbh grid\n");
|
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
|
|
|
gridHeight = atoi(*argv);
|
2012-11-02 18:11:49 +00:00
|
|
|
} else {
|
|
|
|
SkString err;
|
|
|
|
err.printf("%s is not a valid value for --bbhType\n", *argv);
|
|
|
|
gLogger.logError(err);
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-11-02 18:11:49 +00:00
|
|
|
}
|
|
|
|
|
2012-08-02 18:57:53 +00:00
|
|
|
} else if (0 == strcmp(*argv, "--mode")) {
|
2012-11-02 21:28:12 +00:00
|
|
|
if (renderer.get() != NULL) {
|
|
|
|
SkDebugf("Cannot combine modes.\n");
|
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
2012-08-02 18:57:53 +00:00
|
|
|
|
2012-06-27 19:33:29 +00:00
|
|
|
++argv;
|
2012-08-02 18:57:53 +00:00
|
|
|
if (argv >= stop) {
|
2012-09-07 15:21:18 +00:00
|
|
|
gLogger.logError("Missing mode for --mode\n");
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-08-02 18:57:53 +00:00
|
|
|
}
|
|
|
|
|
2012-08-31 16:15:22 +00:00
|
|
|
if (0 == strcmp(*argv, "record")) {
|
2012-11-02 21:28:12 +00:00
|
|
|
renderer.reset(SkNEW(sk_tools::RecordPictureRenderer));
|
2012-11-06 18:58:43 +00:00
|
|
|
gridSupported = true;
|
2012-12-10 16:05:09 +00:00
|
|
|
} else if (0 == strcmp(*argv, "clone")) {
|
|
|
|
renderer.reset(sk_tools::CreatePictureCloneRenderer());
|
2012-08-02 18:57:53 +00:00
|
|
|
} else if (0 == strcmp(*argv, "simple")) {
|
2012-11-02 21:28:12 +00:00
|
|
|
renderer.reset(SkNEW(sk_tools::SimplePictureRenderer));
|
2012-11-07 18:01:46 +00:00
|
|
|
} else if ((0 == strcmp(*argv, "tile")) || (0 == strcmp(*argv, "pow2tile"))
|
|
|
|
|| 0 == strcmp(*argv, "copyTile")) {
|
2012-08-31 16:15:22 +00:00
|
|
|
useTiles = true;
|
|
|
|
mode = *argv;
|
2012-08-23 20:53:25 +00:00
|
|
|
|
|
|
|
if (0 == strcmp(*argv, "pow2tile")) {
|
|
|
|
isPowerOf2Mode = true;
|
2012-11-07 18:01:46 +00:00
|
|
|
} else if (0 == strcmp(*argv, "copyTile")) {
|
|
|
|
isCopyMode = true;
|
2012-11-06 18:58:43 +00:00
|
|
|
} else {
|
|
|
|
gridSupported = true;
|
2012-08-23 20:53:25 +00:00
|
|
|
}
|
|
|
|
|
2012-08-02 18:57:53 +00:00
|
|
|
++argv;
|
|
|
|
if (argv >= stop) {
|
2012-09-07 15:21:18 +00:00
|
|
|
SkString err;
|
|
|
|
err.printf("Missing width for --mode %s\n", mode);
|
|
|
|
gLogger.logError(err);
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-08-02 18:57:53 +00:00
|
|
|
}
|
|
|
|
|
2012-08-31 16:15:22 +00:00
|
|
|
widthString = *argv;
|
2012-08-02 18:57:53 +00:00
|
|
|
++argv;
|
|
|
|
if (argv >= stop) {
|
2012-11-07 18:01:46 +00:00
|
|
|
SkString err;
|
|
|
|
err.appendf("Missing height for --mode %s\n", mode);
|
|
|
|
gLogger.logError(err);
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-08-02 18:57:53 +00:00
|
|
|
}
|
2012-08-31 16:15:22 +00:00
|
|
|
heightString = *argv;
|
2012-09-07 15:21:18 +00:00
|
|
|
} else if (0 == strcmp(*argv, "playbackCreation")) {
|
2012-11-02 21:28:12 +00:00
|
|
|
renderer.reset(SkNEW(sk_tools::PlaybackCreationRenderer));
|
2012-11-06 18:58:43 +00:00
|
|
|
gridSupported = true;
|
2012-11-29 21:00:39 +00:00
|
|
|
} else if (0 == strcmp(*argv, "gatherPixelRefs")) {
|
|
|
|
renderer.reset(sk_tools::CreateGatherPixelRefsRenderer());
|
2012-06-27 19:33:29 +00:00
|
|
|
} else {
|
2012-09-07 15:21:18 +00:00
|
|
|
SkString err;
|
|
|
|
err.printf("%s is not a valid mode for --mode\n", *argv);
|
|
|
|
gLogger.logError(err);
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-06-27 19:33:29 +00:00
|
|
|
}
|
2012-12-13 21:40:48 +00:00
|
|
|
} else if (0 == strcmp(*argv, "--viewport")) {
|
|
|
|
++argv;
|
|
|
|
if (argv >= stop) {
|
|
|
|
gLogger.logError("Missing width for --viewport\n");
|
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
|
|
|
viewport.fWidth = atoi(*argv);
|
|
|
|
++argv;
|
|
|
|
if (argv >= stop) {
|
|
|
|
gLogger.logError("Missing height for --viewport\n");
|
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
|
|
|
viewport.fHeight = atoi(*argv);
|
2012-12-17 19:25:54 +00:00
|
|
|
} else if (0 == strcmp(*argv, "--scale")) {
|
|
|
|
++argv;
|
|
|
|
if (argv >= stop) {
|
|
|
|
gLogger.logError("Missing scaleFactor for --scale\n");
|
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
2013-01-07 22:26:05 +00:00
|
|
|
scaleFactor = SkDoubleToScalar(atof(*argv));
|
2012-11-07 18:01:46 +00:00
|
|
|
} else if (0 == strcmp(*argv, "--tiles")) {
|
|
|
|
++argv;
|
|
|
|
if (argv >= stop) {
|
|
|
|
gLogger.logError("Missing x for --tiles\n");
|
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
|
|
|
xTilesString = *argv;
|
|
|
|
++argv;
|
|
|
|
if (argv >= stop) {
|
|
|
|
gLogger.logError("Missing y for --tiles\n");
|
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
|
|
|
yTilesString = *argv;
|
2012-08-20 15:04:04 +00:00
|
|
|
} else if (0 == strcmp(*argv, "--device")) {
|
|
|
|
++argv;
|
|
|
|
if (argv >= stop) {
|
2012-09-13 18:54:48 +00:00
|
|
|
gLogger.logError("Missing mode for --device\n");
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-08-20 15:04:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == strcmp(*argv, "bitmap")) {
|
|
|
|
deviceType = sk_tools::PictureRenderer::kBitmap_DeviceType;
|
|
|
|
}
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
else if (0 == strcmp(*argv, "gpu")) {
|
|
|
|
deviceType = sk_tools::PictureRenderer::kGPU_DeviceType;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
else {
|
2012-09-07 15:21:18 +00:00
|
|
|
SkString err;
|
|
|
|
err.printf("%s is not a valid mode for --device\n", *argv);
|
|
|
|
gLogger.logError(err);
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-08-20 15:04:04 +00:00
|
|
|
}
|
2012-09-11 19:15:32 +00:00
|
|
|
} else if (0 == strcmp(*argv, "--timers")) {
|
|
|
|
++argv;
|
|
|
|
if (argv < stop) {
|
|
|
|
bool timerWall = false;
|
|
|
|
bool truncatedTimerWall = false;
|
|
|
|
bool timerCpu = false;
|
|
|
|
bool truncatedTimerCpu = false;
|
|
|
|
bool timerGpu = false;
|
|
|
|
for (char* t = *argv; *t; ++t) {
|
|
|
|
switch (*t) {
|
|
|
|
case 'w':
|
|
|
|
timerWall = true;
|
|
|
|
break;
|
|
|
|
case 'c':
|
|
|
|
timerCpu = true;
|
|
|
|
break;
|
|
|
|
case 'W':
|
|
|
|
truncatedTimerWall = true;
|
|
|
|
break;
|
|
|
|
case 'C':
|
|
|
|
truncatedTimerCpu = true;
|
|
|
|
break;
|
|
|
|
case 'g':
|
|
|
|
timerGpu = true;
|
|
|
|
break;
|
|
|
|
default: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
benchmark->setTimersToShow(timerWall, truncatedTimerWall, timerCpu,
|
|
|
|
truncatedTimerCpu, timerGpu);
|
|
|
|
} else {
|
|
|
|
gLogger.logError("Missing arg for --timers\n");
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-09-11 19:15:32 +00:00
|
|
|
}
|
Provide an option to bench drawing individual tiles in bench_pictures.
Provides output like the following:
running bench [1236 12045] androidpolice.skp
tile_256x256: tile [0,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [1,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [2,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [3,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [4,0] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,1] out of [5,48]: msecs = 2.00
tile_256x256: tile [1,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [2,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [3,1] out of [5,48]: msecs = 6.00
tile_256x256: tile [4,1] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,2] out of [5,48]: msecs = 2.00
BUG=https://code.google.com/p/skia/issues/detail?id=1016
Review URL: https://codereview.appspot.com/6937047
git-svn-id: http://skia.googlecode.com/svn/trunk@6805 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-12-13 22:09:28 +00:00
|
|
|
} else if (0 == strcmp(*argv, "--timeIndividualTiles")) {
|
|
|
|
benchmark->setTimeIndividualTiles(true);
|
2012-09-11 19:15:32 +00:00
|
|
|
} else if (0 == strcmp(*argv, "--min")) {
|
|
|
|
benchmark->setPrintMin(true);
|
|
|
|
} else if (0 == strcmp(*argv, "--logPerIter")) {
|
|
|
|
++argv;
|
|
|
|
if (argv < stop) {
|
|
|
|
bool log = atoi(*argv) != 0;
|
|
|
|
benchmark->setLogPerIter(log);
|
|
|
|
} else {
|
|
|
|
gLogger.logError("Missing arg for --logPerIter\n");
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-09-11 19:15:32 +00:00
|
|
|
}
|
2012-11-06 21:26:13 +00:00
|
|
|
} else if (0 == strcmp(*argv, "--filter")) {
|
|
|
|
++argv;
|
|
|
|
if (argv < stop) {
|
|
|
|
const char* colon = strchr(*argv, ':');
|
|
|
|
if (colon) {
|
|
|
|
int type = -1;
|
|
|
|
size_t typeLen = colon - *argv;
|
|
|
|
for (size_t tIndex = 0; tIndex < kFilterTypesCount; ++tIndex) {
|
|
|
|
if (typeLen == strlen(gFilterTypes[tIndex])
|
|
|
|
&& !strncmp(*argv, gFilterTypes[tIndex], typeLen)) {
|
|
|
|
type = tIndex;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (type < 0) {
|
|
|
|
SkString err;
|
|
|
|
err.printf("Unknown type for --filter %s\n", *argv);
|
|
|
|
gLogger.logError(err);
|
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
|
|
|
int flag = -1;
|
|
|
|
size_t flagLen = strlen(*argv) - typeLen - 1;
|
|
|
|
for (size_t fIndex = 0; fIndex < kFilterFlagsCount; ++fIndex) {
|
|
|
|
if (flagLen == strlen(gFilterFlags[fIndex])
|
|
|
|
&& !strncmp(colon + 1, gFilterFlags[fIndex], flagLen)) {
|
|
|
|
flag = 1 << fIndex;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (flag < 0) {
|
|
|
|
SkString err;
|
|
|
|
err.printf("Unknown flag for --filter %s\n", *argv);
|
|
|
|
gLogger.logError(err);
|
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
|
|
|
for (int index = 0; index < SkDrawFilter::kTypeCount; ++index) {
|
|
|
|
if (type != SkDrawFilter::kTypeCount && index != type) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
drawFilters[index] = (sk_tools::PictureRenderer::DrawFilterFlags)
|
|
|
|
(drawFilters[index] | flag);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SkString err;
|
|
|
|
err.printf("Unknown arg for --filter %s : missing colon\n", *argv);
|
|
|
|
gLogger.logError(err);
|
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
gLogger.logError("Missing arg for --filter\n");
|
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
2012-06-27 19:33:29 +00:00
|
|
|
} else if (0 == strcmp(*argv, "--help") || 0 == strcmp(*argv, "-h")) {
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-06-27 19:33:29 +00:00
|
|
|
} else {
|
2012-07-09 18:32:08 +00:00
|
|
|
inputs->push_back(SkString(*argv));
|
2012-06-27 19:33:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-20 14:42:33 +00:00
|
|
|
if (numThreads > 1 && !useTiles) {
|
|
|
|
gLogger.logError("Multithreaded drawing requires tiled rendering.\n");
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-09-20 14:42:33 +00:00
|
|
|
}
|
|
|
|
|
2012-11-02 18:11:49 +00:00
|
|
|
if (usePipe && sk_tools::PictureRenderer::kNone_BBoxHierarchyType != bbhType) {
|
|
|
|
gLogger.logError("--pipe and --bbh cannot be used together\n");
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-11-02 18:11:49 +00:00
|
|
|
}
|
|
|
|
|
2012-11-06 18:58:43 +00:00
|
|
|
if (sk_tools::PictureRenderer::kTileGrid_BBoxHierarchyType == bbhType &&
|
|
|
|
!gridSupported) {
|
|
|
|
gLogger.logError("'--bbh grid' is not compatible with specified --mode.\n");
|
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
|
|
|
|
2012-08-31 16:15:22 +00:00
|
|
|
if (useTiles) {
|
2012-09-11 19:15:32 +00:00
|
|
|
SkASSERT(NULL == renderer);
|
2012-11-02 21:28:12 +00:00
|
|
|
sk_tools::TiledPictureRenderer* tiledRenderer;
|
2012-11-07 18:01:46 +00:00
|
|
|
if (isCopyMode) {
|
|
|
|
int x, y;
|
|
|
|
if (xTilesString != NULL) {
|
|
|
|
SkASSERT(yTilesString != NULL);
|
|
|
|
x = atoi(xTilesString);
|
|
|
|
y = atoi(yTilesString);
|
|
|
|
if (x <= 0 || y <= 0) {
|
|
|
|
gLogger.logError("--tiles must be given values > 0\n");
|
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
x = y = 4;
|
|
|
|
}
|
|
|
|
tiledRenderer = SkNEW_ARGS(sk_tools::CopyTilesRenderer, (x, y));
|
Provide an option to bench drawing individual tiles in bench_pictures.
Provides output like the following:
running bench [1236 12045] androidpolice.skp
tile_256x256: tile [0,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [1,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [2,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [3,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [4,0] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,1] out of [5,48]: msecs = 2.00
tile_256x256: tile [1,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [2,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [3,1] out of [5,48]: msecs = 6.00
tile_256x256: tile [4,1] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,2] out of [5,48]: msecs = 2.00
BUG=https://code.google.com/p/skia/issues/detail?id=1016
Review URL: https://codereview.appspot.com/6937047
git-svn-id: http://skia.googlecode.com/svn/trunk@6805 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-12-13 22:09:28 +00:00
|
|
|
if (benchmark->timeIndividualTiles()) {
|
|
|
|
gLogger.logError("timeIndividualTiles is not compatible with copyTile\n");
|
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
2012-11-07 18:01:46 +00:00
|
|
|
} else if (numThreads > 1) {
|
2012-11-02 21:28:12 +00:00
|
|
|
tiledRenderer = SkNEW_ARGS(sk_tools::MultiCorePictureRenderer, (numThreads));
|
|
|
|
} else {
|
|
|
|
tiledRenderer = SkNEW(sk_tools::TiledPictureRenderer);
|
|
|
|
}
|
2012-08-31 16:15:22 +00:00
|
|
|
if (isPowerOf2Mode) {
|
|
|
|
int minWidth = atoi(widthString);
|
|
|
|
if (!SkIsPow2(minWidth) || minWidth < 0) {
|
2012-09-11 19:15:32 +00:00
|
|
|
tiledRenderer->unref();
|
2012-09-07 15:21:18 +00:00
|
|
|
SkString err;
|
2012-09-11 19:15:32 +00:00
|
|
|
err.printf("-mode %s must be given a width"
|
2012-08-31 16:15:22 +00:00
|
|
|
" value that is a power of two\n", mode);
|
2012-09-07 15:21:18 +00:00
|
|
|
gLogger.logError(err);
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-08-31 16:15:22 +00:00
|
|
|
}
|
2012-09-11 19:15:32 +00:00
|
|
|
tiledRenderer->setTileMinPowerOf2Width(minWidth);
|
2012-08-31 16:15:22 +00:00
|
|
|
} else if (sk_tools::is_percentage(widthString)) {
|
2012-11-07 18:01:46 +00:00
|
|
|
if (isCopyMode) {
|
|
|
|
tiledRenderer->unref();
|
|
|
|
SkString err;
|
|
|
|
err.printf("--mode %s does not support percentages.\n", mode);
|
|
|
|
gLogger.logError(err.c_str());
|
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
2012-09-11 19:15:32 +00:00
|
|
|
tiledRenderer->setTileWidthPercentage(atof(widthString));
|
|
|
|
if (!(tiledRenderer->getTileWidthPercentage() > 0)) {
|
|
|
|
tiledRenderer->unref();
|
2012-11-07 18:01:46 +00:00
|
|
|
SkString err;
|
|
|
|
err.appendf("--mode %s must be given a width percentage > 0\n", mode);
|
|
|
|
gLogger.logError(err);
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-08-31 16:15:22 +00:00
|
|
|
}
|
|
|
|
} else {
|
2012-09-11 19:15:32 +00:00
|
|
|
tiledRenderer->setTileWidth(atoi(widthString));
|
|
|
|
if (!(tiledRenderer->getTileWidth() > 0)) {
|
|
|
|
tiledRenderer->unref();
|
2012-11-07 18:01:46 +00:00
|
|
|
SkString err;
|
|
|
|
err.appendf("--mode %s must be given a width > 0\n", mode);
|
|
|
|
gLogger.logError(err);
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-08-31 16:15:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sk_tools::is_percentage(heightString)) {
|
2012-11-07 18:01:46 +00:00
|
|
|
if (isCopyMode) {
|
|
|
|
tiledRenderer->unref();
|
|
|
|
SkString err;
|
|
|
|
err.printf("--mode %s does not support percentages.\n", mode);
|
|
|
|
gLogger.logError(err.c_str());
|
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
2012-09-11 19:15:32 +00:00
|
|
|
tiledRenderer->setTileHeightPercentage(atof(heightString));
|
|
|
|
if (!(tiledRenderer->getTileHeightPercentage() > 0)) {
|
|
|
|
tiledRenderer->unref();
|
2012-11-07 18:01:46 +00:00
|
|
|
SkString err;
|
|
|
|
err.appendf("--mode %s must be given a height percentage > 0\n", mode);
|
|
|
|
gLogger.logError(err);
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-08-31 16:15:22 +00:00
|
|
|
}
|
|
|
|
} else {
|
2012-09-11 19:15:32 +00:00
|
|
|
tiledRenderer->setTileHeight(atoi(heightString));
|
|
|
|
if (!(tiledRenderer->getTileHeight() > 0)) {
|
|
|
|
tiledRenderer->unref();
|
2012-11-07 18:01:46 +00:00
|
|
|
SkString err;
|
|
|
|
err.appendf("--mode %s must be given a height > 0\n", mode);
|
|
|
|
gLogger.logError(err);
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-08-31 16:15:22 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-20 14:42:33 +00:00
|
|
|
if (numThreads > 1) {
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
if (sk_tools::PictureRenderer::kGPU_DeviceType == deviceType) {
|
|
|
|
tiledRenderer->unref();
|
|
|
|
gLogger.logError("GPU not compatible with multithreaded tiling.\n");
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-09-20 14:42:33 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2012-11-02 21:28:12 +00:00
|
|
|
renderer.reset(tiledRenderer);
|
|
|
|
if (usePipe) {
|
Provide an option to bench drawing individual tiles in bench_pictures.
Provides output like the following:
running bench [1236 12045] androidpolice.skp
tile_256x256: tile [0,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [1,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [2,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [3,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [4,0] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,1] out of [5,48]: msecs = 2.00
tile_256x256: tile [1,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [2,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [3,1] out of [5,48]: msecs = 6.00
tile_256x256: tile [4,1] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,2] out of [5,48]: msecs = 2.00
BUG=https://code.google.com/p/skia/issues/detail?id=1016
Review URL: https://codereview.appspot.com/6937047
git-svn-id: http://skia.googlecode.com/svn/trunk@6805 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-12-13 22:09:28 +00:00
|
|
|
gLogger.logError("Pipe rendering is currently not compatible with tiling.\n"
|
2012-11-02 21:28:12 +00:00
|
|
|
"Turning off pipe.\n");
|
|
|
|
}
|
Provide an option to bench drawing individual tiles in bench_pictures.
Provides output like the following:
running bench [1236 12045] androidpolice.skp
tile_256x256: tile [0,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [1,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [2,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [3,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [4,0] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,1] out of [5,48]: msecs = 2.00
tile_256x256: tile [1,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [2,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [3,1] out of [5,48]: msecs = 6.00
tile_256x256: tile [4,1] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,2] out of [5,48]: msecs = 2.00
BUG=https://code.google.com/p/skia/issues/detail?id=1016
Review URL: https://codereview.appspot.com/6937047
git-svn-id: http://skia.googlecode.com/svn/trunk@6805 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-12-13 22:09:28 +00:00
|
|
|
} else {
|
|
|
|
if (benchmark->timeIndividualTiles()) {
|
|
|
|
gLogger.logError("timeIndividualTiles requires tiled rendering.\n");
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
Provide an option to bench drawing individual tiles in bench_pictures.
Provides output like the following:
running bench [1236 12045] androidpolice.skp
tile_256x256: tile [0,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [1,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [2,0] out of [5,48]: msecs = 1.00
tile_256x256: tile [3,0] out of [5,48]: msecs = 1.50
tile_256x256: tile [4,0] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,1] out of [5,48]: msecs = 2.00
tile_256x256: tile [1,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [2,1] out of [5,48]: msecs = 3.50
tile_256x256: tile [3,1] out of [5,48]: msecs = 6.00
tile_256x256: tile [4,1] out of [5,48]: msecs = 2.50
tile_256x256: tile [0,2] out of [5,48]: msecs = 2.00
BUG=https://code.google.com/p/skia/issues/detail?id=1016
Review URL: https://codereview.appspot.com/6937047
git-svn-id: http://skia.googlecode.com/svn/trunk@6805 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-12-13 22:09:28 +00:00
|
|
|
if (usePipe) {
|
|
|
|
if (renderer.get() != NULL) {
|
|
|
|
gLogger.logError("Pipe is incompatible with other modes.\n");
|
|
|
|
PRINT_USAGE_AND_EXIT;
|
|
|
|
}
|
|
|
|
renderer.reset(SkNEW(sk_tools::PipePictureRenderer));
|
|
|
|
}
|
2012-08-31 16:15:22 +00:00
|
|
|
}
|
2012-07-09 18:32:08 +00:00
|
|
|
if (inputs->count() < 1) {
|
2012-11-02 21:28:12 +00:00
|
|
|
PRINT_USAGE_AND_EXIT;
|
2012-06-27 19:33:29 +00:00
|
|
|
}
|
2012-08-01 17:53:29 +00:00
|
|
|
|
2012-09-11 19:15:32 +00:00
|
|
|
if (NULL == renderer) {
|
2012-11-02 21:28:12 +00:00
|
|
|
renderer.reset(SkNEW(sk_tools::SimplePictureRenderer));
|
2012-08-01 17:53:29 +00:00
|
|
|
}
|
2012-11-02 18:11:49 +00:00
|
|
|
|
|
|
|
renderer->setBBoxHierarchyType(bbhType);
|
2012-11-06 21:26:13 +00:00
|
|
|
renderer->setDrawFilters(drawFilters, filtersName(drawFilters));
|
2012-11-06 18:58:43 +00:00
|
|
|
renderer->setGridSize(gridWidth, gridHeight);
|
2012-12-13 21:40:48 +00:00
|
|
|
renderer->setViewport(viewport);
|
2012-12-17 19:25:54 +00:00
|
|
|
renderer->setScaleFactor(scaleFactor);
|
2012-11-02 21:28:12 +00:00
|
|
|
benchmark->setRenderer(renderer);
|
2012-08-01 17:53:29 +00:00
|
|
|
benchmark->setRepeats(repeats);
|
2012-08-20 15:04:04 +00:00
|
|
|
benchmark->setDeviceType(deviceType);
|
2012-09-07 15:21:18 +00:00
|
|
|
benchmark->setLogger(&gLogger);
|
|
|
|
// Report current settings:
|
|
|
|
gLogger.logProgress(commandLine);
|
2012-07-09 18:32:08 +00:00
|
|
|
}
|
|
|
|
|
2012-09-17 18:26:06 +00:00
|
|
|
static int process_input(const SkString& input,
|
|
|
|
sk_tools::PictureBenchmark& benchmark) {
|
2012-07-09 18:32:08 +00:00
|
|
|
SkOSFile::Iter iter(input.c_str(), "skp");
|
|
|
|
SkString inputFilename;
|
2012-09-17 18:26:06 +00:00
|
|
|
int failures = 0;
|
2012-07-09 18:32:08 +00:00
|
|
|
if (iter.next(&inputFilename)) {
|
|
|
|
do {
|
|
|
|
SkString inputPath;
|
2012-08-01 17:53:29 +00:00
|
|
|
sk_tools::make_filepath(&inputPath, input, inputFilename);
|
2012-09-19 17:28:29 +00:00
|
|
|
if (!run_single_benchmark(inputPath, benchmark)) {
|
2012-09-17 18:26:06 +00:00
|
|
|
++failures;
|
2012-09-19 17:28:29 +00:00
|
|
|
}
|
2012-07-09 18:32:08 +00:00
|
|
|
} while(iter.next(&inputFilename));
|
2012-09-19 17:28:29 +00:00
|
|
|
} else if (SkStrEndsWith(input.c_str(), ".skp")) {
|
|
|
|
if (!run_single_benchmark(input, benchmark)) {
|
2012-09-17 18:26:06 +00:00
|
|
|
++failures;
|
2012-09-19 17:28:29 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SkString warning;
|
|
|
|
warning.printf("Warning: skipping %s\n", input.c_str());
|
|
|
|
gLogger.logError(warning);
|
2012-07-09 18:32:08 +00:00
|
|
|
}
|
2012-09-17 18:26:06 +00:00
|
|
|
return failures;
|
2012-06-27 19:33:29 +00:00
|
|
|
}
|
|
|
|
|
2012-10-02 18:33:14 +00:00
|
|
|
int tool_main(int argc, char** argv);
|
|
|
|
int tool_main(int argc, char** argv) {
|
2012-09-11 19:15:32 +00:00
|
|
|
#ifdef SK_ENABLE_INST_COUNT
|
|
|
|
gPrintInstCount = true;
|
|
|
|
#endif
|
2012-09-10 20:29:13 +00:00
|
|
|
SkAutoGraphics ag;
|
2012-09-11 19:15:32 +00:00
|
|
|
|
2012-07-09 18:32:08 +00:00
|
|
|
SkTArray<SkString> inputs;
|
2012-09-11 19:15:32 +00:00
|
|
|
sk_tools::PictureBenchmark benchmark;
|
2012-06-27 19:33:29 +00:00
|
|
|
|
2012-09-11 19:15:32 +00:00
|
|
|
parse_commandline(argc, argv, &inputs, &benchmark);
|
2012-06-27 19:33:29 +00:00
|
|
|
|
2012-09-17 18:26:06 +00:00
|
|
|
int failures = 0;
|
2012-07-09 18:32:08 +00:00
|
|
|
for (int i = 0; i < inputs.count(); ++i) {
|
2012-09-17 18:26:06 +00:00
|
|
|
failures += process_input(inputs[i], benchmark);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (failures != 0) {
|
|
|
|
SkString err;
|
|
|
|
err.printf("Failed to run %i benchmarks.\n", failures);
|
|
|
|
gLogger.logError(err);
|
|
|
|
return 1;
|
2012-06-27 19:33:29 +00:00
|
|
|
}
|
2012-10-02 20:00:03 +00:00
|
|
|
return 0;
|
2012-06-27 19:33:29 +00:00
|
|
|
}
|
2012-10-02 18:33:14 +00:00
|
|
|
|
|
|
|
#if !defined SK_BUILD_FOR_IOS
|
|
|
|
int main(int argc, char * const argv[]) {
|
|
|
|
return tool_main(argc, (char**) argv);
|
|
|
|
}
|
|
|
|
#endif
|