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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 dict.Get(pp::Var(kJSYOffset)).AsDouble()); | 421 dict.Get(pp::Var(kJSYOffset)).AsDouble()); |
422 | 422 |
423 if (pinch_phase == PINCH_START) { | 423 if (pinch_phase == PINCH_START) { |
424 starting_scroll_offset_ = scroll_offset; | 424 starting_scroll_offset_ = scroll_offset; |
425 initial_zoom_ratio_ = zoom_ratio; | 425 initial_zoom_ratio_ = zoom_ratio; |
426 last_bitmap_smaller_ = false; | 426 last_bitmap_smaller_ = false; |
427 needs_reraster_ = false; | 427 needs_reraster_ = false; |
428 return; | 428 return; |
429 } | 429 } |
430 | 430 |
431 if (pinch_phase == PINCH_UPDATE_ZOOM_IN) { | 431 // When zooming in, we set a layer transform to avoid unneeded rerasters. |
| 432 // Also, if we're zooming out and the last time we rerastered was when |
| 433 // we were even further zoomed out (i.e. we pinch zoomed in and are now |
| 434 // pinch zooming back out in the same gesture), we update the layer |
| 435 // transform instead of rerastering. |
| 436 if (pinch_phase == PINCH_UPDATE_ZOOM_IN || |
| 437 (pinch_phase == PINCH_UPDATE_ZOOM_OUT && zoom_ratio > 1.0)) { |
432 if (!(dict.Get(pp::Var(kJSPinchX)).is_number() && | 438 if (!(dict.Get(pp::Var(kJSPinchX)).is_number() && |
433 dict.Get(pp::Var(kJSPinchY)).is_number() && | 439 dict.Get(pp::Var(kJSPinchY)).is_number() && |
434 dict.Get(pp::Var(kJSPinchVectorX)).is_number() && | 440 dict.Get(pp::Var(kJSPinchVectorX)).is_number() && |
435 dict.Get(pp::Var(kJSPinchVectorY)).is_number())) { | 441 dict.Get(pp::Var(kJSPinchVectorY)).is_number())) { |
436 NOTREACHED(); | 442 NOTREACHED(); |
437 return; | 443 return; |
438 } | 444 } |
439 | 445 |
440 pp::Point pinch_center(dict.Get(pp::Var(kJSPinchX)).AsDouble(), | 446 pp::Point pinch_center(dict.Get(pp::Var(kJSPinchX)).AsDouble(), |
441 dict.Get(pp::Var(kJSPinchY)).AsDouble()); | 447 dict.Get(pp::Var(kJSPinchY)).AsDouble()); |
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 const pp::FloatPoint& scroll_offset) { | 1634 const pp::FloatPoint& scroll_offset) { |
1629 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1635 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
1630 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1636 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
1631 float min_y = -top_toolbar_height_; | 1637 float min_y = -top_toolbar_height_; |
1632 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1638 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
1633 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1639 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
1634 return pp::FloatPoint(x, y); | 1640 return pp::FloatPoint(x, y); |
1635 } | 1641 } |
1636 | 1642 |
1637 } // namespace chrome_pdf | 1643 } // namespace chrome_pdf |
OLD | NEW |