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 "content/browser/compositor/surface_display_output_surface.h" | 5 #include "content/browser/compositor/surface_display_output_surface.h" |
6 | 6 |
7 #include "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
8 #include "cc/output/compositor_frame_ack.h" | 8 #include "cc/output/compositor_frame_ack.h" |
9 #include "cc/surfaces/display.h" | 9 #include "cc/surfaces/display.h" |
10 #include "cc/surfaces/surface.h" | 10 #include "cc/surfaces/surface.h" |
11 #include "cc/surfaces/surface_manager.h" | 11 #include "cc/surfaces/surface_manager.h" |
12 #include "content/browser/compositor/onscreen_display_client.h" | 12 #include "content/browser/compositor/onscreen_display_client.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 SurfaceDisplayOutputSurface::SurfaceDisplayOutputSurface( | 16 SurfaceDisplayOutputSurface::SurfaceDisplayOutputSurface( |
17 cc::SurfaceManager* surface_manager, | 17 cc::SurfaceManager* surface_manager, |
18 cc::SurfaceIdAllocator* allocator, | 18 cc::SurfaceIdAllocator* allocator, |
19 const scoped_refptr<cc::ContextProvider>& context_provider) | 19 const scoped_refptr<cc::ContextProvider>& context_provider) |
20 : cc::OutputSurface(context_provider, | 20 : cc::OutputSurface(context_provider, |
21 scoped_ptr<cc::SoftwareOutputDevice>()), | 21 scoped_ptr<cc::SoftwareOutputDevice>()), |
22 display_client_(NULL), | 22 display_client_(NULL), |
23 surface_manager_(surface_manager), | 23 surface_manager_(surface_manager), |
24 factory_(surface_manager, this), | 24 factory_(surface_manager, this), |
25 allocator_(allocator) { | 25 allocator_(allocator) { |
26 capabilities_.delegated_rendering = true; | 26 capabilities_.delegated_rendering = true; |
27 capabilities_.max_frames_pending = 1; | 27 capabilities_.max_frames_pending = 1; |
28 capabilities_.can_force_reclaim_resources = true; | |
28 } | 29 } |
29 | 30 |
30 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() { | 31 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() { |
31 client_ = NULL; | 32 client_ = NULL; |
32 if (!surface_id_.is_null()) { | 33 if (!surface_id_.is_null()) { |
33 factory_.Destroy(surface_id_); | 34 factory_.Destroy(surface_id_); |
34 } | 35 } |
35 } | 36 } |
36 | 37 |
37 void SurfaceDisplayOutputSurface::ReceivedVSyncParameters( | 38 void SurfaceDisplayOutputSurface::ReceivedVSyncParameters( |
(...skipping 30 matching lines...) Expand all Loading... | |
68 bool SurfaceDisplayOutputSurface::BindToClient( | 69 bool SurfaceDisplayOutputSurface::BindToClient( |
69 cc::OutputSurfaceClient* client) { | 70 cc::OutputSurfaceClient* client) { |
70 DCHECK(client); | 71 DCHECK(client); |
71 DCHECK(display_client_); | 72 DCHECK(display_client_); |
72 client_ = client; | 73 client_ = client; |
73 // Avoid initializing GL context here, as this should be sharing the | 74 // Avoid initializing GL context here, as this should be sharing the |
74 // Display's context. | 75 // Display's context. |
75 return display_client_->Initialize(); | 76 return display_client_->Initialize(); |
76 } | 77 } |
77 | 78 |
79 void SurfaceDisplayOutputSurface::ForceReclaimResources() { | |
80 if (!surface_id_.is_null()) { | |
81 scoped_ptr<cc::CompositorFrame> frame_copy(new cc::CompositorFrame()); | |
jamesr
2015/01/09 01:14:45
what is this a copy of? this looks more like a com
| |
82 frame_copy->delegated_frame_data.reset(new cc::DelegatedFrameData); | |
83 factory_.SubmitFrame(surface_id_, frame_copy.Pass(), | |
84 cc::SurfaceFactory::DrawCallback()); | |
85 } | |
86 } | |
87 | |
78 void SurfaceDisplayOutputSurface::ReturnResources( | 88 void SurfaceDisplayOutputSurface::ReturnResources( |
79 const cc::ReturnedResourceArray& resources) { | 89 const cc::ReturnedResourceArray& resources) { |
80 cc::CompositorFrameAck ack; | 90 cc::CompositorFrameAck ack; |
81 ack.resources = resources; | 91 ack.resources = resources; |
82 if (client_) | 92 if (client_) |
83 client_->ReclaimResources(&ack); | 93 client_->ReclaimResources(&ack); |
84 } | 94 } |
85 | 95 |
86 void SurfaceDisplayOutputSurface::SwapBuffersComplete(bool drawn) { | 96 void SurfaceDisplayOutputSurface::SwapBuffersComplete(bool drawn) { |
87 if (client_) | 97 if (client_) |
88 client_->DidSwapBuffersComplete(); | 98 client_->DidSwapBuffersComplete(); |
89 } | 99 } |
90 | 100 |
91 } // namespace content | 101 } // namespace content |
OLD | NEW |