| 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 "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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // http://www.adobe.com/devnet/acrobat/pdfs/pdf_reference_1-7.pdf | 88 // http://www.adobe.com/devnet/acrobat/pdfs/pdf_reference_1-7.pdf |
| 89 #define kPDFPermissionPrintLowQualityMask 1 << 2 | 89 #define kPDFPermissionPrintLowQualityMask 1 << 2 |
| 90 #define kPDFPermissionPrintHighQualityMask 1 << 11 | 90 #define kPDFPermissionPrintHighQualityMask 1 << 11 |
| 91 #define kPDFPermissionCopyMask 1 << 4 | 91 #define kPDFPermissionCopyMask 1 << 4 |
| 92 #define kPDFPermissionCopyAccessibleMask 1 << 9 | 92 #define kPDFPermissionCopyAccessibleMask 1 << 9 |
| 93 | 93 |
| 94 #define kLoadingTextVerticalOffset 50 | 94 #define kLoadingTextVerticalOffset 50 |
| 95 | 95 |
| 96 // The maximum amount of time we'll spend doing a paint before we give back | 96 // The maximum amount of time we'll spend doing a paint before we give back |
| 97 // control of the thread. | 97 // control of the thread. |
| 98 #define kMaxProgressivePaintTimeMs 50 | 98 #define kMaxProgressivePaintTimeMs 300 |
| 99 | 99 |
| 100 // The maximum amount of time we'll spend doing the first paint. This is less | 100 // The maximum amount of time we'll spend doing the first paint. This is less |
| 101 // than the above to keep things smooth if the user is scrolling quickly. We | 101 // than the above to keep things smooth if the user is scrolling quickly. This |
| 102 // try painting a little because with accelerated compositing, we get flushes | 102 // is set to 250 ms to give enough time for most PDFs to render, while avoiding |
| 103 // only every 16 ms. If we were to wait until the next flush to paint the rest | 103 // adding too much latency to the display of the final image when the user |
| 104 // of the pdf, we would never get to draw the pdf and would only draw the | 104 // stops scrolling. |
| 105 // scrollbars. This value is picked to give enough time for gpu related code to | 105 // Setting a higher value has minimal benefit (scrolling at less than 4 fps will |
| 106 // do its thing and still fit within the timelimit for 60Hz. For the | 106 // never be a great experience) and there is some cost, since when the user |
| 107 // non-composited case, this doesn't make things worse since we're still | 107 // stops scrolling the in-progress painting has to complete or timeout before |
| 108 // painting the scrollbars > 60 Hz. | 108 // the final painting can start. |
| 109 #define kMaxInitialProgressivePaintTimeMs 10 | 109 // The scrollbar will always be responsive since it is managed by a separate |
| 110 // process. |
| 111 #define kMaxInitialProgressivePaintTimeMs 250 |
| 110 | 112 |
| 111 std::vector<uint32_t> GetPageNumbersFromPrintPageNumberRange( | 113 std::vector<uint32_t> GetPageNumbersFromPrintPageNumberRange( |
| 112 const PP_PrintPageNumberRange_Dev* page_ranges, | 114 const PP_PrintPageNumberRange_Dev* page_ranges, |
| 113 uint32_t page_range_count) { | 115 uint32_t page_range_count) { |
| 114 std::vector<uint32_t> page_numbers; | 116 std::vector<uint32_t> page_numbers; |
| 115 for (uint32_t index = 0; index < page_range_count; ++index) { | 117 for (uint32_t index = 0; index < page_range_count; ++index) { |
| 116 for (uint32_t page_number = page_ranges[index].first_page_number; | 118 for (uint32_t page_number = page_ranges[index].first_page_number; |
| 117 page_number <= page_ranges[index].last_page_number; ++page_number) { | 119 page_number <= page_ranges[index].last_page_number; ++page_number) { |
| 118 page_numbers.push_back(page_number); | 120 page_numbers.push_back(page_number); |
| 119 } | 121 } |
| (...skipping 3779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3899 FPDF_DOCUMENT doc = | 3901 FPDF_DOCUMENT doc = |
| 3900 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); | 3902 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); |
| 3901 if (!doc) | 3903 if (!doc) |
| 3902 return false; | 3904 return false; |
| 3903 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 3905 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
| 3904 FPDF_CloseDocument(doc); | 3906 FPDF_CloseDocument(doc); |
| 3905 return success; | 3907 return success; |
| 3906 } | 3908 } |
| 3907 | 3909 |
| 3908 } // namespace chrome_pdf | 3910 } // namespace chrome_pdf |
| OLD | NEW |