SkPDF/Bench: add bench for SkPDFSharedStream (deflate)
Also, simplify gyp. BUG=skia:5009 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1730833003 Review URL: https://codereview.chromium.org/1730833003
This commit is contained in:
parent
f7b8b8affe
commit
1e440510d8
@ -7,13 +7,10 @@
|
||||
|
||||
#include "Benchmark.h"
|
||||
#include "Resources.h"
|
||||
#include "SkImage.h"
|
||||
#include "SkPixmap.h"
|
||||
#include "SkData.h"
|
||||
|
||||
#if SK_SUPPORT_PDF
|
||||
|
||||
#include "SkImage.h"
|
||||
#include "SkPDFBitmap.h"
|
||||
#include "SkPixmap.h"
|
||||
|
||||
namespace {
|
||||
struct NullWStream : public SkWStream {
|
||||
@ -23,13 +20,7 @@ struct NullWStream : public SkWStream {
|
||||
size_t fN;
|
||||
};
|
||||
|
||||
static void test_pdf_image_serialization(SkImage* img) {
|
||||
SkAutoTUnref<SkPDFObject> object(
|
||||
SkPDFCreateBitmapObject(img, nullptr));
|
||||
if (!object) {
|
||||
SkDEBUGFAIL("");
|
||||
return;
|
||||
}
|
||||
static void test_pdf_object_serialization(SkPDFObject* object) {
|
||||
// SkDebugWStream wStream;
|
||||
NullWStream wStream;
|
||||
SkPDFSubstituteMap substitutes;
|
||||
@ -72,7 +63,13 @@ protected:
|
||||
return;
|
||||
}
|
||||
while (loops-- > 0) {
|
||||
test_pdf_image_serialization(fImage);
|
||||
SkAutoTUnref<SkPDFObject> object(
|
||||
SkPDFCreateBitmapObject(fImage, nullptr));
|
||||
SkASSERT(object);
|
||||
if (!object) {
|
||||
return;
|
||||
}
|
||||
test_pdf_object_serialization(object);
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,7 +102,13 @@ protected:
|
||||
return;
|
||||
}
|
||||
while (loops-- > 0) {
|
||||
test_pdf_image_serialization(fImage);
|
||||
SkAutoTUnref<SkPDFObject> object(
|
||||
SkPDFCreateBitmapObject(fImage, nullptr));
|
||||
SkASSERT(object);
|
||||
if (!object) {
|
||||
return;
|
||||
}
|
||||
test_pdf_object_serialization(object);
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,8 +116,36 @@ private:
|
||||
SkAutoTUnref<SkImage> fImage;
|
||||
};
|
||||
|
||||
/** 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() {}
|
||||
virtual ~PDFCompressionBench() {}
|
||||
|
||||
protected:
|
||||
const char* onGetName() override { return "PDFCompression"; }
|
||||
bool isSuitableFor(Backend backend) override {
|
||||
return backend == kNonRendering_Backend;
|
||||
}
|
||||
void onDelayedSetup() override {
|
||||
fAsset.reset(GetResourceAsStream("pdf_command_stream.txt"));
|
||||
}
|
||||
void onDraw(int loops, SkCanvas*) override {
|
||||
SkASSERT(fAsset);
|
||||
if (!fAsset) { return; }
|
||||
while (loops-- > 0) {
|
||||
SkAutoTUnref<SkPDFObject> object(
|
||||
new SkPDFSharedStream(fAsset->duplicate()));
|
||||
test_pdf_object_serialization(object);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SkAutoTDelete<SkStreamAsset> fAsset;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
DEF_BENCH(return new PDFImageBench;)
|
||||
DEF_BENCH(return new PDFJpegImageBench;)
|
||||
|
||||
#endif // SK_SUPPORT_PDF
|
||||
DEF_BENCH(return new PDFCompressionBench;)
|
||||
|
@ -25,8 +25,8 @@
|
||||
'skia_lib.gyp:skia_lib',
|
||||
'tools.gyp:crash_handler',
|
||||
'tools.gyp:proc_stats',
|
||||
'tools.gyp:timer',
|
||||
'tools.gyp:thermal_manager',
|
||||
'tools.gyp:timer',
|
||||
],
|
||||
'conditions': [
|
||||
['skia_android_framework', {
|
||||
@ -41,11 +41,6 @@
|
||||
'tools.gyp:android_utils',
|
||||
],
|
||||
}],
|
||||
[ 'skia_pdf',
|
||||
{ 'dependencies': [ 'pdf.gyp:pdf' ],
|
||||
'include_dirs': [ '../src/pdf' ], },
|
||||
{ 'dependencies': [ 'pdf.gyp:nopdf' ], }
|
||||
],
|
||||
],
|
||||
},
|
||||
],
|
||||
|
@ -10,12 +10,14 @@
|
||||
'../src/core',
|
||||
'../src/effects',
|
||||
'../src/gpu',
|
||||
'../src/pdf',
|
||||
'../src/utils',
|
||||
],
|
||||
'sources': [ '<!@(python find.py ../bench "*.cpp")' ],
|
||||
|
||||
'dependencies': [
|
||||
'etc1.gyp:libetc1',
|
||||
'pdf.gyp:pdf',
|
||||
'skia_lib.gyp:skia_lib',
|
||||
'tools.gyp:resources',
|
||||
'tools.gyp:sk_tool_utils',
|
||||
|
@ -21,6 +21,7 @@
|
||||
'../src/core',
|
||||
'../src/effects',
|
||||
'../src/images',
|
||||
'../src/pdf',
|
||||
],
|
||||
'sources': [
|
||||
'../gm/gm.cpp',
|
||||
@ -37,6 +38,7 @@
|
||||
'flags.gyp:flags',
|
||||
'jsoncpp.gyp:jsoncpp',
|
||||
'gputest.gyp:skgputest',
|
||||
'pdf.gyp:pdf',
|
||||
'skia_lib.gyp:skia_lib',
|
||||
'tools.gyp:proc_stats',
|
||||
'tools.gyp:sk_tool_utils',
|
||||
|
4802
resources/pdf_command_stream.txt
Normal file
4802
resources/pdf_command_stream.txt
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user