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

Side by Side Diff: mojo/cc/output_surface_mojo.cc

Issue 826423008: Use local ids for Surfaces APIs that can only apply to local surfaces (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
(Empty)
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.
4
5 #include "mojo/cc/output_surface_mojo.h"
6
7 #include "cc/output/compositor_frame.h"
8 #include "cc/output/output_surface_client.h"
9 #include "mojo/converters/geometry/geometry_type_converters.h"
10 #include "mojo/converters/surfaces/surfaces_type_converters.h"
11
12 namespace mojo {
13
14 OutputSurfaceMojo::OutputSurfaceMojo(
15 OutputSurfaceMojoClient* client,
16 const scoped_refptr<cc::ContextProvider>& context_provider,
17 SurfacePtr surface,
18 uint32_t id_namespace)
19 : cc::OutputSurface(context_provider),
20 output_surface_mojo_client_(client),
21 surface_(surface.Pass()),
22 id_allocator_(id_namespace) {
23 capabilities_.delegated_rendering = true;
24 capabilities_.max_frames_pending = 1;
25 }
26
27 OutputSurfaceMojo::~OutputSurfaceMojo() {
28 }
29
30 void OutputSurfaceMojo::SetIdNamespace(uint32_t id_namespace) {
31 }
32
33 void OutputSurfaceMojo::ReturnResources(Array<ReturnedResourcePtr> resources) {
34 }
35
36 bool OutputSurfaceMojo::BindToClient(cc::OutputSurfaceClient* client) {
37 surface_.set_client(this);
38 return cc::OutputSurface::BindToClient(client);
39 }
40
41 void OutputSurfaceMojo::SwapBuffers(cc::CompositorFrame* frame) {
42 gfx::Size frame_size =
43 frame->delegated_frame_data->render_pass_list.back()->output_rect.size();
44 if (frame_size != surface_size_) {
45 if (!surface_id_.is_null()) {
46 surface_->DestroySurface(SurfaceId::From(surface_id_));
47 }
48 surface_id_ = id_allocator_.GenerateId();
49 surface_->CreateSurface(SurfaceId::From(surface_id_));
50 output_surface_mojo_client_->DidCreateSurface(surface_id_);
51 surface_size_ = frame_size;
52 }
53
54 surface_->SubmitFrame(SurfaceId::From(surface_id_), Frame::From(*frame),
55 mojo::Closure());
56
57 client_->DidSwapBuffers();
58 client_->DidSwapBuffersComplete();
59 }
60
61 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/cc/output_surface_mojo.h ('k') | mojo/services/surfaces/public/interfaces/surface_id.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698