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

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

Issue 12389061: Android: Add support for CompositorFrame swaps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d90c933774cebe2eaa5b4571d348403463de9edc..1514c5ac77e3378b2c97fbcc7bdd9fe016855769 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -10,6 +10,8 @@
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/utf_string_conversions.h"
+#include "cc/compositor_frame.h"
+#include "cc/compositor_frame_ack.h"
#include "cc/layer.h"
#include "cc/texture_layer.h"
#include "content/browser/android/content_view_core_impl.h"
@@ -35,6 +37,38 @@
namespace content {
+namespace {
+
+void InsertSyncPointAndAckForGpu(
+ int gpu_host_id, int route_id, const std::string& return_mailbox) {
+ uint32 sync_point =
+ ImageTransportFactoryAndroid::GetInstance()->InsertSyncPoint();
+ AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
+ ack_params.mailbox_name = return_mailbox;
+ ack_params.sync_point = sync_point;
+ RenderWidgetHostImpl::AcknowledgeBufferPresent(
+ route_id, gpu_host_id, ack_params);
+}
+
+void InsertSyncPointAndAckForCompositor(
+ int renderer_host_id,
+ int route_id,
+ const gpu::Mailbox& return_mailbox,
+ const gfx::Size return_size) {
+ cc::CompositorFrameAck ack;
+ ack.gl_frame_data.reset(new cc::GLFrameData());
+ if (!return_mailbox.IsZero()) {
+ ack.gl_frame_data->mailbox = return_mailbox;
+ ack.gl_frame_data->size = return_size;
+ ack.gl_frame_data->sync_point =
+ ImageTransportFactoryAndroid::GetInstance()->InsertSyncPoint();
+ }
+ RenderWidgetHostImpl::SendSwapCompositorFrameAck(
+ route_id, renderer_host_id, ack);
+}
+
+} // anonymous namespace
+
RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
RenderWidgetHostImpl* widget_host,
ContentViewCoreImpl* content_view_core)
@@ -442,35 +476,71 @@ void RenderWidgetHostViewAndroid::ShowDisambiguationPopup(
void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() {
}
+void RenderWidgetHostViewAndroid::OnSwapCompositorFrame(
+ const cc::CompositorFrame& frame) {
+ if (!frame.gl_frame_data || frame.gl_frame_data->mailbox.IsZero())
+ return;
+
+ base::Closure callback = base::Bind(&InsertSyncPointAndAckForCompositor,
+ host_->GetProcess()->GetID(),
+ host_->GetRoutingID(),
+ current_mailbox_,
+ texture_size_in_layer_);
+ ImageTransportFactoryAndroid::GetInstance()->WaitSyncPoint(
+ frame.gl_frame_data->sync_point);
+ BuffersSwapped(
+ frame.gl_frame_data->mailbox, frame.gl_frame_data->size, callback);
+
+}
+
void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped(
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
int gpu_host_id) {
- ImageTransportFactoryAndroid* factory =
- ImageTransportFactoryAndroid::GetInstance();
-
if (params.mailbox_name.empty())
return;
+ std::string return_mailbox;
+ if (!current_mailbox_.IsZero()) {
+ return_mailbox.assign(
+ reinterpret_cast<const char*>(current_mailbox_.name),
+ sizeof(current_mailbox_.name));
+ }
+
+ base::Closure callback = base::Bind(&InsertSyncPointAndAckForGpu,
+ gpu_host_id, params.route_id,
+ return_mailbox);
+
+ gpu::Mailbox mailbox;
+ std::copy(params.mailbox_name.data(),
+ params.mailbox_name.data() + params.mailbox_name.length(),
+ reinterpret_cast<char*>(mailbox.name));
+
+ BuffersSwapped(mailbox, params.size, callback);
+}
+
+void RenderWidgetHostViewAndroid::BuffersSwapped(
+ const gpu::Mailbox& mailbox,
+ const gfx::Size size,
+ const base::Closure& ack_callback) {
+ ImageTransportFactoryAndroid* factory =
+ ImageTransportFactoryAndroid::GetInstance();
+
// TODO(sievers): When running the impl thread in the browser we
// need to delay the ACK until after commit and use more than a single
// texture.
DCHECK(!CompositorImpl::IsThreadingEnabled());
if (texture_id_in_layer_) {
- DCHECK(!current_mailbox_name_.empty());
+ DCHECK(!current_mailbox_.IsZero());
ImageTransportFactoryAndroid::GetInstance()->ReleaseTexture(
- texture_id_in_layer_,
- reinterpret_cast<const signed char*>(
- current_mailbox_name_.data()));
+ texture_id_in_layer_, current_mailbox_.name);
} else {
texture_id_in_layer_ = factory->CreateTexture();
texture_layer_->setTextureId(texture_id_in_layer_);
}
ImageTransportFactoryAndroid::GetInstance()->AcquireTexture(
- texture_id_in_layer_,
- reinterpret_cast<const signed char*>(
- params.mailbox_name.data()));
+ texture_id_in_layer_, mailbox.name);
// We need to tell ContentViewCore about the new frame before calling
// setNeedsDisplay() below so that it has the needed information schedule the
@@ -479,18 +549,10 @@ void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped(
content_view_core_->DidProduceRendererFrame();
texture_layer_->setNeedsDisplay();
- texture_layer_->setBounds(params.size);
- texture_size_in_layer_ = params.size;
-
- uint32 sync_point =
- ImageTransportFactoryAndroid::GetInstance()->InsertSyncPoint();
-
- AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
- ack_params.mailbox_name = current_mailbox_name_;
- ack_params.sync_point = sync_point;
- RenderWidgetHostImpl::AcknowledgeBufferPresent(
- params.route_id, gpu_host_id, ack_params);
- current_mailbox_name_ = params.mailbox_name;
+ texture_layer_->setBounds(size);
+ texture_size_in_layer_ = size;
+ current_mailbox_ = mailbox;
+ ack_callback.Run();
}
void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer(
@@ -510,7 +572,7 @@ void RenderWidgetHostViewAndroid::AcceleratedSurfaceRelease() {
ImageTransportFactoryAndroid::GetInstance()->DeleteTexture(
texture_id_in_layer_);
texture_id_in_layer_ = 0;
- current_mailbox_name_.clear();
+ current_mailbox_ = gpu::Mailbox();
}
}
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698