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> |
| 9 #include <stdint.h> |
8 | 10 |
9 #include "base/i18n/icu_encoding_detection.h" | 11 #include "base/i18n/icu_encoding_detection.h" |
10 #include "base/i18n/icu_string_conversions.h" | 12 #include "base/i18n/icu_string_conversions.h" |
11 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
12 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
14 #include "base/numerics/safe_conversions.h" | 17 #include "base/numerics/safe_conversions.h" |
15 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
16 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/string_piece.h" | 20 #include "base/strings/string_piece.h" |
18 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
19 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
20 #include "base/values.h" | 23 #include "base/values.h" |
21 #include "gin/array_buffer.h" | 24 #include "gin/array_buffer.h" |
22 #include "gin/public/gin_embedders.h" | 25 #include "gin/public/gin_embedders.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 #define kPageShadowTop 3 | 67 #define kPageShadowTop 3 |
65 #define kPageShadowBottom 7 | 68 #define kPageShadowBottom 7 |
66 #define kPageShadowLeft 5 | 69 #define kPageShadowLeft 5 |
67 #define kPageShadowRight 5 | 70 #define kPageShadowRight 5 |
68 | 71 |
69 #define kPageSeparatorThickness 4 | 72 #define kPageSeparatorThickness 4 |
70 #define kHighlightColorR 153 | 73 #define kHighlightColorR 153 |
71 #define kHighlightColorG 193 | 74 #define kHighlightColorG 193 |
72 #define kHighlightColorB 218 | 75 #define kHighlightColorB 218 |
73 | 76 |
74 const uint32 kPendingPageColor = 0xFFEEEEEE; | 77 const uint32_t kPendingPageColor = 0xFFEEEEEE; |
75 | 78 |
76 #define kFormHighlightColor 0xFFE4DD | 79 #define kFormHighlightColor 0xFFE4DD |
77 #define kFormHighlightAlpha 100 | 80 #define kFormHighlightAlpha 100 |
78 | 81 |
79 #define kMaxPasswordTries 3 | 82 #define kMaxPasswordTries 3 |
80 | 83 |
81 // See Table 3.20 in | 84 // See Table 3.20 in |
82 // http://www.adobe.com/devnet/acrobat/pdfs/pdf_reference_1-7.pdf | 85 // http://www.adobe.com/devnet/acrobat/pdfs/pdf_reference_1-7.pdf |
83 #define kPDFPermissionPrintLowQualityMask 1 << 2 | 86 #define kPDFPermissionPrintLowQualityMask 1 << 2 |
84 #define kPDFPermissionPrintHighQualityMask 1 << 11 | 87 #define kPDFPermissionPrintHighQualityMask 1 << 11 |
(...skipping 3010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3095 new_rect = new_rect.Subtract((*highlighted_rects)[i]); | 3098 new_rect = new_rect.Subtract((*highlighted_rects)[i]); |
3096 | 3099 |
3097 highlighted_rects->push_back(new_rect); | 3100 highlighted_rects->push_back(new_rect); |
3098 int l = new_rect.x(); | 3101 int l = new_rect.x(); |
3099 int t = new_rect.y(); | 3102 int t = new_rect.y(); |
3100 int w = new_rect.width(); | 3103 int w = new_rect.width(); |
3101 int h = new_rect.height(); | 3104 int h = new_rect.height(); |
3102 | 3105 |
3103 for (int y = t; y < t + h; ++y) { | 3106 for (int y = t; y < t + h; ++y) { |
3104 for (int x = l; x < l + w; ++x) { | 3107 for (int x = l; x < l + w; ++x) { |
3105 uint8* pixel = static_cast<uint8*>(buffer) + y * stride + x * 4; | 3108 uint8_t* pixel = static_cast<uint8_t*>(buffer) + y * stride + x * 4; |
3106 // This is our highlight color. | 3109 // This is our highlight color. |
3107 pixel[0] = static_cast<uint8>( | 3110 pixel[0] = static_cast<uint8_t>(pixel[0] * (kHighlightColorB / 255.0)); |
3108 pixel[0] * (kHighlightColorB / 255.0)); | 3111 pixel[1] = static_cast<uint8_t>(pixel[1] * (kHighlightColorG / 255.0)); |
3109 pixel[1] = static_cast<uint8>( | 3112 pixel[2] = static_cast<uint8_t>(pixel[2] * (kHighlightColorR / 255.0)); |
3110 pixel[1] * (kHighlightColorG / 255.0)); | |
3111 pixel[2] = static_cast<uint8>( | |
3112 pixel[2] * (kHighlightColorR / 255.0)); | |
3113 } | 3113 } |
3114 } | 3114 } |
3115 } | 3115 } |
3116 | 3116 |
3117 PDFiumEngine::SelectionChangeInvalidator::SelectionChangeInvalidator( | 3117 PDFiumEngine::SelectionChangeInvalidator::SelectionChangeInvalidator( |
3118 PDFiumEngine* engine) : engine_(engine) { | 3118 PDFiumEngine* engine) : engine_(engine) { |
3119 previous_origin_ = engine_->GetVisibleRect().point(); | 3119 previous_origin_ = engine_->GetVisibleRect().point(); |
3120 GetVisibleSelectionsScreenRects(&old_selections_); | 3120 GetVisibleSelectionsScreenRects(&old_selections_); |
3121 } | 3121 } |
3122 | 3122 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3374 page_rect.Offset(page_offset_); | 3374 page_rect.Offset(page_offset_); |
3375 | 3375 |
3376 pp::Rect shadow_rect(shadow_rc); | 3376 pp::Rect shadow_rect(shadow_rc); |
3377 shadow_rect.Offset(page_offset_); | 3377 shadow_rect.Offset(page_offset_); |
3378 | 3378 |
3379 pp::Rect clip_rect(clip_rc); | 3379 pp::Rect clip_rect(clip_rc); |
3380 clip_rect.Offset(page_offset_); | 3380 clip_rect.Offset(page_offset_); |
3381 | 3381 |
3382 // Page drop shadow parameters. | 3382 // Page drop shadow parameters. |
3383 const double factor = 0.5; | 3383 const double factor = 0.5; |
3384 uint32 depth = std::max( | 3384 uint32_t depth = |
3385 std::max(page_rect.x() - shadow_rect.x(), | 3385 std::max(std::max(page_rect.x() - shadow_rect.x(), |
3386 page_rect.y() - shadow_rect.y()), | 3386 page_rect.y() - shadow_rect.y()), |
3387 std::max(shadow_rect.right() - page_rect.right(), | 3387 std::max(shadow_rect.right() - page_rect.right(), |
3388 shadow_rect.bottom() - page_rect.bottom())); | 3388 shadow_rect.bottom() - page_rect.bottom())); |
3389 depth = static_cast<uint32>(depth * 1.5) + 1; | 3389 depth = static_cast<uint32_t>(depth * 1.5) + 1; |
3390 | 3390 |
3391 // We need to check depth only to verify our copy of shadow matrix is correct. | 3391 // We need to check depth only to verify our copy of shadow matrix is correct. |
3392 if (!page_shadow_.get() || page_shadow_->depth() != depth) | 3392 if (!page_shadow_.get() || page_shadow_->depth() != depth) |
3393 page_shadow_.reset(new ShadowMatrix(depth, factor, | 3393 page_shadow_.reset(new ShadowMatrix(depth, factor, |
3394 client_->GetBackgroundColor())); | 3394 client_->GetBackgroundColor())); |
3395 | 3395 |
3396 DCHECK(!image_data->is_null()); | 3396 DCHECK(!image_data->is_null()); |
3397 DrawShadow(image_data, shadow_rect, page_rect, clip_rect, *page_shadow_); | 3397 DrawShadow(image_data, shadow_rect, page_rect, clip_rect, *page_shadow_); |
3398 } | 3398 } |
3399 | 3399 |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3999 double* height) { | 3999 double* height) { |
4000 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 4000 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); |
4001 if (!doc) | 4001 if (!doc) |
4002 return false; | 4002 return false; |
4003 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 4003 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
4004 FPDF_CloseDocument(doc); | 4004 FPDF_CloseDocument(doc); |
4005 return success; | 4005 return success; |
4006 } | 4006 } |
4007 | 4007 |
4008 } // namespace chrome_pdf | 4008 } // namespace chrome_pdf |
OLD | NEW |