summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkerz@chromium.org <kerz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-21 18:16:30 +0000
committerkerz@chromium.org <kerz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-21 18:16:30 +0000
commit62800c0d8681f3266f9034c528aff7241408f5d3 (patch)
tree75aa9c8d681796eae503216f9d125d8bcf263a48
parent1b7cb4177a5d42020dfe1ed52c3340131ddb4870 (diff)
downloadchromium_src-62800c0d8681f3266f9034c528aff7241408f5d3.zip
chromium_src-62800c0d8681f3266f9034c528aff7241408f5d3.tar.gz
chromium_src-62800c0d8681f3266f9034c528aff7241408f5d3.tar.bz2
Merge 173863
> Subrect snapshot support. > > Handle grabbing the subrect snapshot of a texture. Leaving the old method > in there for now to deal with not breaking other repos when committing. > > BUG= > > > Review URL: https://chromiumcodereview.appspot.com/11558039 TBR=dtrainor@chromium.org Review URL: https://codereview.chromium.org/11644076 git-svn-id: svn://svn.chromium.org/chrome/branches/1364/src@174413 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--android_webview/native/aw_contents.cc11
-rw-r--r--content/browser/renderer_host/compositor_impl_android.cc15
-rw-r--r--content/browser/renderer_host/compositor_impl_android.h5
-rw-r--r--content/browser/renderer_host/render_widget_host_view_android.cc2
-rw-r--r--content/common/gpu/client/gl_helper.cc16
-rw-r--r--content/common/gpu/client/gl_helper.h2
-rw-r--r--content/public/browser/android/compositor.h10
7 files changed, 45 insertions, 16 deletions
diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc
index 74edfa1..7ade0d68 100644
--- a/android_webview/native/aw_contents.cc
+++ b/android_webview/native/aw_contents.cc
@@ -120,8 +120,15 @@ class NullCompositor : public content::Compositor {
return 0;
}
virtual void DeleteTexture(WebKit::WebGLId texture_id) OVERRIDE {}
- virtual void CopyTextureToBitmap(WebKit::WebGLId texture_id,
- gfx::JavaBitmap& bitmap) OVERRIDE {}
+ virtual bool CopyTextureToBitmap(WebKit::WebGLId texture_id,
+ gfx::JavaBitmap& bitmap) OVERRIDE {
+ return false;
+ }
+ virtual bool CopyTextureToBitmap(WebKit::WebGLId texture_id,
+ const gfx::Rect& src_rect,
+ gfx::JavaBitmap& bitmap) OVERRIDE {
+ return false;
+ }
virtual void SetHasTransparentBackground(bool flag) OVERRIDE {}
};
diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc
index a4b9534..a89c2e7 100644
--- a/content/browser/renderer_host/compositor_impl_android.cc
+++ b/content/browser/renderer_host/compositor_impl_android.cc
@@ -272,12 +272,23 @@ void CompositorImpl::DeleteTexture(WebKit::WebGLId texture_id) {
DCHECK(context->getError() == GL_NO_ERROR);
}
-void CompositorImpl::CopyTextureToBitmap(WebKit::WebGLId texture_id,
+bool CompositorImpl::CopyTextureToBitmap(WebKit::WebGLId texture_id,
gfx::JavaBitmap& bitmap) {
+ return CopyTextureToBitmap(texture_id, gfx::Rect(bitmap.size()), bitmap);
+}
+
+bool CompositorImpl::CopyTextureToBitmap(WebKit::WebGLId texture_id,
+ const gfx::Rect& sub_rect,
+ gfx::JavaBitmap& bitmap) {
+ // The sub_rect should match the bitmap size.
+ DCHECK(bitmap.size() == sub_rect.size());
+ if (bitmap.size() != sub_rect.size() || texture_id == 0) return false;
+
GLHelper* helper = ImageTransportFactoryAndroid::GetInstance()->GetGLHelper();
helper->ReadbackTextureSync(texture_id,
- bitmap.size(),
+ sub_rect,
static_cast<unsigned char*> (bitmap.pixels()));
+ return true;
}
void CompositorImpl::animate(double monotonicFrameBeginTime) {
diff --git a/content/browser/renderer_host/compositor_impl_android.h b/content/browser/renderer_host/compositor_impl_android.h
index 9ce37a4..a3b728e 100644
--- a/content/browser/renderer_host/compositor_impl_android.h
+++ b/content/browser/renderer_host/compositor_impl_android.h
@@ -56,7 +56,10 @@ class CONTENT_EXPORT CompositorImpl
virtual WebKit::WebGLId GenerateCompressedTexture(
gfx::Size& size, int data_size, void* data) OVERRIDE;
virtual void DeleteTexture(WebKit::WebGLId texture_id) OVERRIDE;
- virtual void CopyTextureToBitmap(WebKit::WebGLId texture_id,
+ virtual bool CopyTextureToBitmap(WebKit::WebGLId texture_id,
+ gfx::JavaBitmap& bitmap) OVERRIDE;
+ virtual bool CopyTextureToBitmap(WebKit::WebGLId texture_id,
+ const gfx::Rect& sub_rect,
gfx::JavaBitmap& bitmap) OVERRIDE;
// LayerTreeHostClient implementation.
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc
index 44d00fe..47056d5 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -166,7 +166,7 @@ bool RenderWidgetHostViewAndroid::PopulateBitmapWithContents(jobject jbitmap) {
return false;
helper->ReadbackTextureSync(texture,
- bitmap.size(),
+ gfx::Rect(bitmap.size()),
static_cast<unsigned char*> (bitmap.pixels()));
WebKit::WebGraphicsContext3D* context =
diff --git a/content/common/gpu/client/gl_helper.cc b/content/common/gpu/client/gl_helper.cc
index 8843695..d41c55a 100644
--- a/content/common/gpu/client/gl_helper.cc
+++ b/content/common/gpu/client/gl_helper.cc
@@ -268,7 +268,7 @@ class GLHelper::CopyTextureToImpl {
const base::Callback<void(bool)>& callback);
void ReadbackTextureSync(WebGLId texture,
- const gfx::Size& size,
+ const gfx::Rect& src_rect,
unsigned char* out);
WebKit::WebGLId CopyAndScaleTexture(WebGLId texture,
@@ -558,7 +558,7 @@ void GLHelper::CopyTextureToImpl::CropScaleReadbackAndCleanTexture(
}
void GLHelper::CopyTextureToImpl::ReadbackTextureSync(WebGLId texture,
- const gfx::Size& size,
+ const gfx::Rect& src_rect,
unsigned char* out) {
ScopedFramebuffer dst_framebuffer(context_, context_->createFramebuffer());
ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(
@@ -569,10 +569,10 @@ void GLHelper::CopyTextureToImpl::ReadbackTextureSync(WebGLId texture,
GL_TEXTURE_2D,
texture,
0);
- context_->readPixels(0,
- 0,
- size.width(),
- size.height(),
+ context_->readPixels(src_rect.x(),
+ src_rect.y(),
+ src_rect.width(),
+ src_rect.height(),
GL_RGBA,
GL_UNSIGNED_BYTE,
out);
@@ -740,11 +740,11 @@ void GLHelper::CropScaleReadbackAndCleanTexture(
}
void GLHelper::ReadbackTextureSync(WebKit::WebGLId texture,
- const gfx::Size& size,
+ const gfx::Rect& src_rect,
unsigned char* out) {
InitCopyTextToImpl();
copy_texture_to_impl_->ReadbackTextureSync(texture,
- size,
+ src_rect,
out);
}
diff --git a/content/common/gpu/client/gl_helper.h b/content/common/gpu/client/gl_helper.h
index c7f161b..22f4662 100644
--- a/content/common/gpu/client/gl_helper.h
+++ b/content/common/gpu/client/gl_helper.h
@@ -50,7 +50,7 @@ class GLHelper {
// GL_UNSIGNED_BYTE. This is a blocking call that calls glReadPixels on this
// current context.
void ReadbackTextureSync(WebKit::WebGLId texture,
- const gfx::Size& size,
+ const gfx::Rect& src_rect,
unsigned char* out);
// Creates a copy of the specified texture. |size| is the size of the texture.
diff --git a/content/public/browser/android/compositor.h b/content/public/browser/android/compositor.h
index d0f98c2..7cf5da5 100644
--- a/content/public/browser/android/compositor.h
+++ b/content/public/browser/android/compositor.h
@@ -97,7 +97,15 @@ class CONTENT_EXPORT Compositor {
// 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,
+ virtual bool CopyTextureToBitmap(WebKit::WebGLId texture_id,
+ gfx::JavaBitmap& bitmap) = 0;
+
+ // Grabs a copy of |texture_id| and saves it into |bitmap|. No scaling is
+ // done. |src_rect| allows the caller to specify which rect of |texture_id|
+ // to copy to |bitmap|. It needs to match the size of |bitmap|. Returns
+ // true if the |texture_id| was copied into |bitmap|, false if not.
+ virtual bool CopyTextureToBitmap(WebKit::WebGLId texture_id,
+ const gfx::Rect& src_rect,
gfx::JavaBitmap& bitmap) = 0;
protected:
Compositor() {}