| 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 "mojo/services/surfaces/display_impl.h" | 5 #include "mojo/services/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 "mojo/converters/geometry/geometry_type_converters.h" | 9 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 10 #include "mojo/converters/surfaces/surfaces_type_converters.h" | 10 #include "mojo/converters/surfaces/surfaces_type_converters.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 viewport_parameter_listener.Pass(), | 39 viewport_parameter_listener.Pass(), |
| 40 base::Bind(&DisplayImpl::OnContextCreated, base::Unretained(this))); | 40 base::Bind(&DisplayImpl::OnContextCreated, base::Unretained(this))); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void DisplayImpl::OnContextCreated(mojo::CommandBufferPtr gles2_client) { | 43 void DisplayImpl::OnContextCreated(mojo::CommandBufferPtr gles2_client) { |
| 44 DCHECK(!display_); | 44 DCHECK(!display_); |
| 45 | 45 |
| 46 cc::RendererSettings settings; | 46 cc::RendererSettings settings; |
| 47 display_.reset(new cc::Display(this, manager_, nullptr, nullptr, settings)); | 47 display_.reset(new cc::Display(this, manager_, nullptr, nullptr, settings)); |
| 48 scheduler_->AddDisplay(display_.get()); | 48 scheduler_->AddDisplay(display_.get()); |
| 49 | |
| 50 // TODO(brianderson): Reconcile with SurfacesScheduler crbug.com/476676 | |
| 51 cc::DisplayScheduler* null_display_scheduler = nullptr; | |
| 52 display_->Initialize(make_scoped_ptr(new mojo::DirectOutputSurface( | 49 display_->Initialize(make_scoped_ptr(new mojo::DirectOutputSurface( |
| 53 new mojo::ContextProviderMojo(gles2_client.PassMessagePipe()))), | 50 new mojo::ContextProviderMojo(gles2_client.PassMessagePipe())))); |
| 54 null_display_scheduler); | |
| 55 | 51 |
| 56 factory_.Create(cc_id_); | 52 factory_.Create(cc_id_); |
| 57 display_->SetSurfaceId(cc_id_, 1.f); | 53 display_->SetSurfaceId(cc_id_, 1.f); |
| 58 if (pending_frame_) | 54 if (pending_frame_) |
| 59 Draw(); | 55 Draw(); |
| 60 } | 56 } |
| 61 | 57 |
| 62 DisplayImpl::~DisplayImpl() { | 58 DisplayImpl::~DisplayImpl() { |
| 63 if (display_) { | 59 if (display_) { |
| 64 factory_.Destroy(cc_id_); | 60 factory_.Destroy(cc_id_); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 79 gfx::Size frame_size = | 75 gfx::Size frame_size = |
| 80 pending_frame_->passes[0]->output_rect.To<gfx::Rect>().size(); | 76 pending_frame_->passes[0]->output_rect.To<gfx::Rect>().size(); |
| 81 display_->Resize(frame_size); | 77 display_->Resize(frame_size); |
| 82 factory_.SubmitFrame(cc_id_, | 78 factory_.SubmitFrame(cc_id_, |
| 83 pending_frame_.To<scoped_ptr<cc::CompositorFrame>>(), | 79 pending_frame_.To<scoped_ptr<cc::CompositorFrame>>(), |
| 84 base::Bind(&CallCallback, pending_callback_)); | 80 base::Bind(&CallCallback, pending_callback_)); |
| 85 scheduler_->SetNeedsDraw(); | 81 scheduler_->SetNeedsDraw(); |
| 86 pending_callback_.reset(); | 82 pending_callback_.reset(); |
| 87 } | 83 } |
| 88 | 84 |
| 85 void DisplayImpl::DisplayDamaged() { |
| 86 } |
| 87 |
| 88 void DisplayImpl::DidSwapBuffers() { |
| 89 } |
| 90 |
| 91 void DisplayImpl::DidSwapBuffersComplete() { |
| 92 } |
| 93 |
| 89 void DisplayImpl::CommitVSyncParameters(base::TimeTicks timebase, | 94 void DisplayImpl::CommitVSyncParameters(base::TimeTicks timebase, |
| 90 base::TimeDelta interval) { | 95 base::TimeDelta interval) { |
| 91 } | 96 } |
| 92 | 97 |
| 93 void DisplayImpl::OutputSurfaceLost() { | 98 void DisplayImpl::OutputSurfaceLost() { |
| 94 // If our OutputSurface is lost we can't draw until we get a new one. For now, | 99 // If our OutputSurface is lost we can't draw until we get a new one. For now, |
| 95 // destroy the display and create a new one when our ContextProvider provides | 100 // destroy the display and create a new one when our ContextProvider provides |
| 96 // a new one. | 101 // a new one. |
| 97 // TODO: This is more violent than necessary - we could simply remove this | 102 // TODO: This is more violent than necessary - we could simply remove this |
| 98 // display from the scheduler's set and pass a new context in to the | 103 // display from the scheduler's set and pass a new context in to the |
| (...skipping 24 matching lines...) Expand all Loading... |
| 123 DCHECK(returner_); | 128 DCHECK(returner_); |
| 124 | 129 |
| 125 mojo::Array<mojo::ReturnedResourcePtr> ret(resources.size()); | 130 mojo::Array<mojo::ReturnedResourcePtr> ret(resources.size()); |
| 126 for (size_t i = 0; i < resources.size(); ++i) { | 131 for (size_t i = 0; i < resources.size(); ++i) { |
| 127 ret[i] = mojo::ReturnedResource::From(resources[i]); | 132 ret[i] = mojo::ReturnedResource::From(resources[i]); |
| 128 } | 133 } |
| 129 returner_->ReturnResources(ret.Pass()); | 134 returner_->ReturnResources(ret.Pass()); |
| 130 } | 135 } |
| 131 | 136 |
| 132 } // namespace surfaces | 137 } // namespace surfaces |
| OLD | NEW |