Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: content/browser/gpu/browser_client_native_pixmap_factory_ozone.cc

Issue 1248713002: ozone: ClientPixmapManager passes VGEM fd from browser to renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename to ClientNativePixmapFactory Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/browser/gpu/browser_client_native_pixmap_factory_ozone.h"
6
7 #include "base/memory/singleton.h"
8 #include "base/posix/eintr_wrapper.h"
9 #include "content/common/gpu/client_native_pixmap_factory_ozone_messages.h"
10 #include "content/public/browser/browser_thread.h"
11 #include "ui/ozone/public/ozone_platform.h"
12
13 namespace content {
14
15 namespace {
16
17 base::FileDescriptor DupVirtualDeviceFd(int virtual_device) {
18 int duped_fd = -1;
19 base::ThreadRestrictions::AssertIOAllowed();
20 duped_fd = HANDLE_EINTR(dup(virtual_device));
21 if (duped_fd < 0) {
22 PLOG(ERROR) << "dup() failed.";
23 return base::FileDescriptor();
24 }
25 return base::FileDescriptor(duped_fd, true);
26 }
27
28 void OnSendVirtualDevice(IPC::Sender* sender,
29 const base::FileDescriptor& virtual_device) {
30 sender->Send(
31 new ChildClientNativePixmapFactoryMsg_SetVirtualDevice(virtual_device));
32 }
33
34 } // namespace
35
36 struct BrowserClientNativePixmapFactoryTrait
37 : public DefaultSingletonTraits<BrowserClientNativePixmapFactory> {
38 static BrowserClientNativePixmapFactory* New() {
39 BrowserClientNativePixmapFactory* manager =
40 new BrowserClientNativePixmapFactory();
41 manager->Initialize(ui::OzonePlatform::GetInstance()->GetVirtualDeviceFd());
42 return manager;
43 }
44 };
45
46 // static
47 BrowserClientNativePixmapFactory*
48 BrowserClientNativePixmapFactory::GetInstance() {
49 return Singleton<BrowserClientNativePixmapFactory,
50 BrowserClientNativePixmapFactoryTrait>::get();
51 }
52
53 BrowserClientNativePixmapFactory::BrowserClientNativePixmapFactory() {}
54
55 BrowserClientNativePixmapFactory::~BrowserClientNativePixmapFactory() {}
56
57 void BrowserClientNativePixmapFactory::Initialize(
58 const base::FileDescriptor& virtual_device) {
59 pixmap_factory_ = ui::ClientNativePixmapFactory::Create(virtual_device);
60 virtual_device_ = virtual_device;
61 }
62
63 void BrowserClientNativePixmapFactory::SendVirtualDevice(IPC::Sender* sender) {
64 base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool();
reveman 2015/08/13 18:05:28 why do we need to use blocking thread pool to dup(
dshwang 2015/08/14 12:40:03 Done. Removed.
65 base::PostTaskAndReplyWithResult(
66 pool, FROM_HERE, base::Bind(&DupVirtualDeviceFd, virtual_device_.fd),
67 base::Bind(&OnSendVirtualDevice, sender));
68 }
69
70 std::vector<ui::ClientNativePixmapFactory::Configuration>
71 BrowserClientNativePixmapFactory::GetSupportedConfigurations() const {
72 return pixmap_factory_->GetSupportedConfigurations();
73 }
74
75 scoped_ptr<ui::ClientNativePixmap>
76 BrowserClientNativePixmapFactory::ImportNativePixmap(
77 const base::FileDescriptor& handle,
78 const gfx::Size& size,
79 gfx::BufferFormat format,
80 gfx::BufferUsage usage) {
81 return pixmap_factory_->ImportNativePixmap(handle, size, format, usage);
82 }
83
84 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698