| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "android_webview/browser/browser_view_renderer.h" | 5 #include "android_webview/browser/browser_view_renderer.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/browser_view_renderer_client.h" | 7 #include "android_webview/browser/browser_view_renderer_client.h" |
| 8 #include "android_webview/browser/hardware_renderer.h" | 8 #include "android_webview/browser/hardware_renderer.h" |
| 9 #include "android_webview/browser/shared_renderer_state.h" | 9 #include "android_webview/browser/shared_renderer_state.h" |
| 10 #include "android_webview/public/browser/draw_gl.h" | 10 #include "android_webview/public/browser/draw_gl.h" |
| 11 #include "base/android/jni_android.h" | 11 #include "base/android/jni_android.h" |
| 12 #include "base/auto_reset.h" | 12 #include "base/auto_reset.h" |
| 13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "content/public/browser/android/synchronous_compositor.h" | 16 #include "content/public/browser/android/synchronous_compositor.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 19 #include "third_party/skia/include/core/SkBitmap.h" | 19 #include "third_party/skia/include/core/SkBitmap.h" |
| 20 #include "third_party/skia/include/core/SkBitmapDevice.h" |
| 20 #include "third_party/skia/include/core/SkCanvas.h" | 21 #include "third_party/skia/include/core/SkCanvas.h" |
| 21 #include "third_party/skia/include/core/SkPicture.h" | 22 #include "third_party/skia/include/core/SkPicture.h" |
| 22 #include "ui/gfx/vector2d_conversions.h" | 23 #include "ui/gfx/vector2d_conversions.h" |
| 23 | 24 |
| 24 using base::android::AttachCurrentThread; | 25 using base::android::AttachCurrentThread; |
| 25 using base::android::JavaRef; | 26 using base::android::JavaRef; |
| 26 using base::android::ScopedJavaLocalRef; | 27 using base::android::ScopedJavaLocalRef; |
| 27 using content::BrowserThread; | 28 using content::BrowserThread; |
| 28 | 29 |
| 29 namespace android_webview { | 30 namespace android_webview { |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 | 473 |
| 473 // This should only be called if OnDraw or DrawGL did not come in time, which | 474 // This should only be called if OnDraw or DrawGL did not come in time, which |
| 474 // means block_invalidates_ must still be true. | 475 // means block_invalidates_ must still be true. |
| 475 DCHECK(block_invalidates_); | 476 DCHECK(block_invalidates_); |
| 476 if (compositor_needs_continuous_invalidate_ && has_compositor_) | 477 if (compositor_needs_continuous_invalidate_ && has_compositor_) |
| 477 ForceFakeCompositeSW(); | 478 ForceFakeCompositeSW(); |
| 478 } | 479 } |
| 479 | 480 |
| 480 void BrowserViewRenderer::ForceFakeCompositeSW() { | 481 void BrowserViewRenderer::ForceFakeCompositeSW() { |
| 481 DCHECK(has_compositor_); | 482 DCHECK(has_compositor_); |
| 482 SkBitmap bitmap; | 483 SkBitmapDevice device(SkBitmap::kARGB_8888_Config, 1, 1); |
| 483 bitmap.allocN32Pixels(1, 1); | 484 SkCanvas canvas(&device); |
| 484 bitmap.eraseColor(0); | |
| 485 SkCanvas canvas(bitmap); | |
| 486 CompositeSW(&canvas); | 485 CompositeSW(&canvas); |
| 487 } | 486 } |
| 488 | 487 |
| 489 bool BrowserViewRenderer::CompositeSW(SkCanvas* canvas) { | 488 bool BrowserViewRenderer::CompositeSW(SkCanvas* canvas) { |
| 490 DCHECK(has_compositor_); | 489 DCHECK(has_compositor_); |
| 491 | 490 |
| 492 bool result = shared_renderer_state_->CompositorDemandDrawSw(canvas); | 491 bool result = shared_renderer_state_->CompositorDemandDrawSw(canvas); |
| 493 fallback_tick_.Cancel(); | 492 fallback_tick_.Cancel(); |
| 494 block_invalidates_ = false; | 493 block_invalidates_ = false; |
| 495 EnsureContinuousInvalidation(false); | 494 EnsureContinuousInvalidation(false); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 base::StringAppendF(&str, | 529 base::StringAppendF(&str, |
| 531 "surface width height: [%d %d] ", | 530 "surface width height: [%d %d] ", |
| 532 draw_info->width, | 531 draw_info->width, |
| 533 draw_info->height); | 532 draw_info->height); |
| 534 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); | 533 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); |
| 535 } | 534 } |
| 536 return str; | 535 return str; |
| 537 } | 536 } |
| 538 | 537 |
| 539 } // namespace android_webview | 538 } // namespace android_webview |
| OLD | NEW |