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

Side by Side Diff: services/surfaces/surfaces_impl.cc

Issue 920063002: Fix surface crash. (Closed) Base URL: https://github.com/domokit/mojo.git@background_crash_takes3
Patch Set: Delete display instead of resetting the id. Created 5 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 unified diff | Download patch
« no previous file with comments | « services/surfaces/surfaces_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "services/surfaces/surfaces_impl.h" 5 #include "services/surfaces/surfaces_impl.h"
6 6
7 #include "base/trace_event/trace_event.h" 7 #include "base/trace_event/trace_event.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/resources/returned_resource.h" 9 #include "cc/resources/returned_resource.h"
10 #include "cc/surfaces/display.h" 10 #include "cc/surfaces/display.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 const mojo::Closure& callback) { 63 const mojo::Closure& callback) {
64 TRACE_EVENT0("mojo", "SurfacesImpl::SubmitFrame"); 64 TRACE_EVENT0("mojo", "SurfacesImpl::SubmitFrame");
65 factory_.SubmitFrame(QualifyIdentifier(local_id), 65 factory_.SubmitFrame(QualifyIdentifier(local_id),
66 frame.To<scoped_ptr<cc::CompositorFrame>>(), 66 frame.To<scoped_ptr<cc::CompositorFrame>>(),
67 base::Bind(&CallCallback, callback)); 67 base::Bind(&CallCallback, callback));
68 client_->FrameSubmitted(); 68 client_->FrameSubmitted();
69 } 69 }
70 70
71 void SurfacesImpl::DestroySurface(uint32_t local_id) { 71 void SurfacesImpl::DestroySurface(uint32_t local_id) {
72 factory_.Destroy(QualifyIdentifier(local_id)); 72 factory_.Destroy(QualifyIdentifier(local_id));
73 if (local_id == displayed_surface_) {
74 displayed_surface_ = 0;
75 client_->OnDisplayBeingDestroyed(display_.get());
76 display_.reset();
77 }
73 } 78 }
74 79
75 void SurfacesImpl::CreateGLES2BoundSurface( 80 void SurfacesImpl::CreateGLES2BoundSurface(
76 mojo::CommandBufferPtr gles2_client, 81 mojo::CommandBufferPtr gles2_client,
77 uint32_t local_id, 82 uint32_t local_id,
78 mojo::SizePtr size, 83 mojo::SizePtr size,
79 mojo::InterfaceRequest<mojo::ViewportParameterListener> listener_request) { 84 mojo::InterfaceRequest<mojo::ViewportParameterListener> listener_request) {
80 command_buffer_handle_ = gles2_client.PassMessagePipe(); 85 command_buffer_handle_ = gles2_client.PassMessagePipe();
81 86
82 if (!display_) { 87 if (!display_) {
83 cc::RendererSettings settings; 88 cc::RendererSettings settings;
84 display_.reset(new cc::Display(this, manager_, nullptr, nullptr, settings)); 89 display_.reset(new cc::Display(this, manager_, nullptr, nullptr, settings));
85 client_->SetDisplay(display_.get()); 90 client_->SetDisplay(display_.get());
86 display_->Initialize(make_scoped_ptr(new mojo::DirectOutputSurface( 91 display_->Initialize(make_scoped_ptr(new mojo::DirectOutputSurface(
87 new mojo::ContextProviderMojo(command_buffer_handle_.Pass())))); 92 new mojo::ContextProviderMojo(command_buffer_handle_.Pass()))));
88 } 93 }
94 displayed_surface_ = local_id;
89 cc::SurfaceId cc_id = QualifyIdentifier(local_id); 95 cc::SurfaceId cc_id = QualifyIdentifier(local_id);
90 factory_.Create(cc_id); 96 factory_.Create(cc_id);
91 display_->SetSurfaceId(cc_id, 1.f); 97 display_->SetSurfaceId(cc_id, 1.f);
92 display_->Resize(size.To<gfx::Size>()); 98 display_->Resize(size.To<gfx::Size>());
93 parameter_listeners_.AddBinding(this, listener_request.Pass()); 99 parameter_listeners_.AddBinding(this, listener_request.Pass());
94 } 100 }
95 101
96 void SurfacesImpl::ReturnResources(const cc::ReturnedResourceArray& resources) { 102 void SurfacesImpl::ReturnResources(const cc::ReturnedResourceArray& resources) {
97 if (resources.empty() || !returner_) 103 if (resources.empty() || !returner_)
98 return; 104 return;
(...skipping 30 matching lines...) Expand all
129 base::TimeDelta::FromInternalValue(interval)); 135 base::TimeDelta::FromInternalValue(interval));
130 } 136 }
131 137
132 SurfacesImpl::SurfacesImpl(cc::SurfaceManager* manager, 138 SurfacesImpl::SurfacesImpl(cc::SurfaceManager* manager,
133 uint32_t id_namespace, 139 uint32_t id_namespace,
134 Client* client) 140 Client* client)
135 : manager_(manager), 141 : manager_(manager),
136 factory_(manager, this), 142 factory_(manager, this),
137 id_namespace_(id_namespace), 143 id_namespace_(id_namespace),
138 client_(client), 144 client_(client),
145 displayed_surface_(0),
139 binding_(this) { 146 binding_(this) {
140 } 147 }
141 148
142 cc::SurfaceId SurfacesImpl::QualifyIdentifier(uint32_t local_id) { 149 cc::SurfaceId SurfacesImpl::QualifyIdentifier(uint32_t local_id) {
143 return cc::SurfaceId(static_cast<uint64_t>(id_namespace_) << 32 | local_id); 150 return cc::SurfaceId(static_cast<uint64_t>(id_namespace_) << 32 | local_id);
144 } 151 }
145 152
146 } // namespace mojo 153 } // namespace mojo
OLDNEW
« no previous file with comments | « services/surfaces/surfaces_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698