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.
5 #ifndef UI_OZONE_PUBLIC_CLIENT_NATIVE_PIXMAP_FACTORY_H_
6 #define UI_OZONE_PUBLIC_CLIENT_NATIVE_PIXMAP_FACTORY_H_
10 #include "base/files/scoped_file.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "ui/gfx/buffer_types.h"
13 #include "ui/ozone/ozone_export.h"
14 #include "ui/ozone/public/client_native_pixmap.h"
17 struct NativePixmapHandle
;
23 // The Ozone interface allows external implementations to hook into Chromium to
24 // provide a client pixmap for non-GPU processes.
25 class OZONE_EXPORT ClientNativePixmapFactory
{
27 static ClientNativePixmapFactory
* GetInstance();
28 static void SetInstance(ClientNativePixmapFactory
* instance
);
30 static scoped_ptr
<ClientNativePixmapFactory
> Create();
32 virtual ~ClientNativePixmapFactory();
34 // Initialize with the given client native pixmap |device_fd|.
35 virtual void Initialize(base::ScopedFD device_fd
) = 0;
37 struct Configuration
{
38 gfx::BufferFormat format
;
39 gfx::BufferUsage usage
;
42 // Gets supported format/usage configurations.
43 virtual std::vector
<Configuration
> GetSupportedConfigurations() const = 0;
45 // TODO(dshwang): implement it. crbug.com/475633
46 // Import the native pixmap from |handle| to be used in non-GPU processes.
47 // This function takes ownership of any file descriptors in |handle|.
48 virtual scoped_ptr
<ClientNativePixmap
> ImportFromHandle(
49 const gfx::NativePixmapHandle
& handle
,
50 const gfx::Size
& size
,
51 gfx::BufferUsage usage
) = 0;
54 ClientNativePixmapFactory();
57 DISALLOW_COPY_AND_ASSIGN(ClientNativePixmapFactory
);
62 #endif // UI_OZONE_PUBLIC_CLIENT_NATIVE_PIXMAP_FACTORY_H_