| 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 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 SurfaceDisplayOutputSurface::SurfaceDisplayOutputSurface( | 15 SurfaceDisplayOutputSurface::SurfaceDisplayOutputSurface( |
| 16 cc::SurfaceManager* surface_manager, | 16 cc::SurfaceManager* surface_manager, |
| 17 uint32_t surface_id_namespace, | 17 uint32_t surface_id_namespace, |
| 18 const scoped_refptr<cc::ContextProvider>& context_provider) | 18 const scoped_refptr<cc::ContextProvider>& context_provider) |
| 19 : cc::OutputSurface(context_provider, | 19 : cc::OutputSurface(context_provider, |
| 20 scoped_ptr<cc::SoftwareOutputDevice>()), | 20 scoped_ptr<cc::SoftwareOutputDevice>()), |
| 21 display_(NULL), | 21 display_(NULL), |
| 22 surface_manager_(surface_manager), | 22 surface_manager_(surface_manager), |
| 23 factory_(surface_manager, this), | 23 factory_(surface_manager, this), |
| 24 allocator_(surface_id_namespace) { | 24 allocator_(surface_id_namespace) { |
| 25 capabilities_.delegated_rendering = true; | 25 capabilities_.delegated_rendering = true; |
| 26 capabilities_.max_frames_pending = 1; | 26 capabilities_.max_frames_pending = 1; |
| 27 } | 27 } |
| 28 | 28 |
| 29 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() { | 29 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() { |
| 30 client_ = NULL; |
| 31 if (!surface_id_.is_null()) { |
| 32 factory_.Destroy(surface_id_); |
| 33 } |
| 30 } | 34 } |
| 31 | 35 |
| 32 void SurfaceDisplayOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { | 36 void SurfaceDisplayOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { |
| 33 gfx::Size frame_size = | 37 gfx::Size frame_size = |
| 34 frame->delegated_frame_data->render_pass_list.back()->output_rect.size(); | 38 frame->delegated_frame_data->render_pass_list.back()->output_rect.size(); |
| 35 if (frame_size != display_size_) { | 39 if (frame_size != display_size_) { |
| 36 if (!surface_id_.is_null()) { | 40 if (!surface_id_.is_null()) { |
| 37 factory_.Destroy(surface_id_); | 41 factory_.Destroy(surface_id_); |
| 38 } | 42 } |
| 39 surface_id_ = allocator_.GenerateId(); | 43 surface_id_ = allocator_.GenerateId(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 50 return; | 54 return; |
| 51 | 55 |
| 52 client_->DidSwapBuffers(); | 56 client_->DidSwapBuffers(); |
| 53 client_->DidSwapBuffersComplete(); | 57 client_->DidSwapBuffersComplete(); |
| 54 } | 58 } |
| 55 | 59 |
| 56 void SurfaceDisplayOutputSurface::ReturnResources( | 60 void SurfaceDisplayOutputSurface::ReturnResources( |
| 57 const cc::ReturnedResourceArray& resources) { | 61 const cc::ReturnedResourceArray& resources) { |
| 58 cc::CompositorFrameAck ack; | 62 cc::CompositorFrameAck ack; |
| 59 ack.resources = resources; | 63 ack.resources = resources; |
| 60 client_->ReclaimResources(&ack); | 64 if (client_) |
| 65 client_->ReclaimResources(&ack); |
| 61 } | 66 } |
| 62 | 67 |
| 63 } // namespace content | 68 } // namespace content |
| OLD | NEW |