Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / mojo / cc / output_surface_mojo.cc
blob68803baebb6ecc34329ec2abc84285a9dc2544d0
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
3 // found in the LICENSE file.
5 #include "mojo/cc/output_surface_mojo.h"
7 #include "base/bind.h"
8 #include "cc/output/compositor_frame.h"
9 #include "cc/output/compositor_frame_ack.h"
10 #include "cc/output/output_surface_client.h"
11 #include "components/mus/public/cpp/view_surface.h"
12 #include "mojo/converters/surfaces/surfaces_type_converters.h"
14 namespace mojo {
16 OutputSurfaceMojo::OutputSurfaceMojo(
17 const scoped_refptr<cc::ContextProvider>& context_provider,
18 scoped_ptr<mus::ViewSurface> surface)
19 : cc::OutputSurface(context_provider), surface_(surface.Pass()) {
20 capabilities_.delegated_rendering = true;
21 capabilities_.max_frames_pending = 1;
24 OutputSurfaceMojo::~OutputSurfaceMojo() {
27 bool OutputSurfaceMojo::BindToClient(cc::OutputSurfaceClient* client) {
28 surface_->BindToThread();
29 surface_->set_client(this);
30 return cc::OutputSurface::BindToClient(client);
33 void OutputSurfaceMojo::SwapBuffers(cc::CompositorFrame* frame) {
34 // TODO(fsamuel, rjkroege): We should probably throttle compositor frames.
35 surface_->SubmitCompositorFrame(mojo::CompositorFrame::From(*frame));
37 client_->DidSwapBuffers();
38 client_->DidSwapBuffersComplete();
41 void OutputSurfaceMojo::OnResourcesReturned(
42 mus::ViewSurface* surface,
43 mojo::Array<mojo::ReturnedResourcePtr> resources) {
44 cc::CompositorFrameAck cfa;
45 cfa.resources = resources.To<cc::ReturnedResourceArray>();
46 ReclaimResources(&cfa);
49 } // namespace mojo