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

Side by Side Diff: gm/coloremoji.cpp

Issue 1933393002: Move SkTypeface to sk_sp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Restore deleted Android code. Created 4 years, 7 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 | « fuzz/FilterFuzz.cpp ('k') | gm/colortype.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 SkAutoTUnref<SkTypeface> typeface; 53 sk_sp<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 sk_tool_utils::emoji_typeface(&emojiFont.typeface); 57 emojiFont.typeface = sk_tool_utils::emoji_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 17 matching lines...) Expand all
85 paint.setTextSize(SkIntToScalar(textSize[y])); 85 paint.setTextSize(SkIntToScalar(textSize[y]));
86 canvas->drawText(text, strlen(text), 10, SkIntToScalar(textYOffset[y ]), paint); 86 canvas->drawText(text, strlen(text), 10, SkIntToScalar(textYOffset[y ]), paint);
87 y_offset += textYOffset[y]; 87 y_offset += textYOffset[y];
88 } 88 }
89 89
90 // draw with shaders and image filters 90 // draw with shaders and image filters
91 for (int makeLinear = 0; makeLinear < 2; makeLinear++) { 91 for (int makeLinear = 0; makeLinear < 2; makeLinear++) {
92 for (int makeBlur = 0; makeBlur < 2; makeBlur++) { 92 for (int makeBlur = 0; makeBlur < 2; makeBlur++) {
93 for (int makeGray = 0; makeGray < 2; makeGray++) { 93 for (int makeGray = 0; makeGray < 2; makeGray++) {
94 SkPaint shaderPaint; 94 SkPaint shaderPaint;
95 shaderPaint.setTypeface(paint.getTypeface()); 95 shaderPaint.setTypeface(sk_ref_sp(paint.getTypeface()));
96 if (SkToBool(makeLinear)) { 96 if (SkToBool(makeLinear)) {
97 shaderPaint.setShader(MakeLinear()); 97 shaderPaint.setShader(MakeLinear());
98 } 98 }
99 99
100 if (SkToBool(makeBlur) && SkToBool(makeGray)) { 100 if (SkToBool(makeBlur) && SkToBool(makeGray)) {
101 sk_sp<SkImageFilter> grayScale(make_grayscale(nullptr)); 101 sk_sp<SkImageFilter> grayScale(make_grayscale(nullptr));
102 sk_sp<SkImageFilter> blur(make_blur(3.0f, std::move(gray Scale))); 102 sk_sp<SkImageFilter> blur(make_blur(3.0f, std::move(gray Scale)));
103 shaderPaint.setImageFilter(std::move(blur)); 103 shaderPaint.setImageFilter(std::move(blur));
104 } else if (SkToBool(makeBlur)) { 104 } else if (SkToBool(makeBlur)) {
105 shaderPaint.setImageFilter(make_blur(3.0f, nullptr)); 105 shaderPaint.setImageFilter(make_blur(3.0f, nullptr));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 154 }
155 155
156 typedef GM INHERITED; 156 typedef GM INHERITED;
157 }; 157 };
158 158
159 ////////////////////////////////////////////////////////////////////////////// 159 //////////////////////////////////////////////////////////////////////////////
160 160
161 DEF_GM(return new ColorEmojiGM;) 161 DEF_GM(return new ColorEmojiGM;)
162 162
163 } 163 }
OLDNEW
« no previous file with comments | « fuzz/FilterFuzz.cpp ('k') | gm/colortype.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698