Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: components/mus/public/cpp/lib/output_surface.cc

Issue 2092843002: Implement CompositorFrame Struct Traits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed dcheng's comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/mus/public/cpp/BUILD.gn ('k') | components/mus/public/cpp/lib/window_surface.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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/mus/public/cpp/output_surface.h" 5 #include "components/mus/public/cpp/output_surface.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/output/compositor_frame_ack.h" 9 #include "cc/output/compositor_frame_ack.h"
10 #include "cc/output/output_surface_client.h" 10 #include "cc/output/output_surface_client.h"
11 #include "components/mus/public/cpp/surfaces/surfaces_type_converters.h"
12 #include "components/mus/public/cpp/window_surface.h" 11 #include "components/mus/public/cpp/window_surface.h"
13 12
14 namespace mus { 13 namespace mus {
15 14
16 OutputSurface::OutputSurface( 15 OutputSurface::OutputSurface(
17 const scoped_refptr<cc::ContextProvider>& context_provider, 16 const scoped_refptr<cc::ContextProvider>& context_provider,
18 std::unique_ptr<mus::WindowSurface> surface) 17 std::unique_ptr<mus::WindowSurface> surface)
19 : cc::OutputSurface(context_provider, nullptr, nullptr), 18 : cc::OutputSurface(context_provider, nullptr, nullptr),
20 surface_(std::move(surface)) { 19 surface_(std::move(surface)) {
21 capabilities_.delegated_rendering = true; 20 capabilities_.delegated_rendering = true;
(...skipping 23 matching lines...) Expand all
45 return 0; 44 return 0;
46 } 45 }
47 46
48 void OutputSurface::SwapBuffers(cc::CompositorFrame frame) { 47 void OutputSurface::SwapBuffers(cc::CompositorFrame frame) {
49 // TODO(fsamuel, rjkroege): We should probably throttle compositor frames. 48 // TODO(fsamuel, rjkroege): We should probably throttle compositor frames.
50 client_->DidSwapBuffers(); 49 client_->DidSwapBuffers();
51 // OutputSurface owns WindowSurface, and so if OutputSurface is 50 // OutputSurface owns WindowSurface, and so if OutputSurface is
52 // destroyed then SubmitCompositorFrame's callback will never get called. 51 // destroyed then SubmitCompositorFrame's callback will never get called.
53 // Thus, base::Unretained is safe here. 52 // Thus, base::Unretained is safe here.
54 surface_->SubmitCompositorFrame( 53 surface_->SubmitCompositorFrame(
55 cc::mojom::CompositorFrame::From(frame), 54 std::move(frame),
56 base::Bind(&OutputSurface::SwapBuffersComplete, base::Unretained(this))); 55 base::Bind(&OutputSurface::SwapBuffersComplete, base::Unretained(this)));
57 } 56 }
58 57
59 void OutputSurface::OnResourcesReturned( 58 void OutputSurface::OnResourcesReturned(
60 mus::WindowSurface* surface, 59 mus::WindowSurface* surface,
61 mojo::Array<cc::ReturnedResource> resources) { 60 mojo::Array<cc::ReturnedResource> resources) {
62 cc::CompositorFrameAck cfa; 61 cc::CompositorFrameAck cfa;
63 cfa.resources = resources.To<cc::ReturnedResourceArray>(); 62 cfa.resources = resources.To<cc::ReturnedResourceArray>();
64 ReclaimResources(&cfa); 63 ReclaimResources(&cfa);
65 } 64 }
66 65
67 void OutputSurface::SwapBuffersComplete() { 66 void OutputSurface::SwapBuffersComplete() {
68 client_->DidSwapBuffersComplete(); 67 client_->DidSwapBuffersComplete();
69 } 68 }
70 69
71 } // namespace mus 70 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/public/cpp/BUILD.gn ('k') | components/mus/public/cpp/lib/window_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698