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

Unified Diff: ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java

Issue 297683005: android: add Java-side support for browser compositor async readback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed tedchoc comments Created 6 years, 7 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: ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java
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 99c8c415190a9968d289c7584ffd42e91b930239..07f48dcc13f3248fa107f146abd0de462dbd2944 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;
« no previous file with comments | « content/public/browser/android/compositor.h ('k') | ui/android/java/src/org/chromium/ui/base/WindowAndroid.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698