OLD | NEW |
(Empty) | |
| 1 // Copyright 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 "cc/output/vulkan_derived_context_provider.h" |
| 6 |
| 7 #include "gpu/vulkan/vulkan_device_queue.h" |
| 8 #include "gpu/vulkan/vulkan_surface.h" |
| 9 |
| 10 namespace cc { |
| 11 |
| 12 scoped_refptr<VulkanDerivedContextProvider> |
| 13 VulkanDerivedContextProvider::Create( |
| 14 scoped_refptr<VulkanContextProvider> parent_context_provider, |
| 15 gfx::AcceleratedWidget widget) { |
| 16 scoped_refptr<VulkanDerivedContextProvider> context_provider( |
| 17 new VulkanDerivedContextProvider(parent_context_provider, widget)); |
| 18 if (!context_provider->Initialize()) |
| 19 return nullptr; |
| 20 return context_provider; |
| 21 } |
| 22 |
| 23 bool VulkanDerivedContextProvider::Initialize() { |
| 24 if (!surface_->Initialize(GetDeviceQueue(), |
| 25 gpu::VulkanSurface::DEFAULT_SURFACE_FORMAT)) { |
| 26 return false; |
| 27 } |
| 28 |
| 29 return true; |
| 30 } |
| 31 |
| 32 void VulkanDerivedContextProvider::Destroy() { |
| 33 surface_->Destroy(); |
| 34 } |
| 35 |
| 36 gpu::VulkanDeviceQueue* VulkanDerivedContextProvider::GetDeviceQueue() { |
| 37 return parent_context_provider_->GetDeviceQueue(); |
| 38 } |
| 39 |
| 40 void VulkanDerivedContextProvider::SwapBuffers() { |
| 41 surface_->SwapBuffers(); |
| 42 } |
| 43 |
| 44 VulkanDerivedContextProvider::VulkanDerivedContextProvider( |
| 45 scoped_refptr<VulkanContextProvider> parent_context_provider, |
| 46 gfx::AcceleratedWidget widget) |
| 47 : parent_context_provider_(parent_context_provider), |
| 48 surface_(gpu::VulkanSurface::CreateViewSurface(widget)) { |
| 49 DCHECK(parent_context_provider_); |
| 50 } |
| 51 |
| 52 VulkanDerivedContextProvider::~VulkanDerivedContextProvider() {} |
| 53 |
| 54 } // namespace cc |
OLD | NEW |