aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar twiz@google.com <twiz@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-22 18:24:56 +0000
committerGravatar twiz@google.com <twiz@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-22 18:24:56 +0000
commita31b8bb58d064d77d73aa6de851947eff5cc6964 (patch)
treef8ff8cc6a8fb0e12d1ec404c340fae2452063b65
parent1b1e201ea395e9b97778e9a709b7e5a251e35a56 (diff)
Refactoring in preparation for adding the picture benchmarking program.
Review URL: https://codereview.appspot.com/6339043/ git-svn-id: http://skia.googlecode.com/svn/trunk@4310 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--gyp/bench.gyp52
-rw-r--r--gyp/bench.gypi38
-rw-r--r--gyp/tools.gyp12
-rw-r--r--tools/render_pictures_main.cpp43
4 files changed, 75 insertions, 70 deletions
diff --git a/gyp/bench.gyp b/gyp/bench.gyp
index 1935f9d757..dcf9b5f8c2 100644
--- a/gyp/bench.gyp
+++ b/gyp/bench.gyp
@@ -23,8 +23,60 @@
'images.gyp:images',
'ports.gyp:ports',
'utils.gyp:utils',
+ 'bench_timer',
],
},
+ {
+ 'target_name' : 'bench_timer',
+ 'type': 'static_library',
+ 'sources': [
+ '../bench/BenchTimer.h',
+ '../bench/BenchTimer.cpp',
+ '../bench/BenchSysTimer_mach.h',
+ '../bench/BenchSysTimer_mach.cpp',
+ '../bench/BenchSysTimer_posix.h',
+ '../bench/BenchSysTimer_posix.cpp',
+ '../bench/BenchSysTimer_windows.h',
+ '../bench/BenchSysTimer_windows.cpp',
+ '../bench/BenchGpuTimer_gl.h',
+ '../bench/BenchGpuTimer_gl.cpp',
+ ],
+ 'include_dirs': [
+ '../src/core',
+ '../src/gpu',
+ ],
+ 'dependencies': [
+ 'core.gyp:core',
+ 'gpu.gyp:gr',
+ ],
+ 'conditions': [
+ [ 'skia_os != "mac"', {
+ 'sources!': [
+ '../bench/BenchSysTimer_mach.h',
+ '../bench/BenchSysTimer_mach.cpp',
+ ],
+ }],
+ [ 'skia_os not in ["linux", "freebsd", "openbsd", "solaris", "android"]', {
+ 'sources!': [
+ '../bench/BenchSysTimer_posix.h',
+ '../bench/BenchSysTimer_posix.cpp',
+ ],
+ }],
+ [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
+ 'link_settings': {
+ 'libraries': [
+ '-lrt',
+ ],
+ },
+ }],
+ [ 'skia_os != "win"', {
+ 'sources!': [
+ '../bench/BenchSysTimer_windows.h',
+ '../bench/BenchSysTimer_windows.cpp',
+ ],
+ }],
+ ],
+ }
],
}
diff --git a/gyp/bench.gypi b/gyp/bench.gypi
index 9dd1e115dd..b11211ffe7 100644
--- a/gyp/bench.gypi
+++ b/gyp/bench.gypi
@@ -3,17 +3,6 @@
{
'sources': [
'../bench/benchmain.cpp',
- '../bench/BenchTimer.h',
- '../bench/BenchTimer.cpp',
- '../bench/BenchSysTimer_mach.h',
- '../bench/BenchSysTimer_mach.cpp',
- '../bench/BenchSysTimer_posix.h',
- '../bench/BenchSysTimer_posix.cpp',
- '../bench/BenchSysTimer_windows.h',
- '../bench/BenchSysTimer_windows.cpp',
- '../bench/BenchGpuTimer_gl.h',
- '../bench/BenchGpuTimer_gl.cpp',
-
'../bench/SkBenchmark.h',
'../bench/SkBenchmark.cpp',
@@ -45,33 +34,6 @@
'../bench/TextBench.cpp',
'../bench/VertBench.cpp',
],
- 'conditions': [
- [ 'skia_os != "mac"', {
- 'sources!': [
- '../bench/BenchSysTimer_mach.h',
- '../bench/BenchSysTimer_mach.cpp',
- ],
- }],
- [ 'skia_os not in ["linux", "freebsd", "openbsd", "solaris", "android"]', {
- 'sources!': [
- '../bench/BenchSysTimer_posix.h',
- '../bench/BenchSysTimer_posix.cpp',
- ],
- }],
- [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
- 'link_settings': {
- 'libraries': [
- '-lrt',
- ],
- },
- }],
- [ 'skia_os != "win"', {
- 'sources!': [
- '../bench/BenchSysTimer_windows.h',
- '../bench/BenchSysTimer_windows.cpp',
- ],
- }],
- ],
}
# Local Variables:
diff --git a/gyp/tools.gyp b/gyp/tools.gyp
index a43b811b3e..93eab7d793 100644
--- a/gyp/tools.gyp
+++ b/gyp/tools.gyp
@@ -74,6 +74,17 @@
'core.gyp:core',
'images.gyp:images',
'ports.gyp:ports',
+ 'tools.gyp:picture_utils',
+ ],
+ },
+ {
+ 'target_name': 'picture_utils',
+ 'type': 'static_library',
+ 'sources': [
+ '../tools/picture_utils.cpp',
+ ],
+ 'dependencies': [
+ 'core.gyp:core',
],
},
{
@@ -90,7 +101,6 @@
'utils.gyp:utils',
],
},
-
],
}
diff --git a/tools/render_pictures_main.cpp b/tools/render_pictures_main.cpp
index 0e7232e2dc..930089bdff 100644
--- a/tools/render_pictures_main.cpp
+++ b/tools/render_pictures_main.cpp
@@ -14,6 +14,7 @@
#include "SkPicture.h"
#include "SkStream.h"
#include "SkString.h"
+#include "picture_utils.h"
static void usage(const char* argv0) {
@@ -28,43 +29,15 @@ static void usage(const char* argv0) {
" outputDir: directory to write the rendered images.\n");
}
-static void make_filepath(SkString* path, const char* dir,
- const SkString& name) {
- size_t len = strlen(dir);
- path->set(dir);
- if (0 < len && '/' != dir[len - 1]) {
- path->append("/");
- }
- path->append(name);
-}
-
-static void open_picture_stream(const char* inputDir,
- const SkString& inputFilename,
- SkFILEStream* inputStream) {
- SkString inputPath;
- make_filepath(&inputPath, inputDir, inputFilename);
- inputStream->setPath(inputPath.c_str());
- if (!inputStream->isValid()) {
- SkDebugf("Could not open file %s\n", inputPath.c_str());
- }
-}
-
static void make_output_filepath(SkString* path, const char* dir,
const SkString& name) {
- make_filepath(path, dir, name);
+ sk_tools::make_filepath(path, dir, name);
path->remove(path->size() - 3, 3);
path->append("png");
}
-static void setup_bitmap(SkPicture& picture, SkBitmap* bitmap) {
- bitmap->setConfig(SkBitmap::kARGB_8888_Config, picture.width(),
- picture.height());
- bitmap->allocPixels();
- bitmap->eraseColor(0);
-}
-
static void generate_image_from_picture(SkPicture& pict, SkBitmap* bitmap) {
- setup_bitmap(pict, bitmap);
+ sk_tools::setup_bitmap(bitmap, pict.width(), pict.height());
SkCanvas canvas(*bitmap);
canvas.drawPicture(pict);
}
@@ -103,7 +76,15 @@ static void write_output(const char* outputDir, const SkString& inputFilename,
static void render_picture(const char* inputDir, const char* outputDir,
const SkString& inputFilename) {
SkFILEStream inputStream;
- open_picture_stream(inputDir, inputFilename, &inputStream);
+
+ SkString inputPath;
+ sk_tools::make_filepath(&inputPath, inputDir, inputFilename);
+ inputStream.setPath(inputPath.c_str());
+ if (!inputStream.isValid()) {
+ SkDebugf("Could not open file %s\n", inputPath.c_str());
+ return;
+ }
+
SkPicture picture(&inputStream);
SkBitmap bitmap;
generate_image_from_picture(picture, &bitmap);