diff options
author | powei@chromium.org <powei@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-27 21:03:50 +0000 |
---|---|---|
committer | powei@chromium.org <powei@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-27 21:03:50 +0000 |
commit | 0389fc7056045a959ad4364775b37f0cfd79c19e (patch) | |
tree | 513caac368e10d908bc556b29759e0d801381e91 /ui/android | |
parent | a1154f904109fa9e6e2f220054a4f7a8c2550cde (diff) | |
download | chromium_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/android')
-rw-r--r-- | ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java | 42 | ||||
-rw-r--r-- | ui/android/java/src/org/chromium/ui/base/WindowAndroid.java | 9 |
2 files changed, 0 insertions, 51 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); |