aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2016-05-12 10:09:30 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-12 10:09:31 -0700
commit13b9c95295f4c5732e34574789e721a6bc08f7b4 (patch)
treec3ef0aa2af9890c03cb79968f32166af39fba9ba /bench
parent40d21de8b6620d724f34bdc85af1dcb593d33fe0 (diff)
Move SkTypeface to sk_sp.
Diffstat (limited to 'bench')
-rw-r--r--bench/CmapBench.cpp2
-rw-r--r--bench/SkGlyphCacheBench.cpp9
-rw-r--r--bench/TextBench.cpp4
-rw-r--r--bench/TextBlobBench.cpp12
4 files changed, 10 insertions, 17 deletions
diff --git a/bench/CmapBench.cpp b/bench/CmapBench.cpp
index a2fb5065f4..49e89bec8c 100644
--- a/bench/CmapBench.cpp
+++ b/bench/CmapBench.cpp
@@ -77,7 +77,7 @@ public:
// we're jamming values into utf8, so we must keep it legal utf8
fText[i] = 'A' + (i & 31);
}
- fPaint.setTypeface(SkTypeface::RefDefault())->unref();
+ fPaint.setTypeface(SkTypeface::MakeDefault());
}
protected:
diff --git a/bench/SkGlyphCacheBench.cpp b/bench/SkGlyphCacheBench.cpp
index 2e0429fce3..c5e40af746 100644
--- a/bench/SkGlyphCacheBench.cpp
+++ b/bench/SkGlyphCacheBench.cpp
@@ -53,18 +53,15 @@ protected:
void onDraw(int loops, SkCanvas*) override {
size_t oldCacheLimitSize = SkGraphics::GetFontCacheLimit();
SkGraphics::SetFontCacheLimit(fCacheSize);
- SkTypeface* typeface = sk_tool_utils::create_portable_typeface(
- "serif", SkTypeface::kItalic);
SkPaint paint;
paint.setAntiAlias(true);
paint.setSubpixelText(true);
- paint.setTypeface(typeface);
+ paint.setTypeface(sk_tool_utils::create_portable_typeface("serif", SkTypeface::kItalic));
for (int work = 0; work < loops; work++) {
do_font_stuff(&paint);
}
SkGraphics::SetFontCacheLimit(oldCacheLimitSize);
- SkSafeUnref(typeface);
}
private:
@@ -90,7 +87,7 @@ protected:
void onDraw(int loops, SkCanvas*) override {
size_t oldCacheLimitSize = SkGraphics::GetFontCacheLimit();
SkGraphics::SetFontCacheLimit(fCacheSize);
- SkTypeface* typefaces[] =
+ sk_sp<SkTypeface> typefaces[] =
{sk_tool_utils::create_portable_typeface("serif", SkTypeface::kItalic),
sk_tool_utils::create_portable_typeface("sans-serif", SkTypeface::kItalic)};
@@ -104,8 +101,6 @@ protected:
});
}
SkGraphics::SetFontCacheLimit(oldCacheLimitSize);
- SkSafeUnref(typefaces[0]);
- SkSafeUnref(typefaces[1]);
}
private:
diff --git a/bench/TextBench.cpp b/bench/TextBench.cpp
index 04f824c700..a048ffd4a1 100644
--- a/bench/TextBench.cpp
+++ b/bench/TextBench.cpp
@@ -47,7 +47,7 @@ class TextBench : public Benchmark {
FontQuality fFQ;
bool fDoPos;
bool fDoColorEmoji;
- SkAutoTUnref<SkTypeface> fColorEmojiTypeface;
+ sk_sp<SkTypeface> fColorEmojiTypeface;
SkPoint* fPos;
public:
TextBench(const char text[], int ps,
@@ -71,7 +71,7 @@ protected:
void onDelayedSetup() override {
if (fDoColorEmoji) {
SkASSERT(kBW == fFQ);
- fColorEmojiTypeface.reset(GetResourceAsTypeface("/fonts/Funkster.ttf"));
+ fColorEmojiTypeface = MakeResourceAsTypeface("/fonts/Funkster.ttf");
}
if (fDoPos) {
diff --git a/bench/TextBlobBench.cpp b/bench/TextBlobBench.cpp
index a350e7b4c4..37bf311119 100644
--- a/bench/TextBlobBench.cpp
+++ b/bench/TextBlobBench.cpp
@@ -23,13 +23,11 @@
*/
class TextBlobBench : public Benchmark {
public:
- TextBlobBench()
- : fTypeface(nullptr) {
- }
+ TextBlobBench() {}
protected:
void onDelayedSetup() override {
- fTypeface.reset(sk_tool_utils::create_portable_typeface("serif", SkTypeface::kNormal));
+ fTypeface = sk_tool_utils::create_portable_typeface("serif", SkTypeface::kNormal);
// make textblob
SkPaint paint;
paint.setTypeface(fTypeface);
@@ -64,9 +62,9 @@ protected:
private:
- SkAutoTUnref<const SkTextBlob> fBlob;
- SkTDArray<uint16_t> fGlyphs;
- SkAutoTUnref<SkTypeface> fTypeface;
+ SkAutoTUnref<const SkTextBlob> fBlob;
+ SkTDArray<uint16_t> fGlyphs;
+ sk_sp<SkTypeface> fTypeface;
typedef Benchmark INHERITED;
};