diff options
author | Cary Clark <cary@android.com> | 2009-04-24 09:33:29 -0400 |
---|---|---|
committer | Cary Clark <cary@android.com> | 2009-04-24 11:48:34 -0400 |
commit | 2759fd77680ed2b2226098913bf008eb1ab69c8c (patch) | |
tree | e56dc08cbbc1e94640a7018a5c512d6a6b1c4a57 /WebKit/android/jni/WebViewCore.cpp | |
parent | 805e9335952da33d9af0f1ec5c07bc5568feb312 (diff) | |
download | external_webkit-2759fd77680ed2b2226098913bf008eb1ab69c8c.zip external_webkit-2759fd77680ed2b2226098913bf008eb1ab69c8c.tar.gz external_webkit-2759fd77680ed2b2226098913bf008eb1ab69c8c.tar.bz2 |
(1 of 2) add call to determine if picture is ready
This is a half-checkin. The other half is in frameworks/base.
Add WebViewCore::pictureReady(). This uses the last reported
progress when the picture was recorded, and checks to see if
the picture itself is blank. The caller can use this to show
a cached picture or switch to a new one.
http://b/issue?id=1802703
Diffstat (limited to 'WebKit/android/jni/WebViewCore.cpp')
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index ba07c52..bfa83a9 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -293,6 +293,7 @@ void WebViewCore::reset(bool fromConstructor) m_findIsUp = false; m_domtree_version = 0; m_check_domtree_version = true; + m_progressDone = false; } static bool layoutIfNeededRecursive(WebCore::Frame* f) @@ -571,6 +572,18 @@ bool WebViewCore::drawContent(SkCanvas* canvas, SkColor color) return tookTooLong; } +bool WebViewCore::pictureReady() +{ + bool done; + m_contentMutex.lock(); + PictureSet copyContent = PictureSet(m_content); + done = m_progressDone; + m_contentMutex.unlock(); + DBG_NAV_LOGD("done=%s empty=%s", done ? "true" : "false", + copyContent.isEmpty() ? "true" : "false"); + return done || !copyContent.isEmpty(); +} + SkPicture* WebViewCore::rebuildPicture(const SkIRect& inval) { WebCore::FrameView* view = m_mainFrame->view(); @@ -621,12 +634,13 @@ void WebViewCore::rebuildPictureSet(PictureSet* pictureSet) bool WebViewCore::recordContent(SkRegion* region, SkIPoint* point) { DBG_SET_LOG("start"); + float progress = (float) m_mainFrame->page()->progress()->estimatedProgress(); m_contentMutex.lock(); PictureSet contentCopy(m_content); + m_progressDone = progress <= 0.0f || progress >= 1.0f; m_contentMutex.unlock(); recordPictureSet(&contentCopy); - float progress = (float) m_mainFrame->page()->progress()->estimatedProgress(); - if (progress > 0.0f && progress < 1.0f && contentCopy.isEmpty()) { + if (!m_progressDone && contentCopy.isEmpty()) { DBG_SET_LOGD("empty (progress=%g)", progress); return false; } @@ -2562,6 +2576,11 @@ static bool DrawContent(JNIEnv *env, jobject obj, jobject canv, jint color) return viewImpl->drawContent(canvas, color); } +static bool PictureReady(JNIEnv* env, jobject obj) +{ + return GET_NATIVE_VIEW(env, obj)->pictureReady(); +} + // ---------------------------------------------------------------------------- /* @@ -2578,6 +2597,8 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) Key }, { "nativeClick", "()Z", (void*) Click }, + { "nativePictureReady", "()Z", + (void*) PictureReady } , { "nativeSendListBoxChoices", "([ZI)V", (void*) SendListBoxChoices }, { "nativeSendListBoxChoice", "(I)V", |