OLD | NEW |
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 12 matching lines...) Expand all Loading... |
23 display_client_(NULL), | 23 display_client_(NULL), |
24 factory_(surface_manager, this), | 24 factory_(surface_manager, this), |
25 allocator_(allocator) { | 25 allocator_(allocator) { |
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 |
| 34 factory_.manager()->RegisterSurfaceFactoryClient(allocator_->id_namespace(), |
| 35 this); |
33 } | 36 } |
34 | 37 |
35 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() { | 38 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() { |
36 client_ = NULL; | 39 client_ = NULL; |
37 if (!surface_id_.is_null()) { | 40 if (!surface_id_.is_null()) { |
38 factory_.Destroy(surface_id_); | 41 factory_.Destroy(surface_id_); |
39 } | 42 } |
40 } | 43 } |
41 | 44 |
42 void SurfaceDisplayOutputSurface::ReceivedVSyncParameters( | 45 void SurfaceDisplayOutputSurface::ReceivedVSyncParameters( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // Display's context. | 80 // Display's context. |
78 return display_client_->Initialize(); | 81 return display_client_->Initialize(); |
79 } | 82 } |
80 | 83 |
81 void SurfaceDisplayOutputSurface::ForceReclaimResources() { | 84 void SurfaceDisplayOutputSurface::ForceReclaimResources() { |
82 if (!surface_id_.is_null()) | 85 if (!surface_id_.is_null()) |
83 factory_.SubmitCompositorFrame(surface_id_, nullptr, | 86 factory_.SubmitCompositorFrame(surface_id_, nullptr, |
84 SurfaceFactory::DrawCallback()); | 87 SurfaceFactory::DrawCallback()); |
85 } | 88 } |
86 | 89 |
| 90 void SurfaceDisplayOutputSurface::DetachFromClient() { |
| 91 // Unregister the SurfaceFactoryClient here instead of the dtor so that only |
| 92 // one client is alive for this namespace at any given time. |
| 93 factory_.manager()->RegisterSurfaceFactoryClient(allocator_->id_namespace(), |
| 94 nullptr); |
| 95 } |
| 96 |
87 void SurfaceDisplayOutputSurface::ReturnResources( | 97 void SurfaceDisplayOutputSurface::ReturnResources( |
88 const ReturnedResourceArray& resources) { | 98 const ReturnedResourceArray& resources) { |
89 CompositorFrameAck ack; | 99 CompositorFrameAck ack; |
90 ack.resources = resources; | 100 ack.resources = resources; |
91 if (client_) | 101 if (client_) |
92 client_->ReclaimResources(&ack); | 102 client_->ReclaimResources(&ack); |
93 } | 103 } |
94 | 104 |
95 void SurfaceDisplayOutputSurface::SetBeginFrameSource( | 105 void SurfaceDisplayOutputSurface::SetBeginFrameSource( |
96 SurfaceId surface_id, | |
97 BeginFrameSource* begin_frame_source) { | 106 BeginFrameSource* begin_frame_source) { |
98 // TODO(tansell): Hook this up. | 107 // TODO(tansell): Hook this up. |
99 } | 108 } |
100 | 109 |
101 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) { | 110 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) { |
102 if (client_ && !display_client_->output_surface_lost()) | 111 if (client_ && !display_client_->output_surface_lost()) |
103 client_->DidSwapBuffersComplete(); | 112 client_->DidSwapBuffersComplete(); |
104 } | 113 } |
105 | 114 |
106 } // namespace cc | 115 } // namespace cc |
OLD | NEW |