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

Side by Side Diff: tools/using_skia_and_harfbuzz.cpp

Issue 1974783002: Revert of Move SkTypeface to sk_sp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 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 // This sample progam demonstrates how to use Skia and HarfBuzz to 8 // This sample progam demonstrates how to use Skia and HarfBuzz to
9 // produce a PDF file from UTF-8 text in stdin. 9 // produce a PDF file from UTF-8 text in stdin.
10 10
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 struct Face { 135 struct Face {
136 struct HBFDel { void operator()(hb_face_t* f) { hb_face_destroy(f); } }; 136 struct HBFDel { void operator()(hb_face_t* f) { hb_face_destroy(f); } };
137 std::unique_ptr<hb_face_t, HBFDel> fHarfBuzzFace; 137 std::unique_ptr<hb_face_t, HBFDel> fHarfBuzzFace;
138 sk_sp<SkTypeface> fSkiaTypeface; 138 sk_sp<SkTypeface> fSkiaTypeface;
139 139
140 Face(const char* path, int index) { 140 Face(const char* path, int index) {
141 // fairly portable mmap impl 141 // fairly portable mmap impl
142 auto data = SkData::MakeFromFileName(path); 142 auto data = SkData::MakeFromFileName(path);
143 assert(data); 143 assert(data);
144 if (!data) { return; } 144 if (!data) { return; }
145 fSkiaTypeface = SkTypeface::MakeFromStream(new SkMemoryStream(data), index); 145 fSkiaTypeface.reset(
146 SkTypeface::CreateFromStream(
147 new SkMemoryStream(data), index));
146 assert(fSkiaTypeface); 148 assert(fSkiaTypeface);
147 if (!fSkiaTypeface) { return; } 149 if (!fSkiaTypeface) { return; }
148 auto destroy = [](void *d) { static_cast<SkData*>(d)->unref(); }; 150 auto destroy = [](void *d) { static_cast<SkData*>(d)->unref(); };
149 const char* bytes = (const char*)data->data(); 151 const char* bytes = (const char*)data->data();
150 unsigned int size = (unsigned int)data->size(); 152 unsigned int size = (unsigned int)data->size();
151 hb_blob_t* blob = hb_blob_create(bytes, 153 hb_blob_t* blob = hb_blob_create(bytes,
152 size, 154 size,
153 HB_MEMORY_MODE_READONLY, 155 HB_MEMORY_MODE_READONLY,
154 data.release(), 156 data.release(),
155 destroy); 157 destroy);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 Config config(argc, argv); 297 Config config(argc, argv);
296 298
297 Placement placement(config, new SkFILEWStream(config.output_file_name->value .c_str())); 299 Placement placement(config, new SkFILEWStream(config.output_file_name->value .c_str()));
298 for (std::string line; std::getline(std::cin, line);) { 300 for (std::string line; std::getline(std::cin, line);) {
299 placement.WriteLine(line.c_str()); 301 placement.WriteLine(line.c_str());
300 } 302 }
301 placement.Close(); 303 placement.Close();
302 304
303 return 0; 305 return 0;
304 } 306 }
OLDNEW
« src/ports/SkFontMgr_android.cpp ('K') | « tools/sk_tool_utils_font.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698