summaryrefslogtreecommitdiffstats
path: root/android_webview/browser
diff options
context:
space:
mode:
authorjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-24 09:42:22 +0000
committerjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-24 09:42:22 +0000
commitfd03b658fc331a7504e7e885d3ecaac3a7d9264a (patch)
tree46f07dbbf1da775cb1af65ccf14b0c07783d5e6a /android_webview/browser
parent502293e1892eca7f1ca53afe1a032e2ad58601c6 (diff)
downloadchromium_src-fd03b658fc331a7504e7e885d3ecaac3a7d9264a.zip
chromium_src-fd03b658fc331a7504e7e885d3ecaac3a7d9264a.tar.gz
chromium_src-fd03b658fc331a7504e7e885d3ecaac3a7d9264a.tar.bz2
Cache auxiliary bitmap across draw frames
While this mode isn't intended to be used in anger, the slow down caused by reallocating the temp bitmap every frame is very high even for a development configuration. Also add a bunch of useful tracing. BUG= Review URL: https://chromiumcodereview.appspot.com/15795002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202035 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/browser')
-rw-r--r--android_webview/browser/browser_view_renderer.h3
-rw-r--r--android_webview/browser/browser_view_renderer_impl.cc4
-rw-r--r--android_webview/browser/in_process_renderer/in_process_view_renderer.cc23
3 files changed, 22 insertions, 8 deletions
diff --git a/android_webview/browser/browser_view_renderer.h b/android_webview/browser/browser_view_renderer.h
index 0251b26..f372256 100644
--- a/android_webview/browser/browser_view_renderer.h
+++ b/android_webview/browser/browser_view_renderer.h
@@ -53,7 +53,8 @@ class BrowserViewRenderer {
virtual base::android::ScopedJavaLocalRef<jobject> CreateBitmap(
JNIEnv* env,
int width,
- int height) = 0;
+ int height,
+ bool cache_result) = 0;
// Draws the provided Java Bitmap into the provided Java Canvas.
virtual void DrawBitmapIntoCanvas(
diff --git a/android_webview/browser/browser_view_renderer_impl.cc b/android_webview/browser/browser_view_renderer_impl.cc
index aacf9d4..72aaf39 100644
--- a/android_webview/browser/browser_view_renderer_impl.cc
+++ b/android_webview/browser/browser_view_renderer_impl.cc
@@ -342,7 +342,7 @@ bool BrowserViewRendererImpl::DrawSW(jobject java_canvas,
if (!g_sw_draw_functions ||
(pixels = g_sw_draw_functions->access_pixels(env, java_canvas)) == NULL) {
ScopedJavaLocalRef<jobject> jbitmap(java_helper_->CreateBitmap(
- env, clip.width(), clip.height()));
+ env, clip.width(), clip.height(), true));
if (!jbitmap.obj())
return false;
@@ -420,7 +420,7 @@ ScopedJavaLocalRef<jobject> BrowserViewRendererImpl::CapturePicture() {
// If Skia versions are not compatible, workaround it by rasterizing the
// picture into a bitmap and drawing it into a new Java picture.
ScopedJavaLocalRef<jobject> jbitmap(java_helper_->CreateBitmap(
- env, picture->width(), picture->height()));
+ env, picture->width(), picture->height(), false));
if (!jbitmap.obj())
return ScopedJavaLocalRef<jobject>();
diff --git a/android_webview/browser/in_process_renderer/in_process_view_renderer.cc b/android_webview/browser/in_process_renderer/in_process_view_renderer.cc
index 74acde0..e0b9e8f 100644
--- a/android_webview/browser/in_process_renderer/in_process_view_renderer.cc
+++ b/android_webview/browser/in_process_renderer/in_process_view_renderer.cc
@@ -9,6 +9,7 @@
#include "android_webview/public/browser/draw_gl.h"
#include "android_webview/public/browser/draw_sw.h"
#include "base/android/jni_android.h"
+#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "content/public/browser/android/content_view_core.h"
#include "content/public/browser/render_view_host.h"
@@ -246,8 +247,11 @@ bool InProcessViewRenderer::DrawSWInternal(jobject java_canvas,
const gfx::Rect& clip) {
TRACE_EVENT0("android_webview", "InProcessViewRenderer::DrawSW");
- if (clip.IsEmpty())
+ if (clip.IsEmpty()) {
+ TRACE_EVENT_INSTANT0("android_webview", "Empty Clip",
+ TRACE_EVENT_SCOPE_THREAD);
return true;
+ }
JNIEnv* env = AttachCurrentThread();
@@ -256,14 +260,20 @@ bool InProcessViewRenderer::DrawSWInternal(jobject java_canvas,
sw_functions->access_pixels(env, java_canvas) : NULL;
// Render into an auxiliary bitmap if pixel info is not available.
if (pixels == NULL) {
+ TRACE_EVENT0("android_webview", "Render to Aux Bitmap");
ScopedJavaLocalRef<jobject> jbitmap(java_helper_->CreateBitmap(
- env, clip.width(), clip.height()));
- if (!jbitmap.obj())
+ env, clip.width(), clip.height(), true));
+ if (!jbitmap.obj()) {
+ TRACE_EVENT_INSTANT0("android_webview", "Bitmap Alloc Fail",
+ TRACE_EVENT_SCOPE_THREAD);
return false;
+ }
if (!RasterizeIntoBitmap(env, jbitmap, clip.x(), clip.y(),
base::Bind(&InProcessViewRenderer::RenderSW,
base::Unretained(this)))) {
+ TRACE_EVENT_INSTANT0("android_webview", "Rasterize Fail",
+ TRACE_EVENT_SCOPE_THREAD);
return false;
}
@@ -334,9 +344,12 @@ InProcessViewRenderer::CapturePicture() {
}
// If Skia versions are not compatible, workaround it by rasterizing the
- // picture into a bitmap and drawing it into a new Java picture.
+ // picture into a bitmap and drawing it into a new Java picture. Pass false
+ // for |cache_result| as the picture we create will hold a shallow reference
+ // to the bitmap drawn, and we don't want subsequent draws to corrupt any
+ // previously returned pictures.
ScopedJavaLocalRef<jobject> jbitmap(java_helper_->CreateBitmap(
- env, picture->width(), picture->height()));
+ env, picture->width(), picture->height(), false));
if (!jbitmap.obj())
return ScopedJavaLocalRef<jobject>();