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

Side by Side Diff: pdf/out_of_process_instance.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: Update pdfium 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
« no previous file with comments | « pdf/out_of_process_instance.h ('k') | pdf/pdf_engine.h » ('j') | 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/out_of_process_instance.h" 5 #include "pdf/out_of_process_instance.h"
6 6
7 #include <algorithm> // for min/max() 7 #include <algorithm> // for min/max()
8 #define _USE_MATH_DEFINES // for M_PI 8 #define _USE_MATH_DEFINES // for M_PI
9 #include <cmath> // for log() and pow() 9 #include <cmath> // for log() and pow()
10 #include <math.h> 10 #include <math.h>
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 const std::vector<pp::Rect>& paint_rects, 622 const std::vector<pp::Rect>& paint_rects,
623 std::vector<PaintManager::ReadyRect>* ready, 623 std::vector<PaintManager::ReadyRect>* ready,
624 std::vector<pp::Rect>* pending) { 624 std::vector<pp::Rect>* pending) {
625 if (image_data_.is_null()) { 625 if (image_data_.is_null()) {
626 DCHECK(plugin_size_.IsEmpty()); 626 DCHECK(plugin_size_.IsEmpty());
627 return; 627 return;
628 } 628 }
629 if (first_paint_) { 629 if (first_paint_) {
630 first_paint_ = false; 630 first_paint_ = false;
631 pp::Rect rect = pp::Rect(pp::Point(), image_data_.size()); 631 pp::Rect rect = pp::Rect(pp::Point(), image_data_.size());
632 unsigned int color = kBackgroundColorA << 24 | 632 FillRect(rect, kBackgroundColor);
633 kBackgroundColorR << 16 |
634 kBackgroundColorG << 8 |
635 kBackgroundColorB;
636 FillRect(rect, color);
637 ready->push_back(PaintManager::ReadyRect(rect, image_data_, true)); 633 ready->push_back(PaintManager::ReadyRect(rect, image_data_, true));
638 } 634 }
639 635
640 if (!received_viewport_message_) 636 if (!received_viewport_message_)
641 return; 637 return;
642 638
643 engine_->PrePaint(); 639 engine_->PrePaint();
644 640
645 for (size_t i = 0; i < paint_rects.size(); i++) { 641 for (size_t i = 0; i < paint_rects.size(); i++) {
646 // Intersect with plugin area since there could be pending invalidates from 642 // Intersect with plugin area since there could be pending invalidates from
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 713
718 void OutOfProcessInstance::CalculateBackgroundParts() { 714 void OutOfProcessInstance::CalculateBackgroundParts() {
719 background_parts_.clear(); 715 background_parts_.clear();
720 int left_width = available_area_.x(); 716 int left_width = available_area_.x();
721 int right_start = available_area_.right(); 717 int right_start = available_area_.right();
722 int right_width = abs(plugin_size_.width() - available_area_.right()); 718 int right_width = abs(plugin_size_.width() - available_area_.right());
723 int bottom = std::min(available_area_.bottom(), plugin_size_.height()); 719 int bottom = std::min(available_area_.bottom(), plugin_size_.height());
724 720
725 // Add the left, right, and bottom rectangles. Note: we assume only 721 // Add the left, right, and bottom rectangles. Note: we assume only
726 // horizontal centering. 722 // horizontal centering.
727 BackgroundPart part; 723 BackgroundPart part = {
728 part.color = kBackgroundColorA << 24 | 724 pp::Rect(0, 0, left_width, bottom),
729 kBackgroundColorR << 16 | 725 kBackgroundColor
730 kBackgroundColorG << 8 | 726 };
731 kBackgroundColorB;
732 part.location = pp::Rect(0, 0, left_width, bottom);
733 if (!part.location.IsEmpty()) 727 if (!part.location.IsEmpty())
734 background_parts_.push_back(part); 728 background_parts_.push_back(part);
735 part.location = pp::Rect(right_start, 0, right_width, bottom); 729 part.location = pp::Rect(right_start, 0, right_width, bottom);
736 if (!part.location.IsEmpty()) 730 if (!part.location.IsEmpty())
737 background_parts_.push_back(part); 731 background_parts_.push_back(part);
738 part.location = pp::Rect( 732 part.location = pp::Rect(
739 0, bottom, plugin_size_.width(), plugin_size_.height() - bottom); 733 0, bottom, plugin_size_.width(), plugin_size_.height() - bottom);
740 if (!part.location.IsEmpty()) 734 if (!part.location.IsEmpty())
741 background_parts_.push_back(part); 735 background_parts_.push_back(part);
742 } 736 }
743 737
744 int OutOfProcessInstance::GetDocumentPixelWidth() const { 738 int OutOfProcessInstance::GetDocumentPixelWidth() const {
745 return static_cast<int>(ceil(document_size_.width() * zoom_ * device_scale_)); 739 return static_cast<int>(ceil(document_size_.width() * zoom_ * device_scale_));
746 } 740 }
747 741
748 int OutOfProcessInstance::GetDocumentPixelHeight() const { 742 int OutOfProcessInstance::GetDocumentPixelHeight() const {
749 return static_cast<int>( 743 return static_cast<int>(
750 ceil(document_size_.height() * zoom_ * device_scale_)); 744 ceil(document_size_.height() * zoom_ * device_scale_));
751 } 745 }
752 746
753 void OutOfProcessInstance::FillRect(const pp::Rect& rect, unsigned int color) { 747 void OutOfProcessInstance::FillRect(const pp::Rect& rect, uint32 color) {
754 DCHECK(!image_data_.is_null() || rect.IsEmpty()); 748 DCHECK(!image_data_.is_null() || rect.IsEmpty());
755 unsigned int* buffer_start = static_cast<unsigned int*>(image_data_.data()); 749 uint32* buffer_start = static_cast<uint32*>(image_data_.data());
756 int stride = image_data_.stride(); 750 int stride = image_data_.stride();
757 unsigned int* ptr = buffer_start + rect.y() * stride / 4 + rect.x(); 751 uint32* ptr = buffer_start + rect.y() * stride / 4 + rect.x();
758 int height = rect.height(); 752 int height = rect.height();
759 int width = rect.width(); 753 int width = rect.width();
760 for (int y = 0; y < height; ++y) { 754 for (int y = 0; y < height; ++y) {
761 for (int x = 0; x < width; ++x) 755 for (int x = 0; x < width; ++x)
762 *(ptr + x) = color; 756 *(ptr + x) = color;
763 ptr += stride /4; 757 ptr += stride /4;
764 } 758 }
765 } 759 }
766 760
767 void OutOfProcessInstance::DocumentSizeUpdated(const pp::Size& size) { 761 void OutOfProcessInstance::DocumentSizeUpdated(const pp::Size& size) {
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 pp::Point OutOfProcessInstance::BoundScrollOffsetToDocument( 1411 pp::Point OutOfProcessInstance::BoundScrollOffsetToDocument(
1418 const pp::Point& scroll_offset) { 1412 const pp::Point& scroll_offset) {
1419 int max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); 1413 int max_x = document_size_.width() * zoom_ - plugin_dip_size_.width();
1420 int x = std::max(std::min(scroll_offset.x(), max_x), 0); 1414 int x = std::max(std::min(scroll_offset.x(), max_x), 0);
1421 int max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); 1415 int max_y = document_size_.height() * zoom_ - plugin_dip_size_.height();
1422 int y = std::max(std::min(scroll_offset.y(), max_y), 0); 1416 int y = std::max(std::min(scroll_offset.y(), max_y), 0);
1423 return pp::Point(x, y); 1417 return pp::Point(x, y);
1424 } 1418 }
1425 1419
1426 } // namespace chrome_pdf 1420 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « pdf/out_of_process_instance.h ('k') | pdf/pdf_engine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698