From e859a34171f2a36877d95197d118d962078f8aa0 Mon Sep 17 00:00:00 2001 From: John Reck Date: Fri, 27 Apr 2012 08:13:38 -0700 Subject: Rewrite PictureSet with TURBO! This changes how partial invals are done by adding a hybrid mode. What we used to do is generate a SkPicture for the new area. This SkPicture would possibly be larger than the actual inval, depending on various merge rules (more SkPictures == slower to draw a tile) The new code rewrites PictureSet entirely, preserving many of the old rules but cleans up the code and adds the concept of a "PrerenderedInval". This is a partial inval that WebKit has rasterized. By having WebKit produce both a SkPicture and a SkBitmap, we avoid needing to play back the picture and avoid overdrawing. We take this SkBitmap, and simply update the front textures with it. This gives us full partial invals through the entire system without hitting any driver bugs, and with minimal copies. And while the SkPicture may be larger than the inval, the SkBitmap that is rasterized is not - it matches the area webkit has said is dirty. Change-Id: Ieb7ecc9db0d4f679102fda004a43399f9b319ebc --- Source/WebKit/android/nav/WebView.cpp | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) (limited to 'Source/WebKit/android/nav/WebView.cpp') diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index 51ffdfe..9d4d7a4 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -293,12 +293,11 @@ int drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect, return 0; } -PictureSet* draw(SkCanvas* canvas, SkColor bgColor, DrawExtras extras, bool split) +void draw(SkCanvas* canvas, SkColor bgColor, DrawExtras extras) { - PictureSet* ret = 0; if (!m_baseLayer) { canvas->drawColor(bgColor); - return ret; + return; } // draw the content of the base layer first @@ -327,8 +326,6 @@ PictureSet* draw(SkCanvas* canvas, SkColor bgColor, DrawExtras extras, bool spli m_baseLayer->setMatrix(canvas->getTotalMatrix()); canvas->resetMatrix(); m_baseLayer->draw(canvas, getDrawExtra(extras)); - - return ret; } int getScaledMaxXScroll() @@ -543,14 +540,6 @@ bool setBaseLayer(BaseLayerAndroid* newBaseLayer, bool showVisualIndicator, return queueFull; } -void replaceBaseContent(PictureSet* set) -{ - if (!m_baseLayer) - return; - // TODO: remove the split picture codepath - delete set; -} - void copyBaseContentToPicture(SkPicture* picture) { if (!m_baseLayer) @@ -805,16 +794,14 @@ static SkRect jrectf_to_rect(JNIEnv* env, jobject obj) return rect; } -static jint nativeDraw(JNIEnv *env, jobject obj, jobject canv, +static void nativeDraw(JNIEnv *env, jobject obj, jobject canv, jobject visible, jint color, - jint extras, jboolean split) { + jint extras) { SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, canv); WebView* webView = GET_NATIVE_VIEW(env, obj); SkRect visibleRect = jrectf_to_rect(env, visible); webView->setVisibleRect(visibleRect); - PictureSet* pictureSet = webView->draw(canvas, color, - static_cast(extras), split); - return reinterpret_cast(pictureSet); + webView->draw(canvas, color, static_cast(extras)); } static jint nativeCreateDrawGLFunction(JNIEnv *env, jobject obj, jint nativeView, @@ -898,12 +885,6 @@ static BaseLayerAndroid* nativeGetBaseLayer(JNIEnv *env, jobject obj) return GET_NATIVE_VIEW(env, obj)->getBaseLayer(); } -static void nativeReplaceBaseContent(JNIEnv *env, jobject obj, jint content) -{ - PictureSet* set = reinterpret_cast(content); - GET_NATIVE_VIEW(env, obj)->replaceBaseContent(set); -} - static void nativeCopyBaseContentToPicture(JNIEnv *env, jobject obj, jobject pict) { SkPicture* picture = GraphicsJNI::getNativePicture(env, pict); @@ -1110,7 +1091,7 @@ static void nativeDumpDisplayTree(JNIEnv* env, jobject jwebview, jstring jurl) SkDumpCanvas canvas(&dumper); // this will playback the picture into the canvas, which will // spew its contents to the dumper - view->draw(&canvas, 0, WebView::DrawExtrasNone, false); + view->draw(&canvas, 0, WebView::DrawExtrasNone); // we're done with the file now fwrite("\n", 1, 1, file); fclose(file); @@ -1249,7 +1230,7 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeCreate }, { "nativeDestroy", "()V", (void*) nativeDestroy }, - { "nativeDraw", "(Landroid/graphics/Canvas;Landroid/graphics/RectF;IIZ)I", + { "nativeDraw", "(Landroid/graphics/Canvas;Landroid/graphics/RectF;II)V", (void*) nativeDraw }, { "nativeCreateDrawGLFunction", "(ILandroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/RectF;FI)I", (void*) nativeCreateDrawGLFunction }, @@ -1271,8 +1252,6 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeSetBaseLayer }, { "nativeGetBaseLayer", "()I", (void*) nativeGetBaseLayer }, - { "nativeReplaceBaseContent", "(I)V", - (void*) nativeReplaceBaseContent }, { "nativeCopyBaseContentToPicture", "(Landroid/graphics/Picture;)V", (void*) nativeCopyBaseContentToPicture }, { "nativeHasContent", "()Z", -- cgit v1.1