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