diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-09 22:24:42 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-09 22:24:42 +0000 |
commit | 6487f72254a606f3b08b836398feef933830d71b (patch) | |
tree | 73a15d240b2f1adefef5f90f7e7d1ac85f49f261 | |
parent | 25063816c83ae8d9d2d31d706a1a9453032731ae (diff) | |
download | chromium_src-6487f72254a606f3b08b836398feef933830d71b.zip chromium_src-6487f72254a606f3b08b836398feef933830d71b.tar.gz chromium_src-6487f72254a606f3b08b836398feef933830d71b.tar.bz2 |
Fixes for re-enabling more MSVC level 4 warnings: pdf/ edition
This contains fixes for the following sorts of issues:
* Signedness mismatch
This relies on https://codereview.chromium.org/376003003 to make FPDF_FillRect()
take a 32-bit value for the color in order to make the changes here as simple
and clean as possible.
This also contains a few other cleanups to make code simpler or more consistent.
BUG=81439
TEST=none
Review URL: https://codereview.chromium.org/372273005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282146 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | DEPS | 2 | ||||
-rw-r--r-- | pdf/instance.cc | 24 | ||||
-rw-r--r-- | pdf/instance.h | 4 | ||||
-rw-r--r-- | pdf/out_of_process_instance.cc | 22 | ||||
-rw-r--r-- | pdf/out_of_process_instance.h | 4 | ||||
-rw-r--r-- | pdf/pdf_engine.h | 5 | ||||
-rw-r--r-- | pdf/pdfium/pdfium_engine.cc | 61 |
7 files changed, 44 insertions, 78 deletions
@@ -77,7 +77,7 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling PDFIum # and whatever else without interference from each other. - "pdfium_revision": "cb46ea1bca55b448a7a54db2086c6f736f05c35f", + "pdfium_revision": "532a6a7ece21ca4ea253a196bb5c61a1861d12a0", # Three lines of non-changing comments so that # the commit queue can handle CLs rolling openmax_dl # and whatever else without interference from each other. diff --git a/pdf/instance.cc b/pdf/instance.cc index b0b6680..9dee0f6 100644 --- a/pdf/instance.cc +++ b/pdf/instance.cc @@ -768,11 +768,7 @@ void Instance::OnPaint(const std::vector<pp::Rect>& paint_rects, if (first_paint_) { first_paint_ = false; pp::Rect rect = pp::Rect(pp::Point(), plugin_size_); - unsigned int color = kBackgroundColorA << 24 | - kBackgroundColorR << 16 | - kBackgroundColorG << 8 | - kBackgroundColorB; - FillRect(rect, color); + FillRect(rect, kBackgroundColor); ready->push_back(PaintManager::ReadyRect(rect, image_data_, true)); *pending = paint_rects; return; @@ -1024,12 +1020,10 @@ void Instance::CalculateBackgroundParts() { // Add the left, right, and bottom rectangles. Note: we assume only // horizontal centering. - BackgroundPart part; - part.color = kBackgroundColorA << 24 | - kBackgroundColorR << 16 | - kBackgroundColorG << 8 | - kBackgroundColorB; - part.location = pp::Rect(0, 0, left_width, bottom); + BackgroundPart part = { + pp::Rect(0, 0, left_width, bottom), + kBackgroundColor + }; if (!part.location.IsEmpty()) background_parts_.push_back(part); part.location = pp::Rect(right_start, 0, right_width, bottom); @@ -1066,17 +1060,17 @@ int Instance::GetDocumentPixelHeight() const { device_scale_)); } -void Instance::FillRect(const pp::Rect& rect, unsigned int color) { +void Instance::FillRect(const pp::Rect& rect, uint32 color) { DCHECK(!image_data_.is_null() || rect.IsEmpty()); - unsigned int* buffer_start = static_cast<unsigned int*>(image_data_.data()); + uint32* buffer_start = static_cast<uint32*>(image_data_.data()); int stride = image_data_.stride(); - unsigned int* ptr = buffer_start + rect.y() * stride / 4 + rect.x(); + uint32* ptr = buffer_start + rect.y() * stride / 4 + rect.x(); int height = rect.height(); int width = rect.width(); for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) *(ptr + x) = color; - ptr += stride /4; + ptr += stride / 4; } } diff --git a/pdf/instance.h b/pdf/instance.h index 07c1a19..c377b03 100644 --- a/pdf/instance.h +++ b/pdf/instance.h @@ -228,7 +228,7 @@ class Instance : public pp::InstancePrivate, int GetDocumentPixelHeight() const; // Draws a rectangle with the specified dimensions and color in our buffer. - void FillRect(const pp::Rect& rect, unsigned int color); + void FillRect(const pp::Rect& rect, uint32 color); std::vector<pp::ImageData> GetThumbnailResources(); std::vector<pp::ImageData> GetProgressBarResources(pp::ImageData* background); @@ -410,7 +410,7 @@ class Instance : public pp::InstancePrivate, struct BackgroundPart { pp::Rect location; - unsigned int color; + uint32 color; }; std::vector<BackgroundPart> background_parts_; diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc index a08f8b0..6f728b7 100644 --- a/pdf/out_of_process_instance.cc +++ b/pdf/out_of_process_instance.cc @@ -629,11 +629,7 @@ void OutOfProcessInstance::OnPaint( if (first_paint_) { first_paint_ = false; pp::Rect rect = pp::Rect(pp::Point(), image_data_.size()); - unsigned int color = kBackgroundColorA << 24 | - kBackgroundColorR << 16 | - kBackgroundColorG << 8 | - kBackgroundColorB; - FillRect(rect, color); + FillRect(rect, kBackgroundColor); ready->push_back(PaintManager::ReadyRect(rect, image_data_, true)); } @@ -724,12 +720,10 @@ void OutOfProcessInstance::CalculateBackgroundParts() { // Add the left, right, and bottom rectangles. Note: we assume only // horizontal centering. - BackgroundPart part; - part.color = kBackgroundColorA << 24 | - kBackgroundColorR << 16 | - kBackgroundColorG << 8 | - kBackgroundColorB; - part.location = pp::Rect(0, 0, left_width, bottom); + BackgroundPart part = { + pp::Rect(0, 0, left_width, bottom), + kBackgroundColor + }; if (!part.location.IsEmpty()) background_parts_.push_back(part); part.location = pp::Rect(right_start, 0, right_width, bottom); @@ -750,11 +744,11 @@ int OutOfProcessInstance::GetDocumentPixelHeight() const { ceil(document_size_.height() * zoom_ * device_scale_)); } -void OutOfProcessInstance::FillRect(const pp::Rect& rect, unsigned int color) { +void OutOfProcessInstance::FillRect(const pp::Rect& rect, uint32 color) { DCHECK(!image_data_.is_null() || rect.IsEmpty()); - unsigned int* buffer_start = static_cast<unsigned int*>(image_data_.data()); + uint32* buffer_start = static_cast<uint32*>(image_data_.data()); int stride = image_data_.stride(); - unsigned int* ptr = buffer_start + rect.y() * stride / 4 + rect.x(); + uint32* ptr = buffer_start + rect.y() * stride / 4 + rect.x(); int height = rect.height(); int width = rect.width(); for (int y = 0; y < height; ++y) { diff --git a/pdf/out_of_process_instance.h b/pdf/out_of_process_instance.h index f1f8862..c001435 100644 --- a/pdf/out_of_process_instance.h +++ b/pdf/out_of_process_instance.h @@ -159,7 +159,7 @@ class OutOfProcessInstance : public pp::Instance, int GetDocumentPixelHeight() const; // Draws a rectangle with the specified dimensions and color in our buffer. - void FillRect(const pp::Rect& rect, unsigned int color); + void FillRect(const pp::Rect& rect, uint32 color); void LoadUrl(const std::string& url); void LoadPreviewUrl(const std::string& url); @@ -240,7 +240,7 @@ class OutOfProcessInstance : public pp::Instance, struct BackgroundPart { pp::Rect location; - unsigned int color; + uint32 color; }; std::vector<BackgroundPart> background_parts_; diff --git a/pdf/pdf_engine.h b/pdf/pdf_engine.h index ee1cb1f..b8b6fda 100644 --- a/pdf/pdf_engine.h +++ b/pdf/pdf_engine.h @@ -29,10 +29,7 @@ namespace pp { class InputEvent; } -#define kBackgroundColorR 204 -#define kBackgroundColorG 204 -#define kBackgroundColorB 204 -#define kBackgroundColorA 255 +const uint32 kBackgroundColor = 0xFFCCCCCC; namespace chrome_pdf { diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc index c1203bb..84aa47a 100644 --- a/pdf/pdfium/pdfium_engine.cc +++ b/pdf/pdfium/pdfium_engine.cc @@ -55,10 +55,7 @@ namespace chrome_pdf { #define kHighlightColorG 193 #define kHighlightColorB 218 -#define kPendingPageColorR 238 -#define kPendingPageColorG 238 -#define kPendingPageColorB 238 -#define kPendingPageColorA 255 +const uint32 kPendingPageColor = 0xFFEEEEEE; #define kFormHighlightColor 0xFFE4DD #define kFormHighlightAlpha 100 @@ -1058,7 +1055,7 @@ pp::Buffer_Dev PDFiumEngine::PrintPagesAsRasterPDF( // Clear the bitmap FPDFBitmap_FillRect(bitmap, 0, 0, bitmap_size.width(), - bitmap_size.height(), 255, 255, 255, 255); + bitmap_size.height(), 0xFFFFFFFF); pp::Rect page_rect = pages_to_print[i].rect(); FPDF_RenderPageBitmap(bitmap, pages_to_print[i].GetPrintPage(), @@ -1931,18 +1928,15 @@ void PDFiumEngine::PaintThumbnail(pp::ImageData* image_data, int index) { FPDFBitmap_BGRx, image_data->data(), image_data->stride()); if (pages_[index]->available()) { - FPDFBitmap_FillRect( - bitmap, 0, 0, image_data->size().width(), image_data->size().height(), - 255, 255, 255, 255); + FPDFBitmap_FillRect(bitmap, 0, 0, image_data->size().width(), + image_data->size().height(), 0xFFFFFFFF); FPDF_RenderPageBitmap( bitmap, pages_[index]->GetPage(), 0, 0, image_data->size().width(), image_data->size().height(), 0, GetRenderingFlags()); } else { - FPDFBitmap_FillRect( - bitmap, 0, 0, image_data->size().width(), image_data->size().height(), - kPendingPageColorR, kPendingPageColorG, kPendingPageColorB, - kPendingPageColorA); + FPDFBitmap_FillRect(bitmap, 0, 0, image_data->size().width(), + image_data->size().height(), kPendingPageColor); } FPDFBitmap_Destroy(bitmap); @@ -2346,9 +2340,8 @@ bool PDFiumEngine::ContinuePaint(int progressive_index, int start_x, start_y, size_x, size_y; GetPDFiumRect( page_index, dirty, &start_x, &start_y, &size_x, &size_y); - FPDFBitmap_FillRect( - progressive_paints_[progressive_index].bitmap, start_x, start_y, size_x, - size_y, 255, 255, 255, 255); + FPDFBitmap_FillRect(progressive_paints_[progressive_index].bitmap, start_x, + start_y, size_x, size_y, 0xFFFFFFFF); rv = FPDF_RenderPageBitmap_Start( progressive_paints_[progressive_index].bitmap, pages_[page_index]->GetPage(), start_x, start_y, size_x, size_y, @@ -2408,11 +2401,9 @@ void PDFiumEngine::FillPageSides(int progressive_index) { kPageShadowBottom + kPageSeparatorThickness); left = GetScreenRect(left).Intersect(dirty_in_screen); - FPDFBitmap_FillRect( - bitmap, left.x() - dirty_in_screen.x(), - left.y() - dirty_in_screen.y(), left.width(), left.height(), - kBackgroundColorR, kBackgroundColorG, kBackgroundColorB, - kBackgroundColorA); + FPDFBitmap_FillRect(bitmap, left.x() - dirty_in_screen.x(), + left.y() - dirty_in_screen.y(), left.width(), + left.height(), kBackgroundColor); } if (page_rect.right() < document_size_.width()) { @@ -2424,11 +2415,9 @@ void PDFiumEngine::FillPageSides(int progressive_index) { kPageShadowBottom + kPageSeparatorThickness); right = GetScreenRect(right).Intersect(dirty_in_screen); - FPDFBitmap_FillRect( - bitmap, right.x() - dirty_in_screen.x(), - right.y() - dirty_in_screen.y(), right.width(), right.height(), - kBackgroundColorR, kBackgroundColorG, kBackgroundColorB, - kBackgroundColorA); + FPDFBitmap_FillRect(bitmap, right.x() - dirty_in_screen.x(), + right.y() - dirty_in_screen.y(), right.width(), + right.height(), kBackgroundColor); } // Paint separator. @@ -2438,11 +2427,9 @@ void PDFiumEngine::FillPageSides(int progressive_index) { kPageSeparatorThickness); bottom = GetScreenRect(bottom).Intersect(dirty_in_screen); - FPDFBitmap_FillRect( - bitmap, bottom.x() - dirty_in_screen.x(), - bottom.y() - dirty_in_screen.y(), bottom.width(), bottom.height(), - kBackgroundColorR, kBackgroundColorG, kBackgroundColorB, - kBackgroundColorA); + FPDFBitmap_FillRect(bitmap, bottom.x() - dirty_in_screen.x(), + bottom.y() - dirty_in_screen.y(), bottom.width(), + bottom.height(), kBackgroundColor); } void PDFiumEngine::PaintPageShadow(int progressive_index, @@ -2515,8 +2502,7 @@ void PDFiumEngine::PaintUnavailablePage(int page_index, GetPDFiumRect(page_index, dirty, &start_x, &start_y, &size_x, &size_y); FPDF_BITMAP bitmap = CreateBitmap(dirty, image_data); FPDFBitmap_FillRect(bitmap, start_x, start_y, size_x, size_y, - kPendingPageColorR, kPendingPageColorG, kPendingPageColorB, - kPendingPageColorA); + kPendingPageColor); pp::Rect loading_text_in_screen( pages_[page_index]->rect().width() / 2, @@ -2817,10 +2803,6 @@ void PDFiumEngine::DrawPageShadow(const pp::Rect& page_rc, // Page drop shadow parameters. const double factor = 0.5; - const uint32 background = (kBackgroundColorA << 24) | - (kBackgroundColorR << 16) | - (kBackgroundColorG << 8) | - kBackgroundColorB; uint32 depth = std::max( std::max(page_rect.x() - shadow_rect.x(), page_rect.y() - shadow_rect.y()), @@ -2830,7 +2812,7 @@ void PDFiumEngine::DrawPageShadow(const pp::Rect& page_rc, // We need to check depth only to verify our copy of shadow matrix is correct. if (!page_shadow_.get() || page_shadow_->depth() != depth) - page_shadow_.reset(new ShadowMatrix(depth, factor, background)); + page_shadow_.reset(new ShadowMatrix(depth, factor, kBackgroundColor)); DCHECK(!image_data->is_null()); DrawShadow(image_data, shadow_rect, page_rect, clip_rect, *page_shadow_); @@ -3314,8 +3296,7 @@ bool PDFiumEngineExports::RenderPDFPageToDC(const void* pdf_buffer, FPDF_BITMAP bitmap = FPDFBitmap_Create(dest.width(), dest.height(), FPDFBitmap_BGRx); // Clear the bitmap - FPDFBitmap_FillRect(bitmap, 0, 0, dest.width(), dest.height(), 255, 255, - 255, 255); + FPDFBitmap_FillRect(bitmap, 0, 0, dest.width(), dest.height(), 0xFFFFFFFF); FPDF_RenderPageBitmap( bitmap, page, 0, 0, dest.width(), dest.height(), rotate, FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH); @@ -3368,7 +3349,7 @@ bool PDFiumEngineExports::RenderPDFPageToBitmap( settings.bounds.width() * 4); // Clear the bitmap FPDFBitmap_FillRect(bitmap, 0, 0, settings.bounds.width(), - settings.bounds.height(), 255, 255, 255, 255); + settings.bounds.height(), 0xFFFFFFFF); // Shift top-left corner of bounds to (0, 0) if it's not there. dest.set_point(dest.point() - settings.bounds.point()); FPDF_RenderPageBitmap( |