2012-06-12 18:56:36 +04: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.
|
|
|
|
*/
|
|
|
|
|
2012-11-07 22:01:46 +04:00
|
|
|
#include "CopyTilesRenderer.h"
|
2012-06-12 18:56:36 +04:00
|
|
|
#include "SkBitmap.h"
|
2013-02-23 01:38:35 +04:00
|
|
|
#include "SkBitmapFactory.h"
|
2012-06-12 18:56:36 +04:00
|
|
|
#include "SkCanvas.h"
|
2012-07-21 02:34:27 +04:00
|
|
|
#include "SkDevice.h"
|
2013-03-04 20:41:06 +04:00
|
|
|
#include "SkFlags.h"
|
2012-09-10 21:19:06 +04: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-05 01:46:08 +04:00
|
|
|
#include "SkImageDecoder.h"
|
2012-12-19 02:24:03 +04:00
|
|
|
#include "SkImageEncoder.h"
|
2012-08-24 00:53:25 +04:00
|
|
|
#include "SkMath.h"
|
2012-06-12 18:56:36 +04:00
|
|
|
#include "SkOSFile.h"
|
|
|
|
#include "SkPicture.h"
|
|
|
|
#include "SkStream.h"
|
|
|
|
#include "SkString.h"
|
2012-07-13 22:55:53 +04:00
|
|
|
#include "SkTArray.h"
|
2012-07-26 21:27:57 +04:00
|
|
|
#include "PictureRenderer.h"
|
2013-03-04 20:41:06 +04:00
|
|
|
#include "PictureRenderingFlags.h"
|
2012-06-22 22:24:56 +04:00
|
|
|
#include "picture_utils.h"
|
2012-06-12 18:56:36 +04:00
|
|
|
|
2013-03-04 20:41:06 +04:00
|
|
|
// Flags used by this file, alphabetically:
|
|
|
|
DEFINE_int32(clone, 0, "Clone the picture n times before rendering.");
|
|
|
|
DECLARE_bool(deferImageDecoding);
|
|
|
|
DEFINE_int32(maxComponentDiff, 256, "Maximum diff on a component, 0 - 256. Components that differ "
|
|
|
|
"by more than this amount are considered errors, though all diffs are reported. "
|
|
|
|
"Requires --validate.");
|
|
|
|
DECLARE_string(r);
|
|
|
|
DEFINE_string(w, "", "Directory to write the rendered images.");
|
|
|
|
DEFINE_bool(writeWholeImage, false, "In tile mode, write the entire rendered image to a "
|
|
|
|
"file, instead of an image for each tile.");
|
|
|
|
DEFINE_bool(validate, false, "Verify that the rendered image contains the same pixels as "
|
2013-03-13 21:27:16 +04:00
|
|
|
"the picture rendered in simple mode. When used in conjunction with --bbh, results "
|
|
|
|
"are validated against the picture rendered in the same mode, but without the bbh.");
|
2012-06-12 18:56:36 +04:00
|
|
|
|
2012-07-13 22:22:59 +04:00
|
|
|
static void make_output_filepath(SkString* path, const SkString& dir,
|
2012-06-12 18:56:36 +04:00
|
|
|
const SkString& name) {
|
2012-06-22 22:24:56 +04:00
|
|
|
sk_tools::make_filepath(path, dir, name);
|
2012-09-20 18:54:21 +04:00
|
|
|
// Remove ".skp"
|
|
|
|
path->remove(path->size() - 4, 4);
|
2012-06-12 18:56:36 +04:00
|
|
|
}
|
|
|
|
|
2013-02-23 01:38:35 +04:00
|
|
|
#include "SkData.h"
|
|
|
|
#include "SkLruImageCache.h"
|
|
|
|
|
|
|
|
static SkLruImageCache gLruImageCache(1024*1024);
|
|
|
|
|
|
|
|
#ifdef SK_BUILD_FOR_ANDROID
|
|
|
|
#include "SkAshmemImageCache.h"
|
|
|
|
#include "SkImage.h"
|
|
|
|
|
|
|
|
static SkImageCache* cache_selector(const SkImage::Info& info) {
|
|
|
|
if (info.fWidth * info.fHeight > 32 * 1024) {
|
|
|
|
return SkAshmemImageCache::GetAshmemImageCache();
|
|
|
|
}
|
|
|
|
return &gLruImageCache;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap* bitmap) {
|
|
|
|
void* copiedBuffer = sk_malloc_throw(size);
|
|
|
|
memcpy(copiedBuffer, buffer, size);
|
|
|
|
SkAutoDataUnref data(SkData::NewFromMalloc(copiedBuffer, size));
|
|
|
|
SkBitmapFactory factory(&SkImageDecoder::DecodeMemoryToTarget);
|
|
|
|
#ifdef SK_BUILD_FOR_ANDROID
|
|
|
|
factory.setCacheSelector(&cache_selector);
|
|
|
|
#else
|
|
|
|
factory.setImageCache(&gLruImageCache);
|
|
|
|
#endif
|
|
|
|
return factory.installPixelRef(data, bitmap);
|
|
|
|
}
|
|
|
|
|
2012-10-26 17:26:55 +04:00
|
|
|
static bool render_picture(const SkString& inputPath, const SkString* outputDir,
|
2012-12-19 02:24:03 +04:00
|
|
|
sk_tools::PictureRenderer& renderer,
|
2013-03-04 20:41:06 +04:00
|
|
|
SkBitmap** out) {
|
2012-07-09 22:32:08 +04:00
|
|
|
SkString inputFilename;
|
|
|
|
sk_tools::get_basename(&inputFilename, inputPath);
|
2012-06-22 22:24:56 +04:00
|
|
|
|
2012-07-09 22:32:08 +04:00
|
|
|
SkFILEStream inputStream;
|
2012-06-22 22:24:56 +04:00
|
|
|
inputStream.setPath(inputPath.c_str());
|
|
|
|
if (!inputStream.isValid()) {
|
|
|
|
SkDebugf("Could not open file %s\n", inputPath.c_str());
|
2012-09-17 22:26:06 +04:00
|
|
|
return false;
|
2012-06-22 22:24:56 +04:00
|
|
|
}
|
|
|
|
|
2012-09-17 22:26:06 +04:00
|
|
|
bool success = false;
|
2013-02-23 01:38:35 +04:00
|
|
|
SkPicture* picture;
|
2013-03-04 20:41:06 +04:00
|
|
|
if (FLAGS_deferImageDecoding) {
|
2013-02-23 01:38:35 +04:00
|
|
|
picture = SkNEW_ARGS(SkPicture, (&inputStream, &success, &lazy_decode_bitmap));
|
|
|
|
} else {
|
|
|
|
picture = SkNEW_ARGS(SkPicture, (&inputStream, &success, &SkImageDecoder::DecodeMemory));
|
|
|
|
}
|
2012-09-17 22:26:06 +04:00
|
|
|
if (!success) {
|
|
|
|
SkDebugf("Could not read an SkPicture from %s\n", inputPath.c_str());
|
|
|
|
return false;
|
|
|
|
}
|
2012-07-26 21:27:57 +04:00
|
|
|
|
2013-03-04 20:41:06 +04:00
|
|
|
for (int i = 0; i < FLAGS_clone; ++i) {
|
2012-12-19 02:24:03 +04:00
|
|
|
SkPicture* clone = picture->clone();
|
|
|
|
SkDELETE(picture);
|
|
|
|
picture = clone;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkDebugf("drawing... [%i %i] %s\n", picture->width(), picture->height(),
|
2012-09-10 22:18:38 +04:00
|
|
|
inputPath.c_str());
|
2012-09-14 06:01:10 +04:00
|
|
|
|
2012-12-19 02:24:03 +04:00
|
|
|
renderer.init(picture);
|
2012-10-02 00:06:09 +04:00
|
|
|
renderer.setup();
|
2012-08-07 21:11:33 +04:00
|
|
|
|
2012-10-26 17:26:55 +04:00
|
|
|
SkString* outputPath = NULL;
|
2013-03-04 20:41:06 +04:00
|
|
|
if (NULL != outputDir && outputDir->size() > 0) {
|
2012-10-26 17:26:55 +04:00
|
|
|
outputPath = SkNEW(SkString);
|
|
|
|
make_output_filepath(outputPath, *outputDir, inputFilename);
|
|
|
|
}
|
2012-12-19 02:24:03 +04:00
|
|
|
|
|
|
|
success = renderer.render(outputPath, out);
|
2012-10-26 17:26:55 +04:00
|
|
|
if (outputPath) {
|
|
|
|
if (!success) {
|
|
|
|
SkDebugf("Could not write to file %s\n", outputPath->c_str());
|
|
|
|
}
|
|
|
|
SkDELETE(outputPath);
|
2012-09-20 18:54:21 +04:00
|
|
|
}
|
2012-08-07 21:11:33 +04:00
|
|
|
|
|
|
|
renderer.end();
|
2012-12-19 02:24:03 +04:00
|
|
|
|
|
|
|
SkDELETE(picture);
|
2012-09-17 22:26:06 +04:00
|
|
|
return success;
|
2012-06-12 18:56:36 +04:00
|
|
|
}
|
|
|
|
|
2013-01-16 22:18:48 +04:00
|
|
|
static inline int getByte(uint32_t value, int index) {
|
|
|
|
SkASSERT(0 <= index && index < 4);
|
|
|
|
return (value >> (index * 8)) & 0xFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int MaxByteDiff(uint32_t v1, uint32_t v2) {
|
|
|
|
return SkMax32(SkMax32(abs(getByte(v1, 0) - getByte(v2, 0)), abs(getByte(v1, 1) - getByte(v2, 1))),
|
|
|
|
SkMax32(abs(getByte(v1, 2) - getByte(v2, 2)), abs(getByte(v1, 3) - getByte(v2, 3))));
|
|
|
|
}
|
|
|
|
|
2013-03-13 21:27:16 +04:00
|
|
|
namespace {
|
|
|
|
class AutoRestoreBbhType {
|
|
|
|
public:
|
|
|
|
AutoRestoreBbhType() {
|
|
|
|
fRenderer = NULL;
|
2013-03-13 23:03:26 +04:00
|
|
|
fSavedBbhType = sk_tools::PictureRenderer::kNone_BBoxHierarchyType;
|
2013-03-13 21:27:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void set(sk_tools::PictureRenderer* renderer,
|
|
|
|
sk_tools::PictureRenderer::BBoxHierarchyType bbhType) {
|
|
|
|
fRenderer = renderer;
|
|
|
|
fSavedBbhType = renderer->getBBoxHierarchyType();
|
|
|
|
renderer->setBBoxHierarchyType(bbhType);
|
|
|
|
}
|
|
|
|
|
|
|
|
~AutoRestoreBbhType() {
|
|
|
|
if (NULL != fRenderer) {
|
|
|
|
fRenderer->setBBoxHierarchyType(fSavedBbhType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
sk_tools::PictureRenderer* fRenderer;
|
|
|
|
sk_tools::PictureRenderer::BBoxHierarchyType fSavedBbhType;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2012-12-19 02:24:03 +04:00
|
|
|
static bool render_picture(const SkString& inputPath, const SkString* outputDir,
|
2013-03-04 20:41:06 +04:00
|
|
|
sk_tools::PictureRenderer& renderer) {
|
2013-01-16 22:18:48 +04:00
|
|
|
int diffs[256] = {0};
|
2012-12-19 02:24:03 +04:00
|
|
|
SkBitmap* bitmap = NULL;
|
|
|
|
bool success = render_picture(inputPath,
|
2013-03-04 20:41:06 +04:00
|
|
|
FLAGS_writeWholeImage ? NULL : outputDir,
|
2012-12-19 02:24:03 +04:00
|
|
|
renderer,
|
2013-03-04 20:41:06 +04:00
|
|
|
FLAGS_validate || FLAGS_writeWholeImage ? &bitmap : NULL);
|
2012-12-19 02:24:03 +04:00
|
|
|
|
2013-03-04 20:41:06 +04:00
|
|
|
if (!success || ((FLAGS_validate || FLAGS_writeWholeImage) && bitmap == NULL)) {
|
2012-12-19 02:24:03 +04:00
|
|
|
SkDebugf("Failed to draw the picture.\n");
|
|
|
|
SkDELETE(bitmap);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-04 20:41:06 +04:00
|
|
|
if (FLAGS_validate) {
|
2012-12-19 02:24:03 +04:00
|
|
|
SkBitmap* referenceBitmap = NULL;
|
2013-03-13 21:27:16 +04:00
|
|
|
sk_tools::PictureRenderer* referenceRenderer;
|
|
|
|
// If the renderer uses a BBoxHierarchy, then the reference renderer
|
2013-03-14 11:02:51 +04:00
|
|
|
// will be the same renderer, without the bbh.
|
2013-03-13 21:27:16 +04:00
|
|
|
AutoRestoreBbhType arbbh;
|
|
|
|
if (sk_tools::PictureRenderer::kNone_BBoxHierarchyType !=
|
|
|
|
renderer.getBBoxHierarchyType()) {
|
|
|
|
referenceRenderer = &renderer;
|
|
|
|
referenceRenderer->ref(); // to match auto unref below
|
|
|
|
arbbh.set(referenceRenderer, sk_tools::PictureRenderer::kNone_BBoxHierarchyType);
|
|
|
|
} else {
|
|
|
|
referenceRenderer = SkNEW(sk_tools::SimplePictureRenderer);
|
|
|
|
}
|
|
|
|
SkAutoTUnref<sk_tools::PictureRenderer> aurReferenceRenderer(referenceRenderer);
|
|
|
|
|
|
|
|
success = render_picture(inputPath, NULL, *referenceRenderer,
|
2013-03-04 20:41:06 +04:00
|
|
|
&referenceBitmap);
|
2012-12-19 02:24:03 +04:00
|
|
|
|
2013-03-12 23:56:49 +04:00
|
|
|
if (!success || NULL == referenceBitmap || NULL == referenceBitmap->getPixels()) {
|
2012-12-19 02:24:03 +04:00
|
|
|
SkDebugf("Failed to draw the reference picture.\n");
|
|
|
|
SkDELETE(bitmap);
|
|
|
|
SkDELETE(referenceBitmap);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (success && (bitmap->width() != referenceBitmap->width())) {
|
|
|
|
SkDebugf("Expected image width: %i, actual image width %i.\n",
|
|
|
|
referenceBitmap->width(), bitmap->width());
|
|
|
|
SkDELETE(bitmap);
|
|
|
|
SkDELETE(referenceBitmap);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (success && (bitmap->height() != referenceBitmap->height())) {
|
|
|
|
SkDebugf("Expected image height: %i, actual image height %i",
|
|
|
|
referenceBitmap->height(), bitmap->height());
|
|
|
|
SkDELETE(bitmap);
|
|
|
|
SkDELETE(referenceBitmap);
|
|
|
|
return false;
|
|
|
|
}
|
2012-12-19 06:01:38 +04:00
|
|
|
|
2012-12-19 02:24:03 +04:00
|
|
|
for (int y = 0; success && y < bitmap->height(); y++) {
|
|
|
|
for (int x = 0; success && x < bitmap->width(); x++) {
|
2013-01-16 22:18:48 +04:00
|
|
|
int diff = MaxByteDiff(*referenceBitmap->getAddr32(x, y),
|
|
|
|
*bitmap->getAddr32(x, y));
|
|
|
|
SkASSERT(diff >= 0 && diff <= 255);
|
|
|
|
diffs[diff]++;
|
2013-01-17 11:06:06 +04:00
|
|
|
|
2013-03-04 20:41:06 +04:00
|
|
|
if (diff > FLAGS_maxComponentDiff) {
|
2013-01-16 22:18:48 +04:00
|
|
|
SkDebugf("Expected pixel at (%i %i) exceedds maximum "
|
|
|
|
"component diff of %i: 0x%x, actual 0x%x\n",
|
2013-03-04 20:41:06 +04:00
|
|
|
x, y, FLAGS_maxComponentDiff,
|
2013-01-11 20:08:07 +04:00
|
|
|
*referenceBitmap->getAddr32(x, y),
|
2012-12-19 02:24:03 +04:00
|
|
|
*bitmap->getAddr32(x, y));
|
|
|
|
SkDELETE(bitmap);
|
|
|
|
SkDELETE(referenceBitmap);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SkDELETE(referenceBitmap);
|
2013-01-16 22:18:48 +04:00
|
|
|
|
|
|
|
for (int i = 1; i <= 255; ++i) {
|
|
|
|
if(diffs[i] > 0) {
|
|
|
|
SkDebugf("Number of pixels with max diff of %i is %i\n", i, diffs[i]);
|
|
|
|
}
|
|
|
|
}
|
2012-12-19 02:24:03 +04:00
|
|
|
}
|
|
|
|
|
2013-03-04 20:41:06 +04:00
|
|
|
if (FLAGS_writeWholeImage) {
|
2012-12-19 02:24:03 +04:00
|
|
|
sk_tools::force_all_opaque(*bitmap);
|
2013-03-04 20:41:06 +04:00
|
|
|
if (NULL != outputDir && FLAGS_writeWholeImage) {
|
2012-12-19 02:24:03 +04:00
|
|
|
SkString inputFilename;
|
|
|
|
sk_tools::get_basename(&inputFilename, inputPath);
|
|
|
|
SkString outputPath;
|
|
|
|
make_output_filepath(&outputPath, *outputDir, inputFilename);
|
|
|
|
outputPath.append(".png");
|
|
|
|
if (!SkImageEncoder::EncodeFile(outputPath.c_str(), *bitmap,
|
|
|
|
SkImageEncoder::kPNG_Type, 100)) {
|
|
|
|
SkDebugf("Failed to draw the picture.\n");
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SkDELETE(bitmap);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-04 20:41:06 +04:00
|
|
|
static int process_input(const char* input, const SkString* outputDir,
|
|
|
|
sk_tools::PictureRenderer& renderer) {
|
|
|
|
SkOSFile::Iter iter(input, "skp");
|
2012-07-09 22:32:08 +04:00
|
|
|
SkString inputFilename;
|
2012-09-17 22:26:06 +04:00
|
|
|
int failures = 0;
|
2013-03-04 20:41:06 +04:00
|
|
|
SkDebugf("process_input, %s\n", input);
|
2012-07-09 22:32:08 +04:00
|
|
|
if (iter.next(&inputFilename)) {
|
|
|
|
do {
|
|
|
|
SkString inputPath;
|
2013-03-04 20:41:06 +04:00
|
|
|
SkString inputAsSkString(input);
|
|
|
|
sk_tools::make_filepath(&inputPath, inputAsSkString, inputFilename);
|
|
|
|
if (!render_picture(inputPath, outputDir, renderer)) {
|
2012-09-19 21:28:29 +04:00
|
|
|
++failures;
|
|
|
|
}
|
2012-07-09 22:32:08 +04:00
|
|
|
} while(iter.next(&inputFilename));
|
2013-03-04 20:41:06 +04:00
|
|
|
} else if (SkStrEndsWith(input, ".skp")) {
|
2012-07-09 22:32:08 +04:00
|
|
|
SkString inputPath(input);
|
2013-03-04 20:41:06 +04:00
|
|
|
if (!render_picture(inputPath, outputDir, renderer)) {
|
2012-09-19 21:28:29 +04:00
|
|
|
++failures;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SkString warning;
|
2013-03-04 20:41:06 +04:00
|
|
|
warning.printf("Warning: skipping %s\n", input);
|
2012-09-19 21:28:29 +04:00
|
|
|
SkDebugf(warning.c_str());
|
2012-07-09 22:32:08 +04:00
|
|
|
}
|
2012-09-17 22:26:06 +04:00
|
|
|
return failures;
|
2012-07-09 22:32:08 +04:00
|
|
|
}
|
|
|
|
|
2013-03-04 20:41:06 +04:00
|
|
|
int tool_main(int argc, char** argv);
|
|
|
|
int tool_main(int argc, char** argv) {
|
|
|
|
SkFlags::SetUsage("Render .skp files.");
|
|
|
|
SkFlags::ParseCommandLine(argc, argv);
|
2012-07-21 02:34:27 +04:00
|
|
|
|
2013-03-04 20:41:06 +04:00
|
|
|
if (FLAGS_r.isEmpty()) {
|
|
|
|
SkDebugf(".skp files or directories are required.\n");
|
2012-10-03 21:32:33 +04:00
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
2013-03-04 20:41:06 +04:00
|
|
|
if (FLAGS_maxComponentDiff < 0 || FLAGS_maxComponentDiff > 256) {
|
|
|
|
SkDebugf("--maxComponentDiff must be between 0 and 256\n");
|
2012-12-19 02:24:03 +04:00
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
2013-03-04 20:41:06 +04:00
|
|
|
if (FLAGS_maxComponentDiff != 256 && !FLAGS_validate) {
|
|
|
|
SkDebugf("--maxComponentDiff requires --validate\n");
|
2012-12-19 02:24:03 +04:00
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
2013-03-04 20:41:06 +04:00
|
|
|
if (FLAGS_clone < 0) {
|
|
|
|
SkDebugf("--clone must be >= 0. Was %i\n", FLAGS_clone);
|
2012-07-21 02:34:27 +04:00
|
|
|
exit(-1);
|
|
|
|
}
|
2012-07-26 21:27:57 +04:00
|
|
|
|
2013-03-04 20:41:06 +04:00
|
|
|
SkString errorString;
|
|
|
|
SkAutoTUnref<sk_tools::PictureRenderer> renderer(parseRenderer(errorString,
|
|
|
|
kRender_PictureTool));
|
|
|
|
if (errorString.size() > 0) {
|
|
|
|
SkDebugf("%s\n", errorString.c_str());
|
2012-07-26 21:27:57 +04:00
|
|
|
}
|
2012-08-20 19:03:29 +04:00
|
|
|
|
2013-03-04 20:41:06 +04:00
|
|
|
if (renderer.get() == NULL) {
|
2013-02-08 23:38:21 +04:00
|
|
|
exit(-1);
|
|
|
|
}
|
2012-06-12 18:56:36 +04:00
|
|
|
|
2012-09-17 22:26:06 +04:00
|
|
|
SkAutoGraphics ag;
|
2013-03-04 20:41:06 +04:00
|
|
|
|
|
|
|
SkString outputDir;
|
|
|
|
if (FLAGS_w.count() == 1) {
|
|
|
|
outputDir.set(FLAGS_w[0]);
|
|
|
|
}
|
2012-06-12 18:56:36 +04:00
|
|
|
|
2012-09-17 22:26:06 +04:00
|
|
|
int failures = 0;
|
2013-03-04 20:41:06 +04:00
|
|
|
for (int i = 0; i < FLAGS_r.count(); i ++) {
|
|
|
|
failures += process_input(FLAGS_r[i], &outputDir, *renderer.get());
|
2012-09-17 22:26:06 +04:00
|
|
|
}
|
|
|
|
if (failures != 0) {
|
|
|
|
SkDebugf("Failed to render %i pictures.\n", failures);
|
|
|
|
return 1;
|
2012-06-12 18:56:36 +04:00
|
|
|
}
|
2012-09-13 19:40:37 +04:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
#if GR_CACHE_STATS
|
|
|
|
if (renderer->isUsingGpuDevice()) {
|
|
|
|
GrContext* ctx = renderer->getGrContext();
|
|
|
|
|
|
|
|
ctx->printCacheStats();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
2012-10-03 00:00:03 +04:00
|
|
|
return 0;
|
2012-06-12 18:56:36 +04:00
|
|
|
}
|
2012-10-02 22:33:14 +04:00
|
|
|
|
|
|
|
#if !defined SK_BUILD_FOR_IOS
|
|
|
|
int main(int argc, char * const argv[]) {
|
|
|
|
return tool_main(argc, (char**) argv);
|
|
|
|
}
|
|
|
|
#endif
|