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

Unified Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 173023005: Adds support for capturing a sub rect of the compositing surface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to reland Created 6 years, 10 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: content/browser/renderer_host/render_widget_host_view_android.cc
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 8db7f7caa48804b9cc6d76f67f82f3f58d2da5a0..7f7f82f0ed62f9a865dde8e1a706fb4a963d4909 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -254,6 +254,7 @@ void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) {
void RenderWidgetHostViewAndroid::GetScaledContentBitmap(
float scale,
SkBitmap::Config bitmap_config,
+ gfx::Rect src_subrect,
const base::Callback<void(bool, const SkBitmap&)>& result_callback) {
if (!IsSurfaceAvailableForCopy()) {
result_callback.Run(false, SkBitmap());
@@ -261,7 +262,10 @@ void RenderWidgetHostViewAndroid::GetScaledContentBitmap(
}
gfx::Size bounds = layer_->bounds();
- gfx::Rect src_subrect(bounds);
+ if (src_subrect.IsEmpty())
+ src_subrect = gfx::Rect(bounds);
+ DCHECK_LE(src_subrect.width() + src_subrect.x(), bounds.width());
+ DCHECK_LE(src_subrect.height() + src_subrect.y(), bounds.height());
const gfx::Display& display =
gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
float device_scale_factor = display.device_scale_factor();
@@ -272,40 +276,6 @@ void RenderWidgetHostViewAndroid::GetScaledContentBitmap(
src_subrect, dst_size, result_callback, bitmap_config);
}
-bool RenderWidgetHostViewAndroid::PopulateBitmapWithContents(jobject jbitmap) {
- if (!CompositorImpl::IsInitialized() ||
- texture_id_in_layer_ == 0 ||
- texture_size_in_layer_.IsEmpty())
- return false;
-
- gfx::JavaBitmap bitmap(jbitmap);
-
- // TODO(dtrainor): Eventually add support for multiple formats here.
- DCHECK(bitmap.format() == ANDROID_BITMAP_FORMAT_RGBA_8888);
-
- GLHelper* helper = ImageTransportFactoryAndroid::GetInstance()->GetGLHelper();
-
- GLuint texture = helper->CopyAndScaleTexture(
- texture_id_in_layer_,
- texture_size_in_layer_,
- bitmap.size(),
- true,
- GLHelper::SCALER_QUALITY_FAST);
- if (texture == 0u)
- return false;
-
- helper->ReadbackTextureSync(texture,
- gfx::Rect(bitmap.size()),
- static_cast<unsigned char*> (bitmap.pixels()),
- SkBitmap::kARGB_8888_Config);
-
- gpu::gles2::GLES2Interface* gl =
- ImageTransportFactoryAndroid::GetInstance()->GetContextGL();
- gl->DeleteTextures(1, &texture);
-
- return true;
-}
-
bool RenderWidgetHostViewAndroid::HasValidFrame() const {
if (!content_view_core_)
return false;

Powered by Google App Engine
This is Rietveld 408576698