| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 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 | 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/output/vulkan_in_process_context_provider.h" | 5 #include "cc/output/vulkan_in_process_context_provider.h" |
| 6 #include "gpu/vulkan/features.h" |
| 6 | 7 |
| 7 #if defined(ENABLE_VULKAN) | 8 #if BUILDFLAG(ENABLE_VULKAN) |
| 8 #include "gpu/vulkan/vulkan_device_queue.h" | 9 #include "gpu/vulkan/vulkan_device_queue.h" |
| 9 #include "gpu/vulkan/vulkan_implementation.h" | 10 #include "gpu/vulkan/vulkan_implementation.h" |
| 10 #endif // defined(ENABLE_VULKAN) | 11 #endif // BUILDFLAG(ENABLE_VULKAN) |
| 11 | 12 |
| 12 namespace cc { | 13 namespace cc { |
| 13 | 14 |
| 14 scoped_refptr<VulkanInProcessContextProvider> | 15 scoped_refptr<VulkanInProcessContextProvider> |
| 15 VulkanInProcessContextProvider::Create() { | 16 VulkanInProcessContextProvider::Create() { |
| 16 #if defined(ENABLE_VULKAN) | 17 #if BUILDFLAG(ENABLE_VULKAN) |
| 17 if (!gpu::VulkanSupported()) | 18 if (!gpu::VulkanSupported()) |
| 18 return nullptr; | 19 return nullptr; |
| 19 | 20 |
| 20 scoped_refptr<VulkanInProcessContextProvider> context_provider( | 21 scoped_refptr<VulkanInProcessContextProvider> context_provider( |
| 21 new VulkanInProcessContextProvider); | 22 new VulkanInProcessContextProvider); |
| 22 if (!context_provider->Initialize()) | 23 if (!context_provider->Initialize()) |
| 23 return nullptr; | 24 return nullptr; |
| 24 return context_provider; | 25 return context_provider; |
| 25 #else | 26 #else |
| 26 return nullptr; | 27 return nullptr; |
| 27 #endif | 28 #endif |
| 28 } | 29 } |
| 29 | 30 |
| 30 bool VulkanInProcessContextProvider::Initialize() { | 31 bool VulkanInProcessContextProvider::Initialize() { |
| 31 #if defined(ENABLE_VULKAN) | 32 #if BUILDFLAG(ENABLE_VULKAN) |
| 32 DCHECK(!device_queue_); | 33 DCHECK(!device_queue_); |
| 33 std::unique_ptr<gpu::VulkanDeviceQueue> device_queue( | 34 std::unique_ptr<gpu::VulkanDeviceQueue> device_queue( |
| 34 new gpu::VulkanDeviceQueue); | 35 new gpu::VulkanDeviceQueue); |
| 35 if (!device_queue->Initialize( | 36 if (!device_queue->Initialize( |
| 36 gpu::VulkanDeviceQueue::GRAPHICS_QUEUE_FLAG | | 37 gpu::VulkanDeviceQueue::GRAPHICS_QUEUE_FLAG | |
| 37 gpu::VulkanDeviceQueue::PRESENTATION_SUPPORT_QUEUE_FLAG)) { | 38 gpu::VulkanDeviceQueue::PRESENTATION_SUPPORT_QUEUE_FLAG)) { |
| 38 device_queue->Destroy(); | 39 device_queue->Destroy(); |
| 39 return false; | 40 return false; |
| 40 } | 41 } |
| 41 | 42 |
| 42 device_queue_ = std::move(device_queue); | 43 device_queue_ = std::move(device_queue); |
| 43 return true; | 44 return true; |
| 44 #else | 45 #else |
| 45 return false; | 46 return false; |
| 46 #endif | 47 #endif |
| 47 } | 48 } |
| 48 | 49 |
| 49 void VulkanInProcessContextProvider::Destroy() { | 50 void VulkanInProcessContextProvider::Destroy() { |
| 50 #if defined(ENABLE_VULKAN) | 51 #if BUILDFLAG(ENABLE_VULKAN) |
| 51 if (device_queue_) { | 52 if (device_queue_) { |
| 52 device_queue_->Destroy(); | 53 device_queue_->Destroy(); |
| 53 device_queue_.reset(); | 54 device_queue_.reset(); |
| 54 } | 55 } |
| 55 #endif | 56 #endif |
| 56 } | 57 } |
| 57 | 58 |
| 58 gpu::VulkanDeviceQueue* VulkanInProcessContextProvider::GetDeviceQueue() { | 59 gpu::VulkanDeviceQueue* VulkanInProcessContextProvider::GetDeviceQueue() { |
| 59 #if defined(ENABLE_VULKAN) | 60 #if BUILDFLAG(ENABLE_VULKAN) |
| 60 return device_queue_.get(); | 61 return device_queue_.get(); |
| 61 #else | 62 #else |
| 62 return nullptr; | 63 return nullptr; |
| 63 #endif | 64 #endif |
| 64 } | 65 } |
| 65 | 66 |
| 66 VulkanInProcessContextProvider::VulkanInProcessContextProvider() {} | 67 VulkanInProcessContextProvider::VulkanInProcessContextProvider() {} |
| 67 | 68 |
| 68 VulkanInProcessContextProvider::~VulkanInProcessContextProvider() { | 69 VulkanInProcessContextProvider::~VulkanInProcessContextProvider() { |
| 69 Destroy(); | 70 Destroy(); |
| 70 } | 71 } |
| 71 | 72 |
| 72 } // namespace cc | 73 } // namespace cc |
| OLD | NEW |