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

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

Issue 174323003: Expose locks for CopyFromCompositingSurface/CopyFromBackingStore API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments 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 dba444dff70b19c755109494fa7471bcc80f3263..94654b1e43801feb37915246713e6948a9860b2c 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -285,6 +285,9 @@ bool RenderWidgetHostViewAndroid::HasValidFrame() const {
if (texture_size_in_layer_.IsEmpty())
return false;
+ if (!frame_evictor_->HasFrame())
+ return false;
+
if (using_delegated_renderer_) {
if (!delegated_renderer_layer_.get())
return false;
@@ -375,18 +378,33 @@ bool RenderWidgetHostViewAndroid::IsShowing() {
return is_showing_ && content_view_core_;
}
-void RenderWidgetHostViewAndroid::LockResources() {
+void RenderWidgetHostViewAndroid::LockSurfaceForCopy() {
DCHECK(HasValidFrame());
DCHECK(host_);
- DCHECK(!host_->is_hidden());
+ DCHECK(frame_evictor_->HasFrame());
frame_evictor_->LockFrame();
}
-void RenderWidgetHostViewAndroid::UnlockResources() {
+void RenderWidgetHostViewAndroid::UnlockSurfaceForCopy() {
+ if (!frame_evictor_->HasFrame())
+ return;
+
+ size_t target_lock_count = is_showing_ ? 1 : 0;
+ DCHECK_GE(frame_evictor_->FrameLockCount(), target_lock_count);
+ if (frame_evictor_->FrameLockCount() == target_lock_count)
piman 2014/03/04 19:09:55 This feels iffy. If some other code starts talkin
powei 2014/03/04 20:49:22 Done.
+ return;
+
DCHECK(HasValidFrame());
frame_evictor_->UnlockFrame();
}
+void RenderWidgetHostViewAndroid::ReleaseLocksOnSurface() {
+ size_t target_lock_count = is_showing_ ? 1 : 0;
+ while (frame_evictor_->FrameLockCount() > target_lock_count ) {
+ UnlockSurfaceForCopy();
+ }
+}
+
gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const {
if (!content_view_core_)
return gfx::Rect(default_size_);
@@ -808,6 +826,18 @@ void RenderWidgetHostViewAndroid::OnSwapCompositorFrame(
DCHECK(frame->delegated_frame_data);
DCHECK(!frame->delegated_frame_data->render_pass_list.empty());
+ size_t target_lock_count = is_showing_ ? 1 : 0;
+ if (frame_evictor_->FrameLockCount() > target_lock_count) {
+ base::Closure ack_callback =
+ base::Bind(&RenderWidgetHostViewAndroid::SendDelegatedFrameAck,
+ weak_ptr_factory_.GetWeakPtr(),
+ output_surface_id);
+ if (host_->is_hidden())
+ ack_callback.Run();
+ else
+ ack_callbacks_.push(ack_callback);
+ return;
+ }
cc::RenderPass* root_pass =
frame->delegated_frame_data->render_pass_list.back();
texture_size_in_layer_ = root_pass->output_rect.size();
@@ -1260,6 +1290,9 @@ void RenderWidgetHostViewAndroid::SetContentViewCore(
if (content_view_core_ && !using_synchronous_compositor_)
content_view_core_->GetWindowAndroid()->RemoveObserver(this);
+ if (content_view_core != content_view_core_)
+ ReleaseLocksOnSurface();
+
content_view_core_ = content_view_core;
if (GetBrowserAccessibilityManager()) {
@@ -1293,6 +1326,7 @@ void RenderWidgetHostViewAndroid::OnDetachCompositor() {
}
void RenderWidgetHostViewAndroid::OnLostResources() {
+ ReleaseLocksOnSurface();
if (texture_layer_.get())
texture_layer_->SetIsDrawable(false);
if (delegated_renderer_layer_.get())

Powered by Google App Engine
This is Rietveld 408576698