OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/common/font_config_ipc_linux.h" | 5 #include "content/common/font_config_ipc_linux.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <sys/mman.h> | 10 #include <sys/mman.h> |
11 #include <sys/socket.h> | 11 #include <sys/socket.h> |
12 #include <sys/stat.h> | 12 #include <sys/stat.h> |
13 #include <sys/uio.h> | 13 #include <sys/uio.h> |
14 #include <unistd.h> | 14 #include <unistd.h> |
15 | 15 |
16 #include <functional> | 16 #include <functional> |
17 #include <memory> | 17 #include <memory> |
| 18 #include <utility> |
18 | 19 |
19 #include "base/files/file_util.h" | 20 #include "base/files/file_util.h" |
20 #include "base/files/memory_mapped_file.h" | 21 #include "base/files/memory_mapped_file.h" |
21 #include "base/memory/ref_counted.h" | 22 #include "base/memory/ref_counted.h" |
22 #include "base/pickle.h" | 23 #include "base/pickle.h" |
23 #include "base/posix/unix_domain_socket_linux.h" | 24 #include "base/posix/unix_domain_socket_linux.h" |
24 #include "base/threading/thread_restrictions.h" | 25 #include "base/threading/thread_restrictions.h" |
25 #include "base/trace_event/trace_event.h" | 26 #include "base/trace_event/trace_event.h" |
26 #include "skia/ext/skia_utils_base.h" | 27 #include "skia/ext/skia_utils_base.h" |
27 #include "third_party/skia/include/core/SkData.h" | 28 #include "third_party/skia/include/core/SkData.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 base::PickleIterator iter(reply); | 152 base::PickleIterator iter(reply); |
152 if (!iter.ReadBool(&result) || !result) { | 153 if (!iter.ReadBool(&result) || !result) { |
153 if (result_fd) | 154 if (result_fd) |
154 CloseFD(result_fd); | 155 CloseFD(result_fd); |
155 return NULL; | 156 return NULL; |
156 } | 157 } |
157 | 158 |
158 return mapFileDescriptorToStream(result_fd); | 159 return mapFileDescriptorToStream(result_fd); |
159 } | 160 } |
160 | 161 |
161 SkTypeface* FontConfigIPC::createTypeface( | 162 sk_sp<SkTypeface> FontConfigIPC::makeTypeface( |
162 const SkFontConfigInterface::FontIdentity& identity) { | 163 const SkFontConfigInterface::FontIdentity& identity) { |
163 base::AutoLock lock(lock_); | 164 base::AutoLock lock(lock_); |
164 auto mapped_typefaces_it = mapped_typefaces_.Get(identity); | 165 auto mapped_typefaces_it = mapped_typefaces_.Get(identity); |
165 if (mapped_typefaces_it != mapped_typefaces_.end()) | 166 if (mapped_typefaces_it != mapped_typefaces_.end()) |
166 return SkSafeRef(mapped_typefaces_it->second.get()); | 167 return mapped_typefaces_it->second; |
167 | 168 |
168 SkStreamAsset* typeface_stream = openStream(identity); | 169 SkStreamAsset* typeface_stream = openStream(identity); |
169 if (!typeface_stream) | 170 if (!typeface_stream) |
170 return nullptr; | 171 return nullptr; |
171 sk_sp<SkTypeface> typeface_from_stream( | 172 sk_sp<SkTypeface> typeface_from_stream( |
172 SkTypeface::CreateFromStream(typeface_stream, identity.fTTCIndex)); | 173 SkTypeface::MakeFromStream(typeface_stream, identity.fTTCIndex)); |
173 auto mapped_typefaces_insert_it = | 174 auto mapped_typefaces_insert_it = |
174 mapped_typefaces_.Put(identity, typeface_from_stream); | 175 mapped_typefaces_.Put(identity, std::move(typeface_from_stream)); |
175 return SkSafeRef(mapped_typefaces_insert_it->second.get()); | 176 return mapped_typefaces_insert_it->second; |
176 } | 177 } |
177 | 178 |
178 } // namespace content | 179 } // namespace content |
OLD | NEW |