summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorpowei@chromium.org <powei@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-27 21:03:50 +0000
committerpowei@chromium.org <powei@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-27 21:03:50 +0000
commit0389fc7056045a959ad4364775b37f0cfd79c19e (patch)
tree513caac368e10d908bc556b29759e0d801381e91 /ui
parenta1154f904109fa9e6e2f220054a4f7a8c2550cde (diff)
downloadchromium_src-0389fc7056045a959ad4364775b37f0cfd79c19e.zip
chromium_src-0389fc7056045a959ad4364775b37f0cfd79c19e.tar.gz
chromium_src-0389fc7056045a959ad4364775b37f0cfd79c19e.tar.bz2
android: add Java-side support for browser compositor async readback
The android browser compositor removed support for sync readback. Support for async readback was added (https://codereview.chromium.org/281003002/). This patch adds a Java-side API through the existing ContentReadbackHandler. android= https://chrome-internal-review.googlesource.com/#/c/164043/ BUG=252046 Review URL: https://codereview.chromium.org/297683005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273026 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java42
-rw-r--r--ui/android/java/src/org/chromium/ui/base/WindowAndroid.java9
-rw-r--r--ui/base/android/window_android.cc16
-rw-r--r--ui/base/android/window_android.h3
4 files changed, 0 insertions, 70 deletions
diff --git a/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java b/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java
index 99c8c41..07f48dc 100644
--- a/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java
+++ b/ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java
@@ -9,14 +9,7 @@ import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.IntentSender.SendIntentException;
-import android.graphics.Bitmap;
-import android.graphics.Rect;
-import android.util.Log;
-import android.view.View;
-import org.chromium.ui.UiUtils;
-
-import java.io.ByteArrayOutputStream;
import java.lang.ref.WeakReference;
/**
@@ -105,41 +98,6 @@ public class ActivityWindowAndroid extends WindowAndroid {
return new WeakReference<Activity>(mActivityRef.get());
}
- /**
- * Returns a PNG-encoded screenshot of the the window region at (|windowX|,
- * |windowY|) with the size |width| by |height| pixels.
- */
- @Override
- public byte[] grabSnapshot(int windowX, int windowY, int width, int height) {
- Activity activity = mActivityRef.get();
- if (activity == null) return null;
- try {
- // Take a screenshot of the root activity view. This generally includes UI
- // controls such as the URL bar and OS windows such as the status bar.
- View rootView = activity.findViewById(android.R.id.content).getRootView();
- Bitmap bitmap = UiUtils.generateScaledScreenshot(rootView, 0, Bitmap.Config.ARGB_8888);
- if (bitmap == null) return null;
-
- // Clip the result into the requested region.
- if (windowX > 0 || windowY > 0 || width != bitmap.getWidth() ||
- height != bitmap.getHeight()) {
- Rect clip = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
- clip.intersect(windowX, windowY, windowX + width, windowY + height);
- bitmap = Bitmap.createBitmap(
- bitmap, clip.left, clip.top, clip.width(), clip.height());
- }
-
- // Compress the result into a PNG.
- ByteArrayOutputStream result = new ByteArrayOutputStream();
- if (!bitmap.compress(Bitmap.CompressFormat.PNG, 100, result)) return null;
- bitmap.recycle();
- return result.toByteArray();
- } catch (OutOfMemoryError e) {
- Log.e(TAG, "Out of memory while grabbing window snapshot.", e);
- return null;
- }
- }
-
private int generateNextRequestCode() {
int requestCode = REQUEST_CODE_PREFIX + mNextRequestCode;
mNextRequestCode = (mNextRequestCode + 1) % REQUEST_CODE_RANGE_SIZE;
diff --git a/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java b/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java
index 4a68dea..424b566 100644
--- a/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java
+++ b/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java
@@ -279,15 +279,6 @@ public class WindowAndroid {
return mNativeWindowAndroid;
}
- /**
- * Returns a PNG-encoded screenshot of the the window region at (|windowX|,
- * |windowY|) with the size |width| by |height| pixels.
- */
- @CalledByNative
- public byte[] grabSnapshot(int windowX, int windowY, int width, int height) {
- return null;
- }
-
private native long nativeInit(long vsyncPeriod);
private native void nativeOnVSync(long nativeWindowAndroid, long vsyncTimeMicros);
private native void nativeDestroy(long nativeWindowAndroid);
diff --git a/ui/base/android/window_android.cc b/ui/base/android/window_android.cc
index 3dd3e6e..e462550 100644
--- a/ui/base/android/window_android.cc
+++ b/ui/base/android/window_android.cc
@@ -41,22 +41,6 @@ WindowAndroid::~WindowAndroid() {
WindowAndroidObserver, observer_list_, OnWillDestroyWindow());
}
-bool WindowAndroid::GrabSnapshot(
- int content_x, int content_y, int width, int height,
- std::vector<unsigned char>* png_representation) {
- JNIEnv* env = AttachCurrentThread();
- ScopedJavaLocalRef<jbyteArray> result =
- Java_WindowAndroid_grabSnapshot(env, GetJavaObject().obj(),
- content_x + content_offset_.x(),
- content_y + content_offset_.y(),
- width, height);
- if (result.is_null())
- return false;
- base::android::JavaByteArrayToByteVector(
- env, result.obj(), png_representation);
- return true;
-}
-
void WindowAndroid::OnCompositingDidCommit() {
FOR_EACH_OBSERVER(WindowAndroidObserver,
observer_list_,
diff --git a/ui/base/android/window_android.h b/ui/base/android/window_android.h
index 7e39184..df8685d 100644
--- a/ui/base/android/window_android.h
+++ b/ui/base/android/window_android.h
@@ -36,9 +36,6 @@ class UI_BASE_EXPORT WindowAndroid {
content_offset_ = content_offset;
}
- bool GrabSnapshot(int content_x, int content_y, int width, int height,
- std::vector<unsigned char>* png_representation);
-
// Compositor callback relay.
void OnCompositingDidCommit();