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

Unified Diff: blimp/client/core/compositor/blimp_compositor.cc

Issue 2481213003: Make SurfaceFactory lifetime match frame_sink_id_ registration in BlimpCompositor (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/client/core/compositor/blimp_compositor.cc
diff --git a/blimp/client/core/compositor/blimp_compositor.cc b/blimp/client/core/compositor/blimp_compositor.cc
index 4b94dbcfab23b67609f7b84d2dd4466f1e8ebbe5..649c7546ebbd6f6042abada4ca3abed1e4c8c5fc 100644
--- a/blimp/client/core/compositor/blimp_compositor.cc
+++ b/blimp/client/core/compositor/blimp_compositor.cc
@@ -149,6 +149,8 @@ BlimpCompositor::BlimpCompositor(
void BlimpCompositor::Initialize() {
surface_id_allocator_ = base::MakeUnique<cc::SurfaceIdAllocator>();
GetEmbedderDeps()->GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_);
+ surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(
+ frame_sink_id_, GetEmbedderDeps()->GetSurfaceManager(), this);
host_ = CreateLayerTreeHost();
if (use_threaded_layer_tree_host_) {
@@ -184,7 +186,7 @@ void BlimpCompositor::RequestCopyOfOutput(
std::unique_ptr<cc::CopyOutputRequest> copy_request,
bool flush_pending_update) {
// If we don't have a FrameSink, fail right away.
- if (!surface_factory_)
+ if (!proxy_client_)
piman 2016/11/07 22:31:38 Here and other places: even though proxy_client_ i
Khushal 2016/11/08 00:17:22 Won't be able to de-reference the weak ptr here si
return;
if (!use_threaded_layer_tree_host_) {
@@ -255,7 +257,7 @@ void BlimpCompositor::ApplyViewportDeltas(
}
void BlimpCompositor::RequestNewCompositorFrameSink() {
- DCHECK(!surface_factory_);
+ DCHECK(!proxy_client_);
DCHECK(!compositor_frame_sink_request_pending_);
compositor_frame_sink_request_pending_ = true;
@@ -278,9 +280,10 @@ void BlimpCompositor::DidCommitAndDrawFrame() {
for (auto it = pending_commit_trackers_.begin();
it != pending_commit_trackers_.end();) {
if (--it->first == 0) {
- if (surface_factory_)
+ if (proxy_client_) {
surface_factory_->RequestCopyOfSurface(local_frame_id_,
std::move(it->second));
+ }
it = pending_commit_trackers_.erase(it);
} else {
++it;
@@ -371,8 +374,8 @@ const base::WeakPtr<cc::InputHandler>& BlimpCompositor::GetInputHandler() {
void BlimpCompositor::OnContextProvidersCreated(
const scoped_refptr<cc::ContextProvider>& compositor_context_provider,
const scoped_refptr<cc::ContextProvider>& worker_context_provider) {
- DCHECK(!surface_factory_) << "Any connection to the old CompositorFrameSink "
- "should have been destroyed";
+ DCHECK(!proxy_client_) << "Any connection to the old CompositorFrameSink "
+ "should have been destroyed";
// Make sure we still have a host and we're still expecting a
// CompositorFrameSink. This can happen if the host dies while the request is
@@ -400,16 +403,14 @@ void BlimpCompositor::OnContextProvidersCreated(
void BlimpCompositor::BindToProxyClient(
base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client) {
DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(!surface_factory_);
+ DCHECK(!proxy_client_);
proxy_client_ = proxy_client;
- surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(
- frame_sink_id_, GetEmbedderDeps()->GetSurfaceManager(), this);
}
void BlimpCompositor::SubmitCompositorFrame(cc::CompositorFrame frame) {
DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(surface_factory_);
+ DCHECK(proxy_client_);
cc::RenderPass* root_pass = frame.render_pass_list.back().get();
gfx::Size surface_size = root_pass->output_rect.size();
@@ -451,7 +452,7 @@ void BlimpCompositor::SubmitCompositorFrame(cc::CompositorFrame frame) {
}
void BlimpCompositor::SubmitCompositorFrameAck() {
- DCHECK(surface_factory_);
+ DCHECK(proxy_client_);
compositor_dependencies_->GetCompositorTaskRunner()->PostTask(
FROM_HERE,
base::Bind(&BlimpCompositorFrameSinkProxyClient::SubmitCompositorFrameAck,
@@ -465,16 +466,16 @@ void BlimpCompositor::MakeCopyRequestOnNextSwap(
void BlimpCompositor::UnbindProxyClient() {
DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(surface_factory_);
+ DCHECK(proxy_client_);
DestroyDelegatedContent();
- surface_factory_.reset();
+ surface_factory_->Reset();
proxy_client_ = nullptr;
}
void BlimpCompositor::ReturnResources(
const cc::ReturnedResourceArray& resources) {
- DCHECK(surface_factory_);
+ DCHECK(proxy_client_);
compositor_dependencies_->GetCompositorTaskRunner()->PostTask(
FROM_HERE,
base::Bind(
@@ -560,7 +561,6 @@ void BlimpCompositor::DestroyLayerTreeHost() {
// Tear down the output surface connection with the old LayerTreeHost
// instance.
DestroyDelegatedContent();
- surface_factory_.reset();
piman 2016/11/07 22:31:38 I believe there's no need to do an explicit Reset
Khushal 2016/11/08 00:17:22 Makes sense. Thanks for the clean up!
// Destroy the old LayerTreeHost state.
host_.reset();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698