Commit 61654002 authored by jinsukkim's avatar jinsukkim Committed by Commit bot

Avoid repeating frame info calculation in Java layer

Native layer is already calculating some frame info about
top control (position + update flag). This CL passes
the values to Java layer so that it won't repeat those
operations again.

Review-Url: https://codereview.chromium.org/2841033002
Cr-Commit-Position: refs/heads/master@{#467871}
parent 4bceb980
......@@ -398,7 +398,7 @@ jint ContentViewCoreImpl::GetBackgroundColor(JNIEnv* env, jobject obj) {
return rwhva->GetCachedBackgroundColor();
}
// All positions and sizes are in CSS pixels.
// All positions and sizes (except |top_shown_pix|) are in CSS pixels.
// Note that viewport_width/height is a best effort based.
// ContentViewCore has the actual information about the physical viewport size.
void ContentViewCoreImpl::UpdateFrameInfo(
......@@ -407,16 +407,16 @@ void ContentViewCoreImpl::UpdateFrameInfo(
const gfx::Vector2dF& page_scale_factor_limits,
const gfx::SizeF& content_size,
const gfx::SizeF& viewport_size,
const float top_controls_height,
const float top_controls_shown_ratio,
const float content_offset,
const float top_shown_pix,
bool top_changed,
bool is_mobile_optimized_hint) {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
if (obj.is_null() || !GetWindowAndroid())
return;
GetViewAndroid()->set_content_offset(
gfx::Vector2dF(0.0f, top_controls_height * top_controls_shown_ratio));
GetViewAndroid()->set_content_offset(gfx::Vector2dF(0.0f, content_offset));
page_scale_ = page_scale_factor;
......@@ -424,7 +424,7 @@ void ContentViewCoreImpl::UpdateFrameInfo(
env, obj, scroll_offset.x(), scroll_offset.y(), page_scale_factor,
page_scale_factor_limits.x(), page_scale_factor_limits.y(),
content_size.width(), content_size.height(), viewport_size.width(),
viewport_size.height(), top_controls_height, top_controls_shown_ratio,
viewport_size.height(), top_shown_pix, top_changed,
is_mobile_optimized_hint);
}
......
......@@ -252,14 +252,16 @@ class ContentViewCoreImpl : public ContentViewCore,
// Hides a visible popup menu.
void HideSelectPopupMenu();
// All sizes and offsets are in CSS pixels as cached by the renderer.
// All sizes and offsets are in CSS pixels (except |top_show_pix|)
// as cached by the renderer.
void UpdateFrameInfo(const gfx::Vector2dF& scroll_offset,
float page_scale_factor,
const gfx::Vector2dF& page_scale_factor_limits,
const gfx::SizeF& content_size,
const gfx::SizeF& viewport_size,
const float top_controls_height,
const float top_controls_shown_ratio,
const float content_offset,
const float top_shown_pix,
bool top_changed,
bool is_mobile_optimized_hint);
bool HasFocus();
......
......@@ -1429,8 +1429,9 @@ void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated(
gfx::Vector2dF(frame_metadata.min_page_scale_factor,
frame_metadata.max_page_scale_factor),
frame_metadata.root_layer_size, frame_metadata.scrollable_viewport_size,
frame_metadata.top_controls_height,
frame_metadata.top_controls_shown_ratio, is_mobile_optimized);
frame_metadata.top_controls_height *
frame_metadata.top_controls_shown_ratio,
top_shown_pix, top_changed, is_mobile_optimized);
}
void RenderWidgetHostViewAndroid::ShowInternal() {
......
......@@ -1576,9 +1576,8 @@ public class ContentViewCore
@CalledByNative
private void updateFrameInfo(float scrollOffsetX, float scrollOffsetY, float pageScaleFactor,
float minPageScaleFactor, float maxPageScaleFactor, float contentWidth,
float contentHeight, float viewportWidth, float viewportHeight,
float browserControlsHeightDp, float browserControlsShownRatio,
boolean isMobileOptimizedHint) {
float contentHeight, float viewportWidth, float viewportHeight, float topBarShownPix,
boolean topBarChanged, boolean isMobileOptimizedHint) {
TraceEvent.begin("ContentViewCore:updateFrameInfo");
mIsMobileOptimizedHint = isMobileOptimizedHint;
// Adjust contentWidth/Height to be always at least as big as
......@@ -1588,8 +1587,6 @@ public class ContentViewCore
mViewportWidthPix / (deviceScale * pageScaleFactor));
contentHeight = Math.max(contentHeight,
mViewportHeightPix / (deviceScale * pageScaleFactor));
final float topBarShownPix =
browserControlsHeightDp * deviceScale * browserControlsShownRatio;
final boolean contentSizeChanged =
contentWidth != mRenderCoordinates.getContentWidthCss()
......@@ -1603,8 +1600,6 @@ public class ContentViewCore
pageScaleChanged
|| scrollOffsetX != mRenderCoordinates.getScrollX()
|| scrollOffsetY != mRenderCoordinates.getScrollY();
final boolean topBarChanged = Float.compare(topBarShownPix,
mRenderCoordinates.getContentOffsetYPix()) != 0;
final boolean needHidePopupZoomer = contentSizeChanged || scrollChanged;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment