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"
|
2013-03-22 17:29:46 +00:00
|
|
|
#include "gm_error.h"
|
2013-01-19 04:21:27 +00:00
|
|
|
#include "gm_expectations.h"
|
2012-02-14 14:53:59 +00:00
|
|
|
#include "system_preferences.h"
|
2013-01-31 16:30:55 +00:00
|
|
|
#include "SkBitmap.h"
|
2009-07-08 02:54:47 +00:00
|
|
|
#include "SkColorPriv.h"
|
2013-03-21 19:43:15 +00:00
|
|
|
#include "SkCommandLineFlags.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"
|
2013-04-03 18:00:39 +00:00
|
|
|
#include "SkTDict.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-19 04:21:27 +00:00
|
|
|
// exceptions; see https://code.google.com/p/skia/issues/detail?id=1067
|
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 "SkGpuDevice.h"
|
|
|
|
typedef GrContextFactory::GLContextType GLContextType;
|
2013-03-22 17:29:46 +00:00
|
|
|
#define DEFAULT_CACHE_VALUE -1
|
|
|
|
static int gGpuCacheSizeBytes;
|
|
|
|
static int gGpuCacheSizeCount;
|
2012-08-02 14:03:32 +00:00
|
|
|
#else
|
2013-03-21 13:49:54 +00:00
|
|
|
class GrContextFactory;
|
2012-08-02 14:03:32 +00:00
|
|
|
class GrContext;
|
2013-03-28 19:18:12 +00:00
|
|
|
class GrSurface;
|
2012-08-02 14:03:32 +00:00
|
|
|
typedef int GLContextType;
|
|
|
|
#endif
|
|
|
|
|
2013-04-26 15:06:44 +00:00
|
|
|
#define DEBUGFAIL_SEE_STDERR SkDEBUGFAIL("see stderr for message")
|
|
|
|
|
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
|
|
|
|
|
2009-06-10 15:38:48 +00:00
|
|
|
using namespace skiagm;
|
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2013-05-14 15:17:46 +00:00
|
|
|
// TODO(epoger): Right now, various places in this code assume that all the
|
|
|
|
// image files read/written by GM use this file extension.
|
|
|
|
// Search for references to this constant to find these assumptions.
|
|
|
|
const static char kPNG_FileExtension[] = "png";
|
|
|
|
|
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;
|
2013-03-19 18:58:43 +00:00
|
|
|
bool fRunByDefault;
|
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 }
|
|
|
|
};
|
|
|
|
|
2013-04-24 13:01:01 +00:00
|
|
|
static bool encode_to_dct_stream(SkWStream* stream, const SkBitmap& bitmap, const SkIRect& rect);
|
|
|
|
|
2013-04-12 14:11:21 +00:00
|
|
|
const static ErrorCombination kDefaultIgnorableErrorTypes = ErrorCombination()
|
|
|
|
.plus(kMissingExpectations_ErrorType)
|
|
|
|
.plus(kIntentionallySkipped_ErrorType);
|
|
|
|
|
2012-10-26 18:56:36 +00:00
|
|
|
class GMMain {
|
|
|
|
public:
|
2013-04-12 14:11:21 +00:00
|
|
|
GMMain() : fUseFileHierarchy(false), fIgnorableErrorTypes(kDefaultIgnorableErrorTypes),
|
|
|
|
fMismatchPath(NULL), fTestsRun(0), fRenderModesEncountered(1) {}
|
2012-10-29 16:42:11 +00:00
|
|
|
|
2013-05-21 15:45:45 +00:00
|
|
|
/**
|
|
|
|
* Assemble shortNamePlusConfig from (surprise!) shortName and configName.
|
|
|
|
*
|
|
|
|
* The method for doing so depends on whether we are using hierarchical naming.
|
|
|
|
* For example, shortName "selftest1" and configName "8888" could be assembled into
|
|
|
|
* either "selftest1_8888" or "8888/selftest1".
|
|
|
|
*/
|
|
|
|
SkString make_shortname_plus_config(const char *shortName, const char *configName) {
|
2012-10-29 16:42:11 +00:00
|
|
|
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-05-21 15:45:45 +00:00
|
|
|
/**
|
|
|
|
* Assemble filename, suitable for writing out the results of a particular test.
|
|
|
|
*/
|
|
|
|
SkString make_filename(const char *path,
|
|
|
|
const char *shortName,
|
|
|
|
const char *configName,
|
|
|
|
const char *renderModeDescriptor,
|
|
|
|
const char *suffix) {
|
|
|
|
SkString filename = make_shortname_plus_config(shortName, configName);
|
|
|
|
filename.append(renderModeDescriptor);
|
|
|
|
filename.appendUnichar('.');
|
|
|
|
filename.append(suffix);
|
2013-05-28 16:45:07 +00:00
|
|
|
return SkOSPath::SkPathJoin(path, filename.c_str());
|
2013-05-21 15:45:45 +00:00
|
|
|
}
|
|
|
|
|
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) {
|
2013-01-31 16:30:55 +00:00
|
|
|
SkBitmap::Config config = bitmap.config();
|
|
|
|
switch (config) {
|
|
|
|
case SkBitmap::kARGB_8888_Config:
|
|
|
|
force_all_opaque_8888(bitmap);
|
|
|
|
break;
|
|
|
|
case SkBitmap::kRGB_565_Config:
|
|
|
|
// nothing to do here; 565 bitmaps are inherently opaque
|
|
|
|
break;
|
|
|
|
default:
|
2013-03-13 14:18:40 +00:00
|
|
|
gm_fprintf(stderr, "unsupported bitmap config %d\n", config);
|
|
|
|
DEBUGFAIL_SEE_STDERR;
|
2013-01-31 16:30:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void force_all_opaque_8888(const SkBitmap& bitmap) {
|
2012-10-26 18:56:36 +00:00
|
|
|
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) {
|
2013-01-31 16:30:55 +00:00
|
|
|
// TODO(epoger): Now that we have removed force_all_opaque()
|
|
|
|
// from this method, we should be able to get rid of the
|
|
|
|
// transformation to 8888 format also.
|
2012-10-26 18:56:36 +00:00
|
|
|
SkBitmap copy;
|
|
|
|
bitmap.copyTo(©, SkBitmap::kARGB_8888_Config);
|
|
|
|
return SkImageEncoder::EncodeFile(path.c_str(), copy,
|
|
|
|
SkImageEncoder::kPNG_Type, 100);
|
|
|
|
}
|
2011-04-25 15:49:53 +00:00
|
|
|
|
2013-03-22 17:29:46 +00:00
|
|
|
/**
|
2013-04-03 18:00:39 +00:00
|
|
|
* Add all render modes encountered thus far to the "modes" array.
|
2013-03-22 17:29:46 +00:00
|
|
|
*/
|
2013-04-03 18:00:39 +00:00
|
|
|
void GetRenderModesEncountered(SkTArray<SkString> &modes) {
|
|
|
|
SkTDict<int>::Iter iter(this->fRenderModesEncountered);
|
|
|
|
const char* mode;
|
|
|
|
while ((mode = iter.next(NULL)) != NULL) {
|
|
|
|
SkString modeAsString = SkString(mode);
|
|
|
|
// TODO(epoger): It seems a bit silly that all of these modes were
|
|
|
|
// recorded with a leading "-" which we have to remove here
|
|
|
|
// (except for mode "", which means plain old original mode).
|
|
|
|
// But that's how renderModeDescriptor has been passed into
|
|
|
|
// compare_test_results_to_reference_bitmap() historically,
|
|
|
|
// and changing that now may affect other parts of our code.
|
|
|
|
if (modeAsString.startsWith("-")) {
|
|
|
|
modeAsString.remove(0, 1);
|
|
|
|
modes.push_back(modeAsString);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Records the results of this test in fTestsRun and fFailedTests.
|
|
|
|
*
|
|
|
|
* We even record successes, and errors that we regard as
|
|
|
|
* "ignorable"; we can filter them out later.
|
|
|
|
*/
|
2013-05-21 15:45:45 +00:00
|
|
|
void RecordTestResults(const ErrorCombination& errorCombination,
|
|
|
|
const SkString& shortNamePlusConfig,
|
2013-04-03 18:00:39 +00:00
|
|
|
const char renderModeDescriptor []) {
|
|
|
|
// Things to do regardless of errorCombination.
|
|
|
|
fTestsRun++;
|
|
|
|
int renderModeCount = 0;
|
|
|
|
this->fRenderModesEncountered.find(renderModeDescriptor, &renderModeCount);
|
|
|
|
renderModeCount++;
|
|
|
|
this->fRenderModesEncountered.set(renderModeDescriptor, renderModeCount);
|
|
|
|
|
2013-03-22 17:29:46 +00:00
|
|
|
if (errorCombination.isEmpty()) {
|
2013-01-08 18:47:31 +00:00
|
|
|
return;
|
2013-03-08 09:39:36 +00:00
|
|
|
}
|
|
|
|
|
2013-04-03 18:00:39 +00:00
|
|
|
// Things to do only if there is some error condition.
|
2013-05-21 15:45:45 +00:00
|
|
|
SkString fullName = shortNamePlusConfig;
|
2013-04-04 19:23:11 +00:00
|
|
|
fullName.append(renderModeDescriptor);
|
2013-04-03 18:00:39 +00:00
|
|
|
for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) {
|
|
|
|
ErrorType type = static_cast<ErrorType>(typeInt);
|
|
|
|
if (errorCombination.includes(type)) {
|
|
|
|
fFailedTests[type].push_back(fullName);
|
|
|
|
}
|
2012-11-13 03:41:55 +00:00
|
|
|
}
|
2013-04-03 18:00:39 +00:00
|
|
|
}
|
2013-01-08 18:47:31 +00:00
|
|
|
|
2013-04-03 18:00:39 +00:00
|
|
|
/**
|
|
|
|
* Return the number of significant (non-ignorable) errors we have
|
|
|
|
* encountered so far.
|
|
|
|
*/
|
|
|
|
int NumSignificantErrors() {
|
|
|
|
int significantErrors = 0;
|
|
|
|
for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) {
|
|
|
|
ErrorType type = static_cast<ErrorType>(typeInt);
|
2013-04-12 14:11:21 +00:00
|
|
|
if (!fIgnorableErrorTypes.includes(type)) {
|
2013-04-03 18:00:39 +00:00
|
|
|
significantErrors += fFailedTests[type].count();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return significantErrors;
|
2012-11-13 03:41:55 +00:00
|
|
|
}
|
|
|
|
|
2013-04-10 15:24:53 +00:00
|
|
|
/**
|
|
|
|
* Display the summary of results with this ErrorType.
|
|
|
|
*
|
|
|
|
* @param type which ErrorType
|
|
|
|
* @param verbose whether to be all verbose about it
|
|
|
|
*/
|
|
|
|
void DisplayResultTypeSummary(ErrorType type, bool verbose) {
|
2013-04-12 14:11:21 +00:00
|
|
|
bool isIgnorableType = fIgnorableErrorTypes.includes(type);
|
2013-04-10 15:24:53 +00:00
|
|
|
|
|
|
|
SkString line;
|
|
|
|
if (isIgnorableType) {
|
|
|
|
line.append("[ ] ");
|
|
|
|
} else {
|
|
|
|
line.append("[*] ");
|
|
|
|
}
|
|
|
|
|
|
|
|
SkTArray<SkString> *failedTestsOfThisType = &fFailedTests[type];
|
|
|
|
int count = failedTestsOfThisType->count();
|
|
|
|
line.appendf("%d %s", count, getErrorTypeName(type));
|
|
|
|
if (!isIgnorableType || verbose) {
|
|
|
|
line.append(":");
|
|
|
|
for (int i = 0; i < count; ++i) {
|
|
|
|
line.append(" ");
|
|
|
|
line.append((*failedTestsOfThisType)[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gm_fprintf(stdout, "%s\n", line.c_str());
|
|
|
|
}
|
|
|
|
|
2013-04-03 18:00:39 +00:00
|
|
|
/**
|
|
|
|
* List contents of fFailedTests to stdout.
|
2013-04-10 15:24:53 +00:00
|
|
|
*
|
|
|
|
* @param verbose whether to be all verbose about it
|
2013-04-03 18:00:39 +00:00
|
|
|
*/
|
2013-04-10 15:24:53 +00:00
|
|
|
void ListErrors(bool verbose) {
|
2013-04-03 18:00:39 +00:00
|
|
|
// First, print a single summary line.
|
|
|
|
SkString summary;
|
|
|
|
summary.appendf("Ran %d tests:", fTestsRun);
|
|
|
|
for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) {
|
|
|
|
ErrorType type = static_cast<ErrorType>(typeInt);
|
|
|
|
summary.appendf(" %s=%d", getErrorTypeName(type), fFailedTests[type].count());
|
|
|
|
}
|
|
|
|
gm_fprintf(stdout, "%s\n", summary.c_str());
|
|
|
|
|
|
|
|
// Now, for each failure type, list the tests that failed that way.
|
|
|
|
for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) {
|
2013-04-10 15:24:53 +00:00
|
|
|
this->DisplayResultTypeSummary(static_cast<ErrorType>(typeInt), verbose);
|
2012-11-13 03:41:55 +00:00
|
|
|
}
|
2013-04-03 18:00:39 +00:00
|
|
|
gm_fprintf(stdout, "(results marked with [*] will cause nonzero return value)\n");
|
2012-11-13 03:41:55 +00:00
|
|
|
}
|
|
|
|
|
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());
|
2013-05-06 14:28:43 +00:00
|
|
|
return stream.write(data->data(), data->size());
|
2012-10-26 18:56:36 +00:00
|
|
|
}
|
2011-04-25 15:49:53 +00:00
|
|
|
|
2013-01-31 16:30:55 +00:00
|
|
|
/**
|
|
|
|
* Prepare an SkBitmap to render a GM into.
|
|
|
|
*
|
|
|
|
* After you've rendered the GM into the SkBitmap, you must call
|
|
|
|
* complete_bitmap()!
|
|
|
|
*
|
|
|
|
* @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.
|
|
|
|
*/
|
2012-10-26 18:56:36 +00:00
|
|
|
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
|
|
|
|
2013-01-31 16:30:55 +00:00
|
|
|
/**
|
|
|
|
* Any finalization steps we need to perform on the SkBitmap after
|
|
|
|
* we have rendered the GM into it.
|
|
|
|
*
|
|
|
|
* It's too bad that we are throwing away alpha channel data
|
|
|
|
* we could otherwise be examining, but this had always been happening
|
|
|
|
* before... it was buried within the compare() method at
|
|
|
|
* https://code.google.com/p/skia/source/browse/trunk/gm/gmmain.cpp?r=7289#305 .
|
|
|
|
*
|
|
|
|
* Apparently we need this, at least for bitmaps that are either:
|
|
|
|
* (a) destined to be written out as PNG files, or
|
|
|
|
* (b) compared against bitmaps read in from PNG files
|
|
|
|
* for the reasons described just above the force_all_opaque() method.
|
|
|
|
*
|
|
|
|
* Neglecting to do this led to the difficult-to-diagnose
|
|
|
|
* http://code.google.com/p/skia/issues/detail?id=1079 ('gm generating
|
|
|
|
* spurious pixel_error messages as of r7258')
|
|
|
|
*
|
|
|
|
* TODO(epoger): Come up with a better solution that allows us to
|
|
|
|
* compare full pixel data, including alpha channel, while still being
|
|
|
|
* robust in the face of transformations to/from PNG files.
|
|
|
|
* Options include:
|
|
|
|
*
|
|
|
|
* 1. Continue to call force_all_opaque(), but ONLY for bitmaps that
|
|
|
|
* will be written to, or compared against, PNG files.
|
|
|
|
* PRO: Preserve/compare alpha channel info for the non-PNG cases
|
|
|
|
* (comparing different renderModes in-memory)
|
2013-04-12 02:23:55 +00:00
|
|
|
* CON: The bitmaps (and hash digests) for these non-PNG cases would be
|
2013-01-31 16:30:55 +00:00
|
|
|
* different than those for the PNG-compared cases, and in the
|
|
|
|
* case of a failed renderMode comparison, how would we write the
|
|
|
|
* image to disk for examination?
|
|
|
|
*
|
2013-04-12 02:23:55 +00:00
|
|
|
* 2. Always compute image hash digests from PNG format (either
|
2013-01-31 16:30:55 +00:00
|
|
|
* directly from the the bytes of a PNG file, or capturing the
|
|
|
|
* bytes we would have written to disk if we were writing the
|
|
|
|
* bitmap out as a PNG).
|
|
|
|
* PRO: I think this would allow us to never force opaque, and to
|
|
|
|
* the extent that alpha channel data can be preserved in a PNG
|
|
|
|
* file, we could observe it.
|
2013-04-12 02:23:55 +00:00
|
|
|
* CON: If we read a bitmap from disk, we need to take its hash digest
|
2013-01-31 16:30:55 +00:00
|
|
|
* from the source PNG (we can't compute it from the bitmap we
|
|
|
|
* read out of the PNG, because we will have already premultiplied
|
|
|
|
* the alpha).
|
|
|
|
* CON: Seems wasteful to convert a bitmap to PNG format just to take
|
2013-04-12 02:23:55 +00:00
|
|
|
* its hash digest. (Although we're wasting lots of effort already
|
2013-01-31 16:30:55 +00:00
|
|
|
* calling force_all_opaque().)
|
|
|
|
*
|
|
|
|
* 3. Make the alpha premultiply/unpremultiply routines 100% consistent,
|
|
|
|
* so we can transform images back and forth without fear of off-by-one
|
|
|
|
* errors.
|
|
|
|
* CON: Math is hard.
|
|
|
|
*
|
|
|
|
* 4. Perform a "close enough" comparison of bitmaps (+/- 1 bit in each
|
|
|
|
* channel), rather than demanding absolute equality.
|
2013-04-12 02:23:55 +00:00
|
|
|
* CON: Can't do this with hash digests.
|
2013-01-31 16:30:55 +00:00
|
|
|
*/
|
|
|
|
static void complete_bitmap(SkBitmap* bitmap) {
|
|
|
|
force_all_opaque(*bitmap);
|
|
|
|
}
|
|
|
|
|
2013-03-20 14:20:18 +00:00
|
|
|
static void installFilter(SkCanvas* canvas);
|
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
|
|
|
|
2013-03-22 17:29:46 +00:00
|
|
|
static ErrorCombination generate_image(GM* gm, const ConfigData& gRec,
|
2013-03-28 19:18:12 +00:00
|
|
|
GrSurface* gpuTarget,
|
2013-03-22 17:29:46 +00:00
|
|
|
SkBitmap* bitmap,
|
|
|
|
bool deferred) {
|
2012-10-26 18:56:36 +00:00
|
|
|
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
|
2013-03-28 19:18:12 +00:00
|
|
|
SkAutoTUnref<SkDevice> device(SkGpuDevice::Create(gpuTarget));
|
2012-10-26 18:56:36 +00:00
|
|
|
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
|
2013-01-31 16:30:55 +00:00
|
|
|
complete_bitmap(bitmap);
|
2013-03-22 17:29:46 +00:00
|
|
|
return kEmpty_ErrorCombination;
|
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,
|
2013-04-02 15:18:41 +00:00
|
|
|
SkScalar scale = SK_Scalar1,
|
|
|
|
bool tile = false) {
|
2012-10-26 18:56:36 +00:00
|
|
|
SkISize size = gm->getISize();
|
|
|
|
setup_bitmap(gRec, size, bitmap);
|
2013-04-02 15:18:41 +00:00
|
|
|
|
|
|
|
if (tile) {
|
|
|
|
// Generate the result image by rendering to tiles and accumulating
|
|
|
|
// the results in 'bitmap'
|
|
|
|
|
2013-04-03 07:01:14 +00:00
|
|
|
// This 16x16 tiling matches the settings applied to 'pict' in
|
2013-04-02 15:18:41 +00:00
|
|
|
// 'generate_new_picture'
|
|
|
|
SkISize tileSize = SkISize::Make(16, 16);
|
|
|
|
|
|
|
|
SkBitmap tileBM;
|
|
|
|
setup_bitmap(gRec, tileSize, &tileBM);
|
|
|
|
SkCanvas tileCanvas(tileBM);
|
|
|
|
installFilter(&tileCanvas);
|
|
|
|
|
|
|
|
SkCanvas bmpCanvas(*bitmap);
|
|
|
|
SkPaint bmpPaint;
|
|
|
|
bmpPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
|
|
|
|
|
|
|
for (int yTile = 0; yTile < (size.height()+15)/16; ++yTile) {
|
|
|
|
for (int xTile = 0; xTile < (size.width()+15)/16; ++xTile) {
|
|
|
|
int saveCount = tileCanvas.save();
|
|
|
|
SkMatrix mat(tileCanvas.getTotalMatrix());
|
2013-04-03 07:01:14 +00:00
|
|
|
mat.postTranslate(SkIntToScalar(-xTile*tileSize.width()),
|
2013-04-02 15:18:41 +00:00
|
|
|
SkIntToScalar(-yTile*tileSize.height()));
|
|
|
|
tileCanvas.setMatrix(mat);
|
|
|
|
pict->draw(&tileCanvas);
|
|
|
|
tileCanvas.flush();
|
|
|
|
tileCanvas.restoreToCount(saveCount);
|
2013-04-03 07:01:14 +00:00
|
|
|
bmpCanvas.drawBitmap(tileBM,
|
|
|
|
SkIntToScalar(xTile * tileSize.width()),
|
2013-04-02 15:18:41 +00:00
|
|
|
SkIntToScalar(yTile * tileSize.height()),
|
|
|
|
&bmpPaint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SkCanvas canvas(*bitmap);
|
|
|
|
installFilter(&canvas);
|
|
|
|
canvas.scale(scale, scale);
|
|
|
|
canvas.drawPicture(*pict);
|
|
|
|
complete_bitmap(bitmap);
|
|
|
|
}
|
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);
|
|
|
|
}
|
2013-04-24 13:01:01 +00:00
|
|
|
dev->setDCTEncoder(encode_to_dct_stream);
|
2012-10-26 18:56:36 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-03-22 17:29:46 +00:00
|
|
|
ErrorCombination write_reference_image(const ConfigData& gRec, const char writePath [],
|
2013-05-21 15:45:45 +00:00
|
|
|
const char renderModeDescriptor [],
|
|
|
|
const char *shortName, SkBitmap& bitmap,
|
|
|
|
SkDynamicMemoryWStream* document) {
|
2012-10-26 18:56:36 +00:00
|
|
|
SkString path;
|
|
|
|
bool success = false;
|
|
|
|
if (gRec.fBackend == kRaster_Backend ||
|
|
|
|
gRec.fBackend == kGPU_Backend ||
|
|
|
|
(gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) {
|
|
|
|
|
2013-05-21 15:45:45 +00:00
|
|
|
path = make_filename(writePath, shortName, gRec.fName, renderModeDescriptor,
|
2013-05-14 15:17:46 +00:00
|
|
|
kPNG_FileExtension);
|
2012-10-26 18:56:36 +00:00
|
|
|
success = write_bitmap(path, bitmap);
|
|
|
|
}
|
|
|
|
if (kPDF_Backend == gRec.fBackend) {
|
2013-05-21 15:45:45 +00:00
|
|
|
path = make_filename(writePath, shortName, gRec.fName, renderModeDescriptor,
|
2013-01-19 04:21:27 +00:00
|
|
|
"pdf");
|
2012-10-26 18:56:36 +00:00
|
|
|
success = write_document(path, *document);
|
|
|
|
}
|
|
|
|
if (kXPS_Backend == gRec.fBackend) {
|
2013-05-21 15:45:45 +00:00
|
|
|
path = make_filename(writePath, shortName, gRec.fName, renderModeDescriptor,
|
2013-01-19 04:21:27 +00:00
|
|
|
"xps");
|
2012-10-26 18:56:36 +00:00
|
|
|
success = write_document(path, *document);
|
|
|
|
}
|
|
|
|
if (success) {
|
2013-03-22 17:29:46 +00:00
|
|
|
return kEmpty_ErrorCombination;
|
2012-10-26 18:56:36 +00:00
|
|
|
} else {
|
2013-03-13 14:18:40 +00:00
|
|
|
gm_fprintf(stderr, "FAILED to write %s\n", path.c_str());
|
2013-03-22 17:29:46 +00:00
|
|
|
ErrorCombination errors(kWritingReferenceImage_ErrorType);
|
2013-04-03 18:00:39 +00:00
|
|
|
// TODO(epoger): Don't call RecordTestResults() here...
|
|
|
|
// Instead, we should make sure to call RecordTestResults
|
|
|
|
// exactly ONCE per test. (Otherwise, gmmain.fTestsRun
|
|
|
|
// will be incremented twice for this test: once in
|
|
|
|
// compare_test_results_to_stored_expectations() before
|
|
|
|
// that method calls this one, and again here.)
|
|
|
|
//
|
|
|
|
// When we make that change, we should probably add a
|
|
|
|
// WritingReferenceImage test to the gm self-tests.)
|
2013-05-21 15:45:45 +00:00
|
|
|
RecordTestResults(errors, make_shortname_plus_config(shortName, gRec.fName),
|
|
|
|
renderModeDescriptor);
|
2013-03-22 17:29:46 +00:00
|
|
|
return errors;
|
2011-12-28 19:31:01 +00:00
|
|
|
}
|
2011-06-17 13:11:45 +00:00
|
|
|
}
|
|
|
|
|
2013-02-01 20:39:15 +00:00
|
|
|
/**
|
|
|
|
* Log more detail about the mistmatch between expectedBitmap and
|
|
|
|
* actualBitmap.
|
|
|
|
*/
|
|
|
|
void report_bitmap_diffs(const SkBitmap& expectedBitmap, const SkBitmap& actualBitmap,
|
|
|
|
const char *testName) {
|
|
|
|
const int expectedWidth = expectedBitmap.width();
|
|
|
|
const int expectedHeight = expectedBitmap.height();
|
|
|
|
const int width = actualBitmap.width();
|
|
|
|
const int height = actualBitmap.height();
|
|
|
|
if ((expectedWidth != width) || (expectedHeight != height)) {
|
2013-03-13 14:18:40 +00:00
|
|
|
gm_fprintf(stderr, "---- %s: dimension mismatch --"
|
|
|
|
" expected [%d %d], actual [%d %d]\n",
|
|
|
|
testName, expectedWidth, expectedHeight, width, height);
|
2013-02-01 20:39:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((SkBitmap::kARGB_8888_Config != expectedBitmap.config()) ||
|
|
|
|
(SkBitmap::kARGB_8888_Config != actualBitmap.config())) {
|
2013-03-13 14:18:40 +00:00
|
|
|
gm_fprintf(stderr, "---- %s: not computing max per-channel"
|
|
|
|
" pixel mismatch because non-8888\n", testName);
|
2013-02-01 20:39:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkAutoLockPixels alp0(expectedBitmap);
|
|
|
|
SkAutoLockPixels alp1(actualBitmap);
|
|
|
|
int errR = 0;
|
|
|
|
int errG = 0;
|
|
|
|
int errB = 0;
|
|
|
|
int errA = 0;
|
|
|
|
int differingPixels = 0;
|
|
|
|
|
|
|
|
for (int y = 0; y < height; ++y) {
|
|
|
|
const SkPMColor* expectedPixelPtr = expectedBitmap.getAddr32(0, y);
|
|
|
|
const SkPMColor* actualPixelPtr = actualBitmap.getAddr32(0, y);
|
|
|
|
for (int x = 0; x < width; ++x) {
|
|
|
|
SkPMColor expectedPixel = *expectedPixelPtr++;
|
|
|
|
SkPMColor actualPixel = *actualPixelPtr++;
|
|
|
|
if (expectedPixel != actualPixel) {
|
|
|
|
differingPixels++;
|
|
|
|
errR = SkMax32(errR, SkAbs32((int)SkGetPackedR32(expectedPixel) -
|
|
|
|
(int)SkGetPackedR32(actualPixel)));
|
|
|
|
errG = SkMax32(errG, SkAbs32((int)SkGetPackedG32(expectedPixel) -
|
|
|
|
(int)SkGetPackedG32(actualPixel)));
|
|
|
|
errB = SkMax32(errB, SkAbs32((int)SkGetPackedB32(expectedPixel) -
|
|
|
|
(int)SkGetPackedB32(actualPixel)));
|
|
|
|
errA = SkMax32(errA, SkAbs32((int)SkGetPackedA32(expectedPixel) -
|
|
|
|
(int)SkGetPackedA32(actualPixel)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-03-13 14:18:40 +00:00
|
|
|
gm_fprintf(stderr, "---- %s: %d (of %d) differing pixels,"
|
|
|
|
" max per-channel mismatch R=%d G=%d B=%d A=%d\n",
|
|
|
|
testName, differingPixels, width*height, errR, errG, errB, errA);
|
2013-02-01 20:39:15 +00:00
|
|
|
}
|
|
|
|
|
2013-01-19 04:21:27 +00:00
|
|
|
/**
|
2013-04-12 02:23:55 +00:00
|
|
|
* Compares actual hash digest to expectations, returning the set of errors
|
2013-03-22 17:29:46 +00:00
|
|
|
* (if any) that we saw along the way.
|
2013-01-19 04:21:27 +00:00
|
|
|
*
|
|
|
|
* If fMismatchPath has been set, and there are pixel diffs, then the
|
|
|
|
* actual bitmap will be written out to a file within fMismatchPath.
|
|
|
|
*
|
|
|
|
* @param expectations what expectations to compare actualBitmap against
|
|
|
|
* @param actualBitmap the image we actually generated
|
2013-05-21 15:45:45 +00:00
|
|
|
* @param shortName name of test, e.g. "selftest1"
|
|
|
|
* @param configName name of config, e.g. "8888"
|
2013-01-19 04:21:27 +00:00
|
|
|
* @param renderModeDescriptor e.g., "-rtree", "-deferred"
|
|
|
|
* @param addToJsonSummary whether to add these results (both actual and
|
2013-04-04 19:23:11 +00:00
|
|
|
* expected) to the JSON summary. Regardless of this setting, if
|
|
|
|
* we find an image mismatch in this test, we will write these
|
|
|
|
* results to the JSON summary. (This is so that we will always
|
|
|
|
* report errors across rendering modes, such as pipe vs tiled.
|
|
|
|
* See https://codereview.chromium.org/13650002/ )
|
2013-01-19 04:21:27 +00:00
|
|
|
*/
|
2013-03-22 17:29:46 +00:00
|
|
|
ErrorCombination compare_to_expectations(Expectations expectations,
|
|
|
|
const SkBitmap& actualBitmap,
|
2013-05-21 15:45:45 +00:00
|
|
|
const char *shortName, const char *configName,
|
|
|
|
const char *renderModeDescriptor,
|
2013-04-04 19:23:11 +00:00
|
|
|
bool addToJsonSummary) {
|
2013-03-22 17:29:46 +00:00
|
|
|
ErrorCombination errors;
|
2013-05-24 14:33:28 +00:00
|
|
|
GmResultDigest actualResultDigest(actualBitmap);
|
2013-05-21 15:45:45 +00:00
|
|
|
SkString shortNamePlusConfig = make_shortname_plus_config(shortName, configName);
|
|
|
|
SkString completeNameString(shortNamePlusConfig);
|
2013-01-19 04:21:27 +00:00
|
|
|
completeNameString.append(renderModeDescriptor);
|
2013-05-14 15:17:46 +00:00
|
|
|
completeNameString.append(".");
|
|
|
|
completeNameString.append(kPNG_FileExtension);
|
2013-01-19 04:21:27 +00:00
|
|
|
const char* completeName = completeNameString.c_str();
|
|
|
|
|
|
|
|
if (expectations.empty()) {
|
2013-03-22 17:29:46 +00:00
|
|
|
errors.add(kMissingExpectations_ErrorType);
|
2013-05-24 14:33:28 +00:00
|
|
|
} else if (!expectations.match(actualResultDigest)) {
|
2013-04-04 19:23:11 +00:00
|
|
|
addToJsonSummary = true;
|
|
|
|
// The error mode we record depends on whether this was running
|
|
|
|
// in a non-standard renderMode.
|
|
|
|
if ('\0' == *renderModeDescriptor) {
|
|
|
|
errors.add(kExpectationsMismatch_ErrorType);
|
|
|
|
} else {
|
|
|
|
errors.add(kRenderModeMismatch_ErrorType);
|
|
|
|
}
|
2013-02-01 20:39:15 +00:00
|
|
|
|
|
|
|
// Write out the "actuals" for any mismatches, if we have
|
|
|
|
// been directed to do so.
|
2013-01-19 04:21:27 +00:00
|
|
|
if (fMismatchPath) {
|
|
|
|
SkString path =
|
2013-05-21 15:45:45 +00:00
|
|
|
make_filename(fMismatchPath, shortName, configName, renderModeDescriptor,
|
|
|
|
kPNG_FileExtension);
|
2013-01-19 04:21:27 +00:00
|
|
|
write_bitmap(path, actualBitmap);
|
2012-10-26 18:56:36 +00:00
|
|
|
}
|
2013-02-01 20:39:15 +00:00
|
|
|
|
|
|
|
// If we have access to a single expected bitmap, log more
|
|
|
|
// detail about the mismatch.
|
|
|
|
const SkBitmap *expectedBitmapPtr = expectations.asBitmap();
|
|
|
|
if (NULL != expectedBitmapPtr) {
|
|
|
|
report_bitmap_diffs(*expectedBitmapPtr, actualBitmap, completeName);
|
|
|
|
}
|
2012-12-18 19:13:49 +00:00
|
|
|
}
|
2013-05-21 15:45:45 +00:00
|
|
|
RecordTestResults(errors, shortNamePlusConfig, renderModeDescriptor);
|
2013-01-19 04:21:27 +00:00
|
|
|
|
|
|
|
if (addToJsonSummary) {
|
2013-05-24 14:33:28 +00:00
|
|
|
add_actual_results_to_json_summary(completeName, actualResultDigest, errors,
|
2013-01-19 04:21:27 +00:00
|
|
|
expectations.ignoreFailure());
|
|
|
|
add_expected_results_to_json_summary(completeName, expectations);
|
|
|
|
}
|
|
|
|
|
2013-03-22 17:29:46 +00:00
|
|
|
return errors;
|
2013-01-19 04:21:27 +00:00
|
|
|
}
|
2012-12-18 19:13:49 +00:00
|
|
|
|
2013-01-19 04:21:27 +00:00
|
|
|
/**
|
|
|
|
* Add this result to the appropriate JSON collection of actual results,
|
2013-04-26 15:06:44 +00:00
|
|
|
* depending on errors encountered.
|
2013-01-19 04:21:27 +00:00
|
|
|
*/
|
|
|
|
void add_actual_results_to_json_summary(const char testName[],
|
2013-05-24 14:33:28 +00:00
|
|
|
const GmResultDigest &actualResultDigest,
|
2013-04-26 15:06:44 +00:00
|
|
|
ErrorCombination errors,
|
2013-01-19 04:21:27 +00:00
|
|
|
bool ignoreFailure) {
|
2013-05-24 14:33:28 +00:00
|
|
|
Json::Value jsonActualResults = actualResultDigest.asJsonTypeValuePair();
|
2013-04-26 15:06:44 +00:00
|
|
|
if (errors.isEmpty()) {
|
|
|
|
this->fJsonActualResults_Succeeded[testName] = jsonActualResults;
|
2013-01-19 04:21:27 +00:00
|
|
|
} else {
|
|
|
|
if (ignoreFailure) {
|
|
|
|
// TODO: Once we have added the ability to compare
|
|
|
|
// actual results against expectations in a JSON file
|
|
|
|
// (where we can set ignore-failure to either true or
|
2013-02-01 20:39:15 +00:00
|
|
|
// false), add test cases that exercise ignored
|
2013-03-22 17:29:46 +00:00
|
|
|
// failures (both for kMissingExpectations_ErrorType
|
2013-04-04 19:23:11 +00:00
|
|
|
// and kExpectationsMismatch_ErrorType).
|
2013-01-19 04:21:27 +00:00
|
|
|
this->fJsonActualResults_FailureIgnored[testName] =
|
2013-04-26 15:06:44 +00:00
|
|
|
jsonActualResults;
|
2012-12-18 19:13:49 +00:00
|
|
|
} else {
|
2013-04-26 15:06:44 +00:00
|
|
|
if (errors.includes(kMissingExpectations_ErrorType)) {
|
2013-01-19 04:21:27 +00:00
|
|
|
// TODO: What about the case where there IS an
|
2013-04-12 02:23:55 +00:00
|
|
|
// expected image hash digest, but that gm test
|
2013-01-19 04:21:27 +00:00
|
|
|
// doesn't actually run? For now, those cases
|
|
|
|
// will always be ignored, because gm only looks
|
|
|
|
// at expectations that correspond to gm tests
|
|
|
|
// that were actually run.
|
|
|
|
//
|
|
|
|
// Once we have the ability to express
|
|
|
|
// expectations as a JSON file, we should fix this
|
|
|
|
// (and add a test case for which an expectation
|
|
|
|
// is given but the test is never run).
|
|
|
|
this->fJsonActualResults_NoComparison[testName] =
|
2013-04-26 15:06:44 +00:00
|
|
|
jsonActualResults;
|
2013-03-08 09:39:36 +00:00
|
|
|
}
|
2013-04-26 15:06:44 +00:00
|
|
|
if (errors.includes(kExpectationsMismatch_ErrorType) ||
|
|
|
|
errors.includes(kRenderModeMismatch_ErrorType)) {
|
|
|
|
this->fJsonActualResults_Failed[testName] = jsonActualResults;
|
2013-01-19 04:21:27 +00:00
|
|
|
}
|
2012-12-18 19:13:49 +00:00
|
|
|
}
|
2012-10-26 18:56:36 +00:00
|
|
|
}
|
2013-01-19 04:21:27 +00:00
|
|
|
}
|
2012-12-18 19:13:49 +00:00
|
|
|
|
2013-01-19 04:21:27 +00:00
|
|
|
/**
|
|
|
|
* Add this test to the JSON collection of expected results.
|
|
|
|
*/
|
|
|
|
void add_expected_results_to_json_summary(const char testName[],
|
|
|
|
Expectations expectations) {
|
2013-04-26 15:06:44 +00:00
|
|
|
this->fJsonExpectedResults[testName] = expectations.asJsonValue();
|
2013-01-18 21:45:42 +00:00
|
|
|
}
|
2013-01-17 17:54:28 +00:00
|
|
|
|
2013-01-19 04:21:27 +00:00
|
|
|
/**
|
|
|
|
* Compare actualBitmap to expectations stored in this->fExpectationsSource.
|
|
|
|
*
|
|
|
|
* @param gm which test generated the actualBitmap
|
|
|
|
* @param gRec
|
|
|
|
* @param writePath unless this is NULL, write out actual images into this
|
|
|
|
* directory
|
|
|
|
* @param actualBitmap bitmap generated by this run
|
|
|
|
* @param pdf
|
|
|
|
*/
|
2013-03-22 17:29:46 +00:00
|
|
|
ErrorCombination compare_test_results_to_stored_expectations(
|
2013-01-19 04:21:27 +00:00
|
|
|
GM* gm, const ConfigData& gRec, const char writePath[],
|
|
|
|
SkBitmap& actualBitmap, SkDynamicMemoryWStream* pdf) {
|
|
|
|
|
2013-05-21 15:45:45 +00:00
|
|
|
SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName(), gRec.fName);
|
|
|
|
SkString nameWithExtension(shortNamePlusConfig);
|
|
|
|
nameWithExtension.append(".");
|
|
|
|
nameWithExtension.append(kPNG_FileExtension);
|
2012-10-26 18:56:36 +00:00
|
|
|
|
2013-05-21 15:45:45 +00:00
|
|
|
ErrorCombination errors;
|
2013-03-22 17:29:46 +00:00
|
|
|
ExpectationsSource *expectationsSource = this->fExpectationsSource.get();
|
2013-01-19 04:21:27 +00:00
|
|
|
if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) {
|
|
|
|
/*
|
|
|
|
* Get the expected results for this test, as one or more allowed
|
2013-04-12 02:23:55 +00:00
|
|
|
* hash digests. The current implementation of expectationsSource
|
|
|
|
* get this by computing the hash digest of a single PNG file on disk.
|
2013-01-19 04:21:27 +00:00
|
|
|
*
|
|
|
|
* TODO(epoger): This relies on the fact that
|
|
|
|
* force_all_opaque() was called on the bitmap before it
|
|
|
|
* was written to disk as a PNG in the first place. If
|
2013-04-12 02:23:55 +00:00
|
|
|
* not, the hash digest returned here may not match the
|
|
|
|
* hash digest of actualBitmap, which *has* been run through
|
2013-01-19 04:21:27 +00:00
|
|
|
* force_all_opaque().
|
2013-01-31 16:30:55 +00:00
|
|
|
* See comments above complete_bitmap() for more detail.
|
2013-01-19 04:21:27 +00:00
|
|
|
*/
|
2013-05-14 15:17:46 +00:00
|
|
|
Expectations expectations = expectationsSource->get(nameWithExtension.c_str());
|
2013-03-22 17:29:46 +00:00
|
|
|
errors.add(compare_to_expectations(expectations, actualBitmap,
|
2013-05-21 15:45:45 +00:00
|
|
|
gm->shortName(), gRec.fName, "", true));
|
2013-01-19 04:21:27 +00:00
|
|
|
} else {
|
|
|
|
// If we are running without expectations, we still want to
|
2012-12-20 18:34:29 +00:00
|
|
|
// record the actual results.
|
2013-05-24 14:33:28 +00:00
|
|
|
GmResultDigest actualResultDigest(actualBitmap);
|
|
|
|
add_actual_results_to_json_summary(nameWithExtension.c_str(), actualResultDigest,
|
2013-03-22 17:29:46 +00:00
|
|
|
ErrorCombination(kMissingExpectations_ErrorType),
|
2013-01-19 04:21:27 +00:00
|
|
|
false);
|
2013-05-21 15:45:45 +00:00
|
|
|
RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType),
|
|
|
|
shortNamePlusConfig, "");
|
2012-10-26 18:56:36 +00:00
|
|
|
}
|
2013-01-19 04:21:27 +00:00
|
|
|
|
|
|
|
// TODO: Consider moving this into compare_to_expectations(),
|
|
|
|
// similar to fMismatchPath... for now, we don't do that, because
|
|
|
|
// we don't want to write out the actual bitmaps for all
|
|
|
|
// renderModes of all tests! That would be a lot of files.
|
2012-10-26 18:56:36 +00:00
|
|
|
if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) {
|
2013-05-21 15:45:45 +00:00
|
|
|
errors.add(write_reference_image(gRec, writePath, "", gm->shortName(),
|
|
|
|
actualBitmap, pdf));
|
2012-10-26 18:56:36 +00:00
|
|
|
}
|
2013-01-19 04:21:27 +00:00
|
|
|
|
2013-03-22 17:29:46 +00:00
|
|
|
return errors;
|
2012-04-18 13:36:54 +00:00
|
|
|
}
|
2011-04-25 15:49:53 +00:00
|
|
|
|
2013-01-19 04:21:27 +00:00
|
|
|
/**
|
|
|
|
* Compare actualBitmap to referenceBitmap.
|
|
|
|
*
|
2013-05-21 15:45:45 +00:00
|
|
|
* @param shortName test name, e.g. "selftest1"
|
|
|
|
* @param configName configuration name, e.g. "8888"
|
2013-01-19 04:21:27 +00:00
|
|
|
* @param renderModeDescriptor
|
|
|
|
* @param actualBitmap actual bitmap generated by this run
|
|
|
|
* @param referenceBitmap bitmap we expected to be generated
|
|
|
|
*/
|
2013-03-22 17:29:46 +00:00
|
|
|
ErrorCombination compare_test_results_to_reference_bitmap(
|
2013-05-21 15:45:45 +00:00
|
|
|
const char *shortName, const char *configName, const char *renderModeDescriptor,
|
2013-01-19 04:21:27 +00:00
|
|
|
SkBitmap& actualBitmap, const SkBitmap* referenceBitmap) {
|
|
|
|
|
|
|
|
SkASSERT(referenceBitmap);
|
2013-02-01 20:39:15 +00:00
|
|
|
Expectations expectations(*referenceBitmap);
|
2013-05-21 15:45:45 +00:00
|
|
|
return compare_to_expectations(expectations, actualBitmap, shortName,
|
|
|
|
configName, renderModeDescriptor, false);
|
2013-01-19 04:21:27 +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) {
|
2013-02-27 18:35:16 +00:00
|
|
|
SkTileGridPicture::TileGridInfo info;
|
|
|
|
info.fMargin.setEmpty();
|
|
|
|
info.fOffset.setZero();
|
|
|
|
info.fTileInterval.set(16, 16);
|
|
|
|
pict = new SkTileGridPicture(width, height, info);
|
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);
|
|
|
|
|
2013-03-20 14:20:18 +00:00
|
|
|
size_t streamSize = storage.getOffset();
|
2012-10-26 18:56:36 +00:00
|
|
|
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);
|
2013-04-30 02:32:41 +00:00
|
|
|
bool success;
|
|
|
|
// Pass a decoding bitmap function so that the factory GM (which has an SkBitmap with
|
|
|
|
// encoded data) does not fail.
|
|
|
|
SkPicture* retval = new SkPicture (&pictReadback, &success, &SkImageDecoder::DecodeMemory);
|
2012-10-26 18:56:36 +00:00
|
|
|
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.
|
2013-03-22 17:29:46 +00:00
|
|
|
ErrorCombination test_drawing(GM* gm,
|
|
|
|
const ConfigData& gRec,
|
|
|
|
const char writePath [],
|
2013-03-28 19:18:12 +00:00
|
|
|
GrSurface* gpuTarget,
|
2013-03-22 17:29:46 +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.
|
2013-03-28 19:18:12 +00:00
|
|
|
ErrorCombination errors = generate_image(gm, gRec, gpuTarget, bitmap, false);
|
2013-03-22 17:29:46 +00:00
|
|
|
if (!errors.isEmpty()) {
|
2013-01-19 04:21:27 +00:00
|
|
|
// TODO: Add a test to exercise what the stdout and
|
|
|
|
// JSON look like if we get an "early error" while
|
|
|
|
// trying to generate the image.
|
2012-10-26 18:56:36 +00:00
|
|
|
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-19 04:21:27 +00:00
|
|
|
return compare_test_results_to_stored_expectations(
|
|
|
|
gm, gRec, writePath, *bitmap, &document);
|
2011-04-25 15:49:53 +00:00
|
|
|
}
|
|
|
|
|
2013-03-22 17:29:46 +00:00
|
|
|
ErrorCombination test_deferred_drawing(GM* gm,
|
|
|
|
const ConfigData& gRec,
|
|
|
|
const SkBitmap& referenceBitmap,
|
2013-03-28 19:18:12 +00:00
|
|
|
GrSurface* gpuTarget) {
|
2012-10-26 18:56:36 +00:00
|
|
|
SkDynamicMemoryWStream document;
|
|
|
|
|
|
|
|
if (gRec.fBackend == kRaster_Backend ||
|
|
|
|
gRec.fBackend == kGPU_Backend) {
|
2013-04-10 12:17:34 +00:00
|
|
|
const char renderModeDescriptor[] = "-deferred";
|
2012-10-26 18:56:36 +00:00
|
|
|
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.
|
2013-03-28 19:18:12 +00:00
|
|
|
ErrorCombination errors = generate_image(gm, gRec, gpuTarget, &bitmap, true);
|
2013-03-22 17:29:46 +00:00
|
|
|
// TODO(epoger): This logic is the opposite of what is
|
|
|
|
// described above... if we succeeded in generating the
|
|
|
|
// -deferred image, we exit early! We should fix this
|
|
|
|
// ASAP, because it is hiding -deferred errors... but for
|
|
|
|
// now, I'm leaving the logic as it is so that the
|
|
|
|
// refactoring change
|
|
|
|
// https://codereview.chromium.org/12992003/ is unblocked.
|
|
|
|
//
|
|
|
|
// Filed as https://code.google.com/p/skia/issues/detail?id=1180
|
|
|
|
// ('image-surface gm test is failing in "deferred" mode,
|
|
|
|
// and gm is not reporting the failure')
|
|
|
|
if (errors.isEmpty()) {
|
2013-04-03 18:00:39 +00:00
|
|
|
// TODO(epoger): Report this as a new ErrorType,
|
|
|
|
// something like kImageGeneration_ErrorType?
|
2013-03-22 17:29:46 +00:00
|
|
|
return kEmpty_ErrorCombination;
|
2012-10-26 18:56:36 +00:00
|
|
|
}
|
2013-01-19 04:21:27 +00:00
|
|
|
return compare_test_results_to_reference_bitmap(
|
2013-05-21 15:45:45 +00:00
|
|
|
gm->shortName(), gRec.fName, renderModeDescriptor, bitmap, &referenceBitmap);
|
2012-01-18 16:21:08 +00:00
|
|
|
}
|
2013-03-22 17:29:46 +00:00
|
|
|
return kEmpty_ErrorCombination;
|
2012-01-18 16:21:08 +00:00
|
|
|
}
|
|
|
|
|
2013-04-04 19:23:11 +00:00
|
|
|
ErrorCombination test_pipe_playback(GM* gm, const ConfigData& gRec,
|
|
|
|
const SkBitmap& referenceBitmap, bool simulateFailure) {
|
2013-05-21 15:45:45 +00:00
|
|
|
const SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName(),
|
|
|
|
gRec.fName);
|
2013-03-22 17:29:46 +00:00
|
|
|
ErrorCombination errors;
|
2012-10-26 18:56:36 +00:00
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) {
|
2013-04-10 12:17:34 +00:00
|
|
|
SkString renderModeDescriptor("-pipe");
|
|
|
|
renderModeDescriptor.append(gPipeWritingFlagCombos[i].name);
|
|
|
|
|
|
|
|
if (gm->getFlags() & GM::kSkipPipe_Flag) {
|
2013-05-21 15:45:45 +00:00
|
|
|
RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlusConfig,
|
2013-04-10 12:17:34 +00:00
|
|
|
renderModeDescriptor.c_str());
|
|
|
|
errors.add(kIntentionallySkipped_ErrorType);
|
|
|
|
} else {
|
|
|
|
SkBitmap bitmap;
|
|
|
|
SkISize size = gm->getISize();
|
|
|
|
setup_bitmap(gRec, size, &bitmap);
|
|
|
|
SkCanvas canvas(bitmap);
|
|
|
|
installFilter(&canvas);
|
2013-04-30 02:32:41 +00:00
|
|
|
// Pass a decoding function so the factory GM (which has an SkBitmap
|
|
|
|
// with encoded data) will not fail playback.
|
|
|
|
PipeController pipeController(&canvas, &SkImageDecoder::DecodeMemory);
|
2013-04-10 12:17:34 +00:00
|
|
|
SkGPipeWriter writer;
|
|
|
|
SkCanvas* pipeCanvas = writer.startRecording(&pipeController,
|
2013-04-10 18:10:41 +00:00
|
|
|
gPipeWritingFlagCombos[i].flags,
|
|
|
|
size.width(), size.height());
|
2013-04-10 12:17:34 +00:00
|
|
|
if (!simulateFailure) {
|
|
|
|
invokeGM(gm, pipeCanvas, false, false);
|
|
|
|
}
|
|
|
|
complete_bitmap(&bitmap);
|
|
|
|
writer.endRecording();
|
|
|
|
errors.add(compare_test_results_to_reference_bitmap(
|
2013-05-21 15:45:45 +00:00
|
|
|
gm->shortName(), gRec.fName, renderModeDescriptor.c_str(), bitmap,
|
|
|
|
&referenceBitmap));
|
2013-04-10 12:17:34 +00:00
|
|
|
if (!errors.isEmpty()) {
|
|
|
|
break;
|
|
|
|
}
|
2012-10-26 18:56:36 +00:00
|
|
|
}
|
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
|
|
|
|
2013-03-22 17:29:46 +00:00
|
|
|
ErrorCombination test_tiled_pipe_playback(GM* gm, const ConfigData& gRec,
|
|
|
|
const SkBitmap& referenceBitmap) {
|
2013-05-21 15:45:45 +00:00
|
|
|
const SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName(),
|
|
|
|
gRec.fName);
|
2013-03-22 17:29:46 +00:00
|
|
|
ErrorCombination errors;
|
2012-10-26 18:56:36 +00:00
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) {
|
2013-04-10 12:17:34 +00:00
|
|
|
SkString renderModeDescriptor("-tiled pipe");
|
|
|
|
renderModeDescriptor.append(gPipeWritingFlagCombos[i].name);
|
|
|
|
|
|
|
|
if ((gm->getFlags() & GM::kSkipPipe_Flag) ||
|
|
|
|
(gm->getFlags() & GM::kSkipTiled_Flag)) {
|
2013-05-21 15:45:45 +00:00
|
|
|
RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlusConfig,
|
2013-04-10 12:17:34 +00:00
|
|
|
renderModeDescriptor.c_str());
|
|
|
|
errors.add(kIntentionallySkipped_ErrorType);
|
|
|
|
} else {
|
|
|
|
SkBitmap bitmap;
|
|
|
|
SkISize size = gm->getISize();
|
|
|
|
setup_bitmap(gRec, size, &bitmap);
|
|
|
|
SkCanvas canvas(bitmap);
|
|
|
|
installFilter(&canvas);
|
2013-04-30 02:32:41 +00:00
|
|
|
TiledPipeController pipeController(bitmap, &SkImageDecoder::DecodeMemory);
|
2013-04-10 12:17:34 +00:00
|
|
|
SkGPipeWriter writer;
|
|
|
|
SkCanvas* pipeCanvas = writer.startRecording(&pipeController,
|
2013-04-10 18:10:41 +00:00
|
|
|
gPipeWritingFlagCombos[i].flags,
|
|
|
|
size.width(), size.height());
|
2013-04-10 12:17:34 +00:00
|
|
|
invokeGM(gm, pipeCanvas, false, false);
|
|
|
|
complete_bitmap(&bitmap);
|
|
|
|
writer.endRecording();
|
2013-05-21 15:45:45 +00:00
|
|
|
errors.add(compare_test_results_to_reference_bitmap(gm->shortName(), gRec.fName,
|
2013-04-10 12:17:34 +00:00
|
|
|
renderModeDescriptor.c_str(),
|
|
|
|
bitmap, &referenceBitmap));
|
|
|
|
if (!errors.isEmpty()) {
|
|
|
|
break;
|
|
|
|
}
|
2012-10-26 18:56:36 +00:00
|
|
|
}
|
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().
|
|
|
|
//
|
|
|
|
|
|
|
|
bool fUseFileHierarchy;
|
2013-04-12 14:11:21 +00:00
|
|
|
ErrorCombination fIgnorableErrorTypes;
|
2012-10-29 16:42:11 +00:00
|
|
|
|
2013-01-11 21:04:40 +00:00
|
|
|
const char* fMismatchPath;
|
|
|
|
|
2013-04-03 18:00:39 +00:00
|
|
|
// collection of tests that have failed with each ErrorType
|
|
|
|
SkTArray<SkString> fFailedTests[kLast_ErrorType+1];
|
|
|
|
int fTestsRun;
|
|
|
|
SkTDict<int> fRenderModesEncountered;
|
2012-11-13 03:41:55 +00:00
|
|
|
|
2013-04-12 02:23:55 +00:00
|
|
|
// Where to read expectations (expected image hash digests, etc.) from.
|
2013-01-19 04:21:27 +00:00
|
|
|
// If unset, we don't do comparisons.
|
|
|
|
SkAutoTUnref<ExpectationsSource> fExpectationsSource;
|
|
|
|
|
|
|
|
// JSON summaries that we generate as we go (just for output).
|
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[] = {
|
2013-03-19 18:58:43 +00:00
|
|
|
{ SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextType, 0, kRW_ConfigFlag, "8888", true },
|
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!!!)
|
2013-03-19 18:58:43 +00:00
|
|
|
{ SkBitmap::kARGB_4444_Config, kRaster_Backend, kDontCare_GLContextType, 0, kRW_ConfigFlag, "4444", true },
|
2012-08-02 17:56:02 +00:00
|
|
|
#endif
|
2013-03-19 18:58:43 +00:00
|
|
|
{ SkBitmap::kRGB_565_Config, kRaster_Backend, kDontCare_GLContextType, 0, kRW_ConfigFlag, "565", true },
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
{ SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kNative_GLContextType, 0, kRW_ConfigFlag, "gpu", true },
|
|
|
|
{ SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kNative_GLContextType, 16, kRW_ConfigFlag, "msaa16", true },
|
|
|
|
{ SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kNative_GLContextType, 4, kRW_ConfigFlag, "msaa4", false},
|
2012-04-19 19:15:35 +00:00
|
|
|
/* The debug context does not generate images */
|
2013-03-20 15:35:08 +00:00
|
|
|
{ SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kDebug_GLContextType, 0, kNone_ConfigFlag, "gpudebug", GR_DEBUG},
|
2012-08-02 14:03:32 +00:00
|
|
|
#if SK_ANGLE
|
2013-03-19 18:58:43 +00:00
|
|
|
{ SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kANGLE_GLContextType, 0, kRW_ConfigFlag, "angle", true },
|
|
|
|
{ SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kANGLE_GLContextType, 16, kRW_ConfigFlag, "anglemsaa16", true },
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif // SK_ANGLE
|
|
|
|
#ifdef SK_MESA
|
2013-03-19 18:58:43 +00:00
|
|
|
{ SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kMESA_GLContextType, 0, kRW_ConfigFlag, "mesa", true },
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif // SK_MESA
|
2013-03-19 18:58:43 +00:00
|
|
|
#endif // 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). */
|
2013-03-19 18:58:43 +00:00
|
|
|
{ SkBitmap::kARGB_8888_Config, kXPS_Backend, kDontCare_GLContextType, 0, kWrite_ConfigFlag, "xps", true },
|
2012-08-02 17:56:02 +00:00
|
|
|
#endif // SK_SUPPORT_XPS
|
2012-04-19 19:15:35 +00:00
|
|
|
#ifdef SK_SUPPORT_PDF
|
2013-03-19 18:58:43 +00:00
|
|
|
{ SkBitmap::kARGB_8888_Config, kPDF_Backend, kDontCare_GLContextType, 0, kPDFConfigFlags, "pdf", true },
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif // SK_SUPPORT_PDF
|
2009-06-10 15:38:48 +00:00
|
|
|
};
|
|
|
|
|
2013-04-24 18:07:11 +00:00
|
|
|
static const char kDefaultsConfigStr[] = "defaults";
|
|
|
|
static const char kExcludeConfigChar = '~';
|
|
|
|
|
2013-03-20 14:20:18 +00:00
|
|
|
static SkString configUsage() {
|
2013-03-20 15:35:08 +00:00
|
|
|
SkString result;
|
|
|
|
result.appendf("Space delimited list of which configs to run. Possible options: [");
|
2012-06-07 17:39:48 +00:00
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
|
2013-04-24 18:07:11 +00:00
|
|
|
SkASSERT(gRec[i].fName != kDefaultsConfigStr);
|
2012-06-07 17:39:48 +00:00
|
|
|
if (i > 0) {
|
2013-03-20 15:35:08 +00:00
|
|
|
result.append("|");
|
2012-06-07 17:39:48 +00:00
|
|
|
}
|
2013-03-20 14:20:18 +00:00
|
|
|
result.appendf("%s", gRec[i].fName);
|
2012-06-07 17:39:48 +00:00
|
|
|
}
|
2013-03-20 15:35:08 +00:00
|
|
|
result.append("]\n");
|
|
|
|
result.appendf("The default value is: \"");
|
2013-04-24 18:07:11 +00:00
|
|
|
SkString firstDefault;
|
|
|
|
SkString allButFirstDefaults;
|
|
|
|
SkString nonDefault;
|
2013-03-20 15:35:08 +00:00
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
|
|
|
|
if (gRec[i].fRunByDefault) {
|
|
|
|
if (i > 0) {
|
|
|
|
result.append(" ");
|
|
|
|
}
|
2013-04-24 18:07:11 +00:00
|
|
|
result.append(gRec[i].fName);
|
|
|
|
if (firstDefault.isEmpty()) {
|
|
|
|
firstDefault = gRec[i].fName;
|
|
|
|
} else {
|
|
|
|
if (!allButFirstDefaults.isEmpty()) {
|
|
|
|
allButFirstDefaults.append(" ");
|
|
|
|
}
|
|
|
|
allButFirstDefaults.append(gRec[i].fName);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
nonDefault = gRec[i].fName;
|
2013-03-20 15:35:08 +00:00
|
|
|
}
|
|
|
|
}
|
2013-04-24 18:07:11 +00:00
|
|
|
result.append("\"\n");
|
|
|
|
result.appendf("\"%s\" evaluates to the default set of configs.\n", kDefaultsConfigStr);
|
|
|
|
result.appendf("Prepending \"%c\" on a config name excludes it from the set of configs to run.\n"
|
|
|
|
"Exclusions always override inclusions regardless of order.\n",
|
|
|
|
kExcludeConfigChar);
|
|
|
|
result.appendf("E.g. \"--config %s %c%s %s\" will run these configs:\n\t%s %s",
|
|
|
|
kDefaultsConfigStr,
|
|
|
|
kExcludeConfigChar,
|
|
|
|
firstDefault.c_str(),
|
|
|
|
nonDefault.c_str(),
|
|
|
|
allButFirstDefaults.c_str(),
|
|
|
|
nonDefault.c_str());
|
2013-03-20 14:20:18 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-03-22 17:29:46 +00:00
|
|
|
// Macro magic to convert a numeric preprocessor token into a string.
|
|
|
|
// Adapted from http://stackoverflow.com/questions/240353/convert-a-preprocessor-token-to-a-string
|
|
|
|
// This should probably be moved into one of our common headers...
|
|
|
|
#define TOSTRING_INTERNAL(x) #x
|
|
|
|
#define TOSTRING(x) TOSTRING_INTERNAL(x)
|
|
|
|
|
2013-03-19 17:28:10 +00:00
|
|
|
// Alphabetized ignoring "no" prefix ("readPath", "noreplay", "resourcePath").
|
2013-03-20 15:35:08 +00:00
|
|
|
DEFINE_string(config, "", configUsage().c_str());
|
2013-03-20 14:20:18 +00:00
|
|
|
DEFINE_bool(deferred, true, "Exercise the deferred rendering test pass.");
|
|
|
|
DEFINE_string(excludeConfig, "", "Space delimited list of configs to skip.");
|
|
|
|
DEFINE_bool(forceBWtext, false, "Disable text anti-aliasing.");
|
2013-03-19 17:38:50 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2013-03-20 14:20:18 +00:00
|
|
|
DEFINE_string(gpuCacheSize, "", "<bytes> <count>: Limit the gpu cache to byte size or "
|
2013-03-22 17:29:46 +00:00
|
|
|
"object count. " TOSTRING(DEFAULT_CACHE_VALUE) " for either value means "
|
|
|
|
"use the default. 0 for either disables the cache.");
|
2013-03-19 17:38:50 +00:00
|
|
|
#endif
|
2013-03-20 14:20:18 +00:00
|
|
|
DEFINE_bool(hierarchy, false, "Whether to use multilevel directory structure "
|
|
|
|
"when reading/writing files.");
|
2013-04-12 14:11:21 +00:00
|
|
|
DEFINE_string(ignoreErrorTypes, kDefaultIgnorableErrorTypes.asString(" ").c_str(),
|
|
|
|
"Space-separated list of ErrorTypes that should be ignored. If any *other* error "
|
|
|
|
"types are encountered, the tool will exit with a nonzero return value.");
|
2013-05-10 15:16:13 +00:00
|
|
|
DEFINE_string(match, "", "[~][^]substring[$] [...] of test name to run.\n"
|
|
|
|
"Multiple matches may be separated by spaces.\n"
|
|
|
|
"~ causes a matching test to always be skipped\n"
|
|
|
|
"^ requires the start of the test to match\n"
|
|
|
|
"$ requires the end of the test to match\n"
|
|
|
|
"^ and $ requires an exact match\n"
|
|
|
|
"If a test does not match any list entry,\n"
|
|
|
|
"it is skipped unless some list entry starts with ~");
|
2013-03-20 14:20:18 +00:00
|
|
|
DEFINE_string(mismatchPath, "", "Write images for tests that failed due to "
|
|
|
|
"pixel mismatches into this directory.");
|
|
|
|
DEFINE_string(modulo, "", "[--modulo <remainder> <divisor>]: only run tests for which "
|
|
|
|
"testIndex %% divisor == remainder.");
|
|
|
|
DEFINE_bool(pdf, true, "Exercise the pdf rendering test pass.");
|
|
|
|
DEFINE_bool(pipe, true, "Exercise the SkGPipe replay test pass.");
|
|
|
|
DEFINE_string2(readPath, r, "", "Read reference images from this dir, and report "
|
|
|
|
"any differences between those and the newly generated ones.");
|
|
|
|
DEFINE_bool(replay, true, "Exercise the SkPicture replay test pass.");
|
|
|
|
DEFINE_string2(resourcePath, i, "", "Directory that stores image resources.");
|
|
|
|
DEFINE_bool(rtree, true, "Exercise the R-Tree variant of SkPicture test pass.");
|
|
|
|
DEFINE_bool(serialize, true, "Exercise the SkPicture serialization & deserialization test pass.");
|
2013-04-04 19:23:11 +00:00
|
|
|
DEFINE_bool(simulatePipePlaybackFailure, false, "Simulate a rendering failure in pipe mode only.");
|
2013-03-20 14:20:18 +00:00
|
|
|
DEFINE_bool(tiledPipe, false, "Exercise tiled SkGPipe replay.");
|
|
|
|
DEFINE_bool(tileGrid, true, "Exercise the tile grid variant of SkPicture.");
|
|
|
|
DEFINE_string(tileGridReplayScales, "", "Space separated list of floating-point scale "
|
|
|
|
"factors to be used for tileGrid playback testing. Default value: 1.0");
|
|
|
|
DEFINE_string(writeJsonSummaryPath, "", "Write a JSON-formatted result summary to this file.");
|
2013-04-10 18:46:25 +00:00
|
|
|
DEFINE_bool2(verbose, v, false, "Give more detail (e.g. list all GMs run, more info about "
|
|
|
|
"each test).");
|
2013-03-20 14:20:18 +00:00
|
|
|
DEFINE_string2(writePath, w, "", "Write rendered images into this directory.");
|
2013-04-09 21:25:46 +00:00
|
|
|
DEFINE_string2(writePicturePath, p, "", "Write .skp files into this directory.");
|
2013-04-24 13:01:01 +00:00
|
|
|
DEFINE_int32(pdfJpegQuality, -1, "Encodes images in JPEG at quality level N, "
|
|
|
|
"which can be in range 0-100). N = -1 will disable JPEG compression. "
|
|
|
|
"Default is N = 100, maximum quality.");
|
|
|
|
|
|
|
|
static bool encode_to_dct_stream(SkWStream* stream, const SkBitmap& bitmap, const SkIRect& rect) {
|
|
|
|
// Filter output of warnings that JPEG is not available for the image.
|
|
|
|
if (bitmap.width() >= 65500 || bitmap.height() >= 65500) return false;
|
|
|
|
if (FLAGS_pdfJpegQuality == -1) return false;
|
|
|
|
|
|
|
|
SkIRect bitmapBounds;
|
|
|
|
SkBitmap subset;
|
|
|
|
const SkBitmap* bitmapToUse = &bitmap;
|
|
|
|
bitmap.getBounds(&bitmapBounds);
|
|
|
|
if (rect != bitmapBounds) {
|
|
|
|
SkAssertResult(bitmap.extractSubset(&subset, rect));
|
|
|
|
bitmapToUse = ⊂
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(SK_BUILD_FOR_MAC)
|
|
|
|
// Workaround bug #1043 where bitmaps with referenced pixels cause
|
|
|
|
// CGImageDestinationFinalize to crash
|
|
|
|
SkBitmap copy;
|
|
|
|
bitmapToUse->deepCopyTo(©, bitmapToUse->config());
|
|
|
|
bitmapToUse = ©
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return SkImageEncoder::EncodeStream(stream,
|
|
|
|
*bitmapToUse,
|
|
|
|
SkImageEncoder::kJPEG_Type,
|
|
|
|
FLAGS_pdfJpegQuality);
|
|
|
|
}
|
2013-03-19 17:28:10 +00:00
|
|
|
|
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)) {
|
2013-03-20 14:20:18 +00:00
|
|
|
return (int) i;
|
2012-06-07 17:39:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-04-23 15:38:09 +00:00
|
|
|
static bool skip_name(SkCommandLineFlags::StringArray array, const char name[]) {
|
2013-05-10 15:16:13 +00:00
|
|
|
// FIXME: this duplicates the logic in test/skia_test.cpp -- consolidate
|
|
|
|
int count = array.count();
|
|
|
|
size_t testLen = strlen(name);
|
|
|
|
bool anyExclude = count == 0;
|
2011-10-31 16:30:04 +00:00
|
|
|
for (int i = 0; i < array.count(); ++i) {
|
2013-05-10 15:16:13 +00:00
|
|
|
const char* matchName = array[i];
|
|
|
|
size_t matchLen = strlen(matchName);
|
|
|
|
bool matchExclude, matchStart, matchEnd;
|
|
|
|
if ((matchExclude = matchName[0] == '~')) {
|
|
|
|
anyExclude = true;
|
|
|
|
matchName++;
|
|
|
|
matchLen--;
|
|
|
|
}
|
|
|
|
if ((matchStart = matchName[0] == '^')) {
|
|
|
|
matchName++;
|
|
|
|
matchLen--;
|
|
|
|
}
|
|
|
|
if ((matchEnd = matchName[matchLen - 1] == '$')) {
|
|
|
|
matchLen--;
|
|
|
|
}
|
|
|
|
if (matchStart ? (!matchEnd || matchLen == testLen)
|
|
|
|
&& strncmp(name, matchName, matchLen) == 0
|
|
|
|
: matchEnd ? matchLen <= testLen
|
|
|
|
&& strncmp(name + testLen - matchLen, matchName, matchLen) == 0
|
|
|
|
: strstr(name, matchName) != 0) {
|
|
|
|
return matchExclude;
|
2011-10-31 16:30:04 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-10 15:16:13 +00:00
|
|
|
return !anyExclude;
|
2011-10-31 16:30:04 +00:00
|
|
|
}
|
|
|
|
|
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
|
2013-03-21 13:49:54 +00:00
|
|
|
GrContext* GetGr();
|
2012-08-02 14:03:32 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-21 13:49:54 +00:00
|
|
|
/**
|
|
|
|
* Run this test in a number of different configs (8888, 565, PDF,
|
|
|
|
* etc.), confirming that the resulting bitmaps match expectations
|
|
|
|
* (which may be different for each config).
|
|
|
|
*
|
|
|
|
* Returns all errors encountered while doing so.
|
|
|
|
*/
|
2013-03-22 17:29:46 +00:00
|
|
|
ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<size_t> &configs,
|
|
|
|
GrContextFactory *grFactory);
|
|
|
|
ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<size_t> &configs,
|
|
|
|
GrContextFactory *grFactory) {
|
2013-04-10 12:17:34 +00:00
|
|
|
const char renderModeDescriptor[] = "";
|
2013-03-22 17:29:46 +00:00
|
|
|
ErrorCombination errorsForAllConfigs;
|
2013-03-21 13:49:54 +00:00
|
|
|
uint32_t gmFlags = gm->getFlags();
|
|
|
|
|
|
|
|
for (int i = 0; i < configs.count(); i++) {
|
|
|
|
ConfigData config = gRec[configs[i]];
|
2013-05-21 15:45:45 +00:00
|
|
|
const SkString shortNamePlusConfig = gmmain.make_shortname_plus_config(gm->shortName(),
|
|
|
|
config.fName);
|
2013-03-21 13:49:54 +00:00
|
|
|
|
|
|
|
// Skip any tests that we don't even need to try.
|
2013-04-10 12:17:34 +00:00
|
|
|
// If any of these were skipped on a per-GM basis, record them as
|
|
|
|
// kIntentionallySkipped.
|
|
|
|
if (kPDF_Backend == config.fBackend) {
|
|
|
|
if (!FLAGS_pdf) {
|
2013-03-21 13:49:54 +00:00
|
|
|
continue;
|
|
|
|
}
|
2013-04-10 12:17:34 +00:00
|
|
|
if (gmFlags & GM::kSkipPDF_Flag) {
|
2013-05-21 15:45:45 +00:00
|
|
|
gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlusConfig,
|
2013-04-10 12:17:34 +00:00
|
|
|
renderModeDescriptor);
|
|
|
|
errorsForAllConfigs.add(kIntentionallySkipped_ErrorType);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2013-03-21 13:49:54 +00:00
|
|
|
if ((gmFlags & GM::kSkip565_Flag) &&
|
|
|
|
(kRaster_Backend == config.fBackend) &&
|
|
|
|
(SkBitmap::kRGB_565_Config == config.fConfig)) {
|
2013-05-21 15:45:45 +00:00
|
|
|
gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlusConfig,
|
2013-04-10 12:17:34 +00:00
|
|
|
renderModeDescriptor);
|
|
|
|
errorsForAllConfigs.add(kIntentionallySkipped_ErrorType);
|
2013-03-21 13:49:54 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ((gmFlags & GM::kSkipGPU_Flag) &&
|
|
|
|
kGPU_Backend == config.fBackend) {
|
2013-05-21 15:45:45 +00:00
|
|
|
gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlusConfig,
|
2013-04-10 12:17:34 +00:00
|
|
|
renderModeDescriptor);
|
|
|
|
errorsForAllConfigs.add(kIntentionallySkipped_ErrorType);
|
2013-03-21 13:49:54 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now we know that we want to run this test and record its
|
|
|
|
// success or failure.
|
2013-03-22 17:29:46 +00:00
|
|
|
ErrorCombination errorsForThisConfig;
|
2013-03-28 19:18:12 +00:00
|
|
|
GrSurface* gpuTarget = NULL;
|
2013-03-21 13:49:54 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2013-03-28 19:18:12 +00:00
|
|
|
SkAutoTUnref<GrSurface> auGpuTarget;
|
2013-03-21 13:49:54 +00:00
|
|
|
AutoResetGr autogr;
|
2013-03-22 17:29:46 +00:00
|
|
|
if ((errorsForThisConfig.isEmpty()) && (kGPU_Backend == config.fBackend)) {
|
2013-03-21 13:49:54 +00:00
|
|
|
GrContext* gr = grFactory->get(config.fGLContextType);
|
|
|
|
bool grSuccess = false;
|
|
|
|
if (gr) {
|
|
|
|
// create a render target to back the device
|
|
|
|
GrTextureDesc desc;
|
|
|
|
desc.fConfig = kSkia8888_GrPixelConfig;
|
|
|
|
desc.fFlags = kRenderTarget_GrTextureFlagBit;
|
|
|
|
desc.fWidth = gm->getISize().width();
|
|
|
|
desc.fHeight = gm->getISize().height();
|
|
|
|
desc.fSampleCnt = config.fSampleCnt;
|
2013-03-28 19:18:12 +00:00
|
|
|
auGpuTarget.reset(gr->createUncachedTexture(desc, NULL, 0));
|
|
|
|
if (NULL != auGpuTarget) {
|
|
|
|
gpuTarget = auGpuTarget;
|
|
|
|
grSuccess = true;
|
2013-03-21 13:49:54 +00:00
|
|
|
autogr.set(gr);
|
2013-03-28 19:18:12 +00:00
|
|
|
// Set the user specified cache limits if non-default.
|
|
|
|
size_t bytes;
|
|
|
|
int count;
|
|
|
|
gr->getTextureCacheLimits(&count, &bytes);
|
|
|
|
if (DEFAULT_CACHE_VALUE != gGpuCacheSizeBytes) {
|
|
|
|
bytes = static_cast<size_t>(gGpuCacheSizeBytes);
|
|
|
|
}
|
|
|
|
if (DEFAULT_CACHE_VALUE != gGpuCacheSizeCount) {
|
|
|
|
count = gGpuCacheSizeCount;
|
|
|
|
}
|
|
|
|
gr->setTextureCacheLimits(count, bytes);
|
2013-03-21 13:49:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!grSuccess) {
|
2013-03-22 17:29:46 +00:00
|
|
|
errorsForThisConfig.add(kNoGpuContext_ErrorType);
|
2013-03-21 13:49:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
SkBitmap comparisonBitmap;
|
|
|
|
|
|
|
|
const char* writePath;
|
|
|
|
if (FLAGS_writePath.count() == 1) {
|
|
|
|
writePath = FLAGS_writePath[0];
|
|
|
|
} else {
|
|
|
|
writePath = NULL;
|
|
|
|
}
|
2013-03-22 17:29:46 +00:00
|
|
|
if (errorsForThisConfig.isEmpty()) {
|
2013-03-28 19:18:12 +00:00
|
|
|
errorsForThisConfig.add(gmmain.test_drawing(gm,config, writePath, gpuTarget,
|
|
|
|
&comparisonBitmap));
|
2013-03-21 13:49:54 +00:00
|
|
|
}
|
|
|
|
|
2013-03-22 17:29:46 +00:00
|
|
|
if (FLAGS_deferred && errorsForThisConfig.isEmpty() &&
|
|
|
|
(kGPU_Backend == config.fBackend || kRaster_Backend == config.fBackend)) {
|
|
|
|
errorsForThisConfig.add(gmmain.test_deferred_drawing(gm, config, comparisonBitmap,
|
2013-03-28 19:18:12 +00:00
|
|
|
gpuTarget));
|
2013-03-21 13:49:54 +00:00
|
|
|
}
|
|
|
|
|
2013-03-22 17:29:46 +00:00
|
|
|
errorsForAllConfigs.add(errorsForThisConfig);
|
2013-03-21 13:49:54 +00:00
|
|
|
}
|
|
|
|
return errorsForAllConfigs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run this test in a number of different drawing modes (pipe,
|
|
|
|
* deferred, tiled, etc.), confirming that the resulting bitmaps all
|
|
|
|
* *exactly* match comparisonBitmap.
|
|
|
|
*
|
|
|
|
* Returns all errors encountered while doing so.
|
|
|
|
*/
|
2013-03-22 17:29:46 +00:00
|
|
|
ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &compareConfig,
|
|
|
|
const SkBitmap &comparisonBitmap,
|
|
|
|
const SkTDArray<SkScalar> &tileGridReplayScales);
|
|
|
|
ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &compareConfig,
|
|
|
|
const SkBitmap &comparisonBitmap,
|
|
|
|
const SkTDArray<SkScalar> &tileGridReplayScales) {
|
|
|
|
ErrorCombination errorsForAllModes;
|
2013-03-21 13:49:54 +00:00
|
|
|
uint32_t gmFlags = gm->getFlags();
|
2013-05-21 15:45:45 +00:00
|
|
|
const SkString shortNamePlusConfig = gmmain.make_shortname_plus_config(gm->shortName(),
|
|
|
|
compareConfig.fName);
|
2013-04-10 12:17:34 +00:00
|
|
|
|
|
|
|
SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0);
|
|
|
|
SkAutoUnref aur(pict);
|
|
|
|
if (FLAGS_replay) {
|
|
|
|
const char renderModeDescriptor[] = "-replay";
|
|
|
|
if (gmFlags & GM::kSkipPicture_Flag) {
|
2013-05-21 15:45:45 +00:00
|
|
|
gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlusConfig,
|
|
|
|
renderModeDescriptor);
|
2013-04-10 12:17:34 +00:00
|
|
|
errorsForAllModes.add(kIntentionallySkipped_ErrorType);
|
|
|
|
} else {
|
2013-03-21 13:49:54 +00:00
|
|
|
SkBitmap bitmap;
|
|
|
|
gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap);
|
2013-04-10 12:17:34 +00:00
|
|
|
errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitmap(
|
2013-05-21 15:45:45 +00:00
|
|
|
gm->shortName(), compareConfig.fName, renderModeDescriptor, bitmap,
|
|
|
|
&comparisonBitmap));
|
2013-03-21 13:49:54 +00:00
|
|
|
}
|
2013-04-10 12:17:34 +00:00
|
|
|
}
|
2013-03-21 13:49:54 +00:00
|
|
|
|
2013-04-10 12:17:34 +00:00
|
|
|
if (FLAGS_serialize) {
|
|
|
|
const char renderModeDescriptor[] = "-serialize";
|
|
|
|
if (gmFlags & GM::kSkipPicture_Flag) {
|
2013-05-21 15:45:45 +00:00
|
|
|
gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlusConfig,
|
|
|
|
renderModeDescriptor);
|
2013-04-10 12:17:34 +00:00
|
|
|
errorsForAllModes.add(kIntentionallySkipped_ErrorType);
|
|
|
|
} else {
|
2013-03-21 13:49:54 +00:00
|
|
|
SkPicture* repict = gmmain.stream_to_new_picture(*pict);
|
|
|
|
SkAutoUnref aurr(repict);
|
|
|
|
SkBitmap bitmap;
|
|
|
|
gmmain.generate_image_from_picture(gm, compareConfig, repict, &bitmap);
|
2013-04-10 12:17:34 +00:00
|
|
|
errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitmap(
|
2013-05-21 15:45:45 +00:00
|
|
|
gm->shortName(), compareConfig.fName, renderModeDescriptor, bitmap,
|
|
|
|
&comparisonBitmap));
|
2013-03-21 13:49:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-10 12:17:34 +00:00
|
|
|
if ((1 == FLAGS_writePicturePath.count()) &&
|
|
|
|
!(gmFlags & GM::kSkipPicture_Flag)) {
|
|
|
|
const char* pictureSuffix = "skp";
|
2013-05-21 15:45:45 +00:00
|
|
|
// TODO(epoger): Make sure this still works even though the
|
|
|
|
// filename now contains the config name (it used to contain
|
|
|
|
// just the shortName). I think this is actually an
|
|
|
|
// *improvement*, because now runs with different configs will
|
|
|
|
// write out their SkPictures to separate files rather than
|
|
|
|
// overwriting each other. But we should make sure it doesn't
|
|
|
|
// break anybody.
|
|
|
|
SkString path = gmmain.make_filename(FLAGS_writePicturePath[0], gm->shortName(),
|
|
|
|
compareConfig.fName, "", pictureSuffix);
|
2013-04-10 12:17:34 +00:00
|
|
|
SkFILEWStream stream(path.c_str());
|
|
|
|
pict->serialize(&stream);
|
2013-03-21 13:49:54 +00:00
|
|
|
}
|
|
|
|
|
2013-04-10 12:17:34 +00:00
|
|
|
if (FLAGS_rtree) {
|
|
|
|
const char renderModeDescriptor[] = "-rtree";
|
|
|
|
if (gmFlags & GM::kSkipPicture_Flag) {
|
2013-05-21 15:45:45 +00:00
|
|
|
gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlusConfig,
|
|
|
|
renderModeDescriptor);
|
2013-04-10 12:17:34 +00:00
|
|
|
errorsForAllModes.add(kIntentionallySkipped_ErrorType);
|
|
|
|
} else {
|
2013-03-21 13:49:54 +00:00
|
|
|
SkPicture* pict = gmmain.generate_new_picture(
|
2013-04-10 12:17:34 +00:00
|
|
|
gm, kRTree_BbhType, SkPicture::kUsePathBoundsForClip_RecordingFlag);
|
2013-03-21 13:49:54 +00:00
|
|
|
SkAutoUnref aur(pict);
|
|
|
|
SkBitmap bitmap;
|
2013-04-10 12:17:34 +00:00
|
|
|
gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap);
|
2013-03-22 17:29:46 +00:00
|
|
|
errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitmap(
|
2013-05-21 15:45:45 +00:00
|
|
|
gm->shortName(), compareConfig.fName, renderModeDescriptor, bitmap,
|
|
|
|
&comparisonBitmap));
|
2013-03-21 13:49:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-10 12:17:34 +00:00
|
|
|
if (FLAGS_tileGrid) {
|
|
|
|
for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); ++scaleIndex) {
|
|
|
|
SkScalar replayScale = tileGridReplayScales[scaleIndex];
|
|
|
|
SkString renderModeDescriptor("-tilegrid");
|
|
|
|
if (SK_Scalar1 != replayScale) {
|
|
|
|
renderModeDescriptor += "-scale-";
|
|
|
|
renderModeDescriptor.appendScalar(replayScale);
|
|
|
|
}
|
2013-03-21 13:49:54 +00:00
|
|
|
|
2013-04-10 12:17:34 +00:00
|
|
|
if ((gmFlags & GM::kSkipPicture_Flag) ||
|
|
|
|
((gmFlags & GM::kSkipScaledReplay_Flag) && replayScale != 1)) {
|
2013-05-21 15:45:45 +00:00
|
|
|
gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlusConfig,
|
2013-04-10 12:17:34 +00:00
|
|
|
renderModeDescriptor.c_str());
|
|
|
|
errorsForAllModes.add(kIntentionallySkipped_ErrorType);
|
|
|
|
} else {
|
|
|
|
// We record with the reciprocal scale to obtain a replay
|
|
|
|
// result that can be validated against comparisonBitmap.
|
|
|
|
SkScalar recordScale = SkScalarInvert(replayScale);
|
|
|
|
SkPicture* pict = gmmain.generate_new_picture(
|
|
|
|
gm, kTileGrid_BbhType, SkPicture::kUsePathBoundsForClip_RecordingFlag,
|
|
|
|
recordScale);
|
|
|
|
SkAutoUnref aur(pict);
|
|
|
|
SkBitmap bitmap;
|
|
|
|
// We cannot yet pass 'true' to generate_image_from_picture to
|
|
|
|
// perform actual tiled rendering (see Issue 1198 -
|
|
|
|
// https://code.google.com/p/skia/issues/detail?id=1198)
|
|
|
|
gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap,
|
|
|
|
replayScale /*, true */);
|
|
|
|
errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitmap(
|
2013-05-21 15:45:45 +00:00
|
|
|
gm->shortName(), compareConfig.fName, renderModeDescriptor.c_str(), bitmap,
|
|
|
|
&comparisonBitmap));
|
2013-04-10 12:17:34 +00:00
|
|
|
}
|
2013-03-21 13:49:54 +00:00
|
|
|
}
|
2013-04-10 12:17:34 +00:00
|
|
|
}
|
2013-03-21 13:49:54 +00:00
|
|
|
|
2013-04-10 12:17:34 +00:00
|
|
|
// run the pipe centric GM steps
|
|
|
|
if (FLAGS_pipe) {
|
|
|
|
errorsForAllModes.add(gmmain.test_pipe_playback(gm, compareConfig, comparisonBitmap,
|
|
|
|
FLAGS_simulatePipePlaybackFailure));
|
|
|
|
if (FLAGS_tiledPipe) {
|
|
|
|
errorsForAllModes.add(gmmain.test_tiled_pipe_playback(gm, compareConfig,
|
|
|
|
comparisonBitmap));
|
2013-03-21 13:49:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return errorsForAllModes;
|
|
|
|
}
|
|
|
|
|
2013-04-03 18:00:39 +00:00
|
|
|
/**
|
|
|
|
* Return a list of all entries in an array of strings as a single string
|
|
|
|
* of this form:
|
|
|
|
* "item1", "item2", "item3"
|
|
|
|
*/
|
|
|
|
SkString list_all(const SkTArray<SkString> &stringArray);
|
|
|
|
SkString list_all(const SkTArray<SkString> &stringArray) {
|
|
|
|
SkString total;
|
|
|
|
for (int i = 0; i < stringArray.count(); i++) {
|
|
|
|
if (i > 0) {
|
|
|
|
total.append(", ");
|
|
|
|
}
|
|
|
|
total.append("\"");
|
|
|
|
total.append(stringArray[i]);
|
|
|
|
total.append("\"");
|
|
|
|
}
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a list of configuration names, as a single string of this form:
|
|
|
|
* "item1", "item2", "item3"
|
|
|
|
*
|
|
|
|
* @param configs configurations, as a list of indices into gRec
|
|
|
|
*/
|
|
|
|
SkString list_all_config_names(const SkTDArray<size_t> &configs);
|
|
|
|
SkString list_all_config_names(const SkTDArray<size_t> &configs) {
|
|
|
|
SkString total;
|
|
|
|
for (int i = 0; i < configs.count(); i++) {
|
|
|
|
if (i > 0) {
|
|
|
|
total.append(", ");
|
|
|
|
}
|
|
|
|
total.append("\"");
|
|
|
|
total.append(gRec[configs[i]].fName);
|
|
|
|
total.append("\"");
|
|
|
|
}
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
2013-05-02 18:24:03 +00:00
|
|
|
bool prepare_subdirectories(const char *root, bool useFileHierarchy,
|
|
|
|
const SkTDArray<size_t> &configs);
|
|
|
|
bool prepare_subdirectories(const char *root, bool useFileHierarchy,
|
|
|
|
const SkTDArray<size_t> &configs) {
|
|
|
|
if (!sk_mkdir(root)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (useFileHierarchy) {
|
|
|
|
for (int i = 0; i < configs.count(); i++) {
|
|
|
|
ConfigData config = gRec[configs[i]];
|
|
|
|
SkString subdir;
|
|
|
|
subdir.appendf("%s%c%s", root, SkPATH_SEPARATOR, config.fName);
|
|
|
|
if (!sk_mkdir(subdir.c_str())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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-06-07 17:39:48 +00:00
|
|
|
SkTDArray<size_t> configs;
|
2013-01-04 14:43:03 +00:00
|
|
|
SkTDArray<size_t> excludeConfigs;
|
2012-06-07 17:39:48 +00:00
|
|
|
bool userConfig = false;
|
2012-01-31 18:35:30 +00:00
|
|
|
|
2013-03-20 14:20:18 +00:00
|
|
|
SkString usage;
|
2013-03-20 15:35:08 +00:00
|
|
|
usage.printf("Run the golden master tests.\n");
|
2013-03-21 19:43:15 +00:00
|
|
|
SkCommandLineFlags::SetUsage(usage.c_str());
|
|
|
|
SkCommandLineFlags::Parse(argc, argv);
|
2012-10-18 21:30:57 +00:00
|
|
|
|
2013-03-20 14:20:18 +00:00
|
|
|
gmmain.fUseFileHierarchy = FLAGS_hierarchy;
|
|
|
|
if (FLAGS_mismatchPath.count() == 1) {
|
|
|
|
gmmain.fMismatchPath = FLAGS_mismatchPath[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < FLAGS_config.count(); i++) {
|
2013-04-24 18:07:11 +00:00
|
|
|
const char* config = FLAGS_config[i];
|
|
|
|
userConfig = true;
|
|
|
|
bool exclude = false;
|
|
|
|
if (*config == kExcludeConfigChar) {
|
|
|
|
exclude = true;
|
|
|
|
config += 1;
|
|
|
|
}
|
|
|
|
int index = findConfig(config);
|
2013-03-20 14:20:18 +00:00
|
|
|
if (index >= 0) {
|
2013-04-24 18:07:11 +00:00
|
|
|
if (exclude) {
|
|
|
|
*excludeConfigs.append() = index;
|
|
|
|
} else {
|
|
|
|
appendUnique<size_t>(&configs, index);
|
|
|
|
}
|
|
|
|
} else if (0 == strcmp(kDefaultsConfigStr, config)) {
|
|
|
|
for (size_t c = 0; c < SK_ARRAY_COUNT(gRec); ++c) {
|
|
|
|
if (gRec[c].fRunByDefault) {
|
|
|
|
if (exclude) {
|
|
|
|
gm_fprintf(stderr, "%c%s is not allowed.\n",
|
|
|
|
kExcludeConfigChar, kDefaultsConfigStr);
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
appendUnique<size_t>(&configs, c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-03-20 14:20:18 +00:00
|
|
|
} else {
|
2013-04-24 18:07:11 +00:00
|
|
|
gm_fprintf(stderr, "unrecognized config %s\n", config);
|
2012-03-20 17:40:58 +00:00
|
|
|
return -1;
|
2013-03-20 14:20:18 +00:00
|
|
|
}
|
|
|
|
}
|
2013-03-19 17:28:10 +00:00
|
|
|
|
2013-03-20 14:20:18 +00:00
|
|
|
for (int i = 0; i < FLAGS_excludeConfig.count(); i++) {
|
|
|
|
int index = findConfig(FLAGS_excludeConfig[i]);
|
|
|
|
if (index >= 0) {
|
|
|
|
*excludeConfigs.append() = index;
|
2013-03-19 17:38:50 +00:00
|
|
|
} else {
|
2013-03-20 14:20:18 +00:00
|
|
|
gm_fprintf(stderr, "unrecognized excludeConfig %s\n", FLAGS_excludeConfig[i]);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int moduloRemainder = -1;
|
|
|
|
int moduloDivisor = -1;
|
|
|
|
|
|
|
|
if (FLAGS_modulo.count() == 2) {
|
|
|
|
moduloRemainder = atoi(FLAGS_modulo[0]);
|
|
|
|
moduloDivisor = atoi(FLAGS_modulo[1]);
|
|
|
|
if (moduloRemainder < 0 || moduloDivisor <= 0 || moduloRemainder >= moduloDivisor) {
|
|
|
|
gm_fprintf(stderr, "invalid modulo values.");
|
|
|
|
return -1;
|
|
|
|
}
|
2011-04-25 15:49:53 +00:00
|
|
|
}
|
2010-12-23 15:00:45 +00:00
|
|
|
|
2013-04-12 14:11:21 +00:00
|
|
|
if (FLAGS_ignoreErrorTypes.count() > 0) {
|
|
|
|
gmmain.fIgnorableErrorTypes = ErrorCombination();
|
|
|
|
for (int i = 0; i < FLAGS_ignoreErrorTypes.count(); i++) {
|
|
|
|
ErrorType type;
|
|
|
|
const char *name = FLAGS_ignoreErrorTypes[i];
|
|
|
|
if (!getErrorTypeByName(name, &type)) {
|
|
|
|
gm_fprintf(stderr, "cannot find ErrorType with name '%s'\n", name);
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
gmmain.fIgnorableErrorTypes.add(type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-22 17:29:46 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
if (FLAGS_gpuCacheSize.count() > 0) {
|
|
|
|
if (FLAGS_gpuCacheSize.count() != 2) {
|
|
|
|
gm_fprintf(stderr, "--gpuCacheSize requires two arguments\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
gGpuCacheSizeBytes = atoi(FLAGS_gpuCacheSize[0]);
|
|
|
|
gGpuCacheSizeCount = atoi(FLAGS_gpuCacheSize[1]);
|
|
|
|
} else {
|
|
|
|
gGpuCacheSizeBytes = DEFAULT_CACHE_VALUE;
|
|
|
|
gGpuCacheSizeCount = DEFAULT_CACHE_VALUE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
SkTDArray<SkScalar> tileGridReplayScales;
|
|
|
|
*tileGridReplayScales.append() = SK_Scalar1; // By default only test at scale 1.0
|
|
|
|
if (FLAGS_tileGridReplayScales.count() > 0) {
|
|
|
|
tileGridReplayScales.reset();
|
|
|
|
for (int i = 0; i < FLAGS_tileGridReplayScales.count(); i++) {
|
|
|
|
double val = atof(FLAGS_tileGridReplayScales[i]);
|
|
|
|
if (0 < val) {
|
|
|
|
*tileGridReplayScales.append() = SkDoubleToScalar(val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (0 == tileGridReplayScales.count()) {
|
|
|
|
// Should have at least one scale
|
|
|
|
gm_fprintf(stderr, "--tileGridReplayScales requires at least one scale.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-07 17:39:48 +00:00
|
|
|
if (!userConfig) {
|
2013-03-19 18:58:43 +00:00
|
|
|
// if no config is specified by user, add the defaults
|
2012-06-07 17:39:48 +00:00
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
|
2013-03-19 18:58:43 +00:00
|
|
|
if (gRec[i].fRunByDefault) {
|
|
|
|
*configs.append() = i;
|
|
|
|
}
|
2012-06-07 17:39:48 +00:00
|
|
|
}
|
|
|
|
}
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-19 18:58:43 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
GrContextFactory* grFactory = new GrContextFactory;
|
|
|
|
for (int i = 0; i < configs.count(); ++i) {
|
2013-03-20 14:20:18 +00:00
|
|
|
size_t index = configs[i];
|
2013-03-19 18:58:43 +00:00
|
|
|
if (kGPU_Backend == gRec[index].fBackend) {
|
|
|
|
GrContext* ctx = grFactory->get(gRec[index].fGLContextType);
|
|
|
|
if (NULL == ctx) {
|
2013-04-10 18:46:25 +00:00
|
|
|
gm_fprintf(stderr, "GrContext could not be created for config %s."
|
|
|
|
" Config will be skipped.\n", gRec[index].fName);
|
2013-03-19 18:58:43 +00:00
|
|
|
configs.remove(i);
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
if (gRec[index].fSampleCnt > ctx->getMaxSampleCount()) {
|
2013-04-10 18:46:25 +00:00
|
|
|
gm_fprintf(stderr, "Sample count (%d) of config %s is not supported."
|
|
|
|
" Config will be skipped.\n", gRec[index].fSampleCnt, gRec[index].fName);
|
2013-03-19 18:58:43 +00:00
|
|
|
configs.remove(i);
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-03-21 13:49:54 +00:00
|
|
|
#else
|
|
|
|
GrContextFactory* grFactory = NULL;
|
2013-03-19 18:58:43 +00:00
|
|
|
#endif
|
|
|
|
|
2013-04-24 18:07:11 +00:00
|
|
|
if (configs.isEmpty()) {
|
|
|
|
gm_fprintf(stderr, "No configs to run.");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// now show the user the set of configs that will be run.
|
|
|
|
SkString configStr("These configs will be run: ");
|
|
|
|
// show the user the config that will run.
|
|
|
|
for (int i = 0; i < configs.count(); ++i) {
|
|
|
|
configStr.appendf("%s%s", gRec[configs[i]].fName, (i == configs.count() - 1) ? "\n" : " ");
|
|
|
|
}
|
|
|
|
gm_fprintf(stdout, "%s", configStr.c_str());
|
|
|
|
|
2013-03-20 14:20:18 +00:00
|
|
|
if (FLAGS_resourcePath.count() == 1) {
|
|
|
|
GM::SetResourcePath(FLAGS_resourcePath[0]);
|
|
|
|
}
|
2012-03-20 17:40:58 +00:00
|
|
|
|
2013-03-20 14:20:18 +00:00
|
|
|
if (FLAGS_readPath.count() == 1) {
|
|
|
|
const char* readPath = FLAGS_readPath[0];
|
2013-01-19 04:21:27 +00:00
|
|
|
if (!sk_exists(readPath)) {
|
2013-03-13 14:18:40 +00:00
|
|
|
gm_fprintf(stderr, "readPath %s does not exist!\n", readPath);
|
2013-01-19 04:21:27 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (sk_isdir(readPath)) {
|
2013-04-10 18:46:25 +00:00
|
|
|
if (FLAGS_verbose) {
|
|
|
|
gm_fprintf(stdout, "reading from %s\n", readPath);
|
|
|
|
}
|
2013-01-19 04:21:27 +00:00
|
|
|
gmmain.fExpectationsSource.reset(SkNEW_ARGS(
|
2013-04-10 18:46:25 +00:00
|
|
|
IndividualImageExpectationsSource, (readPath)));
|
2013-01-19 04:21:27 +00:00
|
|
|
} else {
|
2013-04-10 18:46:25 +00:00
|
|
|
if (FLAGS_verbose) {
|
|
|
|
gm_fprintf(stdout, "reading expectations from JSON summary file %s\n", readPath);
|
|
|
|
}
|
2013-02-13 18:14:48 +00:00
|
|
|
gmmain.fExpectationsSource.reset(SkNEW_ARGS(
|
|
|
|
JsonExpectationsSource, (readPath)));
|
2013-01-19 04:21:27 +00:00
|
|
|
}
|
2012-07-12 15:42:37 +00:00
|
|
|
}
|
2013-04-10 18:46:25 +00:00
|
|
|
if (FLAGS_verbose) {
|
|
|
|
if (FLAGS_writePath.count() == 1) {
|
|
|
|
gm_fprintf(stdout, "writing to %s\n", FLAGS_writePath[0]);
|
|
|
|
}
|
2013-05-02 18:24:03 +00:00
|
|
|
if (NULL != gmmain.fMismatchPath) {
|
|
|
|
gm_fprintf(stdout, "writing mismatches to %s\n", gmmain.fMismatchPath);
|
|
|
|
}
|
2013-04-10 18:46:25 +00:00
|
|
|
if (FLAGS_writePicturePath.count() == 1) {
|
|
|
|
gm_fprintf(stdout, "writing pictures to %s\n", FLAGS_writePicturePath[0]);
|
|
|
|
}
|
|
|
|
if (FLAGS_resourcePath.count() == 1) {
|
|
|
|
gm_fprintf(stdout, "reading resources from %s\n", FLAGS_resourcePath[0]);
|
|
|
|
}
|
2012-03-20 17:40:58 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-04-03 18:00:39 +00:00
|
|
|
int gmsRun = 0;
|
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.
|
2013-03-20 14:20:18 +00:00
|
|
|
if (FLAGS_writePath.count() == 1) {
|
2013-05-02 18:24:03 +00:00
|
|
|
if (!prepare_subdirectories(FLAGS_writePath[0], gmmain.fUseFileHierarchy, configs)) {
|
2012-10-29 16:42:11 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2013-05-02 18:24:03 +00:00
|
|
|
}
|
|
|
|
if (NULL != gmmain.fMismatchPath) {
|
|
|
|
if (!prepare_subdirectories(gmmain.fMismatchPath, gmmain.fUseFileHierarchy, configs)) {
|
|
|
|
return -1;
|
2012-10-29 16:42:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-24 13:01:01 +00:00
|
|
|
if (FLAGS_pdfJpegQuality < -1 || FLAGS_pdfJpegQuality > 100) {
|
|
|
|
gm_fprintf(stderr, "%s\n", "pdfJpegQuality must be in [-1 .. 100] range.");
|
|
|
|
}
|
|
|
|
|
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) {
|
2013-04-16 19:11:14 +00:00
|
|
|
SkAutoTDelete<GM> adgm(gm);
|
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();
|
2013-03-20 14:20:18 +00:00
|
|
|
if (skip_name(FLAGS_match, shortName)) {
|
2011-07-25 14:28:57 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-04-03 18:00:39 +00:00
|
|
|
gmsRun++;
|
2011-04-25 15:49:53 +00:00
|
|
|
SkISize size = gm->getISize();
|
2013-04-12 02:11:54 +00:00
|
|
|
gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), shortName,
|
|
|
|
size.width(), size.height());
|
2012-10-26 14:07:13 +00:00
|
|
|
|
2013-04-03 18:00:39 +00:00
|
|
|
run_multiple_configs(gmmain, gm, configs, grFactory);
|
2011-12-28 19:31:01 +00:00
|
|
|
|
2012-10-26 14:07:13 +00:00
|
|
|
SkBitmap comparisonBitmap;
|
|
|
|
const ConfigData compareConfig =
|
2013-03-19 18:58:43 +00:00
|
|
|
{ SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextType, 0, kRW_ConfigFlag, "comparison", false };
|
2013-04-03 18:00:39 +00:00
|
|
|
gmmain.generate_image(gm, compareConfig, NULL, &comparisonBitmap, false);
|
2012-06-04 17:17:36 +00:00
|
|
|
|
2013-03-21 13:49:54 +00:00
|
|
|
// TODO(epoger): only run this if gmmain.generate_image() succeeded?
|
|
|
|
// Otherwise, what are we comparing against?
|
2013-04-03 18:00:39 +00:00
|
|
|
run_multiple_modes(gmmain, gm, compareConfig, comparisonBitmap, tileGridReplayScales);
|
2009-06-10 15:38:48 +00:00
|
|
|
}
|
2013-04-03 18:00:39 +00:00
|
|
|
|
|
|
|
SkTArray<SkString> modes;
|
|
|
|
gmmain.GetRenderModesEncountered(modes);
|
2013-04-10 12:17:34 +00:00
|
|
|
bool reportError = false;
|
|
|
|
if (gmmain.NumSignificantErrors() > 0) {
|
|
|
|
reportError = true;
|
|
|
|
}
|
2013-04-10 15:24:53 +00:00
|
|
|
int expectedNumberOfTests = gmsRun * (configs.count() + modes.count());
|
2013-04-03 18:00:39 +00:00
|
|
|
|
|
|
|
// Output summary to stdout.
|
2013-04-10 15:24:53 +00:00
|
|
|
if (FLAGS_verbose) {
|
|
|
|
gm_fprintf(stdout, "Ran %d GMs\n", gmsRun);
|
|
|
|
gm_fprintf(stdout, "... over %2d configs [%s]\n", configs.count(),
|
|
|
|
list_all_config_names(configs).c_str());
|
|
|
|
gm_fprintf(stdout, "... and %2d modes [%s]\n", modes.count(), list_all(modes).c_str());
|
|
|
|
gm_fprintf(stdout, "... so there should be a total of %d tests.\n", expectedNumberOfTests);
|
|
|
|
}
|
|
|
|
gmmain.ListErrors(FLAGS_verbose);
|
2012-08-22 10:57:05 +00:00
|
|
|
|
2013-04-11 15:41:02 +00:00
|
|
|
// TODO(epoger): Enable this check for Android, too, once we resolve
|
|
|
|
// https://code.google.com/p/skia/issues/detail?id=1222
|
|
|
|
// ('GM is unexpectedly skipping tests on Android')
|
|
|
|
#ifndef SK_BUILD_FOR_ANDROID
|
2013-04-10 12:17:34 +00:00
|
|
|
if (expectedNumberOfTests != gmmain.fTestsRun) {
|
|
|
|
gm_fprintf(stderr, "expected %d tests, but ran or skipped %d tests\n",
|
|
|
|
expectedNumberOfTests, gmmain.fTestsRun);
|
|
|
|
reportError = true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-03-20 14:20:18 +00:00
|
|
|
if (FLAGS_writeJsonSummaryPath.count() == 1) {
|
2013-04-26 15:06:44 +00:00
|
|
|
Json::Value root = CreateJsonTree(
|
|
|
|
gmmain.fJsonExpectedResults,
|
|
|
|
gmmain.fJsonActualResults_Failed, gmmain.fJsonActualResults_FailureIgnored,
|
|
|
|
gmmain.fJsonActualResults_NoComparison, gmmain.fJsonActualResults_Succeeded);
|
2012-12-18 19:13:49 +00:00
|
|
|
std::string jsonStdString = root.toStyledString();
|
2013-03-20 14:20:18 +00:00
|
|
|
SkFILEWStream stream(FLAGS_writeJsonSummaryPath[0]);
|
2012-12-18 19:13:49 +00:00
|
|
|
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]];
|
|
|
|
|
2013-04-10 18:46:25 +00:00
|
|
|
if (FLAGS_verbose && (kGPU_Backend == config.fBackend)) {
|
2012-08-22 10:57:05 +00:00
|
|
|
GrContext* gr = grFactory->get(config.fGLContextType);
|
|
|
|
|
2013-03-13 14:18:40 +00:00
|
|
|
gm_fprintf(stdout, "config: %s %x\n", config.fName, gr);
|
2012-08-22 10:57:05 +00:00
|
|
|
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();
|
|
|
|
|
2013-04-10 12:17:34 +00:00
|
|
|
return (reportError) ? -1 : 0;
|
2009-06-10 15:38:48 +00:00
|
|
|
}
|
2012-10-02 18:33:14 +00:00
|
|
|
|
2013-03-20 14:20:18 +00:00
|
|
|
void GMMain::installFilter(SkCanvas* canvas) {
|
|
|
|
if (FLAGS_forceBWtext) {
|
|
|
|
canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|