| OLD | NEW |
| 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/shared_renderer_state.h" | 8 #include "android_webview/browser/shared_renderer_state.h" |
| 9 #include "android_webview/public/browser/draw_gl.h" | 9 #include "android_webview/public/browser/draw_gl.h" |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 TRACE_EVENT_SCOPE_THREAD, | 482 TRACE_EVENT_SCOPE_THREAD, |
| 483 "invalidate", | 483 "invalidate", |
| 484 invalidate); | 484 invalidate); |
| 485 compositor_needs_continuous_invalidate_ = invalidate; | 485 compositor_needs_continuous_invalidate_ = invalidate; |
| 486 | 486 |
| 487 EnsureContinuousInvalidation(false); | 487 EnsureContinuousInvalidation(false); |
| 488 } | 488 } |
| 489 | 489 |
| 490 void BrowserViewRenderer::SetDipScale(float dip_scale) { | 490 void BrowserViewRenderer::SetDipScale(float dip_scale) { |
| 491 dip_scale_ = dip_scale; | 491 dip_scale_ = dip_scale; |
| 492 CHECK(dip_scale_ > 0); | 492 CHECK_GT(dip_scale_, 0); |
| 493 } | 493 } |
| 494 | 494 |
| 495 gfx::Vector2d BrowserViewRenderer::max_scroll_offset() const { | 495 gfx::Vector2d BrowserViewRenderer::max_scroll_offset() const { |
| 496 DCHECK_GT(dip_scale_, 0); | 496 DCHECK_GT(dip_scale_, 0); |
| 497 return gfx::ToCeiledVector2d(gfx::ScaleVector2d( | 497 return gfx::ToCeiledVector2d(gfx::ScaleVector2d( |
| 498 max_scroll_offset_dip_, dip_scale_ * page_scale_factor_)); | 498 max_scroll_offset_dip_, dip_scale_ * page_scale_factor_)); |
| 499 } | 499 } |
| 500 | 500 |
| 501 void BrowserViewRenderer::ScrollTo(gfx::Vector2d scroll_offset) { | 501 void BrowserViewRenderer::ScrollTo(gfx::Vector2d scroll_offset) { |
| 502 gfx::Vector2d max_offset = max_scroll_offset(); | 502 gfx::Vector2d max_offset = max_scroll_offset(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 if (max_scroll_offset_dip_.x()) { | 561 if (max_scroll_offset_dip_.x()) { |
| 562 scroll_offset.set_x((scroll_offset_dip.x() * max_offset.x()) / | 562 scroll_offset.set_x((scroll_offset_dip.x() * max_offset.x()) / |
| 563 max_scroll_offset_dip_.x()); | 563 max_scroll_offset_dip_.x()); |
| 564 } | 564 } |
| 565 | 565 |
| 566 if (max_scroll_offset_dip_.y()) { | 566 if (max_scroll_offset_dip_.y()) { |
| 567 scroll_offset.set_y((scroll_offset_dip.y() * max_offset.y()) / | 567 scroll_offset.set_y((scroll_offset_dip.y() * max_offset.y()) / |
| 568 max_scroll_offset_dip_.y()); | 568 max_scroll_offset_dip_.y()); |
| 569 } | 569 } |
| 570 | 570 |
| 571 DCHECK(0 <= scroll_offset.x()); | 571 DCHECK_LE(0, scroll_offset.x()); |
| 572 DCHECK(0 <= scroll_offset.y()); | 572 DCHECK_LE(0, scroll_offset.y()); |
| 573 DCHECK(scroll_offset.x() <= max_offset.x()); | 573 DCHECK_LE(scroll_offset.x(), max_offset.x()); |
| 574 DCHECK(scroll_offset.y() <= max_offset.y()); | 574 DCHECK_LE(scroll_offset.y(), max_offset.y()); |
| 575 | 575 |
| 576 client_->ScrollContainerViewTo(scroll_offset); | 576 client_->ScrollContainerViewTo(scroll_offset); |
| 577 } | 577 } |
| 578 | 578 |
| 579 gfx::Vector2dF BrowserViewRenderer::GetTotalRootLayerScrollOffset() { | 579 gfx::Vector2dF BrowserViewRenderer::GetTotalRootLayerScrollOffset() { |
| 580 return scroll_offset_dip_; | 580 return scroll_offset_dip_; |
| 581 } | 581 } |
| 582 | 582 |
| 583 bool BrowserViewRenderer::IsExternalFlingActive() const { | 583 bool BrowserViewRenderer::IsExternalFlingActive() const { |
| 584 return client_->IsFlingActive(); | 584 return client_->IsFlingActive(); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 base::StringAppendF(&str, | 759 base::StringAppendF(&str, |
| 760 "surface width height: [%d %d] ", | 760 "surface width height: [%d %d] ", |
| 761 draw_info->width, | 761 draw_info->width, |
| 762 draw_info->height); | 762 draw_info->height); |
| 763 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); | 763 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); |
| 764 } | 764 } |
| 765 return str; | 765 return str; |
| 766 } | 766 } |
| 767 | 767 |
| 768 } // namespace android_webview | 768 } // namespace android_webview |
| OLD | NEW |