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

Side by Side Diff: gm/coloremoji.cpp

Issue 1239303003: fix typeface leak (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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/dftext.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 2013 Google Inc. 2 * Copyright 2013 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 "gm.h" 8 #include "gm.h"
9 9
10 #include "Resources.h" 10 #include "Resources.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 44
45 namespace skiagm { 45 namespace skiagm {
46 46
47 class ColorEmojiGM : public GM { 47 class ColorEmojiGM : public GM {
48 public: 48 public:
49 ColorEmojiGM() { } 49 ColorEmojiGM() { }
50 50
51 protected: 51 protected:
52 struct EmojiFont { 52 struct EmojiFont {
53 SkTypeface* typeface; 53 SkAutoTUnref<SkTypeface> typeface;
54 const char* text; 54 const char* text;
55 } emojiFont; 55 } emojiFont;
56 virtual void onOnceBeforeDraw() override { 56 virtual void onOnceBeforeDraw() override {
57 emojiFont.typeface = sk_tool_utils::emoji_typeface(); 57 sk_tool_utils::emoji_typeface(&emojiFont.typeface);
58 emojiFont.text = sk_tool_utils::emoji_sample_text(); 58 emojiFont.text = sk_tool_utils::emoji_sample_text();
59 } 59 }
60 60
61 SkString onShortName() override { 61 SkString onShortName() override {
62 SkString name("coloremoji"); 62 SkString name("coloremoji");
63 name.append(sk_tool_utils::platform_os_emoji()); 63 name.append(sk_tool_utils::platform_os_emoji());
64 return name; 64 return name;
65 } 65 }
66 66
67 SkISize onISize() override { 67 SkISize onISize() override {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 paint.setAlpha(0x20); 148 paint.setAlpha(0x20);
149 canvas->drawText(text, strlen(text), 0, 0, paint); 149 canvas->drawText(text, strlen(text), 0, 0, paint);
150 canvas->clipRect(clipRects[x]); 150 canvas->clipRect(clipRects[x]);
151 paint.setAlpha(0xFF); 151 paint.setAlpha(0xFF);
152 canvas->drawText(text, strlen(text), 0, 0, paint); 152 canvas->drawText(text, strlen(text), 0, 0, paint);
153 canvas->restore(); 153 canvas->restore();
154 canvas->translate(0, bounds.height() + SkIntToScalar(25)); 154 canvas->translate(0, bounds.height() + SkIntToScalar(25));
155 } 155 }
156 } 156 }
157 157
158 private:
159 SkAutoTUnref<SkTypeface> fCBDT_CBLC_Typeface;
160 SkAutoTUnref<SkTypeface> fSBIX_Typeface;
161
162 typedef GM INHERITED; 158 typedef GM INHERITED;
163 }; 159 };
164 160
165 ////////////////////////////////////////////////////////////////////////////// 161 //////////////////////////////////////////////////////////////////////////////
166 162
167 static GM* MyFactory(void*) { return new ColorEmojiGM; } 163 static GM* MyFactory(void*) { return new ColorEmojiGM; }
168 static GMRegistry reg(MyFactory); 164 static GMRegistry reg(MyFactory);
169 165
170 } 166 }
OLDNEW
« no previous file with comments | « no previous file | gm/dftext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698