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