2016-02-24 17:25:58 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Benchmark.h"
|
2016-12-30 18:09:03 +00:00
|
|
|
|
2016-02-24 17:25:58 +00:00
|
|
|
#include "Resources.h"
|
2016-03-17 13:58:39 +00:00
|
|
|
#include "SkAutoPixmapStorage.h"
|
2016-02-24 17:25:58 +00:00
|
|
|
#include "SkData.h"
|
2018-12-11 00:59:07 +00:00
|
|
|
#include "SkExecutor.h"
|
2018-01-02 21:25:53 +00:00
|
|
|
#include "SkFloatToDecimal.h"
|
2016-03-25 12:52:57 +00:00
|
|
|
#include "SkGradientShader.h"
|
2016-02-24 23:17:19 +00:00
|
|
|
#include "SkImage.h"
|
2018-12-18 20:11:03 +00:00
|
|
|
#include "SkPDFUnion.h"
|
2016-02-24 23:17:19 +00:00
|
|
|
#include "SkPixmap.h"
|
2016-03-09 18:49:23 +00:00
|
|
|
#include "SkRandom.h"
|
2016-04-12 02:41:48 +00:00
|
|
|
#include "SkStream.h"
|
2018-06-13 13:59:02 +00:00
|
|
|
#include "SkTo.h"
|
2016-02-24 17:25:58 +00:00
|
|
|
|
|
|
|
namespace {
|
2016-12-30 18:09:03 +00:00
|
|
|
struct WStreamWriteTextBenchmark : public Benchmark {
|
|
|
|
std::unique_ptr<SkWStream> fWStream;
|
2017-03-22 14:01:53 +00:00
|
|
|
WStreamWriteTextBenchmark() : fWStream(new SkNullWStream) {}
|
2016-12-30 18:09:03 +00:00
|
|
|
const char* onGetName() override { return "WStreamWriteText"; }
|
|
|
|
bool isSuitableFor(Backend backend) override {
|
|
|
|
return backend == kNonRendering_Backend;
|
|
|
|
}
|
|
|
|
void onDraw(int loops, SkCanvas*) override {
|
|
|
|
while (loops-- > 0) {
|
|
|
|
for (int i = 1000; i-- > 0;) {
|
|
|
|
fWStream->writeText("HELLO SKIA!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
DEF_BENCH(return new WStreamWriteTextBenchmark;)
|
|
|
|
|
2018-01-02 21:25:53 +00:00
|
|
|
// Test speed of SkFloatToDecimal for typical floats that
|
|
|
|
// might be found in a PDF document.
|
|
|
|
struct PDFScalarBench : public Benchmark {
|
2018-02-21 20:49:41 +00:00
|
|
|
PDFScalarBench(const char* n, float (*f)(SkRandom*)) : fName(n), fNextFloat(f) {}
|
|
|
|
const char* fName;
|
|
|
|
float (*fNextFloat)(SkRandom*);
|
2018-01-02 21:25:53 +00:00
|
|
|
bool isSuitableFor(Backend b) override {
|
|
|
|
return b == kNonRendering_Backend;
|
|
|
|
}
|
2018-02-21 20:49:41 +00:00
|
|
|
const char* onGetName() override { return fName; }
|
2018-01-02 21:25:53 +00:00
|
|
|
void onDraw(int loops, SkCanvas*) override {
|
|
|
|
SkRandom random;
|
|
|
|
char dst[kMaximumSkFloatToDecimalLength];
|
|
|
|
while (loops-- > 0) {
|
2018-02-21 20:49:41 +00:00
|
|
|
auto f = fNextFloat(&random);
|
2018-01-02 21:25:53 +00:00
|
|
|
(void)SkFloatToDecimal(f, dst);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-02-21 20:49:41 +00:00
|
|
|
float next_common(SkRandom* random) {
|
|
|
|
return random->nextRangeF(-500.0f, 1500.0f);
|
|
|
|
}
|
|
|
|
float next_any(SkRandom* random) {
|
|
|
|
union { uint32_t u; float f; };
|
|
|
|
u = random->nextU();
|
|
|
|
static_assert(sizeof(float) == sizeof(uint32_t), "");
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_BENCH(return new PDFScalarBench("PDFScalar_common", next_common);)
|
|
|
|
DEF_BENCH(return new PDFScalarBench("PDFScalar_random", next_any);)
|
2018-01-02 21:25:53 +00:00
|
|
|
|
2016-12-30 18:09:03 +00:00
|
|
|
#ifdef SK_SUPPORT_PDF
|
|
|
|
|
|
|
|
#include "SkPDFBitmap.h"
|
2018-09-07 18:33:14 +00:00
|
|
|
#include "SkPDFDocumentPriv.h"
|
2016-12-30 18:09:03 +00:00
|
|
|
#include "SkPDFShader.h"
|
2018-09-07 18:33:14 +00:00
|
|
|
#include "SkPDFUtils.h"
|
2016-12-30 18:09:03 +00:00
|
|
|
|
|
|
|
namespace {
|
2016-02-24 17:25:58 +00:00
|
|
|
class PDFImageBench : public Benchmark {
|
|
|
|
public:
|
|
|
|
PDFImageBench() {}
|
2017-03-22 16:05:03 +00:00
|
|
|
~PDFImageBench() override {}
|
2016-02-24 17:25:58 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
const char* onGetName() override { return "PDFImage"; }
|
|
|
|
bool isSuitableFor(Backend backend) override {
|
|
|
|
return backend == kNonRendering_Backend;
|
|
|
|
}
|
|
|
|
void onDelayedSetup() override {
|
2017-12-08 15:21:31 +00:00
|
|
|
sk_sp<SkImage> img(GetResourceAsImage("images/color_wheel.png"));
|
2016-02-24 17:25:58 +00:00
|
|
|
if (img) {
|
|
|
|
// force decoding, throw away reference to encoded data.
|
|
|
|
SkAutoPixmapStorage pixmap;
|
|
|
|
pixmap.alloc(SkImageInfo::MakeN32Premul(img->dimensions()));
|
|
|
|
if (img->readPixels(pixmap, 0, 0)) {
|
2016-03-17 17:51:11 +00:00
|
|
|
fImage = SkImage::MakeRasterCopy(pixmap);
|
2016-02-24 17:25:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void onDraw(int loops, SkCanvas*) override {
|
|
|
|
if (!fImage) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
while (loops-- > 0) {
|
2018-11-13 21:45:14 +00:00
|
|
|
SkNullWStream nullStream;
|
|
|
|
SkPDFDocument doc(&nullStream, SkPDF::Metadata());
|
|
|
|
doc.beginPage(256, 256);
|
|
|
|
(void)SkPDFSerializeImage(fImage.get(), &doc);
|
2016-02-24 17:25:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> fImage;
|
2016-02-24 17:25:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class PDFJpegImageBench : public Benchmark {
|
|
|
|
public:
|
|
|
|
PDFJpegImageBench() {}
|
2017-03-22 16:05:03 +00:00
|
|
|
~PDFJpegImageBench() override {}
|
2016-02-24 17:25:58 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
const char* onGetName() override { return "PDFJpegImage"; }
|
|
|
|
bool isSuitableFor(Backend backend) override {
|
|
|
|
return backend == kNonRendering_Backend;
|
|
|
|
}
|
|
|
|
void onDelayedSetup() override {
|
2017-12-08 15:21:31 +00:00
|
|
|
sk_sp<SkImage> img(GetResourceAsImage("images/mandrill_512_q075.jpg"));
|
2016-02-24 17:25:58 +00:00
|
|
|
if (!img) { return; }
|
2017-07-11 20:03:13 +00:00
|
|
|
sk_sp<SkData> encoded = img->refEncodedData();
|
2016-02-24 17:25:58 +00:00
|
|
|
SkASSERT(encoded);
|
|
|
|
if (!encoded) { return; }
|
2016-03-17 17:51:11 +00:00
|
|
|
fImage = img;
|
2016-02-24 17:25:58 +00:00
|
|
|
}
|
|
|
|
void onDraw(int loops, SkCanvas*) override {
|
|
|
|
if (!fImage) {
|
|
|
|
SkDEBUGFAIL("");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
while (loops-- > 0) {
|
2018-11-13 21:45:14 +00:00
|
|
|
SkNullWStream nullStream;
|
|
|
|
SkPDFDocument doc(&nullStream, SkPDF::Metadata());
|
|
|
|
doc.beginPage(256, 256);
|
|
|
|
(void)SkPDFSerializeImage(fImage.get(), &doc);
|
2016-02-24 17:25:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> fImage;
|
2016-02-24 17:25:58 +00:00
|
|
|
};
|
|
|
|
|
2016-02-24 23:17:19 +00:00
|
|
|
/** Test calling DEFLATE on a 78k PDF command stream. Used for measuring
|
|
|
|
alternate zlib settings, usage, and library versions. */
|
|
|
|
class PDFCompressionBench : public Benchmark {
|
|
|
|
public:
|
|
|
|
PDFCompressionBench() {}
|
2017-03-22 16:05:03 +00:00
|
|
|
~PDFCompressionBench() override {}
|
2016-02-24 23:17:19 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
const char* onGetName() override { return "PDFCompression"; }
|
|
|
|
bool isSuitableFor(Backend backend) override {
|
|
|
|
return backend == kNonRendering_Backend;
|
|
|
|
}
|
|
|
|
void onDelayedSetup() override {
|
2017-07-23 17:14:10 +00:00
|
|
|
fAsset = GetResourceAsStream("pdf_command_stream.txt");
|
2016-02-24 23:17:19 +00:00
|
|
|
}
|
|
|
|
void onDraw(int loops, SkCanvas*) override {
|
|
|
|
SkASSERT(fAsset);
|
|
|
|
if (!fAsset) { return; }
|
|
|
|
while (loops-- > 0) {
|
2018-12-11 00:59:07 +00:00
|
|
|
SkNullWStream wStream;
|
|
|
|
SkPDFDocument doc(&wStream, SkPDF::Metadata());
|
|
|
|
doc.beginPage(256, 256);
|
|
|
|
(void)SkPDFStreamOut(nullptr, fAsset->duplicate(), &doc, true);
|
|
|
|
}
|
2016-02-24 23:17:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2016-11-03 18:40:50 +00:00
|
|
|
std::unique_ptr<SkStreamAsset> fAsset;
|
2016-02-24 23:17:19 +00:00
|
|
|
};
|
|
|
|
|
2016-07-15 20:41:27 +00:00
|
|
|
struct PDFColorComponentBench : public Benchmark {
|
|
|
|
bool isSuitableFor(Backend b) override {
|
|
|
|
return b == kNonRendering_Backend;
|
|
|
|
}
|
|
|
|
const char* onGetName() override { return "PDFColorComponent"; }
|
|
|
|
void onDraw(int loops, SkCanvas*) override {
|
|
|
|
char dst[5];
|
|
|
|
while (loops-- > 0) {
|
|
|
|
for (int i = 0; i < 256; ++i) {
|
|
|
|
(void)SkPDFUtils::ColorToDecimal(SkToU8(i), dst);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-03-25 12:52:57 +00:00
|
|
|
struct PDFShaderBench : public Benchmark {
|
|
|
|
sk_sp<SkShader> fShader;
|
|
|
|
const char* onGetName() final { return "PDFShader"; }
|
|
|
|
bool isSuitableFor(Backend b) final { return b == kNonRendering_Backend; }
|
|
|
|
void onDelayedSetup() final {
|
|
|
|
const SkPoint pts[2] = {{0.0f, 0.0f}, {100.0f, 100.0f}};
|
|
|
|
const SkColor colors[] = {
|
|
|
|
SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE,
|
|
|
|
SK_ColorWHITE, SK_ColorBLACK,
|
|
|
|
};
|
|
|
|
fShader = SkGradientShader::MakeLinear(
|
|
|
|
pts, colors, nullptr, SK_ARRAY_COUNT(colors),
|
|
|
|
SkShader::kClamp_TileMode);
|
|
|
|
}
|
|
|
|
void onDraw(int loops, SkCanvas*) final {
|
|
|
|
SkASSERT(fShader);
|
|
|
|
while (loops-- > 0) {
|
2017-03-22 14:01:53 +00:00
|
|
|
SkNullWStream nullStream;
|
2018-09-07 18:33:14 +00:00
|
|
|
SkPDFDocument doc(&nullStream, SkPDF::Metadata());
|
2018-12-11 00:59:07 +00:00
|
|
|
doc.beginPage(256, 256);
|
|
|
|
(void) SkPDFMakeShader(&doc, fShader.get(), SkMatrix::I(),
|
|
|
|
{0, 0, 400, 400}, SK_ColorBLACK);
|
2016-03-25 12:52:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-06-23 21:08:11 +00:00
|
|
|
struct WritePDFTextBenchmark : public Benchmark {
|
|
|
|
std::unique_ptr<SkWStream> fWStream;
|
2017-03-22 14:01:53 +00:00
|
|
|
WritePDFTextBenchmark() : fWStream(new SkNullWStream) {}
|
2016-06-23 21:08:11 +00:00
|
|
|
const char* onGetName() override { return "WritePDFText"; }
|
|
|
|
bool isSuitableFor(Backend backend) override {
|
|
|
|
return backend == kNonRendering_Backend;
|
|
|
|
}
|
|
|
|
void onDraw(int loops, SkCanvas*) override {
|
|
|
|
static const char kHello[] = "HELLO SKIA!\n";
|
|
|
|
static const char kBinary[] = "\001\002\003\004\005\006";
|
|
|
|
while (loops-- > 0) {
|
|
|
|
for (int i = 1000; i-- > 0;) {
|
2018-09-12 13:12:36 +00:00
|
|
|
SkPDFWriteString(fWStream.get(), kHello, strlen(kHello));
|
|
|
|
SkPDFWriteString(fWStream.get(), kBinary, strlen(kBinary));
|
2016-06-23 21:08:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-02-24 17:25:58 +00:00
|
|
|
} // namespace
|
|
|
|
DEF_BENCH(return new PDFImageBench;)
|
|
|
|
DEF_BENCH(return new PDFJpegImageBench;)
|
2016-02-24 23:17:19 +00:00
|
|
|
DEF_BENCH(return new PDFCompressionBench;)
|
2016-07-15 20:41:27 +00:00
|
|
|
DEF_BENCH(return new PDFColorComponentBench;)
|
2016-03-25 12:52:57 +00:00
|
|
|
DEF_BENCH(return new PDFShaderBench;)
|
2016-06-23 21:08:11 +00:00
|
|
|
DEF_BENCH(return new WritePDFTextBenchmark;)
|
2016-12-30 18:09:03 +00:00
|
|
|
|
2019-01-09 20:32:35 +00:00
|
|
|
#ifdef SK_PDF_ENABLE_SLOW_TESTS
|
2018-12-11 00:59:07 +00:00
|
|
|
#include "SkExecutor.h"
|
|
|
|
namespace {
|
2019-01-09 20:32:35 +00:00
|
|
|
void big_pdf_test(SkDocument* doc, const SkBitmap& background) {
|
2018-12-11 00:59:07 +00:00
|
|
|
static const char* kText[] = {
|
|
|
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do",
|
|
|
|
"eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad",
|
|
|
|
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut",
|
|
|
|
"aliquip ex ea commodo consequat. Duis aute irure dolor in",
|
|
|
|
"reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla",
|
|
|
|
"pariatur. Excepteur sint occaecat cupidatat non proident, sunt in",
|
|
|
|
"culpa qui officia deserunt mollit anim id est laborum.",
|
|
|
|
"",
|
|
|
|
"Sed ut perspiciatis, unde omnis iste natus error sit voluptatem",
|
|
|
|
"accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae",
|
|
|
|
"ab illo inventore veritatis et quasi architecto beatae vitae dicta",
|
|
|
|
"sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit,",
|
|
|
|
"aspernatur aut odit aut fugit, sed quia consequuntur magni dolores",
|
|
|
|
"eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est,",
|
|
|
|
"qui dolorem ipsum, quia dolor sit amet consectetur adipiscing velit,",
|
|
|
|
"sed quia non numquam do eius modi tempora incididunt, ut labore et",
|
|
|
|
"dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam,",
|
|
|
|
"quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi",
|
|
|
|
"ut aliquid ex ea commodi consequatur? Quis autem vel eum iure",
|
|
|
|
"reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae",
|
|
|
|
"consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla",
|
|
|
|
"pariatur?",
|
|
|
|
"",
|
|
|
|
"At vero eos et accusamus et iusto odio dignissimos ducimus, qui",
|
|
|
|
"blanditiis praesentium voluptatum deleniti atque corrupti, quos",
|
|
|
|
"dolores et quas molestias excepturi sint, obcaecati cupiditate non",
|
|
|
|
"provident, similique sunt in culpa, qui officia deserunt mollitia",
|
|
|
|
"animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis",
|
|
|
|
"est et expedita distinctio. Nam libero tempore, cum soluta nobis est",
|
|
|
|
"eligendi optio, cumque nihil impedit, quo minus id, quod maxime",
|
|
|
|
"placeat, facere possimus, omnis voluptas assumenda est, omnis dolor",
|
|
|
|
"repellendus. Temporibus autem quibusdam et aut officiis debitis aut",
|
|
|
|
"rerum necessitatibus saepe eveniet, ut et voluptates repudiandae sint",
|
|
|
|
"et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente",
|
|
|
|
"delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut",
|
|
|
|
"perferendis doloribus asperiores repellat",
|
|
|
|
"",
|
|
|
|
"Sed ut perspiciatis, unde omnis iste natus error sit voluptatem",
|
|
|
|
"accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae",
|
|
|
|
"ab illo inventore veritatis et quasi architecto beatae vitae dicta",
|
|
|
|
"sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit,",
|
|
|
|
"aspernatur aut odit aut fugit, sed quia consequuntur magni dolores",
|
|
|
|
"eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est,",
|
|
|
|
"qui dolorem ipsum, quia dolor sit amet consectetur adipiscing velit,",
|
|
|
|
"sed quia non numquam do eius modi tempora incididunt, ut labore et",
|
|
|
|
"dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam,",
|
|
|
|
"quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi",
|
|
|
|
"ut aliquid ex ea commodi consequatur? Quis autem vel eum iure",
|
|
|
|
"reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae",
|
|
|
|
"consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla",
|
|
|
|
"pariatur?",
|
|
|
|
"",
|
|
|
|
};
|
|
|
|
SkCanvas* canvas = nullptr;
|
|
|
|
float x = 36;
|
|
|
|
float y = 36;
|
|
|
|
constexpr size_t kLineCount = SK_ARRAY_COUNT(kText);
|
|
|
|
constexpr int kLoopCount = 200;
|
2019-01-09 20:32:35 +00:00
|
|
|
SkFont font;
|
2018-12-11 00:59:07 +00:00
|
|
|
SkPaint paint;
|
|
|
|
for (int loop = 0; loop < kLoopCount; ++loop) {
|
|
|
|
for (size_t line = 0; line < kLineCount; ++line) {
|
2019-01-09 20:32:35 +00:00
|
|
|
y += font.getSpacing();
|
2018-12-11 00:59:07 +00:00
|
|
|
if (!canvas || y > 792 - 36) {
|
2019-01-09 20:32:35 +00:00
|
|
|
y = 36 + font.getSpacing();
|
2018-12-11 00:59:07 +00:00
|
|
|
canvas = doc->beginPage(612, 792);
|
|
|
|
background.notifyPixelsChanged();
|
|
|
|
canvas->drawBitmap(background, 0, 0);
|
|
|
|
}
|
2019-01-09 20:32:35 +00:00
|
|
|
canvas->drawString(kText[line], x, y, font, paint);
|
2018-12-11 00:59:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SkBitmap make_background() {
|
|
|
|
SkBitmap background;
|
|
|
|
SkBitmap bitmap;
|
|
|
|
bitmap.allocN32Pixels(32, 32);
|
|
|
|
bitmap.eraseColor(SK_ColorWHITE);
|
|
|
|
SkCanvas tmp(bitmap);
|
|
|
|
SkPaint gray;
|
|
|
|
gray.setColor(SkColorSetARGB(0xFF, 0xEE, 0xEE, 0xEE));
|
|
|
|
tmp.drawRect({0,0,16,16}, gray);
|
|
|
|
tmp.drawRect({16,16,32,32}, gray);
|
|
|
|
SkPaint shader;
|
|
|
|
shader.setShader(
|
|
|
|
SkShader::MakeBitmapShader(
|
|
|
|
bitmap, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode));
|
|
|
|
background.allocN32Pixels(612, 792);
|
|
|
|
SkCanvas tmp2(background);
|
|
|
|
tmp2.drawPaint(shader);
|
|
|
|
return background;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct PDFBigDocBench : public Benchmark {
|
2019-01-09 20:32:35 +00:00
|
|
|
bool fFast;
|
2018-12-11 00:59:07 +00:00
|
|
|
SkBitmap fBackground;
|
2019-01-09 20:32:35 +00:00
|
|
|
std::unique_ptr<SkExecutor> fExecutor;
|
|
|
|
PDFBigDocBench(bool fast) : fFast(fast) {}
|
|
|
|
void onDelayedSetup() override {
|
|
|
|
fBackground = make_background();
|
|
|
|
fExecutor = fFast ? SkExecutor::MakeFIFOThreadPool() : nullptr;
|
2018-12-11 00:59:07 +00:00
|
|
|
}
|
2019-01-09 20:32:35 +00:00
|
|
|
const char* onGetName() override {
|
|
|
|
static const char kNameFast[] = "PDFBigDocBench_fast";
|
|
|
|
static const char kNameSlow[] = "PDFBigDocBench_slow";
|
|
|
|
return fFast ? kNameFast : kNameSlow;
|
|
|
|
}
|
|
|
|
bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
|
2018-12-11 00:59:07 +00:00
|
|
|
void onDraw(int loops, SkCanvas*) override {
|
2019-01-09 20:32:35 +00:00
|
|
|
while (loops-- > 0) {
|
|
|
|
#ifdef SK_PDF_TEST_BIGDOCBENCH_OUTPUT
|
|
|
|
SkFILEWStream wStream("/tmp/big_pdf.pdf");
|
|
|
|
#else
|
|
|
|
SkNullWStream wStream;
|
|
|
|
#endif
|
|
|
|
SkPDF::Metadata metadata;
|
|
|
|
metadata.fExecutor = fExecutor.get();
|
2019-01-07 15:00:48 +00:00
|
|
|
auto doc = SkPDF::MakeDocument(&wStream, metadata);
|
2019-01-09 20:32:35 +00:00
|
|
|
big_pdf_test(doc.get(), fBackground);
|
|
|
|
}
|
2018-12-11 00:59:07 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
} // namespace
|
2019-01-09 20:32:35 +00:00
|
|
|
DEF_BENCH(return new PDFBigDocBench(false);)
|
|
|
|
DEF_BENCH(return new PDFBigDocBench(true);)
|
2016-12-30 18:09:03 +00:00
|
|
|
#endif
|
|
|
|
|
2018-12-11 00:59:07 +00:00
|
|
|
#endif // SK_SUPPORT_PDF
|