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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/gpu/browser_client_native_pixmap_factory_ozone.cc
diff --git a/content/browser/gpu/browser_client_native_pixmap_factory_ozone.cc b/content/browser/gpu/browser_client_native_pixmap_factory_ozone.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a5c2c07d3bc6ace2dfca2a102952f756b775b196
--- /dev/null
+++ b/content/browser/gpu/browser_client_native_pixmap_factory_ozone.cc
@@ -0,0 +1,84 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/gpu/browser_client_native_pixmap_factory_ozone.h"
+
+#include "base/memory/singleton.h"
+#include "base/posix/eintr_wrapper.h"
+#include "content/common/gpu/client_native_pixmap_factory_ozone_messages.h"
+#include "content/public/browser/browser_thread.h"
+#include "ui/ozone/public/ozone_platform.h"
+
+namespace content {
+
+namespace {
+
+base::FileDescriptor DupVirtualDeviceFd(int virtual_device) {
+ int duped_fd = -1;
+ base::ThreadRestrictions::AssertIOAllowed();
+ duped_fd = HANDLE_EINTR(dup(virtual_device));
+ if (duped_fd < 0) {
+ PLOG(ERROR) << "dup() failed.";
+ return base::FileDescriptor();
+ }
+ return base::FileDescriptor(duped_fd, true);
+}
+
+void OnSendVirtualDevice(IPC::Sender* sender,
+ const base::FileDescriptor& virtual_device) {
+ sender->Send(
+ new ChildClientNativePixmapFactoryMsg_SetVirtualDevice(virtual_device));
+}
+
+} // namespace
+
+struct BrowserClientNativePixmapFactoryTrait
+ : public DefaultSingletonTraits<BrowserClientNativePixmapFactory> {
+ static BrowserClientNativePixmapFactory* New() {
+ BrowserClientNativePixmapFactory* manager =
+ new BrowserClientNativePixmapFactory();
+ manager->Initialize(ui::OzonePlatform::GetInstance()->GetVirtualDeviceFd());
+ return manager;
+ }
+};
+
+// static
+BrowserClientNativePixmapFactory*
+BrowserClientNativePixmapFactory::GetInstance() {
+ return Singleton<BrowserClientNativePixmapFactory,
+ BrowserClientNativePixmapFactoryTrait>::get();
+}
+
+BrowserClientNativePixmapFactory::BrowserClientNativePixmapFactory() {}
+
+BrowserClientNativePixmapFactory::~BrowserClientNativePixmapFactory() {}
+
+void BrowserClientNativePixmapFactory::Initialize(
+ const base::FileDescriptor& virtual_device) {
+ pixmap_factory_ = ui::ClientNativePixmapFactory::Create(virtual_device);
+ virtual_device_ = virtual_device;
+}
+
+void BrowserClientNativePixmapFactory::SendVirtualDevice(IPC::Sender* sender) {
+ 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.
+ base::PostTaskAndReplyWithResult(
+ pool, FROM_HERE, base::Bind(&DupVirtualDeviceFd, virtual_device_.fd),
+ base::Bind(&OnSendVirtualDevice, sender));
+}
+
+std::vector<ui::ClientNativePixmapFactory::Configuration>
+BrowserClientNativePixmapFactory::GetSupportedConfigurations() const {
+ return pixmap_factory_->GetSupportedConfigurations();
+}
+
+scoped_ptr<ui::ClientNativePixmap>
+BrowserClientNativePixmapFactory::ImportNativePixmap(
+ const base::FileDescriptor& handle,
+ const gfx::Size& size,
+ gfx::BufferFormat format,
+ gfx::BufferUsage usage) {
+ return pixmap_factory_->ImportNativePixmap(handle, size, format, usage);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698