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

Side by Side Diff: components/font_service/public/cpp/font_service_thread.cc

Issue 1877673002: Move legacyCreateTypeface to SkFontStyle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove DEPS change now that Skia change has landed. 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/font_service/public/cpp/font_service_thread.h" 5 #include "components/font_service/public/cpp/font_service_thread.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file.h" 10 #include "base/files/file.h"
(...skipping 13 matching lines...) Expand all
24 : base::Thread(kFontThreadName), 24 : base::Thread(kFontThreadName),
25 font_service_info_(font_service.PassInterface()) { 25 font_service_info_(font_service.PassInterface()) {
26 base::Thread::Options options; 26 base::Thread::Options options;
27 options.message_pump_factory = 27 options.message_pump_factory =
28 base::Bind(&mojo::common::MessagePumpMojo::Create); 28 base::Bind(&mojo::common::MessagePumpMojo::Create);
29 StartWithOptions(options); 29 StartWithOptions(options);
30 } 30 }
31 31
32 bool FontServiceThread::MatchFamilyName( 32 bool FontServiceThread::MatchFamilyName(
33 const char family_name[], 33 const char family_name[],
34 SkTypeface::Style requested_style, 34 SkFontStyle requested_style,
35 SkFontConfigInterface::FontIdentity* out_font_identity, 35 SkFontConfigInterface::FontIdentity* out_font_identity,
36 SkString* out_family_name, 36 SkString* out_family_name,
37 SkTypeface::Style* out_style) { 37 SkFontStyle* out_style) {
38 DCHECK_NE(GetThreadId(), base::PlatformThread::CurrentId()); 38 DCHECK_NE(GetThreadId(), base::PlatformThread::CurrentId());
39 39
40 bool out_valid = false; 40 bool out_valid = false;
41 // This proxies to the other thread, which proxies to mojo. Only on the reply 41 // This proxies to the other thread, which proxies to mojo. Only on the reply
42 // from mojo do we return from this. 42 // from mojo do we return from this.
43 base::WaitableEvent done_event(false, false); 43 base::WaitableEvent done_event(false, false);
44 task_runner()->PostTask( 44 task_runner()->PostTask(
45 FROM_HERE, 45 FROM_HERE,
46 base::Bind(&FontServiceThread::MatchFamilyNameImpl, this, &done_event, 46 base::Bind(&FontServiceThread::MatchFamilyNameImpl, this, &done_event,
47 family_name, requested_style, &out_valid, out_font_identity, 47 family_name, requested_style, &out_valid, out_font_identity,
(...skipping 30 matching lines...) Expand all
78 return mapped_font_file; 78 return mapped_font_file;
79 } 79 }
80 80
81 FontServiceThread::~FontServiceThread() { 81 FontServiceThread::~FontServiceThread() {
82 Stop(); 82 Stop();
83 } 83 }
84 84
85 void FontServiceThread::MatchFamilyNameImpl( 85 void FontServiceThread::MatchFamilyNameImpl(
86 base::WaitableEvent* done_event, 86 base::WaitableEvent* done_event,
87 const char family_name[], 87 const char family_name[],
88 SkTypeface::Style requested_style, 88 SkFontStyle requested_style,
89 bool* out_valid, 89 bool* out_valid,
90 SkFontConfigInterface::FontIdentity* out_font_identity, 90 SkFontConfigInterface::FontIdentity* out_font_identity,
91 SkString* out_family_name, 91 SkString* out_family_name,
92 SkTypeface::Style* out_style) { 92 SkFontStyle* out_style) {
93 DCHECK_EQ(GetThreadId(), base::PlatformThread::CurrentId()); 93 DCHECK_EQ(GetThreadId(), base::PlatformThread::CurrentId());
94 94
95 TypefaceStylePtr style(TypefaceStyle::New());
96 style->weight = requested_style.weight();
97 style->width = requested_style.width();
98 style->slant = static_cast<TypefaceSlant>(requested_style.slant());
99
95 font_service_->MatchFamilyName( 100 font_service_->MatchFamilyName(
96 mojo::String(family_name), static_cast<TypefaceStyle>(requested_style), 101 mojo::String(family_name), std::move(style),
97 base::Bind(&FontServiceThread::OnMatchFamilyNameComplete, this, 102 base::Bind(&FontServiceThread::OnMatchFamilyNameComplete, this,
98 done_event, out_valid, out_font_identity, out_family_name, 103 done_event, out_valid, out_font_identity, out_family_name,
99 out_style)); 104 out_style));
100 } 105 }
101 106
102 void FontServiceThread::OnMatchFamilyNameComplete( 107 void FontServiceThread::OnMatchFamilyNameComplete(
103 base::WaitableEvent* done_event, 108 base::WaitableEvent* done_event,
104 bool* out_valid, 109 bool* out_valid,
105 SkFontConfigInterface::FontIdentity* out_font_identity, 110 SkFontConfigInterface::FontIdentity* out_font_identity,
106 SkString* out_family_name, 111 SkString* out_family_name,
107 SkTypeface::Style* out_style, 112 SkFontStyle* out_style,
108 FontIdentityPtr font_identity, 113 FontIdentityPtr font_identity,
109 mojo::String family_name, 114 mojo::String family_name,
110 TypefaceStyle style) { 115 TypefaceStylePtr style) {
111 DCHECK_EQ(GetThreadId(), base::PlatformThread::CurrentId()); 116 DCHECK_EQ(GetThreadId(), base::PlatformThread::CurrentId());
112 117
113 *out_valid = font_identity; 118 *out_valid = font_identity;
114 if (font_identity) { 119 if (font_identity) {
115 out_font_identity->fID = font_identity->id; 120 out_font_identity->fID = font_identity->id;
116 out_font_identity->fTTCIndex = font_identity->ttc_index; 121 out_font_identity->fTTCIndex = font_identity->ttc_index;
117 out_font_identity->fString = font_identity->str_representation.data(); 122 out_font_identity->fString = font_identity->str_representation.data();
118 // TODO(erg): fStyle isn't set. This is rather odd, however it matches the 123 // TODO(erg): fStyle isn't set. This is rather odd, however it matches the
119 // behaviour of the current Linux IPC version. 124 // behaviour of the current Linux IPC version.
120 125
121 *out_family_name = family_name.data(); 126 *out_family_name = family_name.data();
122 *out_style = static_cast<SkTypeface::Style>(style); 127 *out_style = SkFontStyle(style->weight,
128 style->width,
129 static_cast<SkFontStyle::Slant>(style->slant));
123 } 130 }
124 131
125 done_event->Signal(); 132 done_event->Signal();
126 } 133 }
127 134
128 void FontServiceThread::OpenStreamImpl(base::WaitableEvent* done_event, 135 void FontServiceThread::OpenStreamImpl(base::WaitableEvent* done_event,
129 base::File* output_file, 136 base::File* output_file,
130 const uint32_t id_number) { 137 const uint32_t id_number) {
131 DCHECK_EQ(GetThreadId(), base::PlatformThread::CurrentId()); 138 DCHECK_EQ(GetThreadId(), base::PlatformThread::CurrentId());
132 139
(...skipping 18 matching lines...) Expand all
151 void FontServiceThread::Init() { 158 void FontServiceThread::Init() {
152 font_service_.Bind(std::move(font_service_info_)); 159 font_service_.Bind(std::move(font_service_info_));
153 } 160 }
154 161
155 void FontServiceThread::CleanUp() { 162 void FontServiceThread::CleanUp() {
156 font_service_.reset(); 163 font_service_.reset();
157 } 164 }
158 165
159 } // namespace internal 166 } // namespace internal
160 } // namespace font_service 167 } // namespace font_service
OLDNEW
« no previous file with comments | « components/font_service/public/cpp/font_service_thread.h ('k') | components/font_service/public/interfaces/font_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698