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

Unified Diff: content/browser/android/content_view_core_impl.cc

Issue 143803004: android: Migrate old content readback to use async readback (and delegated renderer) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 6 years, 11 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: content/browser/android/content_view_core_impl.cc
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index 182c0a6f336ca2071a3303065f41072bb9fa2e4b..7201d10674caeb04331921ca3cf5e6da0a4bd6d4 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -8,6 +8,7 @@
#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
#include "base/android/scoped_java_ref.h"
+#include "base/callback_helpers.h"
#include "base/command_line.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
@@ -591,14 +592,41 @@ void ContentViewCoreImpl::ShowPastePopup(int x_dip, int y_dip) {
static_cast<jint>(y_dip));
}
-unsigned int ContentViewCoreImpl::GetScaledContentTexture(
- float scale,
- gfx::Size* out_size) {
+void ContentViewCoreImpl::OnFinishGetScaledContentBitmap(
+ const base::Callback<void(bool, const SkBitmap&)>& compositor_callback,
+ bool success,
+ const SkBitmap& bitmap) {
+ base::ScopedClosureRunner scoped_callback_runner(
+ base::Bind(compositor_callback, false, SkBitmap()));
+
RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid();
if (!view)
- return 0;
+ return;
+ view->UnlockResources();
+
+ if (!success)
+ return;
+ ignore_result(scoped_callback_runner.Release());
+ compositor_callback.Run(success, bitmap);
+}
+
+void ContentViewCoreImpl::GetScaledContentBitmap(
+ float scale,
+ gfx::Size* out_size,
+ const base::Callback<void(bool, const SkBitmap&)>& compositor_callback) {
+ RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid();
+ if (!view || !view->IsSurfaceAvailableForCopy()) {
+ base::ScopedClosureRunner scoped_callback_runner(
+ base::Bind(compositor_callback, false, SkBitmap()));
+ return;
+ }
- return view->GetScaledContentTexture(scale, out_size);
+ base::Callback<void(bool, const SkBitmap&)> callback =
+ base::Bind(&ContentViewCoreImpl::OnFinishGetScaledContentBitmap,
+ base::Unretained(this),
+ compositor_callback);
+ view->LockResources();
+ view->GetScaledContentBitmap(scale, out_size, callback);
}
void ContentViewCoreImpl::StartContentIntent(const GURL& content_url) {

Powered by Google App Engine
This is Rietveld 408576698