diff options
author | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-08 13:36:40 +0000 |
---|---|---|
committer | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-08 13:36:40 +0000 |
commit | f0ac86c6477071dc77cfd08d96b40b88a369ca30 (patch) | |
tree | cf0e81de6e6fcba4c240d6c9ad243c21f53ba261 /android_webview | |
parent | 5b0f5e6223b5ae7fea27744c93637d970f49fc99 (diff) | |
download | chromium_src-f0ac86c6477071dc77cfd08d96b40b88a369ca30.zip chromium_src-f0ac86c6477071dc77cfd08d96b40b88a369ca30.tar.gz chromium_src-f0ac86c6477071dc77cfd08d96b40b88a369ca30.tar.bz2 |
[Android WebView] Clip to visible rect
Only draw to the intersection of the clip and the visible
rect. This is an optimization that is not always correct,
but this matches better with existing behavior.
BUG=
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/22616006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216389 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview')
-rw-r--r-- | android_webview/browser/in_process_view_renderer.cc | 25 | ||||
-rw-r--r-- | android_webview/java/src/org/chromium/android_webview/AwContents.java | 5 |
2 files changed, 25 insertions, 5 deletions
diff --git a/android_webview/browser/in_process_view_renderer.cc b/android_webview/browser/in_process_view_renderer.cc index 3e25680..49d5578 100644 --- a/android_webview/browser/in_process_view_renderer.cc +++ b/android_webview/browser/in_process_view_renderer.cc @@ -305,7 +305,6 @@ bool InProcessViewRenderer::InitializeHwDraw() { void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) { TRACE_EVENT0("android_webview", "InProcessViewRenderer::DrawGL"); - DCHECK(visible_); manager_key_ = g_view_renderer_manager.Get().DidDrawGL(manager_key_, this); @@ -330,8 +329,19 @@ void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) { } } - if (draw_info->mode == AwDrawGLInfo::kModeProcess) + if (draw_info->mode == AwDrawGLInfo::kModeProcess) { + TRACE_EVENT_INSTANT0( + "android_webview", "EarlyOut_ModeProcess", TRACE_EVENT_SCOPE_THREAD); + return; + } + + UpdateCachedGlobalVisibleRect(); + if (cached_global_visible_rect_.IsEmpty()) { + TRACE_EVENT_INSTANT0("android_webview", + "EarlyOut_EmptyVisibleRect", + TRACE_EVENT_SCOPE_THREAD); return; + } // DrawGL may be called without OnDraw, so cancel |fallback_tick_| here as // well just to be safe. @@ -361,6 +371,15 @@ void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) { draw_info->clip_top, draw_info->clip_right - draw_info->clip_left, draw_info->clip_bottom - draw_info->clip_top); + + // Assume we always draw the full visible rect if we are drawing into a layer. + bool drew_full_visible_rect = true; + + if (!draw_info->is_layer) { + clip_rect.Intersect(cached_global_visible_rect_); + drew_full_visible_rect = clip_rect.Contains(cached_global_visible_rect_); + } + block_invalidates_ = true; // TODO(joth): Check return value. compositor_->DemandDrawHw(gfx::Size(draw_info->width, draw_info->height), @@ -370,8 +389,6 @@ void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) { block_invalidates_ = false; gl_surface_->ResetBackingFrameBufferObject(); - UpdateCachedGlobalVisibleRect(); - bool drew_full_visible_rect = clip_rect.Contains(cached_global_visible_rect_); EnsureContinuousInvalidation(draw_info, !drew_full_visible_rect); } diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java index 099a6e9..eb0128e 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java @@ -664,7 +664,10 @@ public class AwContents { @CalledByNative private void updateGlobalVisibleRect() { - mContainerView.getGlobalVisibleRect(sLocalGlobalVisibleRect); + if (!mContainerView.getGlobalVisibleRect(sLocalGlobalVisibleRect)) { + sLocalGlobalVisibleRect.setEmpty(); + } + nativeSetGlobalVisibleRect(mNativeAwContents, sLocalGlobalVisibleRect.left, sLocalGlobalVisibleRect.top, sLocalGlobalVisibleRect.right, sLocalGlobalVisibleRect.bottom); |