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

Side by Side Diff: pdf/out_of_process_instance.cc

Issue 1533413002: Switch to standard integer types in pdf/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 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
« no previous file with comments | « pdf/out_of_process_instance.h ('k') | pdf/paint_aggregator.cc » ('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 <stddef.h>
8 #include <stdint.h>
9
7 #include <algorithm> // for min/max() 10 #include <algorithm> // for min/max()
8 #define _USE_MATH_DEFINES // for M_PI 11 #define _USE_MATH_DEFINES // for M_PI
9 #include <cmath> // for log() and pow() 12 #include <cmath> // for log() and pow()
10 #include <math.h> 13 #include <math.h>
11 #include <list> 14 #include <list>
12 15
13 #include "base/json/json_reader.h" 16 #include "base/json/json_reader.h"
14 #include "base/json/json_writer.h" 17 #include "base/json/json_writer.h"
15 #include "base/logging.h" 18 #include "base/logging.h"
16 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 812
810 int OutOfProcessInstance::GetDocumentPixelWidth() const { 813 int OutOfProcessInstance::GetDocumentPixelWidth() const {
811 return static_cast<int>(ceil(document_size_.width() * zoom_ * device_scale_)); 814 return static_cast<int>(ceil(document_size_.width() * zoom_ * device_scale_));
812 } 815 }
813 816
814 int OutOfProcessInstance::GetDocumentPixelHeight() const { 817 int OutOfProcessInstance::GetDocumentPixelHeight() const {
815 return static_cast<int>( 818 return static_cast<int>(
816 ceil(document_size_.height() * zoom_ * device_scale_)); 819 ceil(document_size_.height() * zoom_ * device_scale_));
817 } 820 }
818 821
819 void OutOfProcessInstance::FillRect(const pp::Rect& rect, uint32 color) { 822 void OutOfProcessInstance::FillRect(const pp::Rect& rect, uint32_t color) {
820 DCHECK(!image_data_.is_null() || rect.IsEmpty()); 823 DCHECK(!image_data_.is_null() || rect.IsEmpty());
821 uint32* buffer_start = static_cast<uint32*>(image_data_.data()); 824 uint32_t* buffer_start = static_cast<uint32_t*>(image_data_.data());
822 int stride = image_data_.stride(); 825 int stride = image_data_.stride();
823 uint32* ptr = buffer_start + rect.y() * stride / 4 + rect.x(); 826 uint32_t* ptr = buffer_start + rect.y() * stride / 4 + rect.x();
824 int height = rect.height(); 827 int height = rect.height();
825 int width = rect.width(); 828 int width = rect.width();
826 for (int y = 0; y < height; ++y) { 829 for (int y = 0; y < height; ++y) {
827 for (int x = 0; x < width; ++x) 830 for (int x = 0; x < width; ++x)
828 *(ptr + x) = color; 831 *(ptr + x) = color;
829 ptr += stride /4; 832 ptr += stride /4;
830 } 833 }
831 } 834 }
832 835
833 void OutOfProcessInstance::DocumentSizeUpdated(const pp::Size& size) { 836 void OutOfProcessInstance::DocumentSizeUpdated(const pp::Size& size) {
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 if (!full_) 1248 if (!full_)
1246 return; 1249 return;
1247 1250
1248 if (told_browser_about_unsupported_feature_) 1251 if (told_browser_about_unsupported_feature_)
1249 return; 1252 return;
1250 told_browser_about_unsupported_feature_ = true; 1253 told_browser_about_unsupported_feature_ = true;
1251 1254
1252 pp::PDF::HasUnsupportedFeature(this); 1255 pp::PDF::HasUnsupportedFeature(this);
1253 } 1256 }
1254 1257
1255 void OutOfProcessInstance::DocumentLoadProgress(uint32 available, 1258 void OutOfProcessInstance::DocumentLoadProgress(uint32_t available,
1256 uint32 doc_size) { 1259 uint32_t doc_size) {
1257 double progress = 0.0; 1260 double progress = 0.0;
1258 if (doc_size == 0) { 1261 if (doc_size == 0) {
1259 // Document size is unknown. Use heuristics. 1262 // Document size is unknown. Use heuristics.
1260 // We'll make progress logarithmic from 0 to 100M. 1263 // We'll make progress logarithmic from 0 to 100M.
1261 static const double kFactor = log(100000000.0) / 100.0; 1264 static const double kFactor = log(100000000.0) / 100.0;
1262 if (available > 0) { 1265 if (available > 0) {
1263 progress = log(static_cast<double>(available)) / kFactor; 1266 progress = log(static_cast<double>(available)) / kFactor;
1264 if (progress > 100.0) 1267 if (progress > 100.0)
1265 progress = 100.0; 1268 progress = 100.0;
1266 } 1269 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 return; 1376 return;
1374 engine_->AppendBlankPages(print_preview_page_count_); 1377 engine_->AppendBlankPages(print_preview_page_count_);
1375 if (!preview_pages_info_.empty()) 1378 if (!preview_pages_info_.empty())
1376 LoadAvailablePreviewPage(); 1379 LoadAvailablePreviewPage();
1377 } 1380 }
1378 1381
1379 bool OutOfProcessInstance::IsPrintPreview() { 1382 bool OutOfProcessInstance::IsPrintPreview() {
1380 return IsPrintPreviewUrl(url_); 1383 return IsPrintPreviewUrl(url_);
1381 } 1384 }
1382 1385
1383 uint32 OutOfProcessInstance::GetBackgroundColor() { 1386 uint32_t OutOfProcessInstance::GetBackgroundColor() {
1384 return background_color_; 1387 return background_color_;
1385 } 1388 }
1386 1389
1387 void OutOfProcessInstance::IsSelectingChanged(bool is_selecting) { 1390 void OutOfProcessInstance::IsSelectingChanged(bool is_selecting) {
1388 pp::VarDictionary message; 1391 pp::VarDictionary message;
1389 message.Set(kType, kJSSetIsSelectingType); 1392 message.Set(kType, kJSSetIsSelectingType);
1390 message.Set(kJSIsSelecting, pp::Var(is_selecting)); 1393 message.Set(kJSIsSelecting, pp::Var(is_selecting));
1391 PostMessage(message); 1394 PostMessage(message);
1392 } 1395 }
1393 1396
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 const pp::FloatPoint& scroll_offset) { 1436 const pp::FloatPoint& scroll_offset) {
1434 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); 1437 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width();
1435 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);
1436 float min_y = -top_toolbar_height_; 1439 float min_y = -top_toolbar_height_;
1437 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); 1440 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height();
1438 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);
1439 return pp::FloatPoint(x, y); 1442 return pp::FloatPoint(x, y);
1440 } 1443 }
1441 1444
1442 } // namespace chrome_pdf 1445 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « pdf/out_of_process_instance.h ('k') | pdf/paint_aggregator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698