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/test/test_client_native_pixmap_factory_ozone.h" |
| 6 |
| 7 #include "base/file_descriptor_posix.h" |
| 8 #include "base/memory/singleton.h" |
| 9 #include "ui/ozone/public/ozone_platform.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 struct TestClientNativePixmapFactoryTrait |
| 14 : public DefaultSingletonTraits<TestClientNativePixmapFactory> { |
| 15 static TestClientNativePixmapFactory* New() { |
| 16 TestClientNativePixmapFactory* manager = |
| 17 new TestClientNativePixmapFactory(); |
| 18 manager->Initialize(ui::OzonePlatform::GetInstance()->GetVirtualDeviceFd()); |
| 19 return manager; |
| 20 } |
| 21 }; |
| 22 |
| 23 // static |
| 24 TestClientNativePixmapFactory* TestClientNativePixmapFactory::GetInstance() { |
| 25 return Singleton<TestClientNativePixmapFactory, |
| 26 TestClientNativePixmapFactoryTrait>::get(); |
| 27 } |
| 28 |
| 29 TestClientNativePixmapFactory::TestClientNativePixmapFactory() {} |
| 30 |
| 31 TestClientNativePixmapFactory::~TestClientNativePixmapFactory() {} |
| 32 |
| 33 void TestClientNativePixmapFactory::Initialize( |
| 34 const base::FileDescriptor& virtual_device) { |
| 35 pixmap_factory_ = ui::ClientNativePixmapFactory::Create(virtual_device); |
| 36 } |
| 37 |
| 38 std::vector<ui::ClientNativePixmapFactory::Configuration> |
| 39 TestClientNativePixmapFactory::GetSupportedConfigurations() const { |
| 40 return pixmap_factory_->GetSupportedConfigurations(); |
| 41 } |
| 42 |
| 43 scoped_ptr<ui::ClientNativePixmap> |
| 44 TestClientNativePixmapFactory::ImportNativePixmap( |
| 45 const base::FileDescriptor& handle, |
| 46 const gfx::Size& size, |
| 47 gfx::BufferFormat format, |
| 48 gfx::BufferUsage usage) { |
| 49 return pixmap_factory_->ImportNativePixmap(handle, size, format, usage); |
| 50 } |
| 51 |
| 52 } // namespace content |
OLD | NEW |