| 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 | 8 |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #define kPageShadowTop 3 | 48 #define kPageShadowTop 3 |
| 49 #define kPageShadowBottom 7 | 49 #define kPageShadowBottom 7 |
| 50 #define kPageShadowLeft 5 | 50 #define kPageShadowLeft 5 |
| 51 #define kPageShadowRight 5 | 51 #define kPageShadowRight 5 |
| 52 | 52 |
| 53 #define kPageSeparatorThickness 4 | 53 #define kPageSeparatorThickness 4 |
| 54 #define kHighlightColorR 153 | 54 #define kHighlightColorR 153 |
| 55 #define kHighlightColorG 193 | 55 #define kHighlightColorG 193 |
| 56 #define kHighlightColorB 218 | 56 #define kHighlightColorB 218 |
| 57 | 57 |
| 58 #define kPendingPageColorR 238 | 58 const uint32 kPendingPageColor = 0xFFEEEEEE; |
| 59 #define kPendingPageColorG 238 | |
| 60 #define kPendingPageColorB 238 | |
| 61 #define kPendingPageColorA 255 | |
| 62 | 59 |
| 63 #define kFormHighlightColor 0xFFE4DD | 60 #define kFormHighlightColor 0xFFE4DD |
| 64 #define kFormHighlightAlpha 100 | 61 #define kFormHighlightAlpha 100 |
| 65 | 62 |
| 66 #define kMaxPasswordTries 3 | 63 #define kMaxPasswordTries 3 |
| 67 | 64 |
| 68 // See Table 3.20 in | 65 // See Table 3.20 in |
| 69 // http://www.adobe.com/devnet/acrobat/pdfs/pdf_reference_1-7.pdf | 66 // http://www.adobe.com/devnet/acrobat/pdfs/pdf_reference_1-7.pdf |
| 70 #define kPDFPermissionPrintLowQualityMask 1 << 2 | 67 #define kPDFPermissionPrintLowQualityMask 1 << 2 |
| 71 #define kPDFPermissionPrintHighQualityMask 1 << 11 | 68 #define kPDFPermissionPrintHighQualityMask 1 << 11 |
| (...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 false); | 1048 false); |
| 1052 | 1049 |
| 1053 FPDF_BITMAP bitmap = FPDFBitmap_CreateEx(bitmap_size.width(), | 1050 FPDF_BITMAP bitmap = FPDFBitmap_CreateEx(bitmap_size.width(), |
| 1054 bitmap_size.height(), | 1051 bitmap_size.height(), |
| 1055 FPDFBitmap_BGRx, | 1052 FPDFBitmap_BGRx, |
| 1056 image.data(), | 1053 image.data(), |
| 1057 image.stride()); | 1054 image.stride()); |
| 1058 | 1055 |
| 1059 // Clear the bitmap | 1056 // Clear the bitmap |
| 1060 FPDFBitmap_FillRect(bitmap, 0, 0, bitmap_size.width(), | 1057 FPDFBitmap_FillRect(bitmap, 0, 0, bitmap_size.width(), |
| 1061 bitmap_size.height(), 255, 255, 255, 255); | 1058 bitmap_size.height(), 0xFFFFFFFF); |
| 1062 | 1059 |
| 1063 pp::Rect page_rect = pages_to_print[i].rect(); | 1060 pp::Rect page_rect = pages_to_print[i].rect(); |
| 1064 FPDF_RenderPageBitmap(bitmap, pages_to_print[i].GetPrintPage(), | 1061 FPDF_RenderPageBitmap(bitmap, pages_to_print[i].GetPrintPage(), |
| 1065 page_rect.x(), page_rect.y(), | 1062 page_rect.x(), page_rect.y(), |
| 1066 page_rect.width(), page_rect.height(), | 1063 page_rect.width(), page_rect.height(), |
| 1067 print_settings.orientation, | 1064 print_settings.orientation, |
| 1068 FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH); | 1065 FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH); |
| 1069 | 1066 |
| 1070 double ratio_x = (static_cast<double>(bitmap_size.width()) * | 1067 double ratio_x = (static_cast<double>(bitmap_size.width()) * |
| 1071 kPointsPerInch) / print_settings.dpi; | 1068 kPointsPerInch) / print_settings.dpi; |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1924 pp::Rect PDFiumEngine::GetPageContentsRect(int index) { | 1921 pp::Rect PDFiumEngine::GetPageContentsRect(int index) { |
| 1925 return GetScreenRect(pages_[index]->rect()); | 1922 return GetScreenRect(pages_[index]->rect()); |
| 1926 } | 1923 } |
| 1927 | 1924 |
| 1928 void PDFiumEngine::PaintThumbnail(pp::ImageData* image_data, int index) { | 1925 void PDFiumEngine::PaintThumbnail(pp::ImageData* image_data, int index) { |
| 1929 FPDF_BITMAP bitmap = FPDFBitmap_CreateEx( | 1926 FPDF_BITMAP bitmap = FPDFBitmap_CreateEx( |
| 1930 image_data->size().width(), image_data->size().height(), | 1927 image_data->size().width(), image_data->size().height(), |
| 1931 FPDFBitmap_BGRx, image_data->data(), image_data->stride()); | 1928 FPDFBitmap_BGRx, image_data->data(), image_data->stride()); |
| 1932 | 1929 |
| 1933 if (pages_[index]->available()) { | 1930 if (pages_[index]->available()) { |
| 1934 FPDFBitmap_FillRect( | 1931 FPDFBitmap_FillRect(bitmap, 0, 0, image_data->size().width(), |
| 1935 bitmap, 0, 0, image_data->size().width(), image_data->size().height(), | 1932 image_data->size().height(), 0xFFFFFFFF); |
| 1936 255, 255, 255, 255); | |
| 1937 | 1933 |
| 1938 FPDF_RenderPageBitmap( | 1934 FPDF_RenderPageBitmap( |
| 1939 bitmap, pages_[index]->GetPage(), 0, 0, image_data->size().width(), | 1935 bitmap, pages_[index]->GetPage(), 0, 0, image_data->size().width(), |
| 1940 image_data->size().height(), 0, GetRenderingFlags()); | 1936 image_data->size().height(), 0, GetRenderingFlags()); |
| 1941 } else { | 1937 } else { |
| 1942 FPDFBitmap_FillRect( | 1938 FPDFBitmap_FillRect(bitmap, 0, 0, image_data->size().width(), |
| 1943 bitmap, 0, 0, image_data->size().width(), image_data->size().height(), | 1939 image_data->size().height(), kPendingPageColor); |
| 1944 kPendingPageColorR, kPendingPageColorG, kPendingPageColorB, | |
| 1945 kPendingPageColorA); | |
| 1946 } | 1940 } |
| 1947 | 1941 |
| 1948 FPDFBitmap_Destroy(bitmap); | 1942 FPDFBitmap_Destroy(bitmap); |
| 1949 } | 1943 } |
| 1950 | 1944 |
| 1951 void PDFiumEngine::SetGrayscale(bool grayscale) { | 1945 void PDFiumEngine::SetGrayscale(bool grayscale) { |
| 1952 render_grayscale_ = grayscale; | 1946 render_grayscale_ = grayscale; |
| 1953 } | 1947 } |
| 1954 | 1948 |
| 1955 void PDFiumEngine::OnCallback(int id) { | 1949 void PDFiumEngine::OnCallback(int id) { |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2339 if (progressive_paints_[progressive_index].bitmap) { | 2333 if (progressive_paints_[progressive_index].bitmap) { |
| 2340 rv = FPDF_RenderPage_Continue( | 2334 rv = FPDF_RenderPage_Continue( |
| 2341 pages_[page_index]->GetPage(), static_cast<IFSDK_PAUSE*>(this)); | 2335 pages_[page_index]->GetPage(), static_cast<IFSDK_PAUSE*>(this)); |
| 2342 } else { | 2336 } else { |
| 2343 pp::Rect dirty = progressive_paints_[progressive_index].rect; | 2337 pp::Rect dirty = progressive_paints_[progressive_index].rect; |
| 2344 progressive_paints_[progressive_index].bitmap = CreateBitmap(dirty, | 2338 progressive_paints_[progressive_index].bitmap = CreateBitmap(dirty, |
| 2345 image_data); | 2339 image_data); |
| 2346 int start_x, start_y, size_x, size_y; | 2340 int start_x, start_y, size_x, size_y; |
| 2347 GetPDFiumRect( | 2341 GetPDFiumRect( |
| 2348 page_index, dirty, &start_x, &start_y, &size_x, &size_y); | 2342 page_index, dirty, &start_x, &start_y, &size_x, &size_y); |
| 2349 FPDFBitmap_FillRect( | 2343 FPDFBitmap_FillRect(progressive_paints_[progressive_index].bitmap, start_x, |
| 2350 progressive_paints_[progressive_index].bitmap, start_x, start_y, size_x, | 2344 start_y, size_x, size_y, 0xFFFFFFFF); |
| 2351 size_y, 255, 255, 255, 255); | |
| 2352 rv = FPDF_RenderPageBitmap_Start( | 2345 rv = FPDF_RenderPageBitmap_Start( |
| 2353 progressive_paints_[progressive_index].bitmap, | 2346 progressive_paints_[progressive_index].bitmap, |
| 2354 pages_[page_index]->GetPage(), start_x, start_y, size_x, size_y, | 2347 pages_[page_index]->GetPage(), start_x, start_y, size_x, size_y, |
| 2355 current_rotation_, | 2348 current_rotation_, |
| 2356 GetRenderingFlags(), static_cast<IFSDK_PAUSE*>(this)); | 2349 GetRenderingFlags(), static_cast<IFSDK_PAUSE*>(this)); |
| 2357 } | 2350 } |
| 2358 return rv != FPDF_RENDER_TOBECOUNTINUED; | 2351 return rv != FPDF_RENDER_TOBECOUNTINUED; |
| 2359 } | 2352 } |
| 2360 | 2353 |
| 2361 void PDFiumEngine::FinishPaint(int progressive_index, | 2354 void PDFiumEngine::FinishPaint(int progressive_index, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2401 | 2394 |
| 2402 pp::Rect page_rect = pages_[page_index]->rect(); | 2395 pp::Rect page_rect = pages_[page_index]->rect(); |
| 2403 if (page_rect.x() > 0) { | 2396 if (page_rect.x() > 0) { |
| 2404 pp::Rect left(0, | 2397 pp::Rect left(0, |
| 2405 page_rect.y() - kPageShadowTop, | 2398 page_rect.y() - kPageShadowTop, |
| 2406 page_rect.x() - kPageShadowLeft, | 2399 page_rect.x() - kPageShadowLeft, |
| 2407 page_rect.height() + kPageShadowTop + | 2400 page_rect.height() + kPageShadowTop + |
| 2408 kPageShadowBottom + kPageSeparatorThickness); | 2401 kPageShadowBottom + kPageSeparatorThickness); |
| 2409 left = GetScreenRect(left).Intersect(dirty_in_screen); | 2402 left = GetScreenRect(left).Intersect(dirty_in_screen); |
| 2410 | 2403 |
| 2411 FPDFBitmap_FillRect( | 2404 FPDFBitmap_FillRect(bitmap, left.x() - dirty_in_screen.x(), |
| 2412 bitmap, left.x() - dirty_in_screen.x(), | 2405 left.y() - dirty_in_screen.y(), left.width(), |
| 2413 left.y() - dirty_in_screen.y(), left.width(), left.height(), | 2406 left.height(), kBackgroundColor); |
| 2414 kBackgroundColorR, kBackgroundColorG, kBackgroundColorB, | |
| 2415 kBackgroundColorA); | |
| 2416 } | 2407 } |
| 2417 | 2408 |
| 2418 if (page_rect.right() < document_size_.width()) { | 2409 if (page_rect.right() < document_size_.width()) { |
| 2419 pp::Rect right(page_rect.right() + kPageShadowRight, | 2410 pp::Rect right(page_rect.right() + kPageShadowRight, |
| 2420 page_rect.y() - kPageShadowTop, | 2411 page_rect.y() - kPageShadowTop, |
| 2421 document_size_.width() - page_rect.right() - | 2412 document_size_.width() - page_rect.right() - |
| 2422 kPageShadowRight, | 2413 kPageShadowRight, |
| 2423 page_rect.height() + kPageShadowTop + | 2414 page_rect.height() + kPageShadowTop + |
| 2424 kPageShadowBottom + kPageSeparatorThickness); | 2415 kPageShadowBottom + kPageSeparatorThickness); |
| 2425 right = GetScreenRect(right).Intersect(dirty_in_screen); | 2416 right = GetScreenRect(right).Intersect(dirty_in_screen); |
| 2426 | 2417 |
| 2427 FPDFBitmap_FillRect( | 2418 FPDFBitmap_FillRect(bitmap, right.x() - dirty_in_screen.x(), |
| 2428 bitmap, right.x() - dirty_in_screen.x(), | 2419 right.y() - dirty_in_screen.y(), right.width(), |
| 2429 right.y() - dirty_in_screen.y(), right.width(), right.height(), | 2420 right.height(), kBackgroundColor); |
| 2430 kBackgroundColorR, kBackgroundColorG, kBackgroundColorB, | |
| 2431 kBackgroundColorA); | |
| 2432 } | 2421 } |
| 2433 | 2422 |
| 2434 // Paint separator. | 2423 // Paint separator. |
| 2435 pp::Rect bottom(page_rect.x() - kPageShadowLeft, | 2424 pp::Rect bottom(page_rect.x() - kPageShadowLeft, |
| 2436 page_rect.bottom() + kPageShadowBottom, | 2425 page_rect.bottom() + kPageShadowBottom, |
| 2437 page_rect.width() + kPageShadowLeft + kPageShadowRight, | 2426 page_rect.width() + kPageShadowLeft + kPageShadowRight, |
| 2438 kPageSeparatorThickness); | 2427 kPageSeparatorThickness); |
| 2439 bottom = GetScreenRect(bottom).Intersect(dirty_in_screen); | 2428 bottom = GetScreenRect(bottom).Intersect(dirty_in_screen); |
| 2440 | 2429 |
| 2441 FPDFBitmap_FillRect( | 2430 FPDFBitmap_FillRect(bitmap, bottom.x() - dirty_in_screen.x(), |
| 2442 bitmap, bottom.x() - dirty_in_screen.x(), | 2431 bottom.y() - dirty_in_screen.y(), bottom.width(), |
| 2443 bottom.y() - dirty_in_screen.y(), bottom.width(), bottom.height(), | 2432 bottom.height(), kBackgroundColor); |
| 2444 kBackgroundColorR, kBackgroundColorG, kBackgroundColorB, | |
| 2445 kBackgroundColorA); | |
| 2446 } | 2433 } |
| 2447 | 2434 |
| 2448 void PDFiumEngine::PaintPageShadow(int progressive_index, | 2435 void PDFiumEngine::PaintPageShadow(int progressive_index, |
| 2449 pp::ImageData* image_data) { | 2436 pp::ImageData* image_data) { |
| 2450 int page_index = progressive_paints_[progressive_index].page_index; | 2437 int page_index = progressive_paints_[progressive_index].page_index; |
| 2451 pp::Rect dirty_in_screen = progressive_paints_[progressive_index].rect; | 2438 pp::Rect dirty_in_screen = progressive_paints_[progressive_index].rect; |
| 2452 pp::Rect page_rect = pages_[page_index]->rect(); | 2439 pp::Rect page_rect = pages_[page_index]->rect(); |
| 2453 pp::Rect shadow_rect(page_rect); | 2440 pp::Rect shadow_rect(page_rect); |
| 2454 shadow_rect.Inset(-kPageShadowLeft, -kPageShadowTop, | 2441 shadow_rect.Inset(-kPageShadowLeft, -kPageShadowTop, |
| 2455 -kPageShadowRight, -kPageShadowBottom); | 2442 -kPageShadowRight, -kPageShadowBottom); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2508 form_highlights_.clear(); | 2495 form_highlights_.clear(); |
| 2509 } | 2496 } |
| 2510 | 2497 |
| 2511 void PDFiumEngine::PaintUnavailablePage(int page_index, | 2498 void PDFiumEngine::PaintUnavailablePage(int page_index, |
| 2512 const pp::Rect& dirty, | 2499 const pp::Rect& dirty, |
| 2513 pp::ImageData* image_data) { | 2500 pp::ImageData* image_data) { |
| 2514 int start_x, start_y, size_x, size_y; | 2501 int start_x, start_y, size_x, size_y; |
| 2515 GetPDFiumRect(page_index, dirty, &start_x, &start_y, &size_x, &size_y); | 2502 GetPDFiumRect(page_index, dirty, &start_x, &start_y, &size_x, &size_y); |
| 2516 FPDF_BITMAP bitmap = CreateBitmap(dirty, image_data); | 2503 FPDF_BITMAP bitmap = CreateBitmap(dirty, image_data); |
| 2517 FPDFBitmap_FillRect(bitmap, start_x, start_y, size_x, size_y, | 2504 FPDFBitmap_FillRect(bitmap, start_x, start_y, size_x, size_y, |
| 2518 kPendingPageColorR, kPendingPageColorG, kPendingPageColorB, | 2505 kPendingPageColor); |
| 2519 kPendingPageColorA); | |
| 2520 | 2506 |
| 2521 pp::Rect loading_text_in_screen( | 2507 pp::Rect loading_text_in_screen( |
| 2522 pages_[page_index]->rect().width() / 2, | 2508 pages_[page_index]->rect().width() / 2, |
| 2523 pages_[page_index]->rect().y() + kLoadingTextVerticalOffset, 0, 0); | 2509 pages_[page_index]->rect().y() + kLoadingTextVerticalOffset, 0, 0); |
| 2524 loading_text_in_screen = GetScreenRect(loading_text_in_screen); | 2510 loading_text_in_screen = GetScreenRect(loading_text_in_screen); |
| 2525 FPDFBitmap_Destroy(bitmap); | 2511 FPDFBitmap_Destroy(bitmap); |
| 2526 } | 2512 } |
| 2527 | 2513 |
| 2528 int PDFiumEngine::GetProgressiveIndex(int page_index) const { | 2514 int PDFiumEngine::GetProgressiveIndex(int page_index) const { |
| 2529 for (size_t i = 0; i < progressive_paints_.size(); ++i) { | 2515 for (size_t i = 0; i < progressive_paints_.size(); ++i) { |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2810 page_rect.Offset(page_offset_); | 2796 page_rect.Offset(page_offset_); |
| 2811 | 2797 |
| 2812 pp::Rect shadow_rect(shadow_rc); | 2798 pp::Rect shadow_rect(shadow_rc); |
| 2813 shadow_rect.Offset(page_offset_); | 2799 shadow_rect.Offset(page_offset_); |
| 2814 | 2800 |
| 2815 pp::Rect clip_rect(clip_rc); | 2801 pp::Rect clip_rect(clip_rc); |
| 2816 clip_rect.Offset(page_offset_); | 2802 clip_rect.Offset(page_offset_); |
| 2817 | 2803 |
| 2818 // Page drop shadow parameters. | 2804 // Page drop shadow parameters. |
| 2819 const double factor = 0.5; | 2805 const double factor = 0.5; |
| 2820 const uint32 background = (kBackgroundColorA << 24) | | |
| 2821 (kBackgroundColorR << 16) | | |
| 2822 (kBackgroundColorG << 8) | | |
| 2823 kBackgroundColorB; | |
| 2824 uint32 depth = std::max( | 2806 uint32 depth = std::max( |
| 2825 std::max(page_rect.x() - shadow_rect.x(), | 2807 std::max(page_rect.x() - shadow_rect.x(), |
| 2826 page_rect.y() - shadow_rect.y()), | 2808 page_rect.y() - shadow_rect.y()), |
| 2827 std::max(shadow_rect.right() - page_rect.right(), | 2809 std::max(shadow_rect.right() - page_rect.right(), |
| 2828 shadow_rect.bottom() - page_rect.bottom())); | 2810 shadow_rect.bottom() - page_rect.bottom())); |
| 2829 depth = static_cast<uint32>(depth * 1.5) + 1; | 2811 depth = static_cast<uint32>(depth * 1.5) + 1; |
| 2830 | 2812 |
| 2831 // We need to check depth only to verify our copy of shadow matrix is correct. | 2813 // We need to check depth only to verify our copy of shadow matrix is correct. |
| 2832 if (!page_shadow_.get() || page_shadow_->depth() != depth) | 2814 if (!page_shadow_.get() || page_shadow_->depth() != depth) |
| 2833 page_shadow_.reset(new ShadowMatrix(depth, factor, background)); | 2815 page_shadow_.reset(new ShadowMatrix(depth, factor, kBackgroundColor)); |
| 2834 | 2816 |
| 2835 DCHECK(!image_data->is_null()); | 2817 DCHECK(!image_data->is_null()); |
| 2836 DrawShadow(image_data, shadow_rect, page_rect, clip_rect, *page_shadow_); | 2818 DrawShadow(image_data, shadow_rect, page_rect, clip_rect, *page_shadow_); |
| 2837 } | 2819 } |
| 2838 | 2820 |
| 2839 void PDFiumEngine::GetRegion(const pp::Point& location, | 2821 void PDFiumEngine::GetRegion(const pp::Point& location, |
| 2840 pp::ImageData* image_data, | 2822 pp::ImageData* image_data, |
| 2841 void** region, | 2823 void** region, |
| 2842 int* stride) const { | 2824 int* stride) const { |
| 2843 if (image_data->is_null()) { | 2825 if (image_data->is_null()) { |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3307 // because of the code to talk Postscript directly to the printer if | 3289 // because of the code to talk Postscript directly to the printer if |
| 3308 // the printer supports this. Need to discuss this with PDFium. For now, | 3290 // the printer supports this. Need to discuss this with PDFium. For now, |
| 3309 // render to a bitmap and then blit the bitmap to the DC if we have been | 3291 // render to a bitmap and then blit the bitmap to the DC if we have been |
| 3310 // supplied a printer DC. | 3292 // supplied a printer DC. |
| 3311 int device_type = GetDeviceCaps(dc, TECHNOLOGY); | 3293 int device_type = GetDeviceCaps(dc, TECHNOLOGY); |
| 3312 if (use_bitmap || | 3294 if (use_bitmap || |
| 3313 (device_type == DT_RASPRINTER) || (device_type == DT_PLOTTER)) { | 3295 (device_type == DT_RASPRINTER) || (device_type == DT_PLOTTER)) { |
| 3314 FPDF_BITMAP bitmap = FPDFBitmap_Create(dest.width(), dest.height(), | 3296 FPDF_BITMAP bitmap = FPDFBitmap_Create(dest.width(), dest.height(), |
| 3315 FPDFBitmap_BGRx); | 3297 FPDFBitmap_BGRx); |
| 3316 // Clear the bitmap | 3298 // Clear the bitmap |
| 3317 FPDFBitmap_FillRect(bitmap, 0, 0, dest.width(), dest.height(), 255, 255, | 3299 FPDFBitmap_FillRect(bitmap, 0, 0, dest.width(), dest.height(), 0xFFFFFFFF); |
| 3318 255, 255); | |
| 3319 FPDF_RenderPageBitmap( | 3300 FPDF_RenderPageBitmap( |
| 3320 bitmap, page, 0, 0, dest.width(), dest.height(), rotate, | 3301 bitmap, page, 0, 0, dest.width(), dest.height(), rotate, |
| 3321 FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH); | 3302 FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH); |
| 3322 int stride = FPDFBitmap_GetStride(bitmap); | 3303 int stride = FPDFBitmap_GetStride(bitmap); |
| 3323 BITMAPINFO bmi; | 3304 BITMAPINFO bmi; |
| 3324 memset(&bmi, 0, sizeof(bmi)); | 3305 memset(&bmi, 0, sizeof(bmi)); |
| 3325 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | 3306 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
| 3326 bmi.bmiHeader.biWidth = dest.width(); | 3307 bmi.bmiHeader.biWidth = dest.width(); |
| 3327 bmi.bmiHeader.biHeight = -dest.height(); // top-down image | 3308 bmi.bmiHeader.biHeight = -dest.height(); // top-down image |
| 3328 bmi.bmiHeader.biPlanes = 1; | 3309 bmi.bmiHeader.biPlanes = 1; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3361 | 3342 |
| 3362 pp::Rect dest; | 3343 pp::Rect dest; |
| 3363 int rotate = CalculatePosition(page, settings, &dest); | 3344 int rotate = CalculatePosition(page, settings, &dest); |
| 3364 | 3345 |
| 3365 FPDF_BITMAP bitmap = | 3346 FPDF_BITMAP bitmap = |
| 3366 FPDFBitmap_CreateEx(settings.bounds.width(), settings.bounds.height(), | 3347 FPDFBitmap_CreateEx(settings.bounds.width(), settings.bounds.height(), |
| 3367 FPDFBitmap_BGRA, bitmap_buffer, | 3348 FPDFBitmap_BGRA, bitmap_buffer, |
| 3368 settings.bounds.width() * 4); | 3349 settings.bounds.width() * 4); |
| 3369 // Clear the bitmap | 3350 // Clear the bitmap |
| 3370 FPDFBitmap_FillRect(bitmap, 0, 0, settings.bounds.width(), | 3351 FPDFBitmap_FillRect(bitmap, 0, 0, settings.bounds.width(), |
| 3371 settings.bounds.height(), 255, 255, 255, 255); | 3352 settings.bounds.height(), 0xFFFFFFFF); |
| 3372 // Shift top-left corner of bounds to (0, 0) if it's not there. | 3353 // Shift top-left corner of bounds to (0, 0) if it's not there. |
| 3373 dest.set_point(dest.point() - settings.bounds.point()); | 3354 dest.set_point(dest.point() - settings.bounds.point()); |
| 3374 FPDF_RenderPageBitmap( | 3355 FPDF_RenderPageBitmap( |
| 3375 bitmap, page, dest.x(), dest.y(), dest.width(), dest.height(), rotate, | 3356 bitmap, page, dest.x(), dest.y(), dest.width(), dest.height(), rotate, |
| 3376 FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH); | 3357 FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH); |
| 3377 FPDFBitmap_Destroy(bitmap); | 3358 FPDFBitmap_Destroy(bitmap); |
| 3378 FPDF_ClosePage(page); | 3359 FPDF_ClosePage(page); |
| 3379 FPDF_CloseDocument(doc); | 3360 FPDF_CloseDocument(doc); |
| 3380 return true; | 3361 return true; |
| 3381 } | 3362 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3400 if (page_width > *max_page_width) { | 3381 if (page_width > *max_page_width) { |
| 3401 *max_page_width = page_width; | 3382 *max_page_width = page_width; |
| 3402 } | 3383 } |
| 3403 } | 3384 } |
| 3404 } | 3385 } |
| 3405 FPDF_CloseDocument(doc); | 3386 FPDF_CloseDocument(doc); |
| 3406 return true; | 3387 return true; |
| 3407 } | 3388 } |
| 3408 | 3389 |
| 3409 } // namespace chrome_pdf | 3390 } // namespace chrome_pdf |
| OLD | NEW |