OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016 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 "content/browser/compositor/vulkan_browser_compositor_output_surface.h" |
| 6 |
| 7 #include "cc/output/output_surface_client.h" |
| 8 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 9 #include "gpu/vulkan/vulkan_surface.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 VulkanBrowserCompositorOutputSurface::VulkanBrowserCompositorOutputSurface( |
| 14 const scoped_refptr<cc::VulkanContextProvider>& context, |
| 15 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) |
| 16 : BrowserCompositorOutputSurface(context, vsync_manager) {} |
| 17 |
| 18 VulkanBrowserCompositorOutputSurface::~VulkanBrowserCompositorOutputSurface() { |
| 19 DCHECK(!surface_); |
| 20 } |
| 21 |
| 22 bool VulkanBrowserCompositorOutputSurface::Initialize( |
| 23 gfx::AcceleratedWidget widget) { |
| 24 DCHECK(!surface_); |
| 25 std::unique_ptr<gpu::VulkanSurface> surface( |
| 26 gpu::VulkanSurface::CreateViewSurface(widget)); |
| 27 if (!surface->Initialize(vulkan_context_provider()->GetDeviceQueue(), |
| 28 gpu::VulkanSurface::DEFAULT_SURFACE_FORMAT)) { |
| 29 return false; |
| 30 } |
| 31 surface_ = std::move(surface); |
| 32 |
| 33 return true; |
| 34 } |
| 35 |
| 36 void VulkanBrowserCompositorOutputSurface::Destroy() { |
| 37 if (surface_) { |
| 38 surface_->Destroy(); |
| 39 surface_.reset(); |
| 40 } |
| 41 } |
| 42 |
| 43 void VulkanBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted( |
| 44 const std::vector<ui::LatencyInfo>& latency_info, |
| 45 gfx::SwapResult result) { |
| 46 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info); |
| 47 OnSwapBuffersComplete(); |
| 48 } |
| 49 |
| 50 void VulkanBrowserCompositorOutputSurface::SwapBuffers( |
| 51 cc::CompositorFrame* frame) { |
| 52 surface_->SwapBuffers(); |
| 53 PostSwapBuffersComplete(); |
| 54 client_->DidSwapBuffers(); |
| 55 } |
| 56 |
| 57 } // namespace content |
OLD | NEW |