OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/surfaces/display_impl.h" | 5 #include "components/surfaces/display_impl.h" |
6 | 6 |
7 #include "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
8 #include "cc/surfaces/display.h" | 8 #include "cc/surfaces/display.h" |
9 #include "components/surfaces/surfaces_context_provider.h" | 9 #include "components/surfaces/surfaces_context_provider.h" |
10 #include "components/surfaces/surfaces_output_surface.h" | 10 #include "components/surfaces/surfaces_output_surface.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 factory_.Create(cc_id_); | 52 factory_.Create(cc_id_); |
53 display_->SetSurfaceId(cc_id_, 1.f); | 53 display_->SetSurfaceId(cc_id_, 1.f); |
54 if (pending_frame_) | 54 if (pending_frame_) |
55 Draw(); | 55 Draw(); |
56 } | 56 } |
57 | 57 |
58 DisplayImpl::~DisplayImpl() { | 58 DisplayImpl::~DisplayImpl() { |
59 if (display_) { | 59 if (display_) { |
60 factory_.Destroy(cc_id_); | 60 factory_.Destroy(cc_id_); |
61 scheduler_->RemoveDisplay(display_.get()); | 61 scheduler_->RemoveDisplay(display_.get()); |
| 62 // By deleting the object after display_ is reset, OutputSurfaceLost can |
| 63 // know not to do anything (which would result in double delete). |
| 64 delete display_.release(); |
62 } | 65 } |
63 } | 66 } |
64 | 67 |
65 void DisplayImpl::SubmitFrame(mojo::FramePtr frame, | 68 void DisplayImpl::SubmitFrame(mojo::FramePtr frame, |
66 const SubmitFrameCallback& callback) { | 69 const SubmitFrameCallback& callback) { |
67 DCHECK(pending_callback_.is_null()); | 70 DCHECK(pending_callback_.is_null()); |
68 pending_frame_ = frame.Pass(); | 71 pending_frame_ = frame.Pass(); |
69 pending_callback_ = callback; | 72 pending_callback_ = callback; |
70 if (display_) | 73 if (display_) |
71 Draw(); | 74 Draw(); |
(...skipping 17 matching lines...) Expand all Loading... |
89 } | 92 } |
90 | 93 |
91 void DisplayImpl::DidSwapBuffersComplete() { | 94 void DisplayImpl::DidSwapBuffersComplete() { |
92 } | 95 } |
93 | 96 |
94 void DisplayImpl::CommitVSyncParameters(base::TimeTicks timebase, | 97 void DisplayImpl::CommitVSyncParameters(base::TimeTicks timebase, |
95 base::TimeDelta interval) { | 98 base::TimeDelta interval) { |
96 } | 99 } |
97 | 100 |
98 void DisplayImpl::OutputSurfaceLost() { | 101 void DisplayImpl::OutputSurfaceLost() { |
| 102 if (!display_) // Shutdown case |
| 103 return; |
| 104 |
99 // If our OutputSurface is lost we can't draw until we get a new one. For now, | 105 // If our OutputSurface is lost we can't draw until we get a new one. For now, |
100 // destroy the display and create a new one when our ContextProvider provides | 106 // destroy the display and create a new one when our ContextProvider provides |
101 // a new one. | 107 // a new one. |
102 // TODO: This is more violent than necessary - we could simply remove this | 108 // TODO: This is more violent than necessary - we could simply remove this |
103 // display from the scheduler's set and pass a new context in to the | 109 // display from the scheduler's set and pass a new context in to the |
104 // OutputSurface. It should be able to reinitialize properly. | 110 // OutputSurface. It should be able to reinitialize properly. |
105 scheduler_->RemoveDisplay(display_.get()); | 111 scheduler_->RemoveDisplay(display_.get()); |
106 display_.reset(); | 112 display_.reset(); |
107 factory_.Destroy(cc_id_); | 113 factory_.Destroy(cc_id_); |
108 viewport_param_binding_.Close(); | 114 viewport_param_binding_.Close(); |
(...skipping 19 matching lines...) Expand all Loading... |
128 DCHECK(returner_); | 134 DCHECK(returner_); |
129 | 135 |
130 mojo::Array<mojo::ReturnedResourcePtr> ret(resources.size()); | 136 mojo::Array<mojo::ReturnedResourcePtr> ret(resources.size()); |
131 for (size_t i = 0; i < resources.size(); ++i) { | 137 for (size_t i = 0; i < resources.size(); ++i) { |
132 ret[i] = mojo::ReturnedResource::From(resources[i]); | 138 ret[i] = mojo::ReturnedResource::From(resources[i]); |
133 } | 139 } |
134 returner_->ReturnResources(ret.Pass()); | 140 returner_->ReturnResources(ret.Pass()); |
135 } | 141 } |
136 | 142 |
137 } // namespace surfaces | 143 } // namespace surfaces |
OLD | NEW |