OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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/child/child_native_pixmap_manager_ozone.h" |
| 6 |
| 7 #include "base/file_descriptor_posix.h" |
| 8 #include "base/lazy_instance.h" |
| 9 #include "base/synchronization/lock.h" |
| 10 #include "content/common/gpu/native_pixmap_manager_ozone_messages.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 namespace { |
| 15 base::LazyInstance<base::Lock> g_creation_lock = LAZY_INSTANCE_INITIALIZER; |
| 16 } |
| 17 |
| 18 // static |
| 19 void ChildNativePixmapManager::CreateSingleton(ThreadSafeSender* sender) { |
| 20 base::AutoLock lock(g_creation_lock.Get()); |
| 21 if (ui::NativePixmapManager::GetInstance()) |
| 22 return; |
| 23 |
| 24 TRACE_EVENT0("renderer", "ChildNativePixmapManager::Create"); |
| 25 DCHECK(sender); |
| 26 scoped_ptr<ChildNativePixmapManager> manager(new ChildNativePixmapManager()); |
| 27 |
| 28 base::FileDescriptor virtual_device; |
| 29 IPC::Message* message = |
| 30 new BrowserNativePixmapManagerMsg_SyncGetVirtualDevice(&virtual_device); |
| 31 bool success = sender->Send(message); |
| 32 if (!success) { |
| 33 LOG(ERROR) |
| 34 << "Fail to send BrowserNativePixmapManagerMsg_SyncGetVirtualDevice"; |
| 35 return; |
| 36 } |
| 37 |
| 38 manager->Initialize(virtual_device); |
| 39 ui::NativePixmapManager::SetInstance(manager.release()); |
| 40 } |
| 41 |
| 42 ChildNativePixmapManager::ChildNativePixmapManager() {} |
| 43 |
| 44 ChildNativePixmapManager::~ChildNativePixmapManager() {} |
| 45 |
| 46 void ChildNativePixmapManager::Initialize( |
| 47 const base::FileDescriptor& device_fd) { |
| 48 pixmap_manager_ = ui::NativePixmapManager::Create(device_fd); |
| 49 } |
| 50 |
| 51 std::vector<ui::NativePixmapManager::Configuration> |
| 52 ChildNativePixmapManager::GetSupportedNativePixmapConfigurations() const { |
| 53 return pixmap_manager_->GetSupportedNativePixmapConfigurations(); |
| 54 } |
| 55 |
| 56 } // namespace content |
OLD | NEW |