| 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 7b70cff1c81191aa8e82a1a3f903259af7fe5f95..019a640e4268ac41ee2bc73f4057f359b439ca14 100644
|
| --- a/android_webview/browser/in_process_view_renderer.cc
|
| +++ b/android_webview/browser/in_process_view_renderer.cc
|
| @@ -297,9 +297,14 @@ bool InProcessViewRenderer::DrawSWInternal(jobject java_canvas,
|
| AwDrawSWFunctionTable* sw_functions = GetAwDrawSWFunctionTable();
|
| 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) {
|
| + SkBitmap::Config config = !pixels ? SkBitmap::kNo_Config :
|
| + pixels->config == AwConfig_ARGB_8888 ? SkBitmap::kARGB_8888_Config :
|
| + pixels->config == AwConfig_ARGB_4444 ? SkBitmap::kARGB_4444_Config :
|
| + pixels->config == AwConfig_RGB_565 ? SkBitmap::kRGB_565_Config :
|
| + SkBitmap::kNo_Config;
|
| + if (config == SkBitmap::kNo_Config) {
|
| + // Render into an auxiliary bitmap if pixel info is not available.
|
| + ScopedJavaLocalRef<jobject> jcanvas(env, java_canvas);
|
| TRACE_EVENT0("android_webview", "RenderToAuxBitmap");
|
| ScopedJavaLocalRef<jobject> jbitmap(java_helper_->CreateBitmap(
|
| env, clip.width(), clip.height(), jcanvas, web_contents_));
|
| @@ -330,7 +335,7 @@ bool InProcessViewRenderer::DrawSWInternal(jobject java_canvas,
|
| bool succeeded = false;
|
| {
|
| SkBitmap bitmap;
|
| - bitmap.setConfig(static_cast<SkBitmap::Config>(pixels->config),
|
| + bitmap.setConfig(config,
|
| pixels->width,
|
| pixels->height,
|
| pixels->row_bytes);
|
| @@ -342,12 +347,25 @@ bool InProcessViewRenderer::DrawSWInternal(jobject java_canvas,
|
| matrix.set(i, pixels->matrix[i]);
|
| canvas.setMatrix(matrix);
|
|
|
| - if (pixels->clip_region_size) {
|
| + if (pixels->clip_rect_count) {
|
| + SkRegion clip;
|
| + for (int i = 0; i < pixels->clip_rect_count; ++i) {
|
| + clip.op(SkIRect::MakeXYWH(pixels->clip_rects[i + 0],
|
| + pixels->clip_rects[i + 1],
|
| + pixels->clip_rects[i + 2],
|
| + pixels->clip_rects[i + 3]),
|
| + SkRegion::kUnion_Op);
|
| + }
|
| + canvas.setClipRegion(clip);
|
| + } else if (pixels->clip_region && pixels->clip_region_size) {
|
| SkRegion clip_region;
|
| size_t bytes_read = clip_region.readFromMemory(pixels->clip_region);
|
| DCHECK_EQ(pixels->clip_region_size, bytes_read);
|
| canvas.setClipRegion(clip_region);
|
| } else {
|
| + NOTREACHED();
|
| + // The |clip| passed in is relative to the canvas, not necessarily to
|
| + // |pixels|, so in general it's not safe to use it as a fallback.
|
| canvas.clipRect(gfx::RectToSkRect(clip));
|
| }
|
| canvas.translate(scroll_at_start_of_frame_.x(),
|
|
|