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

Side by Side Diff: bench/TextBlobBench.cpp

Issue 1974783002: Revert of Move SkTypeface to sk_sp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkPaint.h" 11 #include "SkPaint.h"
12 #include "SkRandom.h" 12 #include "SkRandom.h"
13 #include "SkStream.h" 13 #include "SkStream.h"
14 #include "SkString.h" 14 #include "SkString.h"
15 #include "SkTemplates.h" 15 #include "SkTemplates.h"
16 #include "SkTextBlob.h" 16 #include "SkTextBlob.h"
17 #include "SkTypeface.h" 17 #include "SkTypeface.h"
18 18
19 #include "sk_tool_utils.h" 19 #include "sk_tool_utils.h"
20 20
21 /* 21 /*
22 * A trivial test which benchmarks the performance of a textblob with a single r un. 22 * A trivial test which benchmarks the performance of a textblob with a single r un.
23 */ 23 */
24 class TextBlobBench : public Benchmark { 24 class TextBlobBench : public Benchmark {
25 public: 25 public:
26 TextBlobBench() {} 26 TextBlobBench()
27 : fTypeface(nullptr) {
28 }
27 29
28 protected: 30 protected:
29 void onDelayedSetup() override { 31 void onDelayedSetup() override {
30 fTypeface = sk_tool_utils::create_portable_typeface("serif", SkTypeface: :kNormal); 32 fTypeface.reset(sk_tool_utils::create_portable_typeface("serif", SkTypef ace::kNormal));
31 // make textblob 33 // make textblob
32 SkPaint paint; 34 SkPaint paint;
33 paint.setTypeface(fTypeface); 35 paint.setTypeface(fTypeface);
34 const char* text = "Hello blob!"; 36 const char* text = "Hello blob!";
35 SkTDArray<uint16_t> glyphs; 37 SkTDArray<uint16_t> glyphs;
36 size_t len = strlen(text); 38 size_t len = strlen(text);
37 glyphs.append(paint.textToGlyphs(text, len, nullptr)); 39 glyphs.append(paint.textToGlyphs(text, len, nullptr));
38 paint.textToGlyphs(text, len, glyphs.begin()); 40 paint.textToGlyphs(text, len, glyphs.begin());
39 41
40 SkTextBlobBuilder builder; 42 SkTextBlobBuilder builder;
(...skipping 14 matching lines...) Expand all
55 SkPaint paint; 57 SkPaint paint;
56 58
57 // To ensure maximum caching, we just redraw the blob at the same place everytime 59 // To ensure maximum caching, we just redraw the blob at the same place everytime
58 for (int i = 0; i < loops; i++) { 60 for (int i = 0; i < loops; i++) {
59 canvas->drawTextBlob(fBlob, 0, 0, paint); 61 canvas->drawTextBlob(fBlob, 0, 0, paint);
60 } 62 }
61 } 63 }
62 64
63 private: 65 private:
64 66
65 SkAutoTUnref<const SkTextBlob> fBlob; 67 SkAutoTUnref<const SkTextBlob> fBlob;
66 SkTDArray<uint16_t> fGlyphs; 68 SkTDArray<uint16_t> fGlyphs;
67 sk_sp<SkTypeface> fTypeface; 69 SkAutoTUnref<SkTypeface> fTypeface;
68 70
69 typedef Benchmark INHERITED; 71 typedef Benchmark INHERITED;
70 }; 72 };
71 73
72 DEF_BENCH( return new TextBlobBench(); ) 74 DEF_BENCH( return new TextBlobBench(); )
OLDNEW
« no previous file with comments | « bench/TextBench.cpp ('k') | dm/DM.cpp » ('j') | src/ports/SkFontMgr_android.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698