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

Side by Side Diff: android_webview/browser/browser_view_renderer.cc

Issue 1417893006: sync compositor: pass simple gfx types by const ref (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "android_webview/browser/browser_view_renderer.h" 5 #include "android_webview/browser/browser_view_renderer.h"
6 6
7 #include "android_webview/browser/browser_view_renderer_client.h" 7 #include "android_webview/browser/browser_view_renderer_client.h"
8 #include "android_webview/browser/child_frame.h" 8 #include "android_webview/browser/child_frame.h"
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 dip_scale_ = dip_scale; 481 dip_scale_ = dip_scale;
482 CHECK_GT(dip_scale_, 0.f); 482 CHECK_GT(dip_scale_, 0.f);
483 } 483 }
484 484
485 gfx::Vector2d BrowserViewRenderer::max_scroll_offset() const { 485 gfx::Vector2d BrowserViewRenderer::max_scroll_offset() const {
486 DCHECK_GT(dip_scale_, 0.f); 486 DCHECK_GT(dip_scale_, 0.f);
487 return gfx::ToCeiledVector2d(gfx::ScaleVector2d( 487 return gfx::ToCeiledVector2d(gfx::ScaleVector2d(
488 max_scroll_offset_dip_, dip_scale_ * page_scale_factor_)); 488 max_scroll_offset_dip_, dip_scale_ * page_scale_factor_));
489 } 489 }
490 490
491 void BrowserViewRenderer::ScrollTo(gfx::Vector2d scroll_offset) { 491 void BrowserViewRenderer::ScrollTo(const gfx::Vector2d& scroll_offset) {
492 gfx::Vector2d max_offset = max_scroll_offset(); 492 gfx::Vector2d max_offset = max_scroll_offset();
493 gfx::Vector2dF scroll_offset_dip; 493 gfx::Vector2dF scroll_offset_dip;
494 // To preserve the invariant that scrolling to the maximum physical pixel 494 // To preserve the invariant that scrolling to the maximum physical pixel
495 // value also scrolls to the maximum dip pixel value we transform the physical 495 // value also scrolls to the maximum dip pixel value we transform the physical
496 // offset into the dip offset by using a proportion (instead of dividing by 496 // offset into the dip offset by using a proportion (instead of dividing by
497 // dip_scale * page_scale_factor). 497 // dip_scale * page_scale_factor).
498 if (max_offset.x()) { 498 if (max_offset.x()) {
499 scroll_offset_dip.set_x((scroll_offset.x() * max_scroll_offset_dip_.x()) / 499 scroll_offset_dip.set_x((scroll_offset.x() * max_scroll_offset_dip_.x()) /
500 max_offset.x()); 500 max_offset.x());
501 } 501 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 void BrowserViewRenderer::DidUpdateContent() { 535 void BrowserViewRenderer::DidUpdateContent() {
536 TRACE_EVENT_INSTANT0("android_webview", 536 TRACE_EVENT_INSTANT0("android_webview",
537 "BrowserViewRenderer::DidUpdateContent", 537 "BrowserViewRenderer::DidUpdateContent",
538 TRACE_EVENT_SCOPE_THREAD); 538 TRACE_EVENT_SCOPE_THREAD);
539 clear_view_ = false; 539 clear_view_ = false;
540 if (on_new_picture_enable_) 540 if (on_new_picture_enable_)
541 client_->OnNewPicture(); 541 client_->OnNewPicture();
542 } 542 }
543 543
544 void BrowserViewRenderer::SetTotalRootLayerScrollOffset( 544 void BrowserViewRenderer::SetTotalRootLayerScrollOffset(
545 gfx::Vector2dF scroll_offset_dip) { 545 const gfx::Vector2dF& scroll_offset_dip) {
546 if (scroll_offset_dip_ == scroll_offset_dip) 546 if (scroll_offset_dip_ == scroll_offset_dip)
547 return; 547 return;
548 scroll_offset_dip_ = scroll_offset_dip; 548 scroll_offset_dip_ = scroll_offset_dip;
549 549
550 gfx::Vector2d max_offset = max_scroll_offset(); 550 gfx::Vector2d max_offset = max_scroll_offset();
551 gfx::Vector2d scroll_offset; 551 gfx::Vector2d scroll_offset;
552 // For an explanation as to why this is done this way see the comment in 552 // For an explanation as to why this is done this way see the comment in
553 // BrowserViewRenderer::ScrollTo. 553 // BrowserViewRenderer::ScrollTo.
554 if (max_scroll_offset_dip_.x()) { 554 if (max_scroll_offset_dip_.x()) {
555 scroll_offset.set_x((scroll_offset_dip.x() * max_offset.x()) / 555 scroll_offset.set_x((scroll_offset_dip.x() * max_offset.x()) /
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 state->SetDouble("max_scroll_offset_dip.x", max_scroll_offset_dip_.x()); 620 state->SetDouble("max_scroll_offset_dip.x", max_scroll_offset_dip_.x());
621 state->SetDouble("max_scroll_offset_dip.y", max_scroll_offset_dip_.y()); 621 state->SetDouble("max_scroll_offset_dip.y", max_scroll_offset_dip_.y());
622 622
623 state->SetDouble("scrollable_size_dip.width", scrollable_size_dip.width()); 623 state->SetDouble("scrollable_size_dip.width", scrollable_size_dip.width());
624 state->SetDouble("scrollable_size_dip.height", scrollable_size_dip.height()); 624 state->SetDouble("scrollable_size_dip.height", scrollable_size_dip.height());
625 625
626 state->SetDouble("page_scale_factor", page_scale_factor_); 626 state->SetDouble("page_scale_factor", page_scale_factor_);
627 return state; 627 return state;
628 } 628 }
629 629
630 void BrowserViewRenderer::DidOverscroll(gfx::Vector2dF accumulated_overscroll, 630 void BrowserViewRenderer::DidOverscroll(
631 gfx::Vector2dF latest_overscroll_delta, 631 const gfx::Vector2dF& accumulated_overscroll,
632 gfx::Vector2dF current_fling_velocity) { 632 const gfx::Vector2dF& latest_overscroll_delta,
633 const gfx::Vector2dF& current_fling_velocity) {
633 const float physical_pixel_scale = dip_scale_ * page_scale_factor_; 634 const float physical_pixel_scale = dip_scale_ * page_scale_factor_;
634 if (accumulated_overscroll == latest_overscroll_delta) 635 if (accumulated_overscroll == latest_overscroll_delta)
635 overscroll_rounding_error_ = gfx::Vector2dF(); 636 overscroll_rounding_error_ = gfx::Vector2dF();
636 gfx::Vector2dF scaled_overscroll_delta = 637 gfx::Vector2dF scaled_overscroll_delta =
637 gfx::ScaleVector2d(latest_overscroll_delta, physical_pixel_scale); 638 gfx::ScaleVector2d(latest_overscroll_delta, physical_pixel_scale);
638 gfx::Vector2d rounded_overscroll_delta = gfx::ToRoundedVector2d( 639 gfx::Vector2d rounded_overscroll_delta = gfx::ToRoundedVector2d(
639 scaled_overscroll_delta + overscroll_rounding_error_); 640 scaled_overscroll_delta + overscroll_rounding_error_);
640 overscroll_rounding_error_ = 641 overscroll_rounding_error_ =
641 scaled_overscroll_delta - rounded_overscroll_delta; 642 scaled_overscroll_delta - rounded_overscroll_delta;
642 gfx::Vector2dF fling_velocity_pixels = 643 gfx::Vector2dF fling_velocity_pixels =
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 base::StringAppendF(&str, 756 base::StringAppendF(&str,
756 "overscroll_rounding_error_: %s ", 757 "overscroll_rounding_error_: %s ",
757 overscroll_rounding_error_.ToString().c_str()); 758 overscroll_rounding_error_.ToString().c_str());
758 base::StringAppendF( 759 base::StringAppendF(
759 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); 760 &str, "on_new_picture_enable: %d ", on_new_picture_enable_);
760 base::StringAppendF(&str, "clear_view: %d ", clear_view_); 761 base::StringAppendF(&str, "clear_view: %d ", clear_view_);
761 return str; 762 return str;
762 } 763 }
763 764
764 } // namespace android_webview 765 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/browser_view_renderer.h ('k') | android_webview/browser/browser_view_renderer_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698