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

Side by Side Diff: pdf/pdfium/pdfium_engine.cc

Issue 2398763002: Add font substitution metric for Linux (Closed)
Patch Set: Using Boolean Created 4 years, 2 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 (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 "pdf/pdfium/pdfium_engine.h" 5 #include "pdf/pdfium/pdfium_engine.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // adding too much latency to the display of the final image when the user 103 // adding too much latency to the display of the final image when the user
104 // stops scrolling. 104 // stops scrolling.
105 // Setting a higher value has minimal benefit (scrolling at less than 4 fps will 105 // Setting a higher value has minimal benefit (scrolling at less than 4 fps will
106 // never be a great experience) and there is some cost, since when the user 106 // never be a great experience) and there is some cost, since when the user
107 // stops scrolling the in-progress painting has to complete or timeout before 107 // stops scrolling the in-progress painting has to complete or timeout before
108 // the final painting can start. 108 // the final painting can start.
109 // The scrollbar will always be responsive since it is managed by a separate 109 // The scrollbar will always be responsive since it is managed by a separate
110 // process. 110 // process.
111 const int32_t kMaxInitialProgressivePaintTimeMs = 250; 111 const int32_t kMaxInitialProgressivePaintTimeMs = 250;
112 112
113 PDFEngine::Client* g_client_for_fontmapper_ = nullptr;
114
113 std::vector<uint32_t> GetPageNumbersFromPrintPageNumberRange( 115 std::vector<uint32_t> GetPageNumbersFromPrintPageNumberRange(
114 const PP_PrintPageNumberRange_Dev* page_ranges, 116 const PP_PrintPageNumberRange_Dev* page_ranges,
115 uint32_t page_range_count) { 117 uint32_t page_range_count) {
116 std::vector<uint32_t> page_numbers; 118 std::vector<uint32_t> page_numbers;
117 for (uint32_t index = 0; index < page_range_count; ++index) { 119 for (uint32_t index = 0; index < page_range_count; ++index) {
118 for (uint32_t page_number = page_ranges[index].first_page_number; 120 for (uint32_t page_number = page_ranges[index].first_page_number;
119 page_number <= page_ranges[index].last_page_number; ++page_number) { 121 page_number <= page_ranges[index].last_page_number; ++page_number) {
120 page_numbers.push_back(page_number); 122 page_numbers.push_back(page_number);
121 } 123 }
122 } 124 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 description.set_face(face_utf8); 254 description.set_face(face_utf8);
253 description.set_weight(WeightToBrowserFontTrustedWeight(weight)); 255 description.set_weight(WeightToBrowserFontTrustedWeight(weight));
254 description.set_italic(italic > 0); 256 description.set_italic(italic > 0);
255 } 257 }
256 258
257 if (!pp::PDF::IsAvailable()) { 259 if (!pp::PDF::IsAvailable()) {
258 NOTREACHED(); 260 NOTREACHED();
259 return nullptr; 261 return nullptr;
260 } 262 }
261 263
264 if (g_client_for_fontmapper_)
265 g_client_for_fontmapper_->FontSubstituted();
266
262 PP_Resource font_resource = pp::PDF::GetFontFileWithFallback( 267 PP_Resource font_resource = pp::PDF::GetFontFileWithFallback(
263 pp::InstanceHandle(g_last_instance_id), 268 pp::InstanceHandle(g_last_instance_id),
264 &description.pp_font_description(), 269 &description.pp_font_description(),
265 static_cast<PP_PrivateFontCharset>(charset)); 270 static_cast<PP_PrivateFontCharset>(charset));
266 long res_id = font_resource; 271 long res_id = font_resource;
267 return reinterpret_cast<void*>(res_id); 272 return reinterpret_cast<void*>(res_id);
268 } 273 }
269 274
270 unsigned long GetFontData(struct _FPDF_SYSFONTINFO*, void* font_id, 275 unsigned long GetFontData(struct _FPDF_SYSFONTINFO*, void* font_id,
271 unsigned int table, unsigned char* buffer, 276 unsigned int table, unsigned char* buffer,
(...skipping 2168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2440 !FPDFAvail_IsDocAvail(fpdf_availability_, &download_hints_)) { 2445 !FPDFAvail_IsDocAvail(fpdf_availability_, &download_hints_)) {
2441 return; 2446 return;
2442 } 2447 }
2443 2448
2444 // If we're in the middle of getting a password, just return. We will retry 2449 // If we're in the middle of getting a password, just return. We will retry
2445 // loading the document after we get the password anyway. 2450 // loading the document after we get the password anyway.
2446 if (getting_password_) 2451 if (getting_password_)
2447 return; 2452 return;
2448 2453
2449 ScopedUnsupportedFeature scoped_unsupported_feature(this); 2454 ScopedUnsupportedFeature scoped_unsupported_feature(this);
2455 g_client_for_fontmapper_ = client_;
Lei Zhang 2016/10/11 22:35:59 I'm worried we set this but never unset it. There
npm 2016/10/12 18:19:52 I see that. But this is how g_last_instance_id wor
Lei Zhang 2016/10/12 18:46:58 However, |g_last_instance_id| is an int, and havin
2450 bool needs_password = false; 2456 bool needs_password = false;
2451 if (TryLoadingDoc(std::string(), &needs_password)) { 2457 if (TryLoadingDoc(std::string(), &needs_password)) {
2452 ContinueLoadingDocument(std::string()); 2458 ContinueLoadingDocument(std::string());
2453 return; 2459 return;
2454 } 2460 }
2455 if (needs_password) 2461 if (needs_password)
2456 GetPasswordAndLoad(); 2462 GetPasswordAndLoad();
2457 else 2463 else
2458 client_->DocumentLoadFailed(); 2464 client_->DocumentLoadFailed();
2459 } 2465 }
(...skipping 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after
3975 FPDF_DOCUMENT doc = 3981 FPDF_DOCUMENT doc =
3976 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); 3982 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr);
3977 if (!doc) 3983 if (!doc)
3978 return false; 3984 return false;
3979 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 3985 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
3980 FPDF_CloseDocument(doc); 3986 FPDF_CloseDocument(doc);
3981 return success; 3987 return success;
3982 } 3988 }
3983 3989
3984 } // namespace chrome_pdf 3990 } // namespace chrome_pdf
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698