diff options
author | dtrainor@chromium.org <dtrainor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-23 00:27:19 +0000 |
---|---|---|
committer | dtrainor@chromium.org <dtrainor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-23 00:27:19 +0000 |
commit | bbae2c0c75897a4733394b7134db955e694ae591 (patch) | |
tree | cac00002130873489e549435fa61031998e9247f /content/public | |
parent | 703d90f3e4b26b91a68a455aed84a4a67a81a169 (diff) | |
download | chromium_src-bbae2c0c75897a4733394b7134db955e694ae591.zip chromium_src-bbae2c0c75897a4733394b7134db955e694ae591.tar.gz chromium_src-bbae2c0c75897a4733394b7134db955e694ae591.tar.bz2 |
Enable texture readback support for Android
- Adjust the GLHelper to include methods we can use for our texture readback support.
- Tie it into the RenderWidgetHostViewAndroid/ContentViewCore/Compositor.
BUG=
Review URL: https://chromiumcodereview.appspot.com/11234008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163455 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/public')
4 files changed, 29 insertions, 9 deletions
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentView.java b/content/public/android/java/src/org/chromium/content/browser/ContentView.java index b9046b3..55616a7 100644 --- a/content/public/android/java/src/org/chromium/content/browser/ContentView.java +++ b/content/public/android/java/src/org/chromium/content/browser/ContentView.java @@ -312,11 +312,7 @@ public class ContentView extends FrameLayout implements ContentViewCore.Internal } public Bitmap getBitmap(int width, int height) { - return getBitmap(width, height, Bitmap.Config.ARGB_8888); - } - - public Bitmap getBitmap(int width, int height, Bitmap.Config config) { - return mContentViewCore.getBitmap(width, height, config); + return mContentViewCore.getBitmap(width, height); } /** diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java index ff037b0..5941d8d 100644 --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java @@ -710,11 +710,23 @@ public class ContentViewCore implements MotionEventDelegate { } public Bitmap getBitmap(int width, int height) { - return getBitmap(width, height, Bitmap.Config.ARGB_8888); - } + if (getWidth() == 0 || getHeight() == 0) return null; + + Bitmap b = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + + if (mNativeContentViewCore != 0 && + nativePopulateBitmapFromCompositor(mNativeContentViewCore, b)) { + // If we successfully grabbed a bitmap, check if we have to draw the Android overlay + // components as well. + if (mContainerView.getParent() != null && + mContainerView.getVisibility() == View.VISIBLE) { + Canvas c = new Canvas(b); + c.scale(width / (float) getWidth(), height / (float) getHeight()); + mContainerView.draw(c); + } + return b; + } - public Bitmap getBitmap(int width, int height, Bitmap.Config config) { - // TODO(nileshagrawal): Implement this. return null; } @@ -2203,4 +2215,7 @@ public class ContentViewCore implements MotionEventDelegate { private native void nativeUpdateVSyncParameters(int nativeContentViewCoreImpl, long timebaseMicros, long intervalMicros); + + private native boolean nativePopulateBitmapFromCompositor(int nativeContentViewCoreImpl, + Bitmap bitmap); } diff --git a/content/public/browser/android/compositor.h b/content/public/browser/android/compositor.h index 33da403..721b5fd 100644 --- a/content/public/browser/android/compositor.h +++ b/content/public/browser/android/compositor.h @@ -73,6 +73,10 @@ class Compositor { // Deletes an OpenGL texture. virtual void DeleteTexture(WebKit::WebGLId texture_id) = 0; + // Grabs a copy of |texture_id| and saves it into |bitmap|. No scaling is + // done. It is assumed that the texture size matches that of the bitmap. + virtual void CopyTextureToBitmap(WebKit::WebGLId texture_id, + gfx::JavaBitmap& bitmap) = 0; protected: Compositor() {} }; diff --git a/content/public/browser/android/content_view_core.h b/content/public/browser/android/content_view_core.h index fdb98c3..bce865f 100644 --- a/content/public/browser/android/content_view_core.h +++ b/content/public/browser/android/content_view_core.h @@ -10,6 +10,10 @@ #include "content/public/browser/navigation_controller.h" +namespace gfx { +class Size; +} + namespace ui { class WindowAndroid; } @@ -33,6 +37,7 @@ class ContentViewCore { virtual void OnWebPreferencesUpdated() = 0; virtual jint GetCurrentRenderProcessId(JNIEnv* env, jobject obj) = 0; virtual void ShowPastePopup(int x, int y) = 0; + virtual unsigned int GetScaledContentTexture(const gfx::Size& size) = 0; protected: virtual ~ContentViewCore() {}; |