Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(606)

Unified Diff: android_webview/browser/in_process_view_renderer.cc

Issue 17274013: [Android WebView] Clamp Bitmap size to max. dimensions when drawing into a Canvas (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: joth comments Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: android_webview/browser/in_process_view_renderer.cc
diff --git a/android_webview/browser/in_process_view_renderer.cc b/android_webview/browser/in_process_view_renderer.cc
index 28810e2b7aa3c5d303bed9a3ed1b2fcea98ed103..13d37923faae91fd1cf9e03193e09e7a977cf940 100644
--- a/android_webview/browser/in_process_view_renderer.cc
+++ b/android_webview/browser/in_process_view_renderer.cc
@@ -438,10 +438,11 @@ bool InProcessViewRenderer::DrawSWInternal(jobject java_canvas,
AwPixelInfo* pixels = sw_functions ?
sw_functions->access_pixels(env, java_canvas) : NULL;
// Render into an auxiliary bitmap if pixel info is not available.
+ ScopedJavaLocalRef<jobject> jcanvas(env, java_canvas);
if (pixels == NULL) {
TRACE_EVENT0("android_webview", "RenderToAuxBitmap");
ScopedJavaLocalRef<jobject> jbitmap(java_helper_->CreateBitmap(
- env, clip.width(), clip.height()));
+ env, clip.width(), clip.height(), jcanvas));
if (!jbitmap.obj()) {
TRACE_EVENT_INSTANT0("android_webview",
"EarlyOut_BitmapAllocFail",
@@ -460,7 +461,6 @@ bool InProcessViewRenderer::DrawSWInternal(jobject java_canvas,
return false;
}
- ScopedJavaLocalRef<jobject> jcanvas(env, java_canvas);
java_helper_->DrawBitmapIntoCanvas(env, jbitmap, jcanvas,
clip.x(), clip.y());
return true;
@@ -530,12 +530,11 @@ 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. 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.
+ // picture into a bitmap and drawing it into a new Java picture. Pass null
+ // for |canvas| as we don't have java canvas at this point (and it would be
+ // software anyway).
ScopedJavaLocalRef<jobject> jbitmap(java_helper_->CreateBitmap(
- env, picture->width(), picture->height()));
+ env, picture->width(), picture->height(), ScopedJavaLocalRef<jobject>()));
if (!jbitmap.obj())
return ScopedJavaLocalRef<jobject>();

Powered by Google App Engine
This is Rietveld 408576698