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

Side by Side Diff: content/common/font_config_ipc_linux.cc

Issue 1877673002: Move legacyCreateTypeface to SkFontStyle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comment. Created 4 years, 8 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 | « content/common/font_config_ipc_linux.h ('k') | skia/chromium_skia_defines.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 FontConfigIPC::FontConfigIPC(int fd) 57 FontConfigIPC::FontConfigIPC(int fd)
58 : fd_(fd) 58 : fd_(fd)
59 , mapped_typefaces_(kMaxMappedTypefaces) { 59 , mapped_typefaces_(kMaxMappedTypefaces) {
60 } 60 }
61 61
62 FontConfigIPC::~FontConfigIPC() { 62 FontConfigIPC::~FontConfigIPC() {
63 CloseFD(fd_); 63 CloseFD(fd_);
64 } 64 }
65 65
66 bool FontConfigIPC::matchFamilyName(const char familyName[], 66 bool FontConfigIPC::matchFamilyName(const char familyName[],
67 SkTypeface::Style requestedStyle, 67 SkFontStyle requestedStyle,
68 FontIdentity* outFontIdentity, 68 FontIdentity* outFontIdentity,
69 SkString* outFamilyName, 69 SkString* outFamilyName,
70 SkTypeface::Style* outStyle) { 70 SkFontStyle* outStyle) {
71 TRACE_EVENT0("sandbox_ipc", "FontConfigIPC::matchFamilyName"); 71 TRACE_EVENT0("sandbox_ipc", "FontConfigIPC::matchFamilyName");
72 size_t familyNameLen = familyName ? strlen(familyName) : 0; 72 size_t familyNameLen = familyName ? strlen(familyName) : 0;
73 if (familyNameLen > kMaxFontFamilyLength) 73 if (familyNameLen > kMaxFontFamilyLength)
74 return false; 74 return false;
75 75
76 base::Pickle request; 76 base::Pickle request;
77 request.WriteInt(METHOD_MATCH); 77 request.WriteInt(METHOD_MATCH);
78 request.WriteData(familyName, familyNameLen); 78 request.WriteData(familyName, familyNameLen);
79 request.WriteUInt32(requestedStyle); 79 request.WriteUInt32(static_cast<uint32_t>(requestedStyle));
dcheng 2016/04/11 19:51:06 How does this work? Isn't SkFontStyle a class? htt
bungeman-chromium 2016/04/11 20:32:17 It is a class, but is explicitly convertible to a
dcheng 2016/04/11 21:06:50 Right, I see that it just wraps a union that's uin
bungeman-chromium 2016/04/11 22:31:10 The Skia change linked in the description is being
80 80
81 uint8_t reply_buf[2048]; 81 uint8_t reply_buf[2048];
82 const ssize_t r = base::UnixDomainSocket::SendRecvMsg( 82 const ssize_t r = base::UnixDomainSocket::SendRecvMsg(
83 fd_, reply_buf, sizeof(reply_buf), NULL, request); 83 fd_, reply_buf, sizeof(reply_buf), NULL, request);
84 if (r == -1) 84 if (r == -1)
85 return false; 85 return false;
86 86
87 base::Pickle reply(reinterpret_cast<char*>(reply_buf), r); 87 base::Pickle reply(reinterpret_cast<char*>(reply_buf), r);
88 base::PickleIterator iter(reply); 88 base::PickleIterator iter(reply);
89 bool result; 89 bool result;
90 if (!iter.ReadBool(&result)) 90 if (!iter.ReadBool(&result))
91 return false; 91 return false;
92 if (!result) 92 if (!result)
93 return false; 93 return false;
94 94
95 SkString reply_family; 95 SkString reply_family;
96 FontIdentity reply_identity; 96 FontIdentity reply_identity;
97 uint32_t reply_style; 97 uint32_t reply_style;
98 if (!skia::ReadSkString(&iter, &reply_family) || 98 if (!skia::ReadSkString(&iter, &reply_family) ||
99 !skia::ReadSkFontIdentity(&iter, &reply_identity) || 99 !skia::ReadSkFontIdentity(&iter, &reply_identity) ||
100 !iter.ReadUInt32(&reply_style)) { 100 !iter.ReadUInt32(&reply_style)) {
101 return false; 101 return false;
102 } 102 }
103 103
104 if (outFontIdentity) 104 if (outFontIdentity)
105 *outFontIdentity = reply_identity; 105 *outFontIdentity = reply_identity;
106 if (outFamilyName) 106 if (outFamilyName)
107 *outFamilyName = reply_family; 107 *outFamilyName = reply_family;
108 if (outStyle) 108 if (outStyle)
109 *outStyle = static_cast<SkTypeface::Style>(reply_style); 109 *outStyle = static_cast<SkFontStyle>(reply_style);
110 110
111 return true; 111 return true;
112 } 112 }
113 113
114 static void DestroyMemoryMappedFile(const void*, void* context) { 114 static void DestroyMemoryMappedFile(const void*, void* context) {
115 base::ThreadRestrictions::ScopedAllowIO allow_munmap; 115 base::ThreadRestrictions::ScopedAllowIO allow_munmap;
116 delete static_cast<base::MemoryMappedFile*>(context); 116 delete static_cast<base::MemoryMappedFile*>(context);
117 } 117 }
118 118
119 SkMemoryStream* FontConfigIPC::mapFileDescriptorToStream(int fd) { 119 SkMemoryStream* FontConfigIPC::mapFileDescriptorToStream(int fd) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 if (!typeface_stream) 169 if (!typeface_stream)
170 return nullptr; 170 return nullptr;
171 skia::RefPtr<SkTypeface> typeface_from_stream = skia::AdoptRef( 171 skia::RefPtr<SkTypeface> typeface_from_stream = skia::AdoptRef(
172 SkTypeface::CreateFromStream(typeface_stream, identity.fTTCIndex)); 172 SkTypeface::CreateFromStream(typeface_stream, identity.fTTCIndex));
173 auto mapped_typefaces_insert_it = 173 auto mapped_typefaces_insert_it =
174 mapped_typefaces_.Put(identity, typeface_from_stream); 174 mapped_typefaces_.Put(identity, typeface_from_stream);
175 return SkSafeRef(mapped_typefaces_insert_it->second.get()); 175 return SkSafeRef(mapped_typefaces_insert_it->second.get());
176 } 176 }
177 177
178 } // namespace content 178 } // namespace content
OLDNEW
« no previous file with comments | « content/common/font_config_ipc_linux.h ('k') | skia/chromium_skia_defines.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698