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/out_of_process_instance.h" | 5 #include "pdf/out_of_process_instance.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> // for min/max() | 10 #include <algorithm> // for min/max() |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 pp::Rect rect = pp::Rect(pp::Point(), image_data_.size()); | 695 pp::Rect rect = pp::Rect(pp::Point(), image_data_.size()); |
696 FillRect(rect, background_color_); | 696 FillRect(rect, background_color_); |
697 ready->push_back(PaintManager::ReadyRect(rect, image_data_, true)); | 697 ready->push_back(PaintManager::ReadyRect(rect, image_data_, true)); |
698 } | 698 } |
699 | 699 |
700 if (!received_viewport_message_) | 700 if (!received_viewport_message_) |
701 return; | 701 return; |
702 | 702 |
703 engine_->PrePaint(); | 703 engine_->PrePaint(); |
704 | 704 |
705 for (size_t i = 0; i < paint_rects.size(); i++) { | 705 for (const auto& paint_rect : paint_rects) { |
706 // Intersect with plugin area since there could be pending invalidates from | 706 // Intersect with plugin area since there could be pending invalidates from |
707 // when the plugin area was larger. | 707 // when the plugin area was larger. |
708 pp::Rect rect = | 708 pp::Rect rect = |
709 paint_rects[i].Intersect(pp::Rect(pp::Point(), plugin_size_)); | 709 paint_rect.Intersect(pp::Rect(pp::Point(), plugin_size_)); |
710 if (rect.IsEmpty()) | 710 if (rect.IsEmpty()) |
711 continue; | 711 continue; |
712 | 712 |
713 pp::Rect pdf_rect = available_area_.Intersect(rect); | 713 pp::Rect pdf_rect = available_area_.Intersect(rect); |
714 if (!pdf_rect.IsEmpty()) { | 714 if (!pdf_rect.IsEmpty()) { |
715 pdf_rect.Offset(available_area_.x() * -1, 0); | 715 pdf_rect.Offset(available_area_.x() * -1, 0); |
716 | 716 |
717 std::vector<pp::Rect> pdf_ready; | 717 std::vector<pp::Rect> pdf_ready; |
718 std::vector<pp::Rect> pdf_pending; | 718 std::vector<pp::Rect> pdf_pending; |
719 engine_->Paint(pdf_rect, &image_data_, &pdf_ready, &pdf_pending); | 719 engine_->Paint(pdf_rect, &image_data_, &pdf_ready, &pdf_pending); |
720 for (size_t j = 0; j < pdf_ready.size(); ++j) { | 720 for (auto& ready_rect : pdf_ready) { |
721 pdf_ready[j].Offset(available_area_.point()); | 721 ready_rect.Offset(available_area_.point()); |
722 ready->push_back( | 722 ready->push_back( |
723 PaintManager::ReadyRect(pdf_ready[j], image_data_, false)); | 723 PaintManager::ReadyRect(ready_rect, image_data_, false)); |
724 } | 724 } |
725 for (size_t j = 0; j < pdf_pending.size(); ++j) { | 725 for (auto& pending_rect : pdf_pending) { |
726 pdf_pending[j].Offset(available_area_.point()); | 726 pending_rect.Offset(available_area_.point()); |
727 pending->push_back(pdf_pending[j]); | 727 pending->push_back(pending_rect); |
728 } | 728 } |
729 } | 729 } |
730 | 730 |
731 // Ensure the region above the first page (if any) is filled; | 731 // Ensure the region above the first page (if any) is filled; |
732 int32_t first_page_ypos = engine_->GetNumberOfPages() == 0 ? | 732 int32_t first_page_ypos = engine_->GetNumberOfPages() == 0 ? |
733 0 : engine_->GetPageScreenRect(0).y(); | 733 0 : engine_->GetPageScreenRect(0).y(); |
734 if (rect.y() < first_page_ypos) { | 734 if (rect.y() < first_page_ypos) { |
735 pp::Rect region = rect.Intersect(pp::Rect( | 735 pp::Rect region = rect.Intersect(pp::Rect( |
736 pp::Point(), pp::Size(plugin_size_.width(), first_page_ypos))); | 736 pp::Point(), pp::Size(plugin_size_.width(), first_page_ypos))); |
737 ready->push_back(PaintManager::ReadyRect(region, image_data_, false)); | 737 ready->push_back(PaintManager::ReadyRect(region, image_data_, false)); |
738 FillRect(region, background_color_); | 738 FillRect(region, background_color_); |
739 } | 739 } |
740 | 740 |
741 for (size_t j = 0; j < background_parts_.size(); ++j) { | 741 for (const auto& background_part : background_parts_) { |
742 pp::Rect intersection = background_parts_[j].location.Intersect(rect); | 742 pp::Rect intersection = background_part.location.Intersect(rect); |
743 if (!intersection.IsEmpty()) { | 743 if (!intersection.IsEmpty()) { |
744 FillRect(intersection, background_parts_[j].color); | 744 FillRect(intersection, background_part.color); |
745 ready->push_back( | 745 ready->push_back( |
746 PaintManager::ReadyRect(intersection, image_data_, false)); | 746 PaintManager::ReadyRect(intersection, image_data_, false)); |
747 } | 747 } |
748 } | 748 } |
749 } | 749 } |
750 | 750 |
751 engine_->PostPaint(); | 751 engine_->PostPaint(); |
752 } | 752 } |
753 | 753 |
754 void OutOfProcessInstance::DidOpen(int32_t result) { | 754 void OutOfProcessInstance::DidOpen(int32_t result) { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 } | 915 } |
916 | 916 |
917 cursor_interface->SetCursor( | 917 cursor_interface->SetCursor( |
918 pp_instance(), cursor_, pp::ImageData().pp_resource(), nullptr); | 918 pp_instance(), cursor_, pp::ImageData().pp_resource(), nullptr); |
919 } | 919 } |
920 | 920 |
921 void OutOfProcessInstance::UpdateTickMarks( | 921 void OutOfProcessInstance::UpdateTickMarks( |
922 const std::vector<pp::Rect>& tickmarks) { | 922 const std::vector<pp::Rect>& tickmarks) { |
923 float inverse_scale = 1.0f / device_scale_; | 923 float inverse_scale = 1.0f / device_scale_; |
924 std::vector<pp::Rect> scaled_tickmarks = tickmarks; | 924 std::vector<pp::Rect> scaled_tickmarks = tickmarks; |
925 for (size_t i = 0; i < scaled_tickmarks.size(); i++) | 925 for (auto& tickmark : scaled_tickmarks) |
926 ScaleRect(inverse_scale, &scaled_tickmarks[i]); | 926 ScaleRect(inverse_scale, &tickmark); |
927 tickmarks_ = scaled_tickmarks; | 927 tickmarks_ = scaled_tickmarks; |
928 } | 928 } |
929 | 929 |
930 void OutOfProcessInstance::NotifyNumberOfFindResultsChanged(int total, | 930 void OutOfProcessInstance::NotifyNumberOfFindResultsChanged(int total, |
931 bool final_result) { | 931 bool final_result) { |
932 // We don't want to spam the renderer with too many updates to the number of | 932 // We don't want to spam the renderer with too many updates to the number of |
933 // find results. Don't send an update if we sent one too recently. If it's the | 933 // find results. Don't send an update if we sent one too recently. If it's the |
934 // final update, we always send it though. | 934 // final update, we always send it though. |
935 if (final_result) { | 935 if (final_result) { |
936 NumberOfFindResultsChanged(total, final_result); | 936 NumberOfFindResultsChanged(total, final_result); |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1436 const pp::FloatPoint& scroll_offset) { | 1436 const pp::FloatPoint& scroll_offset) { |
1437 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1437 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
1438 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1438 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
1439 float min_y = -top_toolbar_height_; | 1439 float min_y = -top_toolbar_height_; |
1440 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1440 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
1441 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1441 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
1442 return pp::FloatPoint(x, y); | 1442 return pp::FloatPoint(x, y); |
1443 } | 1443 } |
1444 | 1444 |
1445 } // namespace chrome_pdf | 1445 } // namespace chrome_pdf |
OLD | NEW |