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

Side by Side Diff: tools/Resources.cpp

Issue 2339273002: SkFontData to use smart pointers. (Closed)
Patch Set: Add trivial bodies to the trivial implementations. Created 4 years, 3 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 | « tests/YUVTest.cpp ('k') | tools/dump_record.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 2014 Google Inc. 2 * Copyright 2014 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 "Resources.h" 8 #include "Resources.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCommandLineFlags.h" 10 #include "SkCommandLineFlags.h"
(...skipping 23 matching lines...) Expand all
34 34
35 sk_sp<SkImage> GetResourceAsImage(const char* resource) { 35 sk_sp<SkImage> GetResourceAsImage(const char* resource) {
36 SkString path = GetResourcePath(resource); 36 SkString path = GetResourcePath(resource);
37 sk_sp<SkData> resourceData(SkData::MakeFromFileName(path.c_str())); 37 sk_sp<SkData> resourceData(SkData::MakeFromFileName(path.c_str()));
38 return SkImage::MakeFromEncoded(resourceData); 38 return SkImage::MakeFromEncoded(resourceData);
39 } 39 }
40 40
41 SkStreamAsset* GetResourceAsStream(const char* resource) { 41 SkStreamAsset* GetResourceAsStream(const char* resource) {
42 SkString resourcePath = GetResourcePath(resource); 42 SkString resourcePath = GetResourcePath(resource);
43 SkAutoTDelete<SkFILEStream> stream(new SkFILEStream(resourcePath.c_str())); 43 SkAutoTDelete<SkFILEStream> stream(new SkFILEStream(resourcePath.c_str()));
44 if (stream->isValid()) { 44 if (!stream->isValid()) {
45 return stream.release();
46 } else {
47 SkDebugf("Resource %s not found.\n", resource); 45 SkDebugf("Resource %s not found.\n", resource);
48 return nullptr; 46 return nullptr;
49 } 47 }
48 return stream.release();
50 } 49 }
51 50
52 sk_sp<SkTypeface> MakeResourceAsTypeface(const char* resource) { 51 sk_sp<SkTypeface> MakeResourceAsTypeface(const char* resource) {
53 SkAutoTDelete<SkStreamAsset> stream(GetResourceAsStream(resource)); 52 SkAutoTDelete<SkStreamAsset> stream(GetResourceAsStream(resource));
54 if (!stream) { 53 if (!stream) {
55 return nullptr; 54 return nullptr;
56 } 55 }
57 return SkTypeface::MakeFromStream(stream.release()); 56 return SkTypeface::MakeFromStream(stream.release());
58 } 57 }
OLDNEW
« no previous file with comments | « tests/YUVTest.cpp ('k') | tools/dump_record.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698