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

Side by Side Diff: bench/TextBlobBench.cpp

Issue 2335493005: Use sk_sp text blob APIs (Closed)
Patch Set: SK_SUPPORT_LEGACY_TEXTBLOB_BUILDER Created 4 years, 3 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 | gm/largeglyphblur.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 26 matching lines...) Expand all
37 glyphs.append(paint.textToGlyphs(text, len, nullptr)); 37 glyphs.append(paint.textToGlyphs(text, len, nullptr));
38 paint.textToGlyphs(text, len, glyphs.begin()); 38 paint.textToGlyphs(text, len, glyphs.begin());
39 39
40 SkTextBlobBuilder builder; 40 SkTextBlobBuilder builder;
41 41
42 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 42 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
43 const SkTextBlobBuilder::RunBuffer& run = builder.allocRun(paint, glyphs .count(), 10, 10, 43 const SkTextBlobBuilder::RunBuffer& run = builder.allocRun(paint, glyphs .count(), 10, 10,
44 nullptr); 44 nullptr);
45 memcpy(run.glyphs, glyphs.begin(), glyphs.count() * sizeof(uint16_t)); 45 memcpy(run.glyphs, glyphs.begin(), glyphs.count() * sizeof(uint16_t));
46 46
47 fBlob.reset(builder.build()); 47 fBlob = builder.make();
48 } 48 }
49 49
50 const char* onGetName() override { 50 const char* onGetName() override {
51 return "TextBlobBench"; 51 return "TextBlobBench";
52 } 52 }
53 53
54 void onDraw(int loops, SkCanvas* canvas) override { 54 void onDraw(int loops, SkCanvas* canvas) override {
55 SkPaint paint; 55 SkPaint paint;
56 56
57 // To ensure maximum caching, we just redraw the blob at the same place everytime 57 // To ensure maximum caching, we just redraw the blob at the same place everytime
58 for (int i = 0; i < loops; i++) { 58 for (int i = 0; i < loops; i++) {
59 canvas->drawTextBlob(fBlob, 0, 0, paint); 59 canvas->drawTextBlob(fBlob, 0, 0, paint);
60 } 60 }
61 } 61 }
62 62
63 private: 63 private:
64 64
65 SkAutoTUnref<const SkTextBlob> fBlob; 65 sk_sp<SkTextBlob> fBlob;
66 SkTDArray<uint16_t> fGlyphs; 66 SkTDArray<uint16_t> fGlyphs;
67 sk_sp<SkTypeface> fTypeface; 67 sk_sp<SkTypeface> fTypeface;
68 68
69 typedef Benchmark INHERITED; 69 typedef Benchmark INHERITED;
70 }; 70 };
71 71
72 DEF_BENCH( return new TextBlobBench(); ) 72 DEF_BENCH( return new TextBlobBench(); )
OLDNEW
« no previous file with comments | « no previous file | gm/largeglyphblur.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698