Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2395)

Unified Diff: bench/PDFBench.cpp

Issue 1833793002: SkPDF: speed up SkPDFShader generation. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/pdf/SkPDFDocument.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/PDFBench.cpp
diff --git a/bench/PDFBench.cpp b/bench/PDFBench.cpp
index 75b05de29d89c6fb77037188db84779e75d8ed82..289588a01b6356d0d767b9a9d0bc5d2c470c685e 100644
--- a/bench/PDFBench.cpp
+++ b/bench/PDFBench.cpp
@@ -9,8 +9,11 @@
#include "Resources.h"
#include "SkAutoPixmapStorage.h"
#include "SkData.h"
+#include "SkGradientShader.h"
#include "SkImage.h"
#include "SkPDFBitmap.h"
+#include "SkPDFDocument.h"
+#include "SkPDFShader.h"
#include "SkPDFUtils.h"
#include "SkPixmap.h"
#include "SkRandom.h"
@@ -162,8 +165,36 @@ struct PDFScalarBench : public Benchmark {
}
};
+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) {
+ NullWStream nullStream;
+ SkPDFDocument doc(&nullStream, nullptr, 72, nullptr);
+ sk_sp<SkPDFObject> shader(
+ SkPDFShader::GetPDFShader(
+ &doc, 72, *fShader, SkMatrix::I(),
+ SkIRect::MakeWH(400,400), 72));
+ }
+ }
+};
+
} // namespace
DEF_BENCH(return new PDFImageBench;)
DEF_BENCH(return new PDFJpegImageBench;)
DEF_BENCH(return new PDFCompressionBench;)
DEF_BENCH(return new PDFScalarBench;)
+DEF_BENCH(return new PDFShaderBench;)
« no previous file with comments | « no previous file | src/pdf/SkPDFDocument.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698