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

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

Issue 372273005: Fixes for re-enabling more MSVC level 4 warnings: pdf/ edition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« pdf/pdf_engine.h ('K') | « pdf/pdf_engine.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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
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 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 false); 1042 false);
1046 1043
1047 FPDF_BITMAP bitmap = FPDFBitmap_CreateEx(bitmap_size.width(), 1044 FPDF_BITMAP bitmap = FPDFBitmap_CreateEx(bitmap_size.width(),
1048 bitmap_size.height(), 1045 bitmap_size.height(),
1049 FPDFBitmap_BGRx, 1046 FPDFBitmap_BGRx,
1050 image.data(), 1047 image.data(),
1051 image.stride()); 1048 image.stride());
1052 1049
1053 // Clear the bitmap 1050 // Clear the bitmap
1054 FPDFBitmap_FillRect(bitmap, 0, 0, bitmap_size.width(), 1051 FPDFBitmap_FillRect(bitmap, 0, 0, bitmap_size.width(),
1055 bitmap_size.height(), 255, 255, 255, 255); 1052 bitmap_size.height(), 0xFFFFFFFF);
1056 1053
1057 pp::Rect page_rect = pages_to_print[i].rect(); 1054 pp::Rect page_rect = pages_to_print[i].rect();
1058 FPDF_RenderPageBitmap(bitmap, pages_to_print[i].GetPrintPage(), 1055 FPDF_RenderPageBitmap(bitmap, pages_to_print[i].GetPrintPage(),
1059 page_rect.x(), page_rect.y(), 1056 page_rect.x(), page_rect.y(),
1060 page_rect.width(), page_rect.height(), 1057 page_rect.width(), page_rect.height(),
1061 print_settings.orientation, 1058 print_settings.orientation,
1062 FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH); 1059 FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH);
1063 1060
1064 double ratio_x = (static_cast<double>(bitmap_size.width()) * 1061 double ratio_x = (static_cast<double>(bitmap_size.width()) *
1065 kPointsPerInch) / print_settings.dpi; 1062 kPointsPerInch) / print_settings.dpi;
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 pp::Rect PDFiumEngine::GetPageContentsRect(int index) { 1915 pp::Rect PDFiumEngine::GetPageContentsRect(int index) {
1919 return GetScreenRect(pages_[index]->rect()); 1916 return GetScreenRect(pages_[index]->rect());
1920 } 1917 }
1921 1918
1922 void PDFiumEngine::PaintThumbnail(pp::ImageData* image_data, int index) { 1919 void PDFiumEngine::PaintThumbnail(pp::ImageData* image_data, int index) {
1923 FPDF_BITMAP bitmap = FPDFBitmap_CreateEx( 1920 FPDF_BITMAP bitmap = FPDFBitmap_CreateEx(
1924 image_data->size().width(), image_data->size().height(), 1921 image_data->size().width(), image_data->size().height(),
1925 FPDFBitmap_BGRx, image_data->data(), image_data->stride()); 1922 FPDFBitmap_BGRx, image_data->data(), image_data->stride());
1926 1923
1927 if (pages_[index]->available()) { 1924 if (pages_[index]->available()) {
1928 FPDFBitmap_FillRect( 1925 FPDFBitmap_FillRect(bitmap, 0, 0, image_data->size().width(),
1929 bitmap, 0, 0, image_data->size().width(), image_data->size().height(), 1926 image_data->size().height(), 0xFFFFFFFF);
1930 255, 255, 255, 255);
1931 1927
1932 FPDF_RenderPageBitmap( 1928 FPDF_RenderPageBitmap(
1933 bitmap, pages_[index]->GetPage(), 0, 0, image_data->size().width(), 1929 bitmap, pages_[index]->GetPage(), 0, 0, image_data->size().width(),
1934 image_data->size().height(), 0, GetRenderingFlags()); 1930 image_data->size().height(), 0, GetRenderingFlags());
1935 } else { 1931 } else {
1936 FPDFBitmap_FillRect( 1932 FPDFBitmap_FillRect(bitmap, 0, 0, image_data->size().width(),
1937 bitmap, 0, 0, image_data->size().width(), image_data->size().height(), 1933 image_data->size().height(), kPendingPageColor);
1938 kPendingPageColorR, kPendingPageColorG, kPendingPageColorB,
1939 kPendingPageColorA);
1940 } 1934 }
1941 1935
1942 FPDFBitmap_Destroy(bitmap); 1936 FPDFBitmap_Destroy(bitmap);
1943 } 1937 }
1944 1938
1945 void PDFiumEngine::SetGrayscale(bool grayscale) { 1939 void PDFiumEngine::SetGrayscale(bool grayscale) {
1946 render_grayscale_ = grayscale; 1940 render_grayscale_ = grayscale;
1947 } 1941 }
1948 1942
1949 void PDFiumEngine::OnCallback(int id) { 1943 void PDFiumEngine::OnCallback(int id) {
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
2333 if (progressive_paints_[progressive_index].bitmap) { 2327 if (progressive_paints_[progressive_index].bitmap) {
2334 rv = FPDF_RenderPage_Continue( 2328 rv = FPDF_RenderPage_Continue(
2335 pages_[page_index]->GetPage(), static_cast<IFSDK_PAUSE*>(this)); 2329 pages_[page_index]->GetPage(), static_cast<IFSDK_PAUSE*>(this));
2336 } else { 2330 } else {
2337 pp::Rect dirty = progressive_paints_[progressive_index].rect; 2331 pp::Rect dirty = progressive_paints_[progressive_index].rect;
2338 progressive_paints_[progressive_index].bitmap = CreateBitmap(dirty, 2332 progressive_paints_[progressive_index].bitmap = CreateBitmap(dirty,
2339 image_data); 2333 image_data);
2340 int start_x, start_y, size_x, size_y; 2334 int start_x, start_y, size_x, size_y;
2341 GetPDFiumRect( 2335 GetPDFiumRect(
2342 page_index, dirty, &start_x, &start_y, &size_x, &size_y); 2336 page_index, dirty, &start_x, &start_y, &size_x, &size_y);
2343 FPDFBitmap_FillRect( 2337 FPDFBitmap_FillRect(progressive_paints_[progressive_index].bitmap, start_x,
2344 progressive_paints_[progressive_index].bitmap, start_x, start_y, size_x, 2338 start_y, size_x, size_y, 0xFFFFFFFF);
2345 size_y, 255, 255, 255, 255);
2346 rv = FPDF_RenderPageBitmap_Start( 2339 rv = FPDF_RenderPageBitmap_Start(
2347 progressive_paints_[progressive_index].bitmap, 2340 progressive_paints_[progressive_index].bitmap,
2348 pages_[page_index]->GetPage(), start_x, start_y, size_x, size_y, 2341 pages_[page_index]->GetPage(), start_x, start_y, size_x, size_y,
2349 current_rotation_, 2342 current_rotation_,
2350 GetRenderingFlags(), static_cast<IFSDK_PAUSE*>(this)); 2343 GetRenderingFlags(), static_cast<IFSDK_PAUSE*>(this));
2351 } 2344 }
2352 return rv != FPDF_RENDER_TOBECOUNTINUED; 2345 return rv != FPDF_RENDER_TOBECOUNTINUED;
2353 } 2346 }
2354 2347
2355 void PDFiumEngine::FinishPaint(int progressive_index, 2348 void PDFiumEngine::FinishPaint(int progressive_index,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 2388
2396 pp::Rect page_rect = pages_[page_index]->rect(); 2389 pp::Rect page_rect = pages_[page_index]->rect();
2397 if (page_rect.x() > 0) { 2390 if (page_rect.x() > 0) {
2398 pp::Rect left(0, 2391 pp::Rect left(0,
2399 page_rect.y() - kPageShadowTop, 2392 page_rect.y() - kPageShadowTop,
2400 page_rect.x() - kPageShadowLeft, 2393 page_rect.x() - kPageShadowLeft,
2401 page_rect.height() + kPageShadowTop + 2394 page_rect.height() + kPageShadowTop +
2402 kPageShadowBottom + kPageSeparatorThickness); 2395 kPageShadowBottom + kPageSeparatorThickness);
2403 left = GetScreenRect(left).Intersect(dirty_in_screen); 2396 left = GetScreenRect(left).Intersect(dirty_in_screen);
2404 2397
2405 FPDFBitmap_FillRect( 2398 FPDFBitmap_FillRect(bitmap, left.x() - dirty_in_screen.x(),
2406 bitmap, left.x() - dirty_in_screen.x(), 2399 left.y() - dirty_in_screen.y(), left.width(),
2407 left.y() - dirty_in_screen.y(), left.width(), left.height(), 2400 left.height(), kBackgroundColor);
2408 kBackgroundColorR, kBackgroundColorG, kBackgroundColorB,
2409 kBackgroundColorA);
2410 } 2401 }
2411 2402
2412 if (page_rect.right() < document_size_.width()) { 2403 if (page_rect.right() < document_size_.width()) {
2413 pp::Rect right(page_rect.right() + kPageShadowRight, 2404 pp::Rect right(page_rect.right() + kPageShadowRight,
2414 page_rect.y() - kPageShadowTop, 2405 page_rect.y() - kPageShadowTop,
2415 document_size_.width() - page_rect.right() - 2406 document_size_.width() - page_rect.right() -
2416 kPageShadowRight, 2407 kPageShadowRight,
2417 page_rect.height() + kPageShadowTop + 2408 page_rect.height() + kPageShadowTop +
2418 kPageShadowBottom + kPageSeparatorThickness); 2409 kPageShadowBottom + kPageSeparatorThickness);
2419 right = GetScreenRect(right).Intersect(dirty_in_screen); 2410 right = GetScreenRect(right).Intersect(dirty_in_screen);
2420 2411
2421 FPDFBitmap_FillRect( 2412 FPDFBitmap_FillRect(bitmap, right.x() - dirty_in_screen.x(),
2422 bitmap, right.x() - dirty_in_screen.x(), 2413 right.y() - dirty_in_screen.y(), right.width(),
2423 right.y() - dirty_in_screen.y(), right.width(), right.height(), 2414 right.height(), kBackgroundColor);
2424 kBackgroundColorR, kBackgroundColorG, kBackgroundColorB,
2425 kBackgroundColorA);
2426 } 2415 }
2427 2416
2428 // Paint separator. 2417 // Paint separator.
2429 pp::Rect bottom(page_rect.x() - kPageShadowLeft, 2418 pp::Rect bottom(page_rect.x() - kPageShadowLeft,
2430 page_rect.bottom() + kPageShadowBottom, 2419 page_rect.bottom() + kPageShadowBottom,
2431 page_rect.width() + kPageShadowLeft + kPageShadowRight, 2420 page_rect.width() + kPageShadowLeft + kPageShadowRight,
2432 kPageSeparatorThickness); 2421 kPageSeparatorThickness);
2433 bottom = GetScreenRect(bottom).Intersect(dirty_in_screen); 2422 bottom = GetScreenRect(bottom).Intersect(dirty_in_screen);
2434 2423
2435 FPDFBitmap_FillRect( 2424 FPDFBitmap_FillRect(bitmap, bottom.x() - dirty_in_screen.x(),
2436 bitmap, bottom.x() - dirty_in_screen.x(), 2425 bottom.y() - dirty_in_screen.y(), bottom.width(),
2437 bottom.y() - dirty_in_screen.y(), bottom.width(), bottom.height(), 2426 bottom.height(), kBackgroundColor);
2438 kBackgroundColorR, kBackgroundColorG, kBackgroundColorB,
2439 kBackgroundColorA);
2440 } 2427 }
2441 2428
2442 void PDFiumEngine::PaintPageShadow(int progressive_index, 2429 void PDFiumEngine::PaintPageShadow(int progressive_index,
2443 pp::ImageData* image_data) { 2430 pp::ImageData* image_data) {
2444 int page_index = progressive_paints_[progressive_index].page_index; 2431 int page_index = progressive_paints_[progressive_index].page_index;
2445 pp::Rect dirty_in_screen = progressive_paints_[progressive_index].rect; 2432 pp::Rect dirty_in_screen = progressive_paints_[progressive_index].rect;
2446 pp::Rect page_rect = pages_[page_index]->rect(); 2433 pp::Rect page_rect = pages_[page_index]->rect();
2447 pp::Rect shadow_rect(page_rect); 2434 pp::Rect shadow_rect(page_rect);
2448 shadow_rect.Inset(-kPageShadowLeft, -kPageShadowTop, 2435 shadow_rect.Inset(-kPageShadowLeft, -kPageShadowTop,
2449 -kPageShadowRight, -kPageShadowBottom); 2436 -kPageShadowRight, -kPageShadowBottom);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2502 form_highlights_.clear(); 2489 form_highlights_.clear();
2503 } 2490 }
2504 2491
2505 void PDFiumEngine::PaintUnavailablePage(int page_index, 2492 void PDFiumEngine::PaintUnavailablePage(int page_index,
2506 const pp::Rect& dirty, 2493 const pp::Rect& dirty,
2507 pp::ImageData* image_data) { 2494 pp::ImageData* image_data) {
2508 int start_x, start_y, size_x, size_y; 2495 int start_x, start_y, size_x, size_y;
2509 GetPDFiumRect(page_index, dirty, &start_x, &start_y, &size_x, &size_y); 2496 GetPDFiumRect(page_index, dirty, &start_x, &start_y, &size_x, &size_y);
2510 FPDF_BITMAP bitmap = CreateBitmap(dirty, image_data); 2497 FPDF_BITMAP bitmap = CreateBitmap(dirty, image_data);
2511 FPDFBitmap_FillRect(bitmap, start_x, start_y, size_x, size_y, 2498 FPDFBitmap_FillRect(bitmap, start_x, start_y, size_x, size_y,
2512 kPendingPageColorR, kPendingPageColorG, kPendingPageColorB, 2499 kPendingPageColor);
2513 kPendingPageColorA);
2514 2500
2515 pp::Rect loading_text_in_screen( 2501 pp::Rect loading_text_in_screen(
2516 pages_[page_index]->rect().width() / 2, 2502 pages_[page_index]->rect().width() / 2,
2517 pages_[page_index]->rect().y() + kLoadingTextVerticalOffset, 0, 0); 2503 pages_[page_index]->rect().y() + kLoadingTextVerticalOffset, 0, 0);
2518 loading_text_in_screen = GetScreenRect(loading_text_in_screen); 2504 loading_text_in_screen = GetScreenRect(loading_text_in_screen);
2519 FPDFBitmap_Destroy(bitmap); 2505 FPDFBitmap_Destroy(bitmap);
2520 } 2506 }
2521 2507
2522 int PDFiumEngine::GetProgressiveIndex(int page_index) const { 2508 int PDFiumEngine::GetProgressiveIndex(int page_index) const {
2523 for (size_t i = 0; i < progressive_paints_.size(); ++i) { 2509 for (size_t i = 0; i < progressive_paints_.size(); ++i) {
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
2804 page_rect.Offset(page_offset_); 2790 page_rect.Offset(page_offset_);
2805 2791
2806 pp::Rect shadow_rect(shadow_rc); 2792 pp::Rect shadow_rect(shadow_rc);
2807 shadow_rect.Offset(page_offset_); 2793 shadow_rect.Offset(page_offset_);
2808 2794
2809 pp::Rect clip_rect(clip_rc); 2795 pp::Rect clip_rect(clip_rc);
2810 clip_rect.Offset(page_offset_); 2796 clip_rect.Offset(page_offset_);
2811 2797
2812 // Page drop shadow parameters. 2798 // Page drop shadow parameters.
2813 const double factor = 0.5; 2799 const double factor = 0.5;
2814 const uint32 background = (kBackgroundColorA << 24) |
2815 (kBackgroundColorR << 16) |
2816 (kBackgroundColorG << 8) |
2817 kBackgroundColorB;
2818 uint32 depth = std::max( 2800 uint32 depth = std::max(
2819 std::max(page_rect.x() - shadow_rect.x(), 2801 std::max(page_rect.x() - shadow_rect.x(),
2820 page_rect.y() - shadow_rect.y()), 2802 page_rect.y() - shadow_rect.y()),
2821 std::max(shadow_rect.right() - page_rect.right(), 2803 std::max(shadow_rect.right() - page_rect.right(),
2822 shadow_rect.bottom() - page_rect.bottom())); 2804 shadow_rect.bottom() - page_rect.bottom()));
2823 depth = static_cast<uint32>(depth * 1.5) + 1; 2805 depth = static_cast<uint32>(depth * 1.5) + 1;
2824 2806
2825 // We need to check depth only to verify our copy of shadow matrix is correct. 2807 // We need to check depth only to verify our copy of shadow matrix is correct.
2826 if (!page_shadow_.get() || page_shadow_->depth() != depth) 2808 if (!page_shadow_.get() || page_shadow_->depth() != depth)
2827 page_shadow_.reset(new ShadowMatrix(depth, factor, background)); 2809 page_shadow_.reset(new ShadowMatrix(depth, factor, kBackgroundColor));
2828 2810
2829 DCHECK(!image_data->is_null()); 2811 DCHECK(!image_data->is_null());
2830 DrawShadow(image_data, shadow_rect, page_rect, clip_rect, *page_shadow_); 2812 DrawShadow(image_data, shadow_rect, page_rect, clip_rect, *page_shadow_);
2831 } 2813 }
2832 2814
2833 void PDFiumEngine::GetRegion(const pp::Point& location, 2815 void PDFiumEngine::GetRegion(const pp::Point& location,
2834 pp::ImageData* image_data, 2816 pp::ImageData* image_data,
2835 void** region, 2817 void** region,
2836 int* stride) const { 2818 int* stride) const {
2837 if (image_data->is_null()) { 2819 if (image_data->is_null()) {
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
3301 // because of the code to talk Postscript directly to the printer if 3283 // because of the code to talk Postscript directly to the printer if
3302 // the printer supports this. Need to discuss this with PDFium. For now, 3284 // the printer supports this. Need to discuss this with PDFium. For now,
3303 // render to a bitmap and then blit the bitmap to the DC if we have been 3285 // render to a bitmap and then blit the bitmap to the DC if we have been
3304 // supplied a printer DC. 3286 // supplied a printer DC.
3305 int device_type = GetDeviceCaps(dc, TECHNOLOGY); 3287 int device_type = GetDeviceCaps(dc, TECHNOLOGY);
3306 if (use_bitmap || 3288 if (use_bitmap ||
3307 (device_type == DT_RASPRINTER) || (device_type == DT_PLOTTER)) { 3289 (device_type == DT_RASPRINTER) || (device_type == DT_PLOTTER)) {
3308 FPDF_BITMAP bitmap = FPDFBitmap_Create(dest.width(), dest.height(), 3290 FPDF_BITMAP bitmap = FPDFBitmap_Create(dest.width(), dest.height(),
3309 FPDFBitmap_BGRx); 3291 FPDFBitmap_BGRx);
3310 // Clear the bitmap 3292 // Clear the bitmap
3311 FPDFBitmap_FillRect(bitmap, 0, 0, dest.width(), dest.height(), 255, 255, 3293 FPDFBitmap_FillRect(bitmap, 0, 0, dest.width(), dest.height(), 0xFFFFFFFF);
3312 255, 255);
3313 FPDF_RenderPageBitmap( 3294 FPDF_RenderPageBitmap(
3314 bitmap, page, 0, 0, dest.width(), dest.height(), rotate, 3295 bitmap, page, 0, 0, dest.width(), dest.height(), rotate,
3315 FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH); 3296 FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH);
3316 int stride = FPDFBitmap_GetStride(bitmap); 3297 int stride = FPDFBitmap_GetStride(bitmap);
3317 BITMAPINFO bmi; 3298 BITMAPINFO bmi;
3318 memset(&bmi, 0, sizeof(bmi)); 3299 memset(&bmi, 0, sizeof(bmi));
3319 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 3300 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
3320 bmi.bmiHeader.biWidth = dest.width(); 3301 bmi.bmiHeader.biWidth = dest.width();
3321 bmi.bmiHeader.biHeight = -dest.height(); // top-down image 3302 bmi.bmiHeader.biHeight = -dest.height(); // top-down image
3322 bmi.bmiHeader.biPlanes = 1; 3303 bmi.bmiHeader.biPlanes = 1;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3355 3336
3356 pp::Rect dest; 3337 pp::Rect dest;
3357 int rotate = CalculatePosition(page, settings, &dest); 3338 int rotate = CalculatePosition(page, settings, &dest);
3358 3339
3359 FPDF_BITMAP bitmap = 3340 FPDF_BITMAP bitmap =
3360 FPDFBitmap_CreateEx(settings.bounds.width(), settings.bounds.height(), 3341 FPDFBitmap_CreateEx(settings.bounds.width(), settings.bounds.height(),
3361 FPDFBitmap_BGRA, bitmap_buffer, 3342 FPDFBitmap_BGRA, bitmap_buffer,
3362 settings.bounds.width() * 4); 3343 settings.bounds.width() * 4);
3363 // Clear the bitmap 3344 // Clear the bitmap
3364 FPDFBitmap_FillRect(bitmap, 0, 0, settings.bounds.width(), 3345 FPDFBitmap_FillRect(bitmap, 0, 0, settings.bounds.width(),
3365 settings.bounds.height(), 255, 255, 255, 255); 3346 settings.bounds.height(), 0xFFFFFFFF);
3366 // Shift top-left corner of bounds to (0, 0) if it's not there. 3347 // Shift top-left corner of bounds to (0, 0) if it's not there.
3367 dest.set_point(dest.point() - settings.bounds.point()); 3348 dest.set_point(dest.point() - settings.bounds.point());
3368 FPDF_RenderPageBitmap( 3349 FPDF_RenderPageBitmap(
3369 bitmap, page, dest.x(), dest.y(), dest.width(), dest.height(), rotate, 3350 bitmap, page, dest.x(), dest.y(), dest.width(), dest.height(), rotate,
3370 FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH); 3351 FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH);
3371 FPDFBitmap_Destroy(bitmap); 3352 FPDFBitmap_Destroy(bitmap);
3372 FPDF_ClosePage(page); 3353 FPDF_ClosePage(page);
3373 FPDF_CloseDocument(doc); 3354 FPDF_CloseDocument(doc);
3374 return true; 3355 return true;
3375 } 3356 }
(...skipping 18 matching lines...) Expand all
3394 if (page_width > *max_page_width) { 3375 if (page_width > *max_page_width) {
3395 *max_page_width = page_width; 3376 *max_page_width = page_width;
3396 } 3377 }
3397 } 3378 }
3398 } 3379 }
3399 FPDF_CloseDocument(doc); 3380 FPDF_CloseDocument(doc);
3400 return true; 3381 return true;
3401 } 3382 }
3402 3383
3403 } // namespace chrome_pdf 3384 } // namespace chrome_pdf
OLDNEW
« pdf/pdf_engine.h ('K') | « pdf/pdf_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698