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

Side by Side Diff: cc/surfaces/surface_display_output_surface.cc

Issue 1673783004: Hook up BeginFrameSource to SurfaceFactoryClient via SurfaceManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Register id namespace on Android Created 4 years, 9 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
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 "cc/surfaces/surface_display_output_surface.h" 5 #include "cc/surfaces/surface_display_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/surfaces/display.h" 10 #include "cc/surfaces/display.h"
(...skipping 15 matching lines...) Expand all
26 factory_.set_needs_sync_points(false); 26 factory_.set_needs_sync_points(false);
27 capabilities_.delegated_rendering = true; 27 capabilities_.delegated_rendering = true;
28 capabilities_.adjust_deadline_for_parent = true; 28 capabilities_.adjust_deadline_for_parent = true;
29 capabilities_.can_force_reclaim_resources = true; 29 capabilities_.can_force_reclaim_resources = true;
30 // Display and SurfaceDisplayOutputSurface share a GL context, so sync 30 // Display and SurfaceDisplayOutputSurface share a GL context, so sync
31 // points aren't needed when passing resources between them. 31 // points aren't needed when passing resources between them.
32 capabilities_.delegated_sync_points_required = false; 32 capabilities_.delegated_sync_points_required = false;
33 } 33 }
34 34
35 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() { 35 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() {
36 client_ = NULL; 36 if (HasClient())
37 DetachFromClient();
37 if (!surface_id_.is_null()) { 38 if (!surface_id_.is_null()) {
38 factory_.Destroy(surface_id_); 39 factory_.Destroy(surface_id_);
39 } 40 }
40 } 41 }
41 42
42 void SurfaceDisplayOutputSurface::ReceivedVSyncParameters( 43 void SurfaceDisplayOutputSurface::ReceivedVSyncParameters(
43 base::TimeTicks timebase, 44 base::TimeTicks timebase,
44 base::TimeDelta interval) { 45 base::TimeDelta interval) {
45 CommitVSyncParameters(timebase, interval); 46 CommitVSyncParameters(timebase, interval);
46 } 47 }
(...skipping 18 matching lines...) Expand all
65 frame->AssignTo(frame_copy.get()); 66 frame->AssignTo(frame_copy.get());
66 factory_.SubmitCompositorFrame( 67 factory_.SubmitCompositorFrame(
67 surface_id_, std::move(frame_copy), 68 surface_id_, std::move(frame_copy),
68 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete, 69 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete,
69 base::Unretained(this))); 70 base::Unretained(this)));
70 } 71 }
71 72
72 bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) { 73 bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) {
73 DCHECK(client); 74 DCHECK(client);
74 DCHECK(display_client_); 75 DCHECK(display_client_);
76 factory_.manager()->RegisterSurfaceFactoryClient(allocator_->id_namespace(),
77 this);
78
75 client_ = client; 79 client_ = client;
76 // Avoid initializing GL context here, as this should be sharing the 80 // Avoid initializing GL context here, as this should be sharing the
77 // Display's context. 81 // Display's context.
78 return display_client_->Initialize(); 82 return display_client_->Initialize();
79 } 83 }
80 84
81 void SurfaceDisplayOutputSurface::ForceReclaimResources() { 85 void SurfaceDisplayOutputSurface::ForceReclaimResources() {
82 if (!surface_id_.is_null()) 86 if (!surface_id_.is_null())
83 factory_.SubmitCompositorFrame(surface_id_, nullptr, 87 factory_.SubmitCompositorFrame(surface_id_, nullptr,
84 SurfaceFactory::DrawCallback()); 88 SurfaceFactory::DrawCallback());
85 } 89 }
86 90
91 void SurfaceDisplayOutputSurface::DetachFromClient() {
92 DCHECK(HasClient());
93 // Unregister the SurfaceFactoryClient here instead of the dtor so that only
94 // one client is alive for this namespace at any given time.
95 factory_.manager()->UnregisterSurfaceFactoryClient(
96 allocator_->id_namespace());
97 OutputSurface::DetachFromClient();
98 DCHECK(!HasClient());
99 }
100
87 void SurfaceDisplayOutputSurface::ReturnResources( 101 void SurfaceDisplayOutputSurface::ReturnResources(
88 const ReturnedResourceArray& resources) { 102 const ReturnedResourceArray& resources) {
89 CompositorFrameAck ack; 103 CompositorFrameAck ack;
90 ack.resources = resources; 104 ack.resources = resources;
91 if (client_) 105 if (client_)
92 client_->ReclaimResources(&ack); 106 client_->ReclaimResources(&ack);
93 } 107 }
94 108
95 void SurfaceDisplayOutputSurface::SetBeginFrameSource( 109 void SurfaceDisplayOutputSurface::SetBeginFrameSource(
96 SurfaceId surface_id,
97 BeginFrameSource* begin_frame_source) { 110 BeginFrameSource* begin_frame_source) {
98 // TODO(tansell): Hook this up. 111 // TODO(tansell): Hook this up.
99 } 112 }
100 113
101 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) { 114 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) {
102 if (client_ && !display_client_->output_surface_lost()) 115 if (client_ && !display_client_->output_surface_lost())
103 client_->DidSwapBuffersComplete(); 116 client_->DidSwapBuffersComplete();
104 } 117 }
105 118
106 } // namespace cc 119 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_display_output_surface.h ('k') | cc/surfaces/surface_display_output_surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698