aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench
diff options
context:
space:
mode:
authorGravatar scroggo <scroggo@google.com>2016-05-12 06:22:30 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-12 06:22:30 -0700
commit9a9a7b29e5e5916a7b6453cd124ca437f14b9da4 (patch)
treead5b560f6ed5da12040e5665282fd2227c305ff8 /bench
parenta1b283345b27fef91908b104a30cb89e6fbdaade (diff)
Revert of Move SkTypeface to sk_sp. (patchset #5 id:80001 of https://codereview.chromium.org/1933393002/ )
Reason for revert: fontmgr_iterAndroid failing to draw emoji. E.g. 6296da736fbf40aae881650c239420f64e576c3f&unt=true&head=true&query=source_type%3Dgm">https://gold.skia.org/search2?blame=6296da736fbf40aae881650c239420f64e576c3f&unt=true&head=true&query=source_type%3Dgm Original issue's description: > Move SkTypeface to sk_sp. > > Committed: https://skia.googlesource.com/skia/+/6296da736fbf40aae881650c239420f64e576c3f TBR=reed@google.com,fmalita@chromium.org,tomhudson@google.com,bungeman@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://codereview.chromium.org/1974783002
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, 17 insertions, 10 deletions
diff --git a/bench/CmapBench.cpp b/bench/CmapBench.cpp
index 49e89bec8c..a2fb5065f4 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::MakeDefault());
+ fPaint.setTypeface(SkTypeface::RefDefault())->unref();
}
protected:
diff --git a/bench/SkGlyphCacheBench.cpp b/bench/SkGlyphCacheBench.cpp
index c5e40af746..2e0429fce3 100644
--- a/bench/SkGlyphCacheBench.cpp
+++ b/bench/SkGlyphCacheBench.cpp
@@ -53,15 +53,18 @@ 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(sk_tool_utils::create_portable_typeface("serif", SkTypeface::kItalic));
+ paint.setTypeface(typeface);
for (int work = 0; work < loops; work++) {
do_font_stuff(&paint);
}
SkGraphics::SetFontCacheLimit(oldCacheLimitSize);
+ SkSafeUnref(typeface);
}
private:
@@ -87,7 +90,7 @@ protected:
void onDraw(int loops, SkCanvas*) override {
size_t oldCacheLimitSize = SkGraphics::GetFontCacheLimit();
SkGraphics::SetFontCacheLimit(fCacheSize);
- sk_sp<SkTypeface> typefaces[] =
+ SkTypeface* typefaces[] =
{sk_tool_utils::create_portable_typeface("serif", SkTypeface::kItalic),
sk_tool_utils::create_portable_typeface("sans-serif", SkTypeface::kItalic)};
@@ -101,6 +104,8 @@ protected:
});
}
SkGraphics::SetFontCacheLimit(oldCacheLimitSize);
+ SkSafeUnref(typefaces[0]);
+ SkSafeUnref(typefaces[1]);
}
private:
diff --git a/bench/TextBench.cpp b/bench/TextBench.cpp
index a048ffd4a1..04f824c700 100644
--- a/bench/TextBench.cpp
+++ b/bench/TextBench.cpp
@@ -47,7 +47,7 @@ class TextBench : public Benchmark {
FontQuality fFQ;
bool fDoPos;
bool fDoColorEmoji;
- sk_sp<SkTypeface> fColorEmojiTypeface;
+ SkAutoTUnref<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 = MakeResourceAsTypeface("/fonts/Funkster.ttf");
+ fColorEmojiTypeface.reset(GetResourceAsTypeface("/fonts/Funkster.ttf"));
}
if (fDoPos) {
diff --git a/bench/TextBlobBench.cpp b/bench/TextBlobBench.cpp
index 37bf311119..a350e7b4c4 100644
--- a/bench/TextBlobBench.cpp
+++ b/bench/TextBlobBench.cpp
@@ -23,11 +23,13 @@
*/
class TextBlobBench : public Benchmark {
public:
- TextBlobBench() {}
+ TextBlobBench()
+ : fTypeface(nullptr) {
+ }
protected:
void onDelayedSetup() override {
- fTypeface = sk_tool_utils::create_portable_typeface("serif", SkTypeface::kNormal);
+ fTypeface.reset(sk_tool_utils::create_portable_typeface("serif", SkTypeface::kNormal));
// make textblob
SkPaint paint;
paint.setTypeface(fTypeface);
@@ -62,9 +64,9 @@ protected:
private:
- SkAutoTUnref<const SkTextBlob> fBlob;
- SkTDArray<uint16_t> fGlyphs;
- sk_sp<SkTypeface> fTypeface;
+ SkAutoTUnref<const SkTextBlob> fBlob;
+ SkTDArray<uint16_t> fGlyphs;
+ SkAutoTUnref<SkTypeface> fTypeface;
typedef Benchmark INHERITED;
};