| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "Benchmark.h" | 9 #include "Benchmark.h" |
| 10 #include "Resources.h" | 10 #include "Resources.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 SkTextBlobBuilder builder; | 43 SkTextBlobBuilder builder; |
| 44 | 44 |
| 45 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 45 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
| 46 const SkTextBlobBuilder::RunBuffer& run = builder.allocRun(paint, glyphs
.count(), 10, 10, | 46 const SkTextBlobBuilder::RunBuffer& run = builder.allocRun(paint, glyphs
.count(), 10, 10, |
| 47 NULL); | 47 NULL); |
| 48 memcpy(run.glyphs, glyphs.begin(), glyphs.count() * sizeof(uint16_t)); | 48 memcpy(run.glyphs, glyphs.begin(), glyphs.count() * sizeof(uint16_t)); |
| 49 | 49 |
| 50 fBlob.reset(builder.build()); | 50 fBlob.reset(builder.build()); |
| 51 } | 51 } |
| 52 | 52 |
| 53 const char* onGetName() { | 53 const char* onGetName() override { |
| 54 return "TextBlobBench"; | 54 return "TextBlobBench"; |
| 55 } | 55 } |
| 56 | 56 |
| 57 void onDraw(const int loops, SkCanvas* canvas) { | 57 void onDraw(const int loops, SkCanvas* canvas) override { |
| 58 SkPaint paint; | 58 SkPaint paint; |
| 59 | 59 |
| 60 // To ensure maximum caching, we just redraw the blob at the same place
everytime | 60 // To ensure maximum caching, we just redraw the blob at the same place
everytime |
| 61 for (int i = 0; i < loops; i++) { | 61 for (int i = 0; i < loops; i++) { |
| 62 canvas->drawTextBlob(fBlob, 0, 0, paint); | 62 canvas->drawTextBlob(fBlob, 0, 0, paint); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 | 67 |
| 68 SkAutoTUnref<const SkTextBlob> fBlob; | 68 SkAutoTUnref<const SkTextBlob> fBlob; |
| 69 SkTDArray<uint16_t> fGlyphs; | 69 SkTDArray<uint16_t> fGlyphs; |
| 70 SkAutoTUnref<SkTypeface> fTypeface; | 70 SkAutoTUnref<SkTypeface> fTypeface; |
| 71 | 71 |
| 72 typedef Benchmark INHERITED; | 72 typedef Benchmark INHERITED; |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 DEF_BENCH( return new TextBlobBench(); ) | 75 DEF_BENCH( return new TextBlobBench(); ) |
| OLD | NEW |