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

Side by Side Diff: bench/PDFBench.cpp

Issue 1844343004: SkWStream::writeText inlined. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | include/core/SkStream.h » ('j') | include/core/SkStream.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Benchmark.h" 8 #include "Benchmark.h"
9 #include "Resources.h" 9 #include "Resources.h"
10 #include "SkAutoPixmapStorage.h" 10 #include "SkAutoPixmapStorage.h"
11 #include "SkData.h" 11 #include "SkData.h"
12 #include "SkGradientShader.h" 12 #include "SkGradientShader.h"
13 #include "SkImage.h" 13 #include "SkImage.h"
14 #include "SkPDFBitmap.h" 14 #include "SkPDFBitmap.h"
15 #include "SkPDFDocument.h" 15 #include "SkPDFDocument.h"
16 #include "SkPDFShader.h" 16 #include "SkPDFShader.h"
17 #include "SkPDFUtils.h" 17 #include "SkPDFUtils.h"
18 #include "SkPixmap.h" 18 #include "SkPixmap.h"
19 #include "SkRandom.h" 19 #include "SkRandom.h"
20 #include "SkStream.h"
20 21
21 namespace { 22 namespace {
22 struct NullWStream : public SkWStream { 23 struct NullWStream : public SkWStream {
23 NullWStream() : fN(0) {} 24 NullWStream() : fN(0) {}
24 bool write(const void*, size_t n) override { fN += n; return true; } 25 bool write(const void*, size_t n) override { fN += n; return true; }
25 size_t bytesWritten() const override { return fN; } 26 size_t bytesWritten() const override { return fN; }
26 size_t fN; 27 size_t fN;
27 }; 28 };
28 29
29 static void test_pdf_object_serialization(const sk_sp<SkPDFObject> object) { 30 static void test_pdf_object_serialization(const sk_sp<SkPDFObject> object) {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 NullWStream nullStream; 184 NullWStream nullStream;
184 SkPDFDocument doc(&nullStream, nullptr, 72, nullptr); 185 SkPDFDocument doc(&nullStream, nullptr, 72, nullptr);
185 sk_sp<SkPDFObject> shader( 186 sk_sp<SkPDFObject> shader(
186 SkPDFShader::GetPDFShader( 187 SkPDFShader::GetPDFShader(
187 &doc, 72, fShader.get(), SkMatrix::I(), 188 &doc, 72, fShader.get(), SkMatrix::I(),
188 SkIRect::MakeWH(400,400), 72)); 189 SkIRect::MakeWH(400,400), 72));
189 } 190 }
190 } 191 }
191 }; 192 };
192 193
194 struct WStreamWriteTextBenchmark : public Benchmark {
195 std::unique_ptr<SkWStream> fWStream;
196 WStreamWriteTextBenchmark() : fWStream(new NullWStream) {}
197 const char* onGetName() override { return "WStreamWriteText"; }
198 bool isSuitableFor(Backend backend) override {
199 return backend == kNonRendering_Backend;
200 }
201 void onDraw(int loops, SkCanvas*) override {
202 while (loops-- > 0) {
203 for (int i = 1000; i-- > 0;) {
204 fWStream->writeText("HELLO SKIA!\n");
205 }
206 }
207 }
208 };
209
193 } // namespace 210 } // namespace
194 DEF_BENCH(return new PDFImageBench;) 211 DEF_BENCH(return new PDFImageBench;)
195 DEF_BENCH(return new PDFJpegImageBench;) 212 DEF_BENCH(return new PDFJpegImageBench;)
196 DEF_BENCH(return new PDFCompressionBench;) 213 DEF_BENCH(return new PDFCompressionBench;)
197 DEF_BENCH(return new PDFScalarBench;) 214 DEF_BENCH(return new PDFScalarBench;)
198 DEF_BENCH(return new PDFShaderBench;) 215 DEF_BENCH(return new PDFShaderBench;)
216 DEF_BENCH(return new WStreamWriteTextBenchmark;)
OLDNEW
« no previous file with comments | « no previous file | include/core/SkStream.h » ('j') | include/core/SkStream.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698