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

Side by Side Diff: gm/mixedtextblobs.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 | « gm/gammatext.cpp ('k') | gm/pdf_never_embed.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 21 matching lines...) Expand all
32 canvas->drawTextBlob(blob, 0, 0, paint); 32 canvas->drawTextBlob(blob, 0, 0, paint);
33 canvas->restore(); 33 canvas->restore();
34 } 34 }
35 35
36 class MixedTextBlobsGM : public GM { 36 class MixedTextBlobsGM : public GM {
37 public: 37 public:
38 MixedTextBlobsGM() { } 38 MixedTextBlobsGM() { }
39 39
40 protected: 40 protected:
41 void onOnceBeforeDraw() override { 41 void onOnceBeforeDraw() override {
42 sk_tool_utils::emoji_typeface(&fEmojiTypeface); 42 fEmojiTypeface = sk_tool_utils::emoji_typeface();
43 fEmojiText = sk_tool_utils::emoji_sample_text(); 43 fEmojiText = sk_tool_utils::emoji_sample_text();
44 fReallyBigATypeface.reset(GetResourceAsTypeface("/fonts/ReallyBigA.ttf") ); 44 fReallyBigATypeface = MakeResourceAsTypeface("/fonts/ReallyBigA.ttf");
45 45
46 SkTextBlobBuilder builder; 46 SkTextBlobBuilder builder;
47 47
48 // make textblob 48 // make textblob
49 // Text so large we draw as paths 49 // Text so large we draw as paths
50 SkPaint paint; 50 SkPaint paint;
51 paint.setTextSize(385); 51 paint.setTextSize(385);
52 const char* text = "O"; 52 const char* text = "O";
53 sk_tool_utils::set_portable_typeface(&paint); 53 sk_tool_utils::set_portable_typeface(&paint);
54 54
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 canvas->translate(SkScalarFloorToScalar(bounds.width() + SkIntTo Scalar(25)), 143 canvas->translate(SkScalarFloorToScalar(bounds.width() + SkIntTo Scalar(25)),
144 -(x * SkScalarFloorToScalar(bounds.height() + 144 -(x * SkScalarFloorToScalar(bounds.height() +
145 SkIntToScalar(25)))); 145 SkIntToScalar(25))));
146 } else { 146 } else {
147 canvas->translate(0, SkScalarFloorToScalar(bounds.height() + SkI ntToScalar(25))); 147 canvas->translate(0, SkScalarFloorToScalar(bounds.height() + SkI ntToScalar(25)));
148 } 148 }
149 } 149 }
150 } 150 }
151 151
152 private: 152 private:
153 SkAutoTUnref<SkTypeface> fEmojiTypeface; 153 sk_sp<SkTypeface> fEmojiTypeface;
154 SkAutoTUnref<SkTypeface> fReallyBigATypeface; 154 sk_sp<SkTypeface> fReallyBigATypeface;
155 const char* fEmojiText; 155 const char* fEmojiText;
156 SkAutoTUnref<const SkTextBlob> fBlob; 156 SkAutoTUnref<const SkTextBlob> fBlob;
157 157
158 static const int kWidth = 1250; 158 static const int kWidth = 1250;
159 static const int kHeight = 700; 159 static const int kHeight = 700;
160 160
161 typedef GM INHERITED; 161 typedef GM INHERITED;
162 }; 162 };
163 163
164 ////////////////////////////////////////////////////////////////////////////// 164 //////////////////////////////////////////////////////////////////////////////
165 165
166 DEF_GM(return new MixedTextBlobsGM;) 166 DEF_GM(return new MixedTextBlobsGM;)
167 } 167 }
OLDNEW
« no previous file with comments | « gm/gammatext.cpp ('k') | gm/pdf_never_embed.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698