2011-07-28 14:26:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2011-08-19 17:22:05 +00:00
|
|
|
|
2012-11-13 03:41:55 +00:00
|
|
|
/*
|
|
|
|
* Code for the "gm" (Golden Master) rendering comparison tool.
|
|
|
|
*
|
|
|
|
* If you make changes to this, re-run the self-tests at gm/tests/run.sh
|
|
|
|
* to make sure they still pass... you may need to change the expected
|
|
|
|
* results of the self-test.
|
|
|
|
*/
|
|
|
|
|
2011-10-10 13:19:10 +00:00
|
|
|
#include "gm.h"
|
2012-02-14 14:53:59 +00:00
|
|
|
#include "system_preferences.h"
|
2012-12-18 19:13:49 +00:00
|
|
|
#include "SkBitmapChecksummer.h"
|
2009-07-08 02:54:47 +00:00
|
|
|
#include "SkColorPriv.h"
|
2011-06-24 19:12:12 +00:00
|
|
|
#include "SkData.h"
|
2012-01-18 16:21:08 +00:00
|
|
|
#include "SkDeferredCanvas.h"
|
2011-08-19 17:22:05 +00:00
|
|
|
#include "SkDevice.h"
|
2012-10-26 18:56:36 +00:00
|
|
|
#include "SkDrawFilter.h"
|
2012-06-04 17:17:36 +00:00
|
|
|
#include "SkGPipe.h"
|
2009-06-21 00:49:18 +00:00
|
|
|
#include "SkGraphics.h"
|
|
|
|
#include "SkImageDecoder.h"
|
|
|
|
#include "SkImageEncoder.h"
|
2012-10-29 16:42:11 +00:00
|
|
|
#include "SkOSFile.h"
|
2011-04-25 15:49:53 +00:00
|
|
|
#include "SkPicture.h"
|
2012-06-05 19:35:09 +00:00
|
|
|
#include "SkRefCnt.h"
|
2012-06-06 21:07:10 +00:00
|
|
|
#include "SkStream.h"
|
2012-08-03 14:54:45 +00:00
|
|
|
#include "SkTArray.h"
|
2012-12-13 16:39:53 +00:00
|
|
|
#include "SkTileGridPicture.h"
|
2012-06-06 21:07:10 +00:00
|
|
|
#include "SamplePipeControllers.h"
|
2010-12-20 19:46:07 +00:00
|
|
|
|
2013-01-08 20:31:53 +00:00
|
|
|
#ifdef SK_BUILD_FOR_WIN
|
|
|
|
// json includes xlocale which generates warning 4530 because we're compiling without
|
2013-01-18 21:45:42 +00:00
|
|
|
// exceptions
|
2013-01-08 20:31:53 +00:00
|
|
|
#pragma warning(push)
|
|
|
|
#pragma warning(disable : 4530)
|
|
|
|
#endif
|
2012-12-18 19:13:49 +00:00
|
|
|
#include "json/value.h"
|
2013-01-08 20:31:53 +00:00
|
|
|
#ifdef SK_BUILD_FOR_WIN
|
|
|
|
#pragma warning(pop)
|
|
|
|
#endif
|
2012-12-18 19:13:49 +00:00
|
|
|
|
2012-08-02 14:03:32 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
#include "GrContextFactory.h"
|
|
|
|
#include "GrRenderTarget.h"
|
|
|
|
#include "SkGpuDevice.h"
|
|
|
|
typedef GrContextFactory::GLContextType GLContextType;
|
|
|
|
#else
|
|
|
|
class GrContext;
|
|
|
|
class GrRenderTarget;
|
|
|
|
typedef int GLContextType;
|
|
|
|
#endif
|
|
|
|
|
2011-12-30 16:02:53 +00:00
|
|
|
static bool gForceBWtext;
|
|
|
|
|
2011-11-08 14:59:38 +00:00
|
|
|
extern bool gSkSuppressFontCachePurgeSpew;
|
|
|
|
|
2010-12-20 19:46:07 +00:00
|
|
|
#ifdef SK_SUPPORT_PDF
|
2011-04-25 15:49:53 +00:00
|
|
|
#include "SkPDFDevice.h"
|
|
|
|
#include "SkPDFDocument.h"
|
2010-12-20 19:46:07 +00:00
|
|
|
#endif
|
2009-06-10 15:38:48 +00:00
|
|
|
|
2012-01-18 20:11:13 +00:00
|
|
|
// Until we resolve http://code.google.com/p/skia/issues/detail?id=455 ,
|
|
|
|
// stop writing out XPS-format image baselines in gm.
|
|
|
|
#undef SK_SUPPORT_XPS
|
2011-10-10 13:19:10 +00:00
|
|
|
#ifdef SK_SUPPORT_XPS
|
|
|
|
#include "SkXPSDevice.h"
|
|
|
|
#endif
|
|
|
|
|
2011-06-29 12:54:46 +00:00
|
|
|
#ifdef SK_BUILD_FOR_MAC
|
|
|
|
#include "SkCGUtils.h"
|
2011-06-29 19:42:58 +00:00
|
|
|
#define CAN_IMAGE_PDF 1
|
2011-06-29 12:54:46 +00:00
|
|
|
#else
|
2011-06-29 19:42:58 +00:00
|
|
|
#define CAN_IMAGE_PDF 0
|
2011-06-29 12:54:46 +00:00
|
|
|
#endif
|
|
|
|
|
2011-12-28 19:31:01 +00:00
|
|
|
typedef int ErrorBitfield;
|
|
|
|
const static ErrorBitfield ERROR_NONE = 0x00;
|
|
|
|
const static ErrorBitfield ERROR_NO_GPU_CONTEXT = 0x01;
|
2013-01-08 18:47:31 +00:00
|
|
|
const static ErrorBitfield ERROR_IMAGE_MISMATCH = 0x02;
|
|
|
|
// const static ErrorBitfield ERROR_DIMENSION_MISMATCH = 0x04; DEPRECATED in https://codereview.appspot.com/7064047
|
2011-12-28 19:31:01 +00:00
|
|
|
const static ErrorBitfield ERROR_READING_REFERENCE_IMAGE = 0x08;
|
|
|
|
const static ErrorBitfield ERROR_WRITING_REFERENCE_IMAGE = 0x10;
|
|
|
|
|
2012-12-18 19:13:49 +00:00
|
|
|
const static char kJsonKey_ActualResults[] = "actual-results";
|
|
|
|
const static char kJsonKey_ActualResults_Failed[] = "failed";
|
|
|
|
const static char kJsonKey_ActualResults_FailureIgnored[]= "failure-ignored";
|
2012-12-20 18:34:29 +00:00
|
|
|
const static char kJsonKey_ActualResults_NoComparison[] = "no-comparison";
|
2012-12-18 19:13:49 +00:00
|
|
|
const static char kJsonKey_ActualResults_Succeeded[] = "succeeded";
|
|
|
|
const static char kJsonKey_ActualResults_AnyStatus_Checksum[] = "checksum";
|
|
|
|
|
|
|
|
const static char kJsonKey_ExpectedResults[] = "expected-results";
|
|
|
|
const static char kJsonKey_ExpectedResults_Checksums[] = "checksums";
|
|
|
|
const static char kJsonKey_ExpectedResults_IgnoreFailure[] = "ignore-failure";
|
|
|
|
|
2009-06-10 15:38:48 +00:00
|
|
|
using namespace skiagm;
|
|
|
|
|
2012-11-13 03:41:55 +00:00
|
|
|
struct FailRec {
|
|
|
|
SkString fName;
|
2013-01-08 18:47:31 +00:00
|
|
|
bool fIsPixelError;
|
2012-11-13 03:41:55 +00:00
|
|
|
|
2013-01-08 18:47:31 +00:00
|
|
|
FailRec() : fIsPixelError(false) {}
|
|
|
|
FailRec(const SkString& name) : fName(name), fIsPixelError(false) {}
|
2012-11-13 03:41:55 +00:00
|
|
|
};
|
|
|
|
|
2009-06-10 15:38:48 +00:00
|
|
|
class Iter {
|
|
|
|
public:
|
|
|
|
Iter() {
|
2011-06-13 21:55:32 +00:00
|
|
|
this->reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void reset() {
|
2009-06-20 02:38:16 +00:00
|
|
|
fReg = GMRegistry::Head();
|
2009-06-10 15:38:48 +00:00
|
|
|
}
|
2011-01-18 21:05:42 +00:00
|
|
|
|
2009-06-20 02:38:16 +00:00
|
|
|
GM* next() {
|
2009-06-10 15:38:48 +00:00
|
|
|
if (fReg) {
|
2009-06-20 02:38:16 +00:00
|
|
|
GMRegistry::Factory fact = fReg->factory();
|
2009-06-10 15:38:48 +00:00
|
|
|
fReg = fReg->next();
|
2009-06-20 02:38:16 +00:00
|
|
|
return fact(0);
|
2009-06-10 15:38:48 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-01-18 21:05:42 +00:00
|
|
|
|
2009-06-10 15:38:48 +00:00
|
|
|
static int Count() {
|
2009-06-20 02:38:16 +00:00
|
|
|
const GMRegistry* reg = GMRegistry::Head();
|
2009-06-10 15:38:48 +00:00
|
|
|
int count = 0;
|
|
|
|
while (reg) {
|
|
|
|
count += 1;
|
|
|
|
reg = reg->next();
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
2011-01-18 21:05:42 +00:00
|
|
|
|
2009-06-10 15:38:48 +00:00
|
|
|
private:
|
|
|
|
const GMRegistry* fReg;
|
|
|
|
};
|
|
|
|
|
2011-02-03 23:00:40 +00:00
|
|
|
enum Backend {
|
2012-12-13 16:39:53 +00:00
|
|
|
kRaster_Backend,
|
|
|
|
kGPU_Backend,
|
|
|
|
kPDF_Backend,
|
|
|
|
kXPS_Backend,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum BbhType {
|
|
|
|
kNone_BbhType,
|
|
|
|
kRTree_BbhType,
|
|
|
|
kTileGrid_BbhType,
|
2011-02-03 23:00:40 +00:00
|
|
|
};
|
|
|
|
|
2012-04-19 19:15:35 +00:00
|
|
|
enum ConfigFlags {
|
|
|
|
kNone_ConfigFlag = 0x0,
|
|
|
|
/* Write GM images if a write path is provided. */
|
|
|
|
kWrite_ConfigFlag = 0x1,
|
2012-10-25 16:27:34 +00:00
|
|
|
/* Read reference GM images if a read path is provided. */
|
2012-04-19 19:15:35 +00:00
|
|
|
kRead_ConfigFlag = 0x2,
|
|
|
|
kRW_ConfigFlag = (kWrite_ConfigFlag | kRead_ConfigFlag),
|
|
|
|
};
|
|
|
|
|
2011-04-25 15:49:53 +00:00
|
|
|
struct ConfigData {
|
2012-04-19 19:15:35 +00:00
|
|
|
SkBitmap::Config fConfig;
|
|
|
|
Backend fBackend;
|
2012-08-02 14:03:32 +00:00
|
|
|
GLContextType fGLContextType; // GPU backend only
|
2012-04-19 19:15:35 +00:00
|
|
|
int fSampleCnt; // GPU backend only
|
|
|
|
ConfigFlags fFlags;
|
|
|
|
const char* fName;
|
2011-04-25 15:49:53 +00:00
|
|
|
};
|
|
|
|
|
2011-12-30 16:02:53 +00:00
|
|
|
class BWTextDrawFilter : public SkDrawFilter {
|
|
|
|
public:
|
2012-11-26 20:26:54 +00:00
|
|
|
virtual bool filter(SkPaint*, Type) SK_OVERRIDE;
|
2011-12-30 16:02:53 +00:00
|
|
|
};
|
2012-11-26 20:26:54 +00:00
|
|
|
bool BWTextDrawFilter::filter(SkPaint* p, Type t) {
|
2011-12-30 16:02:53 +00:00
|
|
|
if (kText_Type == t) {
|
|
|
|
p->setAntiAlias(false);
|
|
|
|
}
|
2012-11-26 20:26:54 +00:00
|
|
|
return true;
|
2011-12-30 16:02:53 +00:00
|
|
|
}
|
|
|
|
|
2012-10-26 18:56:36 +00:00
|
|
|
struct PipeFlagComboData {
|
|
|
|
const char* name;
|
|
|
|
uint32_t flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
static PipeFlagComboData gPipeWritingFlagCombos[] = {
|
|
|
|
{ "", 0 },
|
|
|
|
{ " cross-process", SkGPipeWriter::kCrossProcess_Flag },
|
|
|
|
{ " cross-process, shared address", SkGPipeWriter::kCrossProcess_Flag
|
|
|
|
| SkGPipeWriter::kSharedAddressSpace_Flag }
|
|
|
|
};
|
|
|
|
|
|
|
|
class GMMain {
|
|
|
|
public:
|
2012-10-29 16:42:11 +00:00
|
|
|
GMMain() {
|
|
|
|
// Set default values of member variables, which tool_main()
|
|
|
|
// may override.
|
2013-01-18 21:45:42 +00:00
|
|
|
fNotifyMissingReadReference = true;
|
2012-10-29 16:42:11 +00:00
|
|
|
fUseFileHierarchy = false;
|
2013-01-11 21:04:40 +00:00
|
|
|
fMismatchPath = NULL;
|
2012-10-29 16:42:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SkString make_name(const char shortName[], const char configName[]) {
|
|
|
|
SkString name;
|
2012-11-13 03:41:55 +00:00
|
|
|
if (0 == strlen(configName)) {
|
|
|
|
name.append(shortName);
|
|
|
|
} else if (fUseFileHierarchy) {
|
2012-10-29 16:42:11 +00:00
|
|
|
name.appendf("%s%c%s", configName, SkPATH_SEPARATOR, shortName);
|
|
|
|
} else {
|
|
|
|
name.appendf("%s_%s", shortName, configName);
|
|
|
|
}
|
2012-10-26 18:56:36 +00:00
|
|
|
return name;
|
2011-12-30 16:02:53 +00:00
|
|
|
}
|
|
|
|
|
2013-01-18 21:45:42 +00:00
|
|
|
static SkString make_filename(const char path[],
|
|
|
|
const char renderModeDescriptor[],
|
|
|
|
const SkString& name,
|
|
|
|
const char suffix[]) {
|
|
|
|
SkString filename(path);
|
|
|
|
if (filename.endsWith(SkPATH_SEPARATOR)) {
|
|
|
|
filename.remove(filename.size() - 1, 1);
|
|
|
|
}
|
|
|
|
filename.appendf("%c%s%s.%s", SkPATH_SEPARATOR,
|
|
|
|
name.c_str(), renderModeDescriptor, suffix);
|
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
|
2012-10-26 18:56:36 +00:00
|
|
|
/* since PNG insists on unpremultiplying our alpha, we take no
|
|
|
|
precision chances and force all pixels to be 100% opaque,
|
|
|
|
otherwise on compare we may not get a perfect match.
|
|
|
|
*/
|
|
|
|
static void force_all_opaque(const SkBitmap& bitmap) {
|
|
|
|
SkAutoLockPixels lock(bitmap);
|
|
|
|
for (int y = 0; y < bitmap.height(); y++) {
|
|
|
|
for (int x = 0; x < bitmap.width(); x++) {
|
|
|
|
*bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT);
|
|
|
|
}
|
|
|
|
}
|
2012-03-21 17:34:30 +00:00
|
|
|
}
|
2011-12-30 16:02:53 +00:00
|
|
|
|
2012-10-26 18:56:36 +00:00
|
|
|
static bool write_bitmap(const SkString& path, const SkBitmap& bitmap) {
|
|
|
|
SkBitmap copy;
|
|
|
|
bitmap.copyTo(©, SkBitmap::kARGB_8888_Config);
|
|
|
|
force_all_opaque(copy);
|
|
|
|
return SkImageEncoder::EncodeFile(path.c_str(), copy,
|
|
|
|
SkImageEncoder::kPNG_Type, 100);
|
|
|
|
}
|
2011-04-25 15:49:53 +00:00
|
|
|
|
2012-11-13 03:41:55 +00:00
|
|
|
// Records an error in fFailedTests, if we want to record errors
|
|
|
|
// of this type.
|
|
|
|
void RecordError(ErrorBitfield errorType, const SkString& name,
|
2013-01-08 18:47:31 +00:00
|
|
|
const char renderModeDescriptor []) {
|
|
|
|
bool isPixelError = false;
|
2012-11-13 03:41:55 +00:00
|
|
|
switch (errorType) {
|
|
|
|
case ERROR_NONE:
|
2013-01-08 18:47:31 +00:00
|
|
|
return;
|
2012-11-13 03:41:55 +00:00
|
|
|
case ERROR_READING_REFERENCE_IMAGE:
|
2013-01-08 18:47:31 +00:00
|
|
|
return;
|
|
|
|
case ERROR_IMAGE_MISMATCH:
|
|
|
|
isPixelError = true;
|
2012-11-13 03:41:55 +00:00
|
|
|
break;
|
|
|
|
default:
|
2013-01-08 18:47:31 +00:00
|
|
|
isPixelError = false;
|
2012-11-13 03:41:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-01-08 18:47:31 +00:00
|
|
|
|
|
|
|
FailRec& rec = fFailedTests.push_back(make_name(
|
|
|
|
name.c_str(), renderModeDescriptor));
|
|
|
|
rec.fIsPixelError = isPixelError;
|
2012-11-13 03:41:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// List contents of fFailedTests via SkDebug.
|
|
|
|
void ListErrors() {
|
|
|
|
for (int i = 0; i < fFailedTests.count(); ++i) {
|
2013-01-08 18:47:31 +00:00
|
|
|
if (fFailedTests[i].fIsPixelError) {
|
|
|
|
SkDebugf("\t\t%s pixel_error\n", fFailedTests[i].fName.c_str());
|
|
|
|
} else {
|
|
|
|
SkDebugf("\t\t%s\n", fFailedTests[i].fName.c_str());
|
2012-11-13 03:41:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-18 21:45:42 +00:00
|
|
|
// Compares "target" and "base" bitmaps, returning the result
|
|
|
|
// (ERROR_NONE if the two bitmaps are identical).
|
|
|
|
ErrorBitfield compare(const SkBitmap& target, const SkBitmap& base,
|
|
|
|
const SkString& name,
|
|
|
|
const char* renderModeDescriptor) {
|
|
|
|
SkBitmap copy;
|
|
|
|
const SkBitmap* bm = ⌖
|
|
|
|
if (target.config() != SkBitmap::kARGB_8888_Config) {
|
|
|
|
target.copyTo(©, SkBitmap::kARGB_8888_Config);
|
|
|
|
bm = ©
|
|
|
|
}
|
|
|
|
SkBitmap baseCopy;
|
|
|
|
const SkBitmap* bp = &base;
|
|
|
|
if (base.config() != SkBitmap::kARGB_8888_Config) {
|
|
|
|
base.copyTo(&baseCopy, SkBitmap::kARGB_8888_Config);
|
|
|
|
bp = &baseCopy;
|
|
|
|
}
|
|
|
|
|
|
|
|
force_all_opaque(*bm);
|
|
|
|
force_all_opaque(*bp);
|
|
|
|
|
|
|
|
const int w = bm->width();
|
|
|
|
const int h = bm->height();
|
|
|
|
if (w != bp->width() || h != bp->height()) {
|
|
|
|
RecordError(ERROR_IMAGE_MISMATCH, name, renderModeDescriptor);
|
|
|
|
return ERROR_IMAGE_MISMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkAutoLockPixels bmLock(*bm);
|
|
|
|
SkAutoLockPixels baseLock(*bp);
|
|
|
|
|
|
|
|
for (int y = 0; y < h; y++) {
|
|
|
|
for (int x = 0; x < w; x++) {
|
|
|
|
SkPMColor c0 = *bp->getAddr32(x, y);
|
|
|
|
SkPMColor c1 = *bm->getAddr32(x, y);
|
|
|
|
if (c0 != c1) {
|
|
|
|
RecordError(ERROR_IMAGE_MISMATCH, name,
|
|
|
|
renderModeDescriptor);
|
|
|
|
return ERROR_IMAGE_MISMATCH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ERROR_NONE;
|
|
|
|
}
|
|
|
|
|
2012-10-26 18:56:36 +00:00
|
|
|
static bool write_document(const SkString& path,
|
|
|
|
const SkDynamicMemoryWStream& document) {
|
|
|
|
SkFILEWStream stream(path.c_str());
|
|
|
|
SkAutoDataUnref data(document.copyToData());
|
|
|
|
return stream.writeData(data.get());
|
|
|
|
}
|
2011-04-25 15:49:53 +00:00
|
|
|
|
2012-10-26 18:56:36 +00:00
|
|
|
/// Returns true if processing should continue, false to skip the
|
|
|
|
/// remainder of this config for this GM.
|
|
|
|
//@todo thudson 22 April 2011 - could refactor this to take in
|
|
|
|
// a factory to generate the context, always call readPixels()
|
|
|
|
// (logically a noop for rasters, if wasted time), and thus collapse the
|
|
|
|
// GPU special case and also let this be used for SkPicture testing.
|
|
|
|
static void setup_bitmap(const ConfigData& gRec, SkISize& size,
|
|
|
|
SkBitmap* bitmap) {
|
|
|
|
bitmap->setConfig(gRec.fConfig, size.width(), size.height());
|
|
|
|
bitmap->allocPixels();
|
2012-12-06 21:47:40 +00:00
|
|
|
bitmap->eraseColor(SK_ColorTRANSPARENT);
|
2012-03-21 17:34:30 +00:00
|
|
|
}
|
2011-04-25 15:49:53 +00:00
|
|
|
|
2012-10-26 18:56:36 +00:00
|
|
|
static void installFilter(SkCanvas* canvas) {
|
|
|
|
if (gForceBWtext) {
|
|
|
|
canvas->setDrawFilter(new BWTextDrawFilter)->unref();
|
|
|
|
}
|
|
|
|
}
|
2011-04-25 15:49:53 +00:00
|
|
|
|
2012-11-16 13:41:45 +00:00
|
|
|
static void invokeGM(GM* gm, SkCanvas* canvas, bool isPDF, bool isDeferred) {
|
2012-10-26 18:56:36 +00:00
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
2011-04-25 15:49:53 +00:00
|
|
|
|
2012-10-26 18:56:36 +00:00
|
|
|
if (!isPDF) {
|
|
|
|
canvas->concat(gm->getInitialTransform());
|
|
|
|
}
|
|
|
|
installFilter(canvas);
|
2012-11-16 13:41:45 +00:00
|
|
|
gm->setCanvasIsDeferred(isDeferred);
|
2012-10-26 18:56:36 +00:00
|
|
|
gm->draw(canvas);
|
|
|
|
canvas->setDrawFilter(NULL);
|
|
|
|
}
|
2011-10-10 13:19:10 +00:00
|
|
|
|
2012-10-26 18:56:36 +00:00
|
|
|
static ErrorBitfield generate_image(GM* gm, const ConfigData& gRec,
|
|
|
|
GrContext* context,
|
|
|
|
GrRenderTarget* rt,
|
|
|
|
SkBitmap* bitmap,
|
|
|
|
bool deferred) {
|
|
|
|
SkISize size (gm->getISize());
|
|
|
|
setup_bitmap(gRec, size, bitmap);
|
|
|
|
|
|
|
|
SkAutoTUnref<SkCanvas> canvas;
|
2011-10-10 13:19:10 +00:00
|
|
|
|
2012-10-26 18:56:36 +00:00
|
|
|
if (gRec.fBackend == kRaster_Backend) {
|
|
|
|
SkAutoTUnref<SkDevice> device(new SkDevice(*bitmap));
|
|
|
|
if (deferred) {
|
|
|
|
canvas.reset(new SkDeferredCanvas(device));
|
|
|
|
} else {
|
|
|
|
canvas.reset(new SkCanvas(device));
|
|
|
|
}
|
2012-11-16 13:41:45 +00:00
|
|
|
invokeGM(gm, canvas, false, deferred);
|
2012-10-26 18:56:36 +00:00
|
|
|
canvas->flush();
|
|
|
|
}
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
else { // GPU
|
|
|
|
if (NULL == context) {
|
|
|
|
return ERROR_NO_GPU_CONTEXT;
|
|
|
|
}
|
|
|
|
SkAutoTUnref<SkDevice> device(new SkGpuDevice(context, rt));
|
|
|
|
if (deferred) {
|
|
|
|
canvas.reset(new SkDeferredCanvas(device));
|
|
|
|
} else {
|
|
|
|
canvas.reset(new SkCanvas(device));
|
|
|
|
}
|
2012-11-16 13:41:45 +00:00
|
|
|
invokeGM(gm, canvas, false, deferred);
|
2012-10-26 18:56:36 +00:00
|
|
|
// the device is as large as the current rendertarget, so
|
|
|
|
// we explicitly only readback the amount we expect (in
|
|
|
|
// size) overwrite our previous allocation
|
|
|
|
bitmap->setConfig(SkBitmap::kARGB_8888_Config, size.fWidth,
|
|
|
|
size.fHeight);
|
|
|
|
canvas->readPixels(bitmap, 0, 0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return ERROR_NONE;
|
2011-06-29 12:54:46 +00:00
|
|
|
}
|
2012-10-26 18:56:36 +00:00
|
|
|
|
|
|
|
static void generate_image_from_picture(GM* gm, const ConfigData& gRec,
|
2012-12-19 15:24:38 +00:00
|
|
|
SkPicture* pict, SkBitmap* bitmap,
|
|
|
|
SkScalar scale = SK_Scalar1) {
|
2012-10-26 18:56:36 +00:00
|
|
|
SkISize size = gm->getISize();
|
|
|
|
setup_bitmap(gRec, size, bitmap);
|
|
|
|
SkCanvas canvas(*bitmap);
|
|
|
|
installFilter(&canvas);
|
2012-12-19 15:24:38 +00:00
|
|
|
canvas.scale(scale, scale);
|
2012-10-26 18:56:36 +00:00
|
|
|
canvas.drawPicture(*pict);
|
2011-10-10 13:19:10 +00:00
|
|
|
}
|
2012-10-26 18:56:36 +00:00
|
|
|
|
|
|
|
static void generate_pdf(GM* gm, SkDynamicMemoryWStream& pdf) {
|
|
|
|
#ifdef SK_SUPPORT_PDF
|
|
|
|
SkMatrix initialTransform = gm->getInitialTransform();
|
|
|
|
SkISize pageSize = gm->getISize();
|
|
|
|
SkPDFDevice* dev = NULL;
|
|
|
|
if (initialTransform.isIdentity()) {
|
|
|
|
dev = new SkPDFDevice(pageSize, pageSize, initialTransform);
|
|
|
|
} else {
|
|
|
|
SkRect content = SkRect::MakeWH(SkIntToScalar(pageSize.width()),
|
|
|
|
SkIntToScalar(pageSize.height()));
|
|
|
|
initialTransform.mapRect(&content);
|
|
|
|
content.intersect(0, 0, SkIntToScalar(pageSize.width()),
|
|
|
|
SkIntToScalar(pageSize.height()));
|
|
|
|
SkISize contentSize =
|
|
|
|
SkISize::Make(SkScalarRoundToInt(content.width()),
|
|
|
|
SkScalarRoundToInt(content.height()));
|
|
|
|
dev = new SkPDFDevice(pageSize, contentSize, initialTransform);
|
|
|
|
}
|
|
|
|
SkAutoUnref aur(dev);
|
|
|
|
|
|
|
|
SkCanvas c(dev);
|
2012-11-16 13:41:45 +00:00
|
|
|
invokeGM(gm, &c, true, false);
|
2012-10-26 18:56:36 +00:00
|
|
|
|
|
|
|
SkPDFDocument doc;
|
|
|
|
doc.appendPage(dev);
|
|
|
|
doc.emitPDF(&pdf);
|
|
|
|
#endif
|
2011-04-25 15:49:53 +00:00
|
|
|
}
|
2012-10-26 18:56:36 +00:00
|
|
|
|
|
|
|
static void generate_xps(GM* gm, SkDynamicMemoryWStream& xps) {
|
|
|
|
#ifdef SK_SUPPORT_XPS
|
|
|
|
SkISize size = gm->getISize();
|
|
|
|
|
|
|
|
SkSize trimSize = SkSize::Make(SkIntToScalar(size.width()),
|
|
|
|
SkIntToScalar(size.height()));
|
|
|
|
static const SkScalar inchesPerMeter = SkScalarDiv(10000, 254);
|
|
|
|
static const SkScalar upm = 72 * inchesPerMeter;
|
|
|
|
SkVector unitsPerMeter = SkPoint::Make(upm, upm);
|
|
|
|
static const SkScalar ppm = 200 * inchesPerMeter;
|
|
|
|
SkVector pixelsPerMeter = SkPoint::Make(ppm, ppm);
|
|
|
|
|
|
|
|
SkXPSDevice* dev = new SkXPSDevice();
|
|
|
|
SkAutoUnref aur(dev);
|
|
|
|
|
|
|
|
SkCanvas c(dev);
|
|
|
|
dev->beginPortfolio(&xps);
|
|
|
|
dev->beginSheet(unitsPerMeter, pixelsPerMeter, trimSize);
|
2012-11-16 13:41:45 +00:00
|
|
|
invokeGM(gm, &c, false, false);
|
2012-10-26 18:56:36 +00:00
|
|
|
dev->endSheet();
|
|
|
|
dev->endPortfolio();
|
|
|
|
|
|
|
|
#endif
|
2011-04-25 15:49:53 +00:00
|
|
|
}
|
|
|
|
|
2012-11-13 03:41:55 +00:00
|
|
|
ErrorBitfield write_reference_image(
|
2012-10-26 18:56:36 +00:00
|
|
|
const ConfigData& gRec, const char writePath [],
|
|
|
|
const char renderModeDescriptor [], const SkString& name,
|
|
|
|
SkBitmap& bitmap, SkDynamicMemoryWStream* document) {
|
|
|
|
SkString path;
|
|
|
|
bool success = false;
|
|
|
|
if (gRec.fBackend == kRaster_Backend ||
|
|
|
|
gRec.fBackend == kGPU_Backend ||
|
|
|
|
(gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) {
|
|
|
|
|
2013-01-18 21:45:42 +00:00
|
|
|
path = make_filename(writePath, renderModeDescriptor, name, "png");
|
2012-10-26 18:56:36 +00:00
|
|
|
success = write_bitmap(path, bitmap);
|
|
|
|
}
|
|
|
|
if (kPDF_Backend == gRec.fBackend) {
|
2013-01-18 21:45:42 +00:00
|
|
|
path = make_filename(writePath, renderModeDescriptor, name, "pdf");
|
2012-10-26 18:56:36 +00:00
|
|
|
success = write_document(path, *document);
|
|
|
|
}
|
|
|
|
if (kXPS_Backend == gRec.fBackend) {
|
2013-01-18 21:45:42 +00:00
|
|
|
path = make_filename(writePath, renderModeDescriptor, name, "xps");
|
2012-10-26 18:56:36 +00:00
|
|
|
success = write_document(path, *document);
|
|
|
|
}
|
|
|
|
if (success) {
|
|
|
|
return ERROR_NONE;
|
|
|
|
} else {
|
|
|
|
fprintf(stderr, "FAILED to write %s\n", path.c_str());
|
2012-11-13 03:41:55 +00:00
|
|
|
RecordError(ERROR_WRITING_REFERENCE_IMAGE, name,
|
|
|
|
renderModeDescriptor);
|
2012-10-26 18:56:36 +00:00
|
|
|
return ERROR_WRITING_REFERENCE_IMAGE;
|
2011-12-28 19:31:01 +00:00
|
|
|
}
|
2011-06-17 13:11:45 +00:00
|
|
|
}
|
|
|
|
|
2013-01-18 21:45:42 +00:00
|
|
|
// Compares bitmap "bitmap" to a reference bitmap read from disk.
|
|
|
|
//
|
|
|
|
// Returns a description of the difference between "bitmap" and
|
|
|
|
// the reference bitmap, or ERROR_READING_REFERENCE_IMAGE if
|
|
|
|
// unable to read the reference bitmap from disk.
|
|
|
|
ErrorBitfield compare_to_reference_image_on_disk(
|
|
|
|
const char readPath [], const SkString& name, SkBitmap &bitmap,
|
|
|
|
const char renderModeDescriptor []) {
|
2012-12-18 19:13:49 +00:00
|
|
|
ErrorBitfield retval;
|
2013-01-18 21:45:42 +00:00
|
|
|
SkString path = make_filename(readPath, "", name, "png");
|
|
|
|
SkBitmap referenceBitmap;
|
|
|
|
Json::Value expectedChecksumsArray;
|
|
|
|
|
|
|
|
bool decodedReferenceBitmap =
|
|
|
|
SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap,
|
|
|
|
SkBitmap::kARGB_8888_Config,
|
|
|
|
SkImageDecoder::kDecodePixels_Mode,
|
|
|
|
NULL);
|
|
|
|
if (decodedReferenceBitmap) {
|
|
|
|
expectedChecksumsArray.append(Json::UInt64(
|
|
|
|
SkBitmapChecksummer::Compute64(referenceBitmap)));
|
|
|
|
retval = compare(bitmap, referenceBitmap, name,
|
|
|
|
renderModeDescriptor);
|
|
|
|
if (fMismatchPath && (retval & ERROR_IMAGE_MISMATCH)) {
|
|
|
|
SkString path = make_filename(fMismatchPath, renderModeDescriptor, name, "png");
|
|
|
|
write_bitmap(path, bitmap);
|
|
|
|
}
|
2012-10-26 18:56:36 +00:00
|
|
|
} else {
|
2013-01-18 21:45:42 +00:00
|
|
|
if (fNotifyMissingReadReference) {
|
|
|
|
fprintf(stderr, "FAILED to read %s\n", path.c_str());
|
2012-10-26 18:56:36 +00:00
|
|
|
}
|
2013-01-18 21:45:42 +00:00
|
|
|
RecordError(ERROR_READING_REFERENCE_IMAGE, name,
|
|
|
|
renderModeDescriptor);
|
|
|
|
retval = ERROR_READING_REFERENCE_IMAGE;
|
2012-12-18 19:13:49 +00:00
|
|
|
}
|
|
|
|
|
2013-01-18 21:45:42 +00:00
|
|
|
// Add this result to the appropriate JSON collection of actual results,
|
|
|
|
// depending on status.
|
2012-12-18 19:13:49 +00:00
|
|
|
Json::Value actualResults;
|
2013-01-18 21:45:42 +00:00
|
|
|
actualResults[kJsonKey_ActualResults_AnyStatus_Checksum] = Json::UInt64(
|
|
|
|
SkBitmapChecksummer::Compute64(bitmap));
|
|
|
|
if (decodedReferenceBitmap) {
|
|
|
|
if (ERROR_NONE == retval) {
|
|
|
|
fJsonActualResults_Succeeded[name.c_str()] = actualResults;
|
2012-12-18 19:13:49 +00:00
|
|
|
} else {
|
2013-01-18 21:45:42 +00:00
|
|
|
fJsonActualResults_Failed[name.c_str()] = actualResults;
|
2012-12-18 19:13:49 +00:00
|
|
|
}
|
2013-01-18 21:45:42 +00:00
|
|
|
} else {
|
|
|
|
fJsonActualResults_NoComparison[name.c_str()] = actualResults;
|
2012-10-26 18:56:36 +00:00
|
|
|
}
|
2012-12-18 19:13:49 +00:00
|
|
|
|
2013-01-18 21:45:42 +00:00
|
|
|
// Add this test to the JSON collection of expected results.
|
2012-12-18 19:13:49 +00:00
|
|
|
// For now, we assume that this collection starts out empty and we
|
|
|
|
// just fill it in as we go; once gm accepts a JSON file as input,
|
|
|
|
// we'll have to change that.
|
|
|
|
Json::Value expectedResults;
|
2013-01-18 21:45:42 +00:00
|
|
|
expectedResults[kJsonKey_ExpectedResults_Checksums] = expectedChecksumsArray;
|
|
|
|
expectedResults[kJsonKey_ExpectedResults_IgnoreFailure] = !decodedReferenceBitmap;
|
|
|
|
fJsonExpectedResults[name.c_str()] = expectedResults;
|
2013-01-15 19:10:16 +00:00
|
|
|
|
2013-01-18 21:45:42 +00:00
|
|
|
return retval;
|
|
|
|
}
|
2013-01-17 17:54:28 +00:00
|
|
|
|
2013-01-18 21:45:42 +00:00
|
|
|
// NOTE: As far as I can tell, this function is NEVER called with a
|
|
|
|
// non-blank renderModeDescriptor, EXCEPT when readPath and writePath are
|
|
|
|
// both NULL (and thus no images are read from or written to disk).
|
|
|
|
// So I don't trust that the renderModeDescriptor is being used for
|
|
|
|
// anything other than debug output these days.
|
|
|
|
ErrorBitfield handle_test_results(GM* gm,
|
|
|
|
const ConfigData& gRec,
|
|
|
|
const char writePath [],
|
|
|
|
const char readPath [],
|
|
|
|
const char renderModeDescriptor [],
|
|
|
|
SkBitmap& bitmap,
|
|
|
|
SkDynamicMemoryWStream* pdf,
|
|
|
|
const SkBitmap* referenceBitmap) {
|
2012-10-26 18:56:36 +00:00
|
|
|
SkString name = make_name(gm->shortName(), gRec.fName);
|
|
|
|
ErrorBitfield retval = ERROR_NONE;
|
|
|
|
|
2013-01-18 21:45:42 +00:00
|
|
|
if (readPath && (gRec.fFlags & kRead_ConfigFlag)) {
|
|
|
|
retval |= compare_to_reference_image_on_disk(readPath, name, bitmap,
|
|
|
|
renderModeDescriptor);
|
|
|
|
} else if (NULL == referenceBitmap) {
|
|
|
|
// If we are running without "--readPath", we still want to
|
2012-12-20 18:34:29 +00:00
|
|
|
// record the actual results.
|
2013-01-18 21:45:42 +00:00
|
|
|
//
|
|
|
|
// For now, though, we don't record results of comparisons against
|
|
|
|
// different in-memory representations (hence the referenceBitmap
|
|
|
|
// NULL check).
|
|
|
|
Json::Value actualResults;
|
|
|
|
actualResults[kJsonKey_ActualResults_AnyStatus_Checksum] =
|
|
|
|
Json::UInt64(SkBitmapChecksummer::Compute64(bitmap));
|
|
|
|
fJsonActualResults_NoComparison[name.c_str()] = actualResults;
|
2012-10-26 18:56:36 +00:00
|
|
|
}
|
|
|
|
if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) {
|
2013-01-18 21:45:42 +00:00
|
|
|
retval |= write_reference_image(gRec, writePath,
|
|
|
|
renderModeDescriptor,
|
|
|
|
name, bitmap, pdf);
|
|
|
|
}
|
|
|
|
if (referenceBitmap) {
|
|
|
|
ErrorBitfield compareResult = compare(bitmap, *referenceBitmap, name,
|
|
|
|
renderModeDescriptor);
|
|
|
|
if (fMismatchPath && (compareResult & ERROR_IMAGE_MISMATCH)) {
|
|
|
|
SkString path = make_filename(fMismatchPath, renderModeDescriptor, name, "png");
|
|
|
|
write_bitmap(path, bitmap);
|
|
|
|
}
|
|
|
|
retval |= compareResult;
|
2012-10-26 18:56:36 +00:00
|
|
|
}
|
|
|
|
return retval;
|
2012-04-18 13:36:54 +00:00
|
|
|
}
|
2011-04-25 15:49:53 +00:00
|
|
|
|
2013-01-16 18:43:36 +00:00
|
|
|
static SkPicture* generate_new_picture(GM* gm, BbhType bbhType, uint32_t recordFlags,
|
|
|
|
SkScalar scale = SK_Scalar1) {
|
2012-10-26 18:56:36 +00:00
|
|
|
// Pictures are refcounted so must be on heap
|
2012-12-13 16:39:53 +00:00
|
|
|
SkPicture* pict;
|
2012-12-19 15:55:40 +00:00
|
|
|
int width = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().width()), scale));
|
|
|
|
int height = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().height()), scale));
|
2012-12-20 02:01:41 +00:00
|
|
|
|
2012-12-13 16:39:53 +00:00
|
|
|
if (kTileGrid_BbhType == bbhType) {
|
2012-12-19 15:55:40 +00:00
|
|
|
pict = new SkTileGridPicture(16, 16, width, height);
|
2012-12-13 16:39:53 +00:00
|
|
|
} else {
|
|
|
|
pict = new SkPicture;
|
|
|
|
}
|
2013-01-16 18:43:36 +00:00
|
|
|
if (kNone_BbhType != bbhType) {
|
|
|
|
recordFlags |= SkPicture::kOptimizeForClippedPlayback_RecordingFlag;
|
|
|
|
}
|
2012-12-19 15:55:40 +00:00
|
|
|
SkCanvas* cv = pict->beginRecording(width, height, recordFlags);
|
2012-12-19 15:24:38 +00:00
|
|
|
cv->scale(scale, scale);
|
2012-11-16 13:41:45 +00:00
|
|
|
invokeGM(gm, cv, false, false);
|
2012-10-26 18:56:36 +00:00
|
|
|
pict->endRecording();
|
2011-04-25 15:49:53 +00:00
|
|
|
|
2012-10-26 18:56:36 +00:00
|
|
|
return pict;
|
|
|
|
}
|
2011-04-25 15:49:53 +00:00
|
|
|
|
2012-10-26 18:56:36 +00:00
|
|
|
static SkPicture* stream_to_new_picture(const SkPicture& src) {
|
|
|
|
|
|
|
|
// To do in-memory commiunications with a stream, we need to:
|
|
|
|
// * create a dynamic memory stream
|
|
|
|
// * copy it into a buffer
|
|
|
|
// * create a read stream from it
|
|
|
|
// ?!?!
|
|
|
|
|
|
|
|
SkDynamicMemoryWStream storage;
|
|
|
|
src.serialize(&storage);
|
|
|
|
|
|
|
|
int streamSize = storage.getOffset();
|
|
|
|
SkAutoMalloc dstStorage(streamSize);
|
|
|
|
void* dst = dstStorage.get();
|
|
|
|
//char* dst = new char [streamSize];
|
|
|
|
//@todo thudson 22 April 2011 when can we safely delete [] dst?
|
|
|
|
storage.copyTo(dst);
|
|
|
|
SkMemoryStream pictReadback(dst, streamSize);
|
|
|
|
SkPicture* retval = new SkPicture (&pictReadback);
|
|
|
|
return retval;
|
|
|
|
}
|
2011-04-25 15:49:53 +00:00
|
|
|
|
2012-10-26 18:56:36 +00:00
|
|
|
// Test: draw into a bitmap or pdf.
|
2013-01-08 18:47:31 +00:00
|
|
|
// Depending on flags, possibly compare to an expected image.
|
2012-10-29 16:42:11 +00:00
|
|
|
ErrorBitfield test_drawing(GM* gm,
|
|
|
|
const ConfigData& gRec,
|
|
|
|
const char writePath [],
|
2013-01-18 21:45:42 +00:00
|
|
|
const char readPath [],
|
2012-10-29 16:42:11 +00:00
|
|
|
GrContext* context,
|
|
|
|
GrRenderTarget* rt,
|
2012-11-13 03:41:55 +00:00
|
|
|
SkBitmap* bitmap) {
|
2012-10-26 18:56:36 +00:00
|
|
|
SkDynamicMemoryWStream document;
|
|
|
|
|
|
|
|
if (gRec.fBackend == kRaster_Backend ||
|
|
|
|
gRec.fBackend == kGPU_Backend) {
|
|
|
|
// Early exit if we can't generate the image.
|
|
|
|
ErrorBitfield errors = generate_image(gm, gRec, context, rt, bitmap,
|
|
|
|
false);
|
|
|
|
if (ERROR_NONE != errors) {
|
|
|
|
return errors;
|
|
|
|
}
|
|
|
|
} else if (gRec.fBackend == kPDF_Backend) {
|
|
|
|
generate_pdf(gm, document);
|
2011-06-29 12:54:46 +00:00
|
|
|
#if CAN_IMAGE_PDF
|
2012-10-26 18:56:36 +00:00
|
|
|
SkAutoDataUnref data(document.copyToData());
|
|
|
|
SkMemoryStream stream(data->data(), data->size());
|
|
|
|
SkPDFDocumentToBitmap(&stream, bitmap);
|
2011-06-29 12:54:46 +00:00
|
|
|
#endif
|
2012-10-26 18:56:36 +00:00
|
|
|
} else if (gRec.fBackend == kXPS_Backend) {
|
|
|
|
generate_xps(gm, document);
|
|
|
|
}
|
2013-01-18 21:45:42 +00:00
|
|
|
return handle_test_results(gm, gRec, writePath, readPath,
|
|
|
|
"", *bitmap, &document, NULL);
|
2011-04-25 15:49:53 +00:00
|
|
|
}
|
|
|
|
|
2012-10-29 16:42:11 +00:00
|
|
|
ErrorBitfield test_deferred_drawing(GM* gm,
|
|
|
|
const ConfigData& gRec,
|
|
|
|
const SkBitmap& referenceBitmap,
|
|
|
|
GrContext* context,
|
|
|
|
GrRenderTarget* rt) {
|
2012-10-26 18:56:36 +00:00
|
|
|
SkDynamicMemoryWStream document;
|
|
|
|
|
|
|
|
if (gRec.fBackend == kRaster_Backend ||
|
|
|
|
gRec.fBackend == kGPU_Backend) {
|
|
|
|
SkBitmap bitmap;
|
|
|
|
// Early exit if we can't generate the image, but this is
|
|
|
|
// expected in some cases, so don't report a test failure.
|
|
|
|
if (!generate_image(gm, gRec, context, rt, &bitmap, true)) {
|
|
|
|
return ERROR_NONE;
|
|
|
|
}
|
2013-01-18 21:45:42 +00:00
|
|
|
return handle_test_results(gm, gRec, NULL, NULL,
|
|
|
|
"-deferred", bitmap, NULL,
|
|
|
|
&referenceBitmap);
|
2012-01-18 16:21:08 +00:00
|
|
|
}
|
2012-10-26 18:56:36 +00:00
|
|
|
return ERROR_NONE;
|
2012-01-18 16:21:08 +00:00
|
|
|
}
|
|
|
|
|
2012-10-29 16:42:11 +00:00
|
|
|
ErrorBitfield test_pipe_playback(GM* gm,
|
|
|
|
const ConfigData& gRec,
|
2013-01-18 21:45:42 +00:00
|
|
|
const SkBitmap& referenceBitmap,
|
|
|
|
const char readPath []) {
|
2012-10-26 18:56:36 +00:00
|
|
|
ErrorBitfield errors = ERROR_NONE;
|
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) {
|
|
|
|
SkBitmap bitmap;
|
|
|
|
SkISize size = gm->getISize();
|
|
|
|
setup_bitmap(gRec, size, &bitmap);
|
|
|
|
SkCanvas canvas(bitmap);
|
|
|
|
PipeController pipeController(&canvas);
|
|
|
|
SkGPipeWriter writer;
|
|
|
|
SkCanvas* pipeCanvas = writer.startRecording(
|
|
|
|
&pipeController, gPipeWritingFlagCombos[i].flags);
|
2012-11-16 13:41:45 +00:00
|
|
|
invokeGM(gm, pipeCanvas, false, false);
|
2012-10-26 18:56:36 +00:00
|
|
|
writer.endRecording();
|
|
|
|
SkString string("-pipe");
|
|
|
|
string.append(gPipeWritingFlagCombos[i].name);
|
2013-01-18 21:45:42 +00:00
|
|
|
errors |= handle_test_results(gm, gRec, NULL, NULL,
|
|
|
|
string.c_str(), bitmap, NULL,
|
|
|
|
&referenceBitmap);
|
2012-10-26 18:56:36 +00:00
|
|
|
if (errors != ERROR_NONE) {
|
|
|
|
break;
|
|
|
|
}
|
2012-06-28 15:41:32 +00:00
|
|
|
}
|
2012-10-26 18:56:36 +00:00
|
|
|
return errors;
|
2012-06-28 15:41:32 +00:00
|
|
|
}
|
2012-06-04 17:17:36 +00:00
|
|
|
|
2012-10-29 16:42:11 +00:00
|
|
|
ErrorBitfield test_tiled_pipe_playback(
|
2013-01-18 21:45:42 +00:00
|
|
|
GM* gm, const ConfigData& gRec, const SkBitmap& referenceBitmap,
|
|
|
|
const char readPath []) {
|
2012-10-26 18:56:36 +00:00
|
|
|
ErrorBitfield errors = ERROR_NONE;
|
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) {
|
|
|
|
SkBitmap bitmap;
|
|
|
|
SkISize size = gm->getISize();
|
|
|
|
setup_bitmap(gRec, size, &bitmap);
|
|
|
|
SkCanvas canvas(bitmap);
|
|
|
|
TiledPipeController pipeController(bitmap);
|
|
|
|
SkGPipeWriter writer;
|
|
|
|
SkCanvas* pipeCanvas = writer.startRecording(
|
|
|
|
&pipeController, gPipeWritingFlagCombos[i].flags);
|
2012-11-16 13:41:45 +00:00
|
|
|
invokeGM(gm, pipeCanvas, false, false);
|
2012-10-26 18:56:36 +00:00
|
|
|
writer.endRecording();
|
|
|
|
SkString string("-tiled pipe");
|
|
|
|
string.append(gPipeWritingFlagCombos[i].name);
|
2013-01-18 21:45:42 +00:00
|
|
|
errors |= handle_test_results(gm, gRec, NULL, NULL,
|
|
|
|
string.c_str(), bitmap, NULL,
|
|
|
|
&referenceBitmap);
|
2012-10-26 18:56:36 +00:00
|
|
|
if (errors != ERROR_NONE) {
|
|
|
|
break;
|
|
|
|
}
|
2012-06-28 15:41:32 +00:00
|
|
|
}
|
2012-10-26 18:56:36 +00:00
|
|
|
return errors;
|
2012-06-28 15:41:32 +00:00
|
|
|
}
|
2012-10-29 16:42:11 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// member variables.
|
|
|
|
// They are public for now, to allow easier setting by tool_main().
|
|
|
|
//
|
|
|
|
|
2013-01-18 21:45:42 +00:00
|
|
|
// if true, emit a message when we can't find a reference image to compare
|
|
|
|
bool fNotifyMissingReadReference;
|
|
|
|
|
2012-10-29 16:42:11 +00:00
|
|
|
bool fUseFileHierarchy;
|
|
|
|
|
2013-01-11 21:04:40 +00:00
|
|
|
const char* fMismatchPath;
|
|
|
|
|
2012-11-13 03:41:55 +00:00
|
|
|
// information about all failed tests we have encountered so far
|
|
|
|
SkTArray<FailRec> fFailedTests;
|
|
|
|
|
2012-12-18 19:13:49 +00:00
|
|
|
Json::Value fJsonExpectedResults;
|
|
|
|
Json::Value fJsonActualResults_Failed;
|
|
|
|
Json::Value fJsonActualResults_FailureIgnored;
|
2012-12-20 18:34:29 +00:00
|
|
|
Json::Value fJsonActualResults_NoComparison;
|
2012-12-18 19:13:49 +00:00
|
|
|
Json::Value fJsonActualResults_Succeeded;
|
|
|
|
|
2012-10-26 18:56:36 +00:00
|
|
|
}; // end of GMMain class definition
|
2012-06-06 21:07:10 +00:00
|
|
|
|
2012-08-02 14:03:32 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
static const GLContextType kDontCare_GLContextType = GrContextFactory::kNative_GLContextType;
|
|
|
|
#else
|
|
|
|
static const GLContextType kDontCare_GLContextType = 0;
|
|
|
|
#endif
|
2012-04-19 19:15:35 +00:00
|
|
|
|
|
|
|
// If the platform does not support writing PNGs of PDFs then there will be no
|
2012-10-25 16:27:34 +00:00
|
|
|
// reference images to read. However, we can always write the .pdf files
|
2012-04-19 19:15:35 +00:00
|
|
|
static const ConfigFlags kPDFConfigFlags = CAN_IMAGE_PDF ? kRW_ConfigFlag :
|
|
|
|
kWrite_ConfigFlag;
|
|
|
|
|
2011-04-25 15:49:53 +00:00
|
|
|
static const ConfigData gRec[] = {
|
2012-04-19 19:15:35 +00:00
|
|
|
{ SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextType, 0, kRW_ConfigFlag, "8888" },
|
2012-11-29 21:21:54 +00:00
|
|
|
#if 0 // stop testing this (for now at least) since we want to remove support for it (soon please!!!)
|
2012-04-19 19:15:35 +00:00
|
|
|
{ SkBitmap::kARGB_4444_Config, kRaster_Backend, kDontCare_GLContextType, 0, kRW_ConfigFlag, "4444" },
|
2012-11-29 21:21:54 +00:00
|
|
|
#endif
|
2012-04-19 19:15:35 +00:00
|
|
|
{ SkBitmap::kRGB_565_Config, kRaster_Backend, kDontCare_GLContextType, 0, kRW_ConfigFlag, "565" },
|
2012-08-02 14:03:32 +00:00
|
|
|
#if defined(SK_SCALAR_IS_FLOAT) && SK_SUPPORT_GPU
|
2012-04-19 19:15:35 +00:00
|
|
|
{ SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kNative_GLContextType, 0, kRW_ConfigFlag, "gpu" },
|
2012-08-02 17:56:02 +00:00
|
|
|
#ifndef SK_BUILD_FOR_ANDROID
|
|
|
|
// currently we don't want to run MSAA tests on Android
|
2012-04-19 19:15:35 +00:00
|
|
|
{ SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kNative_GLContextType, 16, kRW_ConfigFlag, "msaa16" },
|
2012-08-02 17:56:02 +00:00
|
|
|
#endif
|
2012-04-19 19:15:35 +00:00
|
|
|
/* The debug context does not generate images */
|
|
|
|
{ SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kDebug_GLContextType, 0, kNone_ConfigFlag, "debug" },
|
2012-08-02 14:03:32 +00:00
|
|
|
#if SK_ANGLE
|
2012-04-19 19:15:35 +00:00
|
|
|
{ SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kANGLE_GLContextType, 0, kRW_ConfigFlag, "angle" },
|
|
|
|
{ SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kANGLE_GLContextType, 16, kRW_ConfigFlag, "anglemsaa16" },
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif // SK_ANGLE
|
|
|
|
#ifdef SK_MESA
|
2012-04-19 19:15:35 +00:00
|
|
|
{ SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kMESA_GLContextType, 0, kRW_ConfigFlag, "mesa" },
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif // SK_MESA
|
2012-08-02 17:56:02 +00:00
|
|
|
#endif // defined(SK_SCALAR_IS_FLOAT) && SK_SUPPORT_GPU
|
2011-10-10 13:19:10 +00:00
|
|
|
#ifdef SK_SUPPORT_XPS
|
2012-04-19 19:15:35 +00:00
|
|
|
/* At present we have no way of comparing XPS files (either natively or by converting to PNG). */
|
|
|
|
{ SkBitmap::kARGB_8888_Config, kXPS_Backend, kDontCare_GLContextType, 0, kWrite_ConfigFlag, "xps" },
|
2012-08-02 17:56:02 +00:00
|
|
|
#endif // SK_SUPPORT_XPS
|
2012-04-19 19:15:35 +00:00
|
|
|
#ifdef SK_SUPPORT_PDF
|
|
|
|
{ SkBitmap::kARGB_8888_Config, kPDF_Backend, kDontCare_GLContextType, 0, kPDFConfigFlags, "pdf" },
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif // SK_SUPPORT_PDF
|
2009-06-10 15:38:48 +00:00
|
|
|
};
|
|
|
|
|
2012-06-07 17:39:48 +00:00
|
|
|
static void usage(const char * argv0) {
|
|
|
|
SkDebugf("%s\n", argv0);
|
2012-06-22 15:27:39 +00:00
|
|
|
SkDebugf(" [--config ");
|
2012-06-07 17:39:48 +00:00
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
|
|
|
|
if (i > 0) {
|
|
|
|
SkDebugf("|");
|
|
|
|
}
|
|
|
|
SkDebugf(gRec[i].fName);
|
|
|
|
}
|
2012-10-29 18:59:17 +00:00
|
|
|
SkDebugf("]:\n run these configurations\n");
|
2012-06-07 17:39:48 +00:00
|
|
|
SkDebugf(
|
2012-10-29 18:59:17 +00:00
|
|
|
// Alphabetized ignoring "no" prefix ("readPath", "noreplay", "resourcePath").
|
|
|
|
// It would probably be better if we allowed both yes-and-no settings for each
|
|
|
|
// one, e.g.:
|
|
|
|
// [--replay|--noreplay]: whether to exercise SkPicture replay; default is yes
|
|
|
|
" [--nodeferred]: skip the deferred rendering test pass\n"
|
|
|
|
" [--disable-missing-warning]: don't print a message to stderr if\n"
|
|
|
|
" unable to read a reference image for any tests (NOT default behavior)\n"
|
|
|
|
" [--enable-missing-warning]: print message to stderr (but don't fail) if\n"
|
|
|
|
" unable to read a reference image for any tests (default behavior)\n"
|
2013-01-04 14:43:03 +00:00
|
|
|
" [--exclude-config]: disable this config (may be used multiple times)\n"
|
2012-10-29 18:59:17 +00:00
|
|
|
" [--forceBWtext]: disable text anti-aliasing\n"
|
|
|
|
" [--help|-h]: show this help message\n"
|
|
|
|
" [--hierarchy|--nohierarchy]: whether to use multilevel directory structure\n"
|
|
|
|
" when reading/writing files; default is no\n"
|
|
|
|
" [--match <substring>]: only run tests whose name includes this substring\n"
|
2013-01-11 21:04:40 +00:00
|
|
|
" [--mismatchPath <path>]: write images for tests that failed due to\n"
|
|
|
|
" pixel mismatched into this directory"
|
2012-10-29 18:59:17 +00:00
|
|
|
" [--modulo <remainder> <divisor>]: only run tests for which \n"
|
|
|
|
" testIndex %% divisor == remainder\n"
|
|
|
|
" [--nopdf]: skip the pdf rendering test pass\n"
|
|
|
|
" [--nopipe]: Skip SkGPipe replay\n"
|
|
|
|
" [--readPath|-r <path>]: read reference images from this dir, and report\n"
|
|
|
|
" any differences between those and the newly generated ones\n"
|
|
|
|
" [--noreplay]: do not exercise SkPicture replay\n"
|
|
|
|
" [--resourcePath|-i <path>]: directory that stores image resources\n"
|
2012-12-18 21:09:45 +00:00
|
|
|
" [--nortree]: Do not exercise the R-Tree variant of SkPicture\n"
|
2012-10-29 18:59:17 +00:00
|
|
|
" [--noserialize]: do not exercise SkPicture serialization & deserialization\n"
|
|
|
|
" [--notexturecache]: disable the gpu texture cache\n"
|
|
|
|
" [--tiledPipe]: Exercise tiled SkGPipe replay\n"
|
2012-12-18 21:09:45 +00:00
|
|
|
" [--notileGrid]: Do not exercise the tile grid variant of SkPicture\n"
|
2012-12-19 15:24:38 +00:00
|
|
|
" [--tileGridReplayScales <scales>]: Comma separated list of floating-point scale\n"
|
|
|
|
" factors to be used for tileGrid playback testing. Default value: 1.0\n"
|
2012-12-18 19:13:49 +00:00
|
|
|
" [--writeJsonSummary <path>]: write a JSON-formatted result summary to this file\n"
|
2013-01-04 14:43:03 +00:00
|
|
|
" [--verbose] print diagnostics (e.g. list each config to be tested)\n"
|
2012-10-29 18:59:17 +00:00
|
|
|
" [--writePath|-w <path>]: write rendered images into this directory\n"
|
|
|
|
" [--writePicturePath|-wp <path>]: write .skp files into this directory\n"
|
|
|
|
);
|
2012-06-07 17:39:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int findConfig(const char config[]) {
|
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) {
|
|
|
|
if (!strcmp(config, gRec[i].fName)) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-10-31 16:30:04 +00:00
|
|
|
static bool skip_name(const SkTDArray<const char*> array, const char name[]) {
|
|
|
|
if (0 == array.count()) {
|
|
|
|
// no names, so don't skip anything
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < array.count(); ++i) {
|
|
|
|
if (strstr(name, array[i])) {
|
|
|
|
// found the name, so don't skip
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-07-18 15:25:04 +00:00
|
|
|
namespace skiagm {
|
2012-08-02 14:03:32 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2012-04-19 19:15:35 +00:00
|
|
|
SkAutoTUnref<GrContext> gGrContext;
|
|
|
|
/**
|
2012-11-01 18:03:48 +00:00
|
|
|
* Sets the global GrContext, accessible by individual GMs
|
2012-04-19 19:15:35 +00:00
|
|
|
*/
|
2012-06-06 12:10:45 +00:00
|
|
|
static void SetGr(GrContext* grContext) {
|
2012-04-19 19:15:35 +00:00
|
|
|
SkSafeRef(grContext);
|
|
|
|
gGrContext.reset(grContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the global GrContext, can be called by GM tests.
|
|
|
|
*/
|
2012-06-06 12:10:45 +00:00
|
|
|
GrContext* GetGr();
|
2011-07-18 15:25:04 +00:00
|
|
|
GrContext* GetGr() {
|
2012-04-19 19:15:35 +00:00
|
|
|
return gGrContext.get();
|
2011-07-18 15:25:04 +00:00
|
|
|
}
|
2012-04-19 19:15:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the global GrContext and then resets it to its previous value at
|
|
|
|
* destruction.
|
|
|
|
*/
|
|
|
|
class AutoResetGr : SkNoncopyable {
|
|
|
|
public:
|
|
|
|
AutoResetGr() : fOld(NULL) {}
|
|
|
|
void set(GrContext* context) {
|
|
|
|
SkASSERT(NULL == fOld);
|
|
|
|
fOld = GetGr();
|
|
|
|
SkSafeRef(fOld);
|
|
|
|
SetGr(context);
|
|
|
|
}
|
|
|
|
~AutoResetGr() { SetGr(fOld); SkSafeUnref(fOld); }
|
|
|
|
private:
|
|
|
|
GrContext* fOld;
|
|
|
|
};
|
2012-08-02 14:03:32 +00:00
|
|
|
#else
|
|
|
|
GrContext* GetGr() { return NULL; }
|
|
|
|
#endif
|
2011-07-18 15:25:04 +00:00
|
|
|
}
|
|
|
|
|
2013-01-04 14:43:03 +00:00
|
|
|
template <typename T> void appendUnique(SkTDArray<T>* array, const T& value) {
|
|
|
|
int index = array->find(value);
|
|
|
|
if (index < 0) {
|
|
|
|
*array->append() = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-02 18:33:14 +00:00
|
|
|
int tool_main(int argc, char** argv);
|
|
|
|
int tool_main(int argc, char** argv) {
|
2012-06-27 19:41:42 +00:00
|
|
|
|
2013-01-15 20:37:04 +00:00
|
|
|
#if SK_ENABLE_INST_COUNT
|
2012-06-27 19:41:42 +00:00
|
|
|
gPrintInstCount = true;
|
|
|
|
#endif
|
|
|
|
|
2012-06-05 19:35:09 +00:00
|
|
|
SkGraphics::Init();
|
2011-11-08 14:59:38 +00:00
|
|
|
// we don't need to see this during a run
|
|
|
|
gSkSuppressFontCachePurgeSpew = true;
|
2011-01-18 21:05:42 +00:00
|
|
|
|
2012-02-14 14:53:59 +00:00
|
|
|
setSystemPreferences();
|
2012-10-26 18:56:36 +00:00
|
|
|
GMMain gmmain;
|
2012-02-14 14:53:59 +00:00
|
|
|
|
2012-12-18 19:13:49 +00:00
|
|
|
const char* writeJsonSummaryPath = NULL;// if non-null, where we write the JSON summary
|
2009-06-21 00:49:18 +00:00
|
|
|
const char* writePath = NULL; // if non-null, where we write the originals
|
2012-06-02 14:50:13 +00:00
|
|
|
const char* writePicturePath = NULL; // if non-null, where we write serialized pictures
|
2009-06-21 00:49:18 +00:00
|
|
|
const char* readPath = NULL; // if non-null, were we read from to compare
|
2012-03-20 17:40:58 +00:00
|
|
|
const char* resourcePath = NULL;// if non-null, where we read from for image resources
|
2009-06-21 00:49:18 +00:00
|
|
|
|
2011-10-31 16:30:04 +00:00
|
|
|
SkTDArray<const char*> fMatches;
|
2012-01-31 18:35:30 +00:00
|
|
|
|
2011-09-19 19:01:38 +00:00
|
|
|
bool doPDF = true;
|
2011-05-26 15:57:56 +00:00
|
|
|
bool doReplay = true;
|
2012-06-28 15:41:32 +00:00
|
|
|
bool doPipe = true;
|
2012-06-06 21:07:10 +00:00
|
|
|
bool doTiledPipe = false;
|
2012-09-14 17:37:46 +00:00
|
|
|
bool doSerialize = true;
|
2012-01-18 16:21:08 +00:00
|
|
|
bool doDeferred = true;
|
2012-12-18 21:09:45 +00:00
|
|
|
bool doRTree = true;
|
|
|
|
bool doTileGrid = true;
|
2013-01-04 14:43:03 +00:00
|
|
|
bool doVerbose = false;
|
2012-01-31 18:35:30 +00:00
|
|
|
bool disableTextureCache = false;
|
2012-06-07 17:39:48 +00:00
|
|
|
SkTDArray<size_t> configs;
|
2013-01-04 14:43:03 +00:00
|
|
|
SkTDArray<size_t> excludeConfigs;
|
2012-12-19 15:24:38 +00:00
|
|
|
SkTDArray<SkScalar> tileGridReplayScales;
|
|
|
|
*tileGridReplayScales.append() = SK_Scalar1; // By default only test at scale 1.0
|
2012-06-07 17:39:48 +00:00
|
|
|
bool userConfig = false;
|
2012-01-31 18:35:30 +00:00
|
|
|
|
2012-10-29 18:59:17 +00:00
|
|
|
int moduloRemainder = -1;
|
|
|
|
int moduloDivisor = -1;
|
2012-10-18 21:30:57 +00:00
|
|
|
|
2011-04-25 15:49:53 +00:00
|
|
|
const char* const commandName = argv[0];
|
2009-06-21 00:49:18 +00:00
|
|
|
char* const* stop = argv + argc;
|
|
|
|
for (++argv; argv < stop; ++argv) {
|
2012-10-29 18:59:17 +00:00
|
|
|
if (strcmp(*argv, "--config") == 0) {
|
2012-06-02 14:50:13 +00:00
|
|
|
argv++;
|
2012-10-29 18:59:17 +00:00
|
|
|
if (argv < stop) {
|
|
|
|
int index = findConfig(*argv);
|
|
|
|
if (index >= 0) {
|
2013-01-04 14:43:03 +00:00
|
|
|
appendUnique<size_t>(&configs, index);
|
2012-10-29 18:59:17 +00:00
|
|
|
userConfig = true;
|
|
|
|
} else {
|
|
|
|
SkString str;
|
|
|
|
str.printf("unrecognized config %s\n", *argv);
|
|
|
|
SkDebugf(str.c_str());
|
|
|
|
usage(commandName);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SkDebugf("missing arg for --config\n");
|
|
|
|
usage(commandName);
|
|
|
|
return -1;
|
2009-06-21 00:49:18 +00:00
|
|
|
}
|
2013-01-04 14:43:03 +00:00
|
|
|
} else if (strcmp(*argv, "--exclude-config") == 0) {
|
|
|
|
argv++;
|
|
|
|
if (argv < stop) {
|
|
|
|
int index = findConfig(*argv);
|
|
|
|
if (index >= 0) {
|
|
|
|
*excludeConfigs.append() = index;
|
|
|
|
} else {
|
|
|
|
SkString str;
|
|
|
|
str.printf("unrecognized exclude-config %s\n", *argv);
|
|
|
|
SkDebugf(str.c_str());
|
|
|
|
usage(commandName);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SkDebugf("missing arg for --exclude-config\n");
|
|
|
|
usage(commandName);
|
|
|
|
return -1;
|
|
|
|
}
|
2012-10-29 18:59:17 +00:00
|
|
|
} else if (strcmp(*argv, "--nodeferred") == 0) {
|
|
|
|
doDeferred = false;
|
|
|
|
} else if (strcmp(*argv, "--disable-missing-warning") == 0) {
|
2013-01-18 21:45:42 +00:00
|
|
|
gmmain.fNotifyMissingReadReference = false;
|
2013-01-11 21:04:40 +00:00
|
|
|
} else if (strcmp(*argv, "--mismatchPath") == 0) {
|
|
|
|
argv++;
|
|
|
|
if (argv < stop && **argv) {
|
|
|
|
gmmain.fMismatchPath = *argv;
|
|
|
|
}
|
2012-12-18 21:09:45 +00:00
|
|
|
} else if (strcmp(*argv, "--nortree") == 0) {
|
|
|
|
doRTree = false;
|
|
|
|
} else if (strcmp(*argv, "--notileGrid") == 0) {
|
|
|
|
doTileGrid = false;
|
2012-12-19 15:24:38 +00:00
|
|
|
} else if (strcmp(*argv, "--tileGridReplayScales") == 0) {
|
|
|
|
tileGridReplayScales.reset();
|
|
|
|
++argv;
|
|
|
|
if (argv < stop) {
|
|
|
|
char* token = strtok(*argv, ",");
|
|
|
|
while (NULL != token) {
|
|
|
|
double val = atof(token);
|
|
|
|
if (0 < val) {
|
|
|
|
*tileGridReplayScales.append() = SkDoubleToScalar(val);
|
|
|
|
}
|
|
|
|
token = strtok(NULL, ",");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (0 == tileGridReplayScales.count()) {
|
|
|
|
// Should have at least one scale
|
|
|
|
usage(commandName);
|
|
|
|
return -1;
|
|
|
|
}
|
2012-10-29 18:59:17 +00:00
|
|
|
} else if (strcmp(*argv, "--enable-missing-warning") == 0) {
|
2013-01-18 21:45:42 +00:00
|
|
|
gmmain.fNotifyMissingReadReference = true;
|
2011-12-30 16:02:53 +00:00
|
|
|
} else if (strcmp(*argv, "--forceBWtext") == 0) {
|
|
|
|
gForceBWtext = true;
|
2012-10-29 18:59:17 +00:00
|
|
|
} else if (strcmp(*argv, "--help") == 0 || strcmp(*argv, "-h") == 0) {
|
|
|
|
usage(commandName);
|
|
|
|
return -1;
|
|
|
|
} else if (strcmp(*argv, "--hierarchy") == 0) {
|
|
|
|
gmmain.fUseFileHierarchy = true;
|
|
|
|
} else if (strcmp(*argv, "--nohierarchy") == 0) {
|
|
|
|
gmmain.fUseFileHierarchy = false;
|
|
|
|
} else if (strcmp(*argv, "--match") == 0) {
|
|
|
|
++argv;
|
|
|
|
if (argv < stop && **argv) {
|
|
|
|
// just record the ptr, no need for a deep copy
|
|
|
|
*fMatches.append() = *argv;
|
|
|
|
}
|
2012-10-18 21:30:57 +00:00
|
|
|
} else if (strcmp(*argv, "--modulo") == 0) {
|
|
|
|
++argv;
|
|
|
|
if (argv >= stop) {
|
|
|
|
continue;
|
|
|
|
}
|
2012-10-29 18:59:17 +00:00
|
|
|
moduloRemainder = atoi(*argv);
|
2012-10-19 02:01:19 +00:00
|
|
|
|
2012-10-18 21:30:57 +00:00
|
|
|
++argv;
|
|
|
|
if (argv >= stop) {
|
|
|
|
continue;
|
|
|
|
}
|
2012-10-29 18:59:17 +00:00
|
|
|
moduloDivisor = atoi(*argv);
|
2012-11-01 18:03:48 +00:00
|
|
|
if (moduloRemainder < 0 || moduloDivisor <= 0 || moduloRemainder >= moduloDivisor) {
|
|
|
|
SkDebugf("invalid modulo values.");
|
|
|
|
return -1;
|
|
|
|
}
|
2012-10-29 18:59:17 +00:00
|
|
|
} else if (strcmp(*argv, "--nopdf") == 0) {
|
|
|
|
doPDF = false;
|
|
|
|
} else if (strcmp(*argv, "--nopipe") == 0) {
|
|
|
|
doPipe = false;
|
|
|
|
} else if ((0 == strcmp(*argv, "--readPath")) ||
|
|
|
|
(0 == strcmp(*argv, "-r"))) {
|
|
|
|
argv++;
|
|
|
|
if (argv < stop && **argv) {
|
|
|
|
readPath = *argv;
|
|
|
|
}
|
|
|
|
} else if (strcmp(*argv, "--noreplay") == 0) {
|
|
|
|
doReplay = false;
|
|
|
|
} else if ((0 == strcmp(*argv, "--resourcePath")) ||
|
|
|
|
(0 == strcmp(*argv, "-i"))) {
|
|
|
|
argv++;
|
|
|
|
if (argv < stop && **argv) {
|
|
|
|
resourcePath = *argv;
|
|
|
|
}
|
2011-04-25 19:20:54 +00:00
|
|
|
} else if (strcmp(*argv, "--serialize") == 0) {
|
2012-06-15 13:46:44 +00:00
|
|
|
doSerialize = true;
|
2012-09-14 17:37:46 +00:00
|
|
|
} else if (strcmp(*argv, "--noserialize") == 0) {
|
|
|
|
doSerialize = false;
|
2012-01-31 18:35:30 +00:00
|
|
|
} else if (strcmp(*argv, "--notexturecache") == 0) {
|
2012-03-20 17:40:58 +00:00
|
|
|
disableTextureCache = true;
|
2012-10-29 18:59:17 +00:00
|
|
|
} else if (strcmp(*argv, "--tiledPipe") == 0) {
|
|
|
|
doTiledPipe = true;
|
2013-01-04 14:43:03 +00:00
|
|
|
} else if (!strcmp(*argv, "--verbose") || !strcmp(*argv, "-v")) {
|
|
|
|
doVerbose = true;
|
2012-10-29 18:59:17 +00:00
|
|
|
} else if ((0 == strcmp(*argv, "--writePath")) ||
|
|
|
|
(0 == strcmp(*argv, "-w"))) {
|
2012-06-07 17:39:48 +00:00
|
|
|
argv++;
|
2012-10-29 18:59:17 +00:00
|
|
|
if (argv < stop && **argv) {
|
|
|
|
writePath = *argv;
|
|
|
|
}
|
2012-12-18 19:13:49 +00:00
|
|
|
} else if (0 == strcmp(*argv, "--writeJsonSummary")) {
|
|
|
|
argv++;
|
|
|
|
if (argv < stop && **argv) {
|
|
|
|
writeJsonSummaryPath = *argv;
|
|
|
|
}
|
2012-10-29 18:59:17 +00:00
|
|
|
} else if ((0 == strcmp(*argv, "--writePicturePath")) ||
|
|
|
|
(0 == strcmp(*argv, "-wp"))) {
|
|
|
|
argv++;
|
|
|
|
if (argv < stop && **argv) {
|
|
|
|
writePicturePath = *argv;
|
2012-06-07 17:39:48 +00:00
|
|
|
}
|
2011-04-25 15:49:53 +00:00
|
|
|
} else {
|
2012-03-20 17:40:58 +00:00
|
|
|
usage(commandName);
|
|
|
|
return -1;
|
2011-04-25 15:49:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (argv != stop) {
|
2012-03-20 17:40:58 +00:00
|
|
|
usage(commandName);
|
|
|
|
return -1;
|
2011-04-25 15:49:53 +00:00
|
|
|
}
|
2010-12-23 15:00:45 +00:00
|
|
|
|
2012-06-07 17:39:48 +00:00
|
|
|
if (!userConfig) {
|
|
|
|
// if no config is specified by user, we add them all.
|
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
|
|
|
|
*configs.append() = i;
|
|
|
|
}
|
|
|
|
}
|
2013-01-04 14:43:03 +00:00
|
|
|
// now remove any explicitly excluded configs
|
|
|
|
for (int i = 0; i < excludeConfigs.count(); ++i) {
|
|
|
|
int index = configs.find(excludeConfigs[i]);
|
|
|
|
if (index >= 0) {
|
|
|
|
configs.remove(index);
|
|
|
|
// now assert that there was only one copy in configs[]
|
|
|
|
SkASSERT(configs.find(excludeConfigs[i]) < 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (doVerbose) {
|
|
|
|
SkString str;
|
|
|
|
str.printf("gm: %d configs:", configs.count());
|
|
|
|
for (int i = 0; i < configs.count(); ++i) {
|
|
|
|
str.appendf(" %s", gRec[configs[i]].fName);
|
|
|
|
}
|
|
|
|
SkDebugf("%s\n", str.c_str());
|
|
|
|
}
|
2012-06-07 17:39:48 +00:00
|
|
|
|
2012-03-20 17:40:58 +00:00
|
|
|
GM::SetResourcePath(resourcePath);
|
|
|
|
|
2010-12-14 17:46:14 +00:00
|
|
|
if (readPath) {
|
2013-01-18 21:45:42 +00:00
|
|
|
fprintf(stderr, "reading from %s\n", readPath);
|
2012-07-12 15:42:37 +00:00
|
|
|
}
|
2012-04-18 13:36:54 +00:00
|
|
|
if (writePath) {
|
2010-12-14 17:46:14 +00:00
|
|
|
fprintf(stderr, "writing to %s\n", writePath);
|
|
|
|
}
|
2012-06-02 14:50:13 +00:00
|
|
|
if (writePicturePath) {
|
|
|
|
fprintf(stderr, "writing pictures to %s\n", writePicturePath);
|
|
|
|
}
|
2012-03-20 17:40:58 +00:00
|
|
|
if (resourcePath) {
|
|
|
|
fprintf(stderr, "reading resources from %s\n", resourcePath);
|
|
|
|
}
|
|
|
|
|
2012-10-29 18:59:17 +00:00
|
|
|
if (moduloDivisor <= 0) {
|
|
|
|
moduloRemainder = -1;
|
2012-10-18 21:30:57 +00:00
|
|
|
}
|
2012-10-29 18:59:17 +00:00
|
|
|
if (moduloRemainder < 0 || moduloRemainder >= moduloDivisor) {
|
|
|
|
moduloRemainder = -1;
|
2012-10-18 21:30:57 +00:00
|
|
|
}
|
|
|
|
|
2011-12-28 19:31:01 +00:00
|
|
|
// Accumulate success of all tests.
|
|
|
|
int testsRun = 0;
|
|
|
|
int testsPassed = 0;
|
|
|
|
int testsFailed = 0;
|
|
|
|
int testsMissingReferenceImages = 0;
|
|
|
|
|
2012-08-02 14:03:32 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
GrContextFactory* grFactory = new GrContextFactory;
|
2012-01-31 18:35:30 +00:00
|
|
|
if (disableTextureCache) {
|
|
|
|
skiagm::GetGr()->setTextureCacheLimits(0, 0);
|
|
|
|
}
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif
|
2012-01-31 18:35:30 +00:00
|
|
|
|
2012-10-18 21:30:57 +00:00
|
|
|
int gmIndex = -1;
|
|
|
|
SkString moduloStr;
|
|
|
|
|
2012-10-29 16:42:11 +00:00
|
|
|
// If we will be writing out files, prepare subdirectories.
|
|
|
|
if (writePath) {
|
|
|
|
if (!sk_mkdir(writePath)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (gmmain.fUseFileHierarchy) {
|
|
|
|
for (int i = 0; i < configs.count(); i++) {
|
|
|
|
ConfigData config = gRec[configs[i]];
|
|
|
|
SkString subdir;
|
|
|
|
subdir.appendf("%s%c%s", writePath, SkPATH_SEPARATOR,
|
|
|
|
config.fName);
|
|
|
|
if (!sk_mkdir(subdir.c_str())) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-19 19:15:35 +00:00
|
|
|
Iter iter;
|
|
|
|
GM* gm;
|
2009-06-10 15:38:48 +00:00
|
|
|
while ((gm = iter.next()) != NULL) {
|
2012-10-19 02:01:19 +00:00
|
|
|
|
2012-10-18 21:30:57 +00:00
|
|
|
++gmIndex;
|
2012-10-29 18:59:17 +00:00
|
|
|
if (moduloRemainder >= 0) {
|
|
|
|
if ((gmIndex % moduloDivisor) != moduloRemainder) {
|
2012-10-18 21:30:57 +00:00
|
|
|
continue;
|
|
|
|
}
|
2012-10-29 18:59:17 +00:00
|
|
|
moduloStr.printf("[%d.%d] ", gmIndex, moduloDivisor);
|
2012-10-18 21:30:57 +00:00
|
|
|
}
|
|
|
|
|
2011-07-25 14:28:57 +00:00
|
|
|
const char* shortName = gm->shortName();
|
2011-10-31 16:30:04 +00:00
|
|
|
if (skip_name(fMatches, shortName)) {
|
2011-07-25 14:28:57 +00:00
|
|
|
SkDELETE(gm);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-04-25 15:49:53 +00:00
|
|
|
SkISize size = gm->getISize();
|
2012-10-18 21:30:57 +00:00
|
|
|
SkDebugf("%sdrawing... %s [%d %d]\n", moduloStr.c_str(), shortName,
|
2009-06-21 00:49:18 +00:00
|
|
|
size.width(), size.height());
|
2012-10-26 14:07:13 +00:00
|
|
|
|
|
|
|
ErrorBitfield testErrors = ERROR_NONE;
|
|
|
|
uint32_t gmFlags = gm->getFlags();
|
2009-06-21 00:49:18 +00:00
|
|
|
|
2012-06-07 17:39:48 +00:00
|
|
|
for (int i = 0; i < configs.count(); i++) {
|
|
|
|
ConfigData config = gRec[configs[i]];
|
2012-10-29 16:42:11 +00:00
|
|
|
|
2011-12-28 19:31:01 +00:00
|
|
|
// Skip any tests that we don't even need to try.
|
2012-06-07 17:39:48 +00:00
|
|
|
if ((kPDF_Backend == config.fBackend) &&
|
2011-09-19 19:31:04 +00:00
|
|
|
(!doPDF || (gmFlags & GM::kSkipPDF_Flag)))
|
2012-10-26 18:56:36 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2012-10-10 15:17:24 +00:00
|
|
|
if ((gmFlags & GM::kSkip565_Flag) &&
|
|
|
|
(kRaster_Backend == config.fBackend) &&
|
|
|
|
(SkBitmap::kRGB_565_Config == config.fConfig)) {
|
|
|
|
continue;
|
|
|
|
}
|
2011-09-19 19:01:38 +00:00
|
|
|
|
2011-12-28 19:31:01 +00:00
|
|
|
// Now we know that we want to run this test and record its
|
|
|
|
// success or failure.
|
2012-10-26 14:07:13 +00:00
|
|
|
ErrorBitfield renderErrors = ERROR_NONE;
|
2012-08-02 14:03:32 +00:00
|
|
|
GrRenderTarget* renderTarget = NULL;
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
SkAutoTUnref<GrRenderTarget> rt;
|
|
|
|
AutoResetGr autogr;
|
2012-10-26 14:07:13 +00:00
|
|
|
if ((ERROR_NONE == renderErrors) &&
|
2012-08-02 14:03:32 +00:00
|
|
|
kGPU_Backend == config.fBackend) {
|
|
|
|
GrContext* gr = grFactory->get(config.fGLContextType);
|
|
|
|
bool grSuccess = false;
|
|
|
|
if (gr) {
|
|
|
|
// create a render target to back the device
|
|
|
|
GrTextureDesc desc;
|
|
|
|
desc.fConfig = kSkia8888_PM_GrPixelConfig;
|
|
|
|
desc.fFlags = kRenderTarget_GrTextureFlagBit;
|
|
|
|
desc.fWidth = gm->getISize().width();
|
|
|
|
desc.fHeight = gm->getISize().height();
|
|
|
|
desc.fSampleCnt = config.fSampleCnt;
|
|
|
|
GrTexture* tex = gr->createUncachedTexture(desc, NULL, 0);
|
|
|
|
if (tex) {
|
|
|
|
rt.reset(tex->asRenderTarget());
|
|
|
|
rt.get()->ref();
|
|
|
|
tex->unref();
|
|
|
|
autogr.set(gr);
|
|
|
|
renderTarget = rt.get();
|
|
|
|
grSuccess = NULL != renderTarget;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!grSuccess) {
|
2012-10-26 14:07:13 +00:00
|
|
|
renderErrors |= ERROR_NO_GPU_CONTEXT;
|
2012-08-02 14:03:32 +00:00
|
|
|
}
|
2011-04-25 19:20:54 +00:00
|
|
|
}
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif
|
2011-04-25 15:49:53 +00:00
|
|
|
|
2012-10-26 14:07:13 +00:00
|
|
|
SkBitmap comparisonBitmap;
|
|
|
|
|
|
|
|
if (ERROR_NONE == renderErrors) {
|
2012-10-26 18:56:36 +00:00
|
|
|
renderErrors |= gmmain.test_drawing(gm, config, writePath,
|
2013-01-18 21:45:42 +00:00
|
|
|
readPath, GetGr(),
|
2012-10-26 18:56:36 +00:00
|
|
|
renderTarget,
|
2012-11-13 03:41:55 +00:00
|
|
|
&comparisonBitmap);
|
2011-12-28 19:31:01 +00:00
|
|
|
}
|
|
|
|
|
2012-10-26 14:07:13 +00:00
|
|
|
if (doDeferred && !renderErrors &&
|
2012-06-07 17:39:48 +00:00
|
|
|
(kGPU_Backend == config.fBackend ||
|
|
|
|
kRaster_Backend == config.fBackend)) {
|
2012-10-26 18:56:36 +00:00
|
|
|
renderErrors |= gmmain.test_deferred_drawing(gm, config,
|
|
|
|
comparisonBitmap,
|
2013-01-08 18:47:31 +00:00
|
|
|
GetGr(),
|
2012-10-26 18:56:36 +00:00
|
|
|
renderTarget);
|
2012-01-18 16:21:08 +00:00
|
|
|
}
|
|
|
|
|
2012-10-26 14:07:13 +00:00
|
|
|
testErrors |= renderErrors;
|
|
|
|
}
|
2011-12-28 19:31:01 +00:00
|
|
|
|
2012-10-26 14:07:13 +00:00
|
|
|
SkBitmap comparisonBitmap;
|
|
|
|
const ConfigData compareConfig =
|
|
|
|
{ SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextType, 0, kRW_ConfigFlag, "comparison" };
|
2012-10-26 18:56:36 +00:00
|
|
|
testErrors |= gmmain.generate_image(gm, compareConfig, NULL, NULL, &comparisonBitmap, false);
|
2012-06-04 17:17:36 +00:00
|
|
|
|
2012-10-26 14:07:13 +00:00
|
|
|
// run the picture centric GM steps
|
|
|
|
if (!(gmFlags & GM::kSkipPicture_Flag)) {
|
|
|
|
|
|
|
|
ErrorBitfield pictErrors = ERROR_NONE;
|
|
|
|
|
|
|
|
//SkAutoTUnref<SkPicture> pict(generate_new_picture(gm));
|
2013-01-16 18:43:36 +00:00
|
|
|
SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0);
|
2012-10-26 14:07:13 +00:00
|
|
|
SkAutoUnref aur(pict);
|
|
|
|
|
|
|
|
if ((ERROR_NONE == testErrors) && doReplay) {
|
|
|
|
SkBitmap bitmap;
|
2012-10-26 18:56:36 +00:00
|
|
|
gmmain.generate_image_from_picture(gm, compareConfig, pict,
|
|
|
|
&bitmap);
|
2013-01-18 21:45:42 +00:00
|
|
|
pictErrors |= gmmain.handle_test_results(gm, compareConfig,
|
|
|
|
NULL, NULL,
|
|
|
|
"-replay", bitmap,
|
|
|
|
NULL,
|
|
|
|
&comparisonBitmap);
|
2012-06-06 21:07:10 +00:00
|
|
|
}
|
|
|
|
|
2012-10-26 18:56:36 +00:00
|
|
|
if ((ERROR_NONE == testErrors) &&
|
|
|
|
(ERROR_NONE == pictErrors) &&
|
|
|
|
doSerialize) {
|
|
|
|
SkPicture* repict = gmmain.stream_to_new_picture(*pict);
|
2012-10-26 14:07:13 +00:00
|
|
|
SkAutoUnref aurr(repict);
|
|
|
|
|
|
|
|
SkBitmap bitmap;
|
2012-10-26 18:56:36 +00:00
|
|
|
gmmain.generate_image_from_picture(gm, compareConfig, repict,
|
|
|
|
&bitmap);
|
2013-01-18 21:45:42 +00:00
|
|
|
pictErrors |= gmmain.handle_test_results(gm, compareConfig,
|
|
|
|
NULL, NULL,
|
|
|
|
"-serialize", bitmap,
|
|
|
|
NULL,
|
|
|
|
&comparisonBitmap);
|
2011-12-28 19:31:01 +00:00
|
|
|
}
|
2012-07-12 15:42:37 +00:00
|
|
|
|
2012-10-26 14:07:13 +00:00
|
|
|
if (writePicturePath) {
|
|
|
|
const char* pictureSuffix = "skp";
|
2013-01-18 21:45:42 +00:00
|
|
|
SkString path = gmmain.make_filename(writePicturePath, "",
|
|
|
|
SkString(gm->shortName()),
|
|
|
|
pictureSuffix);
|
2012-10-26 14:07:13 +00:00
|
|
|
SkFILEWStream stream(path.c_str());
|
|
|
|
pict->serialize(&stream);
|
2012-06-02 14:50:13 +00:00
|
|
|
}
|
2011-12-28 19:31:01 +00:00
|
|
|
|
2012-10-26 14:07:13 +00:00
|
|
|
testErrors |= pictErrors;
|
|
|
|
}
|
2012-08-02 16:22:47 +00:00
|
|
|
|
2012-12-18 21:09:45 +00:00
|
|
|
if (!(gmFlags & GM::kSkipPicture_Flag) && doRTree) {
|
2013-01-18 21:45:42 +00:00
|
|
|
SkPicture* pict = gmmain.generate_new_picture(gm, kRTree_BbhType,
|
|
|
|
SkPicture::kUsePathBoundsForClip_RecordingFlag);
|
2012-12-18 21:09:45 +00:00
|
|
|
SkAutoUnref aur(pict);
|
|
|
|
SkBitmap bitmap;
|
|
|
|
gmmain.generate_image_from_picture(gm, compareConfig, pict,
|
|
|
|
&bitmap);
|
2013-01-18 21:45:42 +00:00
|
|
|
testErrors |= gmmain.handle_test_results(gm, compareConfig,
|
|
|
|
NULL, NULL,
|
|
|
|
"-rtree", bitmap,
|
|
|
|
NULL,
|
|
|
|
&comparisonBitmap);
|
2012-12-18 21:09:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(gmFlags & GM::kSkipPicture_Flag) && doTileGrid) {
|
2012-12-19 15:24:38 +00:00
|
|
|
for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); ++scaleIndex) {
|
|
|
|
SkScalar replayScale = tileGridReplayScales[scaleIndex];
|
2013-01-14 16:27:50 +00:00
|
|
|
if ((gmFlags & GM::kSkipScaledReplay_Flag) && replayScale != 1)
|
|
|
|
continue;
|
2012-12-19 15:24:38 +00:00
|
|
|
// We record with the reciprocal scale to obtain a replay
|
|
|
|
// result that can be validated against comparisonBitmap.
|
|
|
|
SkScalar recordScale = SkScalarInvert(replayScale);
|
2013-01-18 21:45:42 +00:00
|
|
|
SkPicture* pict = gmmain.generate_new_picture(gm, kTileGrid_BbhType,
|
|
|
|
SkPicture::kUsePathBoundsForClip_RecordingFlag, recordScale);
|
2012-12-19 15:24:38 +00:00
|
|
|
SkAutoUnref aur(pict);
|
|
|
|
SkBitmap bitmap;
|
|
|
|
gmmain.generate_image_from_picture(gm, compareConfig, pict,
|
|
|
|
&bitmap, replayScale);
|
|
|
|
SkString suffix("-tilegrid");
|
|
|
|
if (SK_Scalar1 != replayScale) {
|
|
|
|
suffix += "-scale-";
|
|
|
|
suffix.appendScalar(replayScale);
|
|
|
|
}
|
2013-01-18 21:45:42 +00:00
|
|
|
testErrors |= gmmain.handle_test_results(gm, compareConfig,
|
|
|
|
NULL, NULL,
|
|
|
|
suffix.c_str(), bitmap,
|
|
|
|
NULL,
|
|
|
|
&comparisonBitmap);
|
2012-12-19 15:24:38 +00:00
|
|
|
}
|
2012-12-18 21:09:45 +00:00
|
|
|
}
|
|
|
|
|
2012-10-26 14:07:13 +00:00
|
|
|
// run the pipe centric GM steps
|
|
|
|
if (!(gmFlags & GM::kSkipPipe_Flag)) {
|
|
|
|
|
|
|
|
ErrorBitfield pipeErrors = ERROR_NONE;
|
|
|
|
|
|
|
|
if ((ERROR_NONE == testErrors) && doPipe) {
|
2012-10-26 18:56:36 +00:00
|
|
|
pipeErrors |= gmmain.test_pipe_playback(gm, compareConfig,
|
2013-01-18 21:45:42 +00:00
|
|
|
comparisonBitmap,
|
|
|
|
readPath);
|
2012-10-26 14:07:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((ERROR_NONE == testErrors) &&
|
|
|
|
(ERROR_NONE == pipeErrors) &&
|
|
|
|
doTiledPipe && !(gmFlags & GM::kSkipTiled_Flag)) {
|
2012-10-26 18:56:36 +00:00
|
|
|
pipeErrors |= gmmain.test_tiled_pipe_playback(gm, compareConfig,
|
2013-01-18 21:45:42 +00:00
|
|
|
comparisonBitmap,
|
|
|
|
readPath);
|
2011-04-25 19:20:54 +00:00
|
|
|
}
|
2012-10-26 14:07:13 +00:00
|
|
|
|
|
|
|
testErrors |= pipeErrors;
|
2011-04-25 15:49:53 +00:00
|
|
|
}
|
2012-10-26 14:07:13 +00:00
|
|
|
|
|
|
|
// Update overall results.
|
|
|
|
// We only tabulate the particular error types that we currently
|
|
|
|
// care about (e.g., missing reference images). Later on, if we
|
2013-01-18 21:45:42 +00:00
|
|
|
// want to also tabulate pixel mismatches vs dimension mistmatches
|
|
|
|
// (or whatever else), we can do so.
|
2012-10-26 14:07:13 +00:00
|
|
|
testsRun++;
|
2013-01-18 21:45:42 +00:00
|
|
|
if (!readPath || (ERROR_READING_REFERENCE_IMAGE & testErrors)) {
|
2012-10-26 14:07:13 +00:00
|
|
|
testsMissingReferenceImages++;
|
2013-01-10 17:11:27 +00:00
|
|
|
} else if (ERROR_NONE == testErrors) {
|
|
|
|
testsPassed++;
|
2012-10-26 14:07:13 +00:00
|
|
|
} else {
|
|
|
|
testsFailed++;
|
|
|
|
}
|
|
|
|
|
2009-06-10 15:38:48 +00:00
|
|
|
SkDELETE(gm);
|
|
|
|
}
|
2012-08-02 16:22:47 +00:00
|
|
|
SkDebugf("Ran %d tests: %d passed, %d failed, %d missing reference images\n",
|
|
|
|
testsRun, testsPassed, testsFailed, testsMissingReferenceImages);
|
2012-11-13 03:41:55 +00:00
|
|
|
gmmain.ListErrors();
|
2012-08-22 10:57:05 +00:00
|
|
|
|
2012-12-18 19:13:49 +00:00
|
|
|
if (NULL != writeJsonSummaryPath) {
|
|
|
|
Json::Value actualResults;
|
|
|
|
actualResults[kJsonKey_ActualResults_Failed] =
|
|
|
|
gmmain.fJsonActualResults_Failed;
|
|
|
|
actualResults[kJsonKey_ActualResults_FailureIgnored] =
|
|
|
|
gmmain.fJsonActualResults_FailureIgnored;
|
2012-12-20 18:34:29 +00:00
|
|
|
actualResults[kJsonKey_ActualResults_NoComparison] =
|
|
|
|
gmmain.fJsonActualResults_NoComparison;
|
2012-12-18 19:13:49 +00:00
|
|
|
actualResults[kJsonKey_ActualResults_Succeeded] =
|
|
|
|
gmmain.fJsonActualResults_Succeeded;
|
|
|
|
Json::Value root;
|
|
|
|
root[kJsonKey_ActualResults] = actualResults;
|
|
|
|
root[kJsonKey_ExpectedResults] = gmmain.fJsonExpectedResults;
|
|
|
|
std::string jsonStdString = root.toStyledString();
|
|
|
|
SkFILEWStream stream(writeJsonSummaryPath);
|
|
|
|
stream.write(jsonStdString.c_str(), jsonStdString.length());
|
|
|
|
}
|
|
|
|
|
2012-08-02 14:03:32 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2012-08-22 10:57:05 +00:00
|
|
|
|
2012-08-31 13:07:37 +00:00
|
|
|
#if GR_CACHE_STATS
|
2012-08-22 10:57:05 +00:00
|
|
|
for (int i = 0; i < configs.count(); i++) {
|
|
|
|
ConfigData config = gRec[configs[i]];
|
|
|
|
|
|
|
|
if (kGPU_Backend == config.fBackend) {
|
|
|
|
GrContext* gr = grFactory->get(config.fGLContextType);
|
|
|
|
|
|
|
|
SkDebugf("config: %s %x\n", config.fName, gr);
|
|
|
|
gr->printCacheStats();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-06-05 19:35:09 +00:00
|
|
|
delete grFactory;
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif
|
2012-06-05 19:35:09 +00:00
|
|
|
SkGraphics::Term();
|
|
|
|
|
2011-12-28 19:31:01 +00:00
|
|
|
return (0 == testsFailed) ? 0 : -1;
|
2009-06-10 15:38:48 +00:00
|
|
|
}
|
2012-10-02 18:33:14 +00:00
|
|
|
|
2012-11-01 17:43:44 +00:00
|
|
|
#if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
|
2012-10-02 18:33:14 +00:00
|
|
|
int main(int argc, char * const argv[]) {
|
|
|
|
return tool_main(argc, (char**) argv);
|
|
|
|
}
|
|
|
|
#endif
|