summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorboliu <boliu@chromium.org>2016-03-23 16:50:10 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-23 23:52:15 +0000
commit7c1bd415bfbed8d80249a4e25788fbe967c97699 (patch)
treec32893695146f4e4b984f6e89b32bb93f9f90499
parenteb40ee9d48c11eda5e2ed2ace0b8507519efc5fc (diff)
downloadchromium_src-7c1bd415bfbed8d80249a4e25788fbe967c97699.zip
chromium_src-7c1bd415bfbed8d80249a4e25788fbe967c97699.tar.gz
chromium_src-7c1bd415bfbed8d80249a4e25788fbe967c97699.tar.bz2
sync compositor: Handle context loss
OutputSurface becomes a mutable part of SynchronousCompositorProxy. Proxy needes to make sure access to OutputSurface are null checked. And the Registry (ie SynchronousCompositorFilter) need to treat the OutputSurface part as an optional part of Proxy init. BUG=592744 Review URL: https://codereview.chromium.org/1773873002 Cr-Commit-Position: refs/heads/master@{#382978}
-rw-r--r--content/renderer/android/synchronous_compositor_filter.cc28
-rw-r--r--content/renderer/android/synchronous_compositor_output_surface.cc5
-rw-r--r--content/renderer/android/synchronous_compositor_output_surface.h1
-rw-r--r--content/renderer/android/synchronous_compositor_proxy.cc39
-rw-r--r--content/renderer/android/synchronous_compositor_proxy.h4
5 files changed, 46 insertions, 31 deletions
diff --git a/content/renderer/android/synchronous_compositor_filter.cc b/content/renderer/android/synchronous_compositor_filter.cc
index b01ce07..ae42cc3 100644
--- a/content/renderer/android/synchronous_compositor_filter.cc
+++ b/content/renderer/android/synchronous_compositor_filter.cc
@@ -4,6 +4,8 @@
#include "content/renderer/android/synchronous_compositor_filter.h"
+#include <utility>
+
#include "base/callback.h"
#include "base/stl_util.h"
#include "base/thread_task_runner_handle.h"
@@ -128,7 +130,11 @@ void SynchronousCompositorFilter::RegisterOutputSurface(
Entry& entry = entry_map_[routing_id];
DCHECK(!entry.output_surface);
entry.output_surface = output_surface;
- CheckIsReady(routing_id);
+
+ SynchronousCompositorProxy* proxy = FindProxy(routing_id);
+ if (proxy) {
+ proxy->SetOutputSurface(output_surface);
+ }
}
void SynchronousCompositorFilter::UnregisterOutputSurface(
@@ -140,8 +146,10 @@ void SynchronousCompositorFilter::UnregisterOutputSurface(
Entry& entry = entry_map_[routing_id];
DCHECK_EQ(output_surface, entry.output_surface);
- if (entry.IsReady())
- UnregisterObjects(routing_id);
+ SynchronousCompositorProxy* proxy = FindProxy(routing_id);
+ if (proxy) {
+ proxy->SetOutputSurface(nullptr);
+ }
entry.output_surface = nullptr;
RemoveEntryIfNeeded(routing_id);
}
@@ -178,11 +186,12 @@ void SynchronousCompositorFilter::CheckIsReady(int routing_id) {
Entry& entry = entry_map_[routing_id];
if (filter_ready_ && entry.IsReady()) {
DCHECK(!sync_compositor_map_.contains(routing_id));
- sync_compositor_map_.add(
- routing_id,
- make_scoped_ptr(new SynchronousCompositorProxy(
- routing_id, this, entry.output_surface, entry.begin_frame_source,
- entry.synchronous_input_handler_proxy, &input_handler_)));
+ scoped_ptr<SynchronousCompositorProxy> proxy(new SynchronousCompositorProxy(
+ routing_id, this, entry.begin_frame_source,
+ entry.synchronous_input_handler_proxy, &input_handler_));
+ if (entry.output_surface)
+ proxy->SetOutputSurface(entry.output_surface);
+ sync_compositor_map_.add(routing_id, std::move(proxy));
}
}
@@ -269,8 +278,7 @@ SynchronousCompositorFilter::Entry::Entry()
synchronous_input_handler_proxy(nullptr) {}
bool SynchronousCompositorFilter::Entry::IsReady() {
- return begin_frame_source && output_surface &&
- synchronous_input_handler_proxy;
+ return begin_frame_source && synchronous_input_handler_proxy;
}
} // namespace content
diff --git a/content/renderer/android/synchronous_compositor_output_surface.cc b/content/renderer/android/synchronous_compositor_output_surface.cc
index 5609735..567de40 100644
--- a/content/renderer/android/synchronous_compositor_output_surface.cc
+++ b/content/renderer/android/synchronous_compositor_output_surface.cc
@@ -98,11 +98,6 @@ void SynchronousCompositorOutputSurface::SetSyncClient(
sync_client_ = compositor;
}
-void SynchronousCompositorOutputSurface::DidLoseOutputSurface() {
- // Android WebView does not handle context loss.
- LOG(FATAL) << "Renderer compositor context loss";
-}
-
bool SynchronousCompositorOutputSurface::BindToClient(
cc::OutputSurfaceClient* surface_client) {
DCHECK(CalledOnValidThread());
diff --git a/content/renderer/android/synchronous_compositor_output_surface.h b/content/renderer/android/synchronous_compositor_output_surface.h
index d373146..97f4bf9 100644
--- a/content/renderer/android/synchronous_compositor_output_surface.h
+++ b/content/renderer/android/synchronous_compositor_output_surface.h
@@ -70,7 +70,6 @@ class SynchronousCompositorOutputSurface
void SetSyncClient(SynchronousCompositorOutputSurfaceClient* compositor);
// OutputSurface.
- void DidLoseOutputSurface() override;
bool BindToClient(cc::OutputSurfaceClient* surface_client) override;
void DetachFromClient() override;
void Reshape(const gfx::Size& size,
diff --git a/content/renderer/android/synchronous_compositor_proxy.cc b/content/renderer/android/synchronous_compositor_proxy.cc
index 820b577..4ecfdff 100644
--- a/content/renderer/android/synchronous_compositor_proxy.cc
+++ b/content/renderer/android/synchronous_compositor_proxy.cc
@@ -24,19 +24,18 @@ namespace content {
SynchronousCompositorProxy::SynchronousCompositorProxy(
int routing_id,
IPC::Sender* sender,
- SynchronousCompositorOutputSurface* output_surface,
SynchronousCompositorExternalBeginFrameSource* begin_frame_source,
ui::SynchronousInputHandlerProxy* input_handler_proxy,
InputHandlerManagerClient::Handler* handler)
: routing_id_(routing_id),
sender_(sender),
- output_surface_(output_surface),
begin_frame_source_(begin_frame_source),
input_handler_proxy_(input_handler_proxy),
input_handler_(handler),
use_in_process_zero_copy_software_draw_(
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSingleProcess)),
+ output_surface_(nullptr),
inside_receive_(false),
hardware_draw_reply_(nullptr),
software_draw_reply_(nullptr),
@@ -49,25 +48,36 @@ SynchronousCompositorProxy::SynchronousCompositorProxy(
need_invalidate_count_(0u),
need_begin_frame_(false),
did_activate_pending_tree_count_(0u) {
- DCHECK(output_surface_);
DCHECK(begin_frame_source_);
DCHECK(input_handler_proxy_);
DCHECK(input_handler_);
- output_surface_->SetSyncClient(this);
- output_surface_->SetTreeActivationCallback(
- base::Bind(&SynchronousCompositorProxy::DidActivatePendingTree,
- base::Unretained(this)));
begin_frame_source_->SetClient(this);
input_handler_proxy_->SetOnlySynchronouslyAnimateRootFlings(this);
}
SynchronousCompositorProxy::~SynchronousCompositorProxy() {
- output_surface_->SetSyncClient(nullptr);
- output_surface_->SetTreeActivationCallback(base::Closure());
+ SetOutputSurface(nullptr);
begin_frame_source_->SetClient(nullptr);
input_handler_proxy_->SetOnlySynchronouslyAnimateRootFlings(nullptr);
}
+void SynchronousCompositorProxy::SetOutputSurface(
+ SynchronousCompositorOutputSurface* output_surface) {
+ DCHECK_NE(output_surface_, output_surface);
+ if (output_surface_) {
+ output_surface_->SetSyncClient(nullptr);
+ output_surface_->SetTreeActivationCallback(base::Closure());
+ }
+ output_surface_ = output_surface;
+ if (output_surface_) {
+ output_surface_->SetSyncClient(this);
+ output_surface_->SetTreeActivationCallback(
+ base::Bind(&SynchronousCompositorProxy::DidActivatePendingTree,
+ base::Unretained(this)));
+ output_surface_->SetMemoryPolicy(bytes_limit_);
+ }
+}
+
void SynchronousCompositorProxy::SetNeedsSynchronousAnimateInput() {
need_animate_scroll_ = true;
Invalidate();
@@ -117,6 +127,7 @@ void SynchronousCompositorProxy::DidActivatePendingTree() {
}
void SynchronousCompositorProxy::DeliverMessages() {
+ DCHECK(output_surface_);
std::vector<scoped_ptr<IPC::Message>> messages;
output_surface_->GetMessagesToDeliver(&messages);
for (auto& msg : messages) {
@@ -206,7 +217,7 @@ void SynchronousCompositorProxy::DemandDrawHw(
inside_receive_ = true;
ProcessCommonParams(common_params);
- {
+ if (output_surface_) {
base::AutoReset<IPC::Message*> scoped_hardware_draw_reply(
&hardware_draw_reply_, reply_message);
output_surface_->DemandDrawHw(params.surface_size, params.transform,
@@ -302,7 +313,7 @@ void SynchronousCompositorProxy::DemandDrawSw(
DCHECK(!inside_receive_);
inside_receive_ = true;
ProcessCommonParams(common_params);
- {
+ if (output_surface_) {
base::AutoReset<IPC::Message*> scoped_software_draw_reply(
&software_draw_reply_, reply_message);
if (use_in_process_zero_copy_software_draw_) {
@@ -325,6 +336,7 @@ void SynchronousCompositorProxy::DemandDrawSw(
void SynchronousCompositorProxy::DoDemandDrawSw(
const SyncCompositorDemandDrawSwParams& params) {
+ DCHECK(output_surface_);
DCHECK(software_draw_shm_->zeroed);
software_draw_shm_->zeroed = false;
@@ -396,7 +408,8 @@ void SynchronousCompositorProxy::ProcessCommonParams(
const SyncCompositorCommonBrowserParams& common_params) {
if (bytes_limit_ != common_params.bytes_limit) {
bytes_limit_ = common_params.bytes_limit;
- output_surface_->SetMemoryPolicy(bytes_limit_);
+ if (output_surface_)
+ output_surface_->SetMemoryPolicy(bytes_limit_);
}
if (common_params.update_root_scroll_offset &&
total_scroll_offset_ != common_params.root_scroll_offset) {
@@ -406,7 +419,7 @@ void SynchronousCompositorProxy::ProcessCommonParams(
}
begin_frame_source_->SetBeginFrameSourcePaused(
common_params.begin_frame_source_paused);
- if (!common_params.ack.resources.empty()) {
+ if (output_surface_ && !common_params.ack.resources.empty()) {
output_surface_->ReturnResources(
common_params.output_surface_id_for_returned_resources,
common_params.ack);
diff --git a/content/renderer/android/synchronous_compositor_proxy.h b/content/renderer/android/synchronous_compositor_proxy.h
index a07e7d8..3bb4692 100644
--- a/content/renderer/android/synchronous_compositor_proxy.h
+++ b/content/renderer/android/synchronous_compositor_proxy.h
@@ -52,7 +52,6 @@ class SynchronousCompositorProxy
SynchronousCompositorProxy(
int routing_id,
IPC::Sender* sender,
- SynchronousCompositorOutputSurface* output_surface,
SynchronousCompositorExternalBeginFrameSource* begin_frame_source,
ui::SynchronousInputHandlerProxy* input_handler_proxy,
InputHandlerManagerClient::Handler* handler);
@@ -75,6 +74,7 @@ class SynchronousCompositorProxy
void SwapBuffers(uint32_t output_surface_id,
cc::CompositorFrame* frame) override;
+ void SetOutputSurface(SynchronousCompositorOutputSurface* output_surface);
void OnMessageReceived(const IPC::Message& message);
bool Send(IPC::Message* message);
void DidOverscroll(const DidOverscrollParams& did_overscroll_params);
@@ -125,11 +125,11 @@ class SynchronousCompositorProxy
const int routing_id_;
IPC::Sender* const sender_;
- SynchronousCompositorOutputSurface* const output_surface_;
SynchronousCompositorExternalBeginFrameSource* const begin_frame_source_;
ui::SynchronousInputHandlerProxy* const input_handler_proxy_;
InputHandlerManagerClient::Handler* const input_handler_;
const bool use_in_process_zero_copy_software_draw_;
+ SynchronousCompositorOutputSurface* output_surface_;
bool inside_receive_;
IPC::Message* hardware_draw_reply_;
IPC::Message* software_draw_reply_;