summaryrefslogtreecommitdiffstats
path: root/android_webview
diff options
context:
space:
mode:
authorjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-29 05:49:55 +0000
committerjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-29 05:49:55 +0000
commit51037daa29b39030590f4134712601e6c665e684 (patch)
tree4fe6d86fbfc32c6dfeb947b74d7b394cfd2d0912 /android_webview
parent26fc10e035b066514fe504c63fe5be89334ffa1a (diff)
downloadchromium_src-51037daa29b39030590f4134712601e6c665e684.zip
chromium_src-51037daa29b39030590f4134712601e6c665e684.tar.gz
chromium_src-51037daa29b39030590f4134712601e6c665e684.tar.bz2
Implement AwContents.invalidate()
Patched in from https://codereview.chromium.org/11411239/ BUG=161409 NOTRY=true Review URL: https://chromiumcodereview.appspot.com/11308263 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170134 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview')
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwContents.java5
-rw-r--r--android_webview/native/aw_contents.cc31
-rw-r--r--android_webview/native/aw_contents.h3
3 files changed, 35 insertions, 4 deletions
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 64bf97d..2d83171 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -702,6 +702,11 @@ public class AwContents {
mPossiblyStaleHitTestData.imgSrc = imgSrc;
}
+ @CalledByNative
+ private void invalidate() {
+ mContainerView.invalidate();
+ }
+
// -------------------------------------------------------------------------------------------
// Helper methods
// -------------------------------------------------------------------------------------------
diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc
index 91926f7..a92c838 100644
--- a/android_webview/native/aw_contents.cc
+++ b/android_webview/native/aw_contents.cc
@@ -121,7 +121,8 @@ AwContents::AwContents(JNIEnv* env,
web_contents_delegate_(
new AwWebContentsDelegate(env, web_contents_delegate)),
view_visible_(false),
- compositor_visible_(false) {
+ compositor_visible_(false),
+ is_composite_pending_(false) {
android_webview::AwBrowserDependencyFactory* dependency_factory =
android_webview::AwBrowserDependencyFactory::GetInstance();
@@ -159,8 +160,14 @@ void AwContents::DrawGL(AwDrawGLInfo* draw_info) {
compositor_visible_ = view_visible_;
compositor_->SetVisible(compositor_visible_);
}
- if (compositor_visible_ && draw_info->mode == AwDrawGLInfo::kModeDraw)
- compositor_->Composite();
+
+ if (!compositor_visible_ || draw_info->mode == AwDrawGLInfo::kModeProcess)
+ return;
+
+ DCHECK_EQ(draw_info->mode, AwDrawGLInfo::kModeDraw);
+
+ compositor_->Composite();
+ is_composite_pending_ = false;
}
jint AwContents::GetWebContents(JNIEnv* env, jobject obj) {
@@ -172,6 +179,7 @@ void AwContents::DidInitializeContentViewCore(JNIEnv* env, jobject obj,
ContentViewCore* core = reinterpret_cast<ContentViewCore*>(content_view_core);
DCHECK(core == ContentViewCore::FromWebContents(web_contents_.get()));
compositor_->SetRootLayer(core->GetWebLayer());
+ Invalidate();
}
void AwContents::Destroy(JNIEnv* env, jobject obj) {
@@ -370,6 +378,21 @@ void AwContents::OnFindResultReceived(int active_ordinal,
void AwContents::ScheduleComposite() {
// TODO(joth): Call back out to framework attachFunctor (Java side) from here.
+ Invalidate();
+}
+
+void AwContents::Invalidate() {
+ if (is_composite_pending_)
+ return;
+
+ is_composite_pending_ = true;
+
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
+ if (obj.is_null())
+ return;
+
+ Java_AwContents_invalidate(env, obj.obj());
}
void AwContents::OnSwapBuffersCompleted() {
@@ -443,7 +466,7 @@ void AwContents::SetWindowViewVisibility(JNIEnv* env, jobject obj,
bool window_visible,
bool view_visible) {
view_visible_ = window_visible && view_visible;
- // TODO(joth): Request a DrawGL (kModeProcess) call, to tell the compositor.
+ Invalidate();
}
void AwContents::OnAttachedToWindow(JNIEnv* env, jobject obj, int w, int h) {
diff --git a/android_webview/native/aw_contents.h b/android_webview/native/aw_contents.h
index 69f141a..eb10438 100644
--- a/android_webview/native/aw_contents.h
+++ b/android_webview/native/aw_contents.h
@@ -108,6 +108,8 @@ class AwContents : public FindHelper::Listener,
virtual void OnSwapBuffersCompleted() OVERRIDE;
private:
+ void Invalidate();
+
JavaObjectWeakGlobalRef java_ref_;
scoped_ptr<content::WebContents> web_contents_;
scoped_ptr<AwWebContentsDelegate> web_contents_delegate_;
@@ -117,6 +119,7 @@ class AwContents : public FindHelper::Listener,
// State to track if the view is visible, and if the compositor knows yet.
bool view_visible_;
bool compositor_visible_;
+ bool is_composite_pending_;
DISALLOW_COPY_AND_ASSIGN(AwContents);
};