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

Unified Diff: chrome/browser/chromeos/dbus/chrome_surface_service_provider_delegate.cc

Issue 1394573003: chromeos: Add SurfaceServiceProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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: chrome/browser/chromeos/dbus/chrome_surface_service_provider_delegate.cc
diff --git a/chrome/browser/chromeos/dbus/chrome_surface_service_provider_delegate.cc b/chrome/browser/chromeos/dbus/chrome_surface_service_provider_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a9d0ccb1e38b205e286473289b23958fb22de5d7
--- /dev/null
+++ b/chrome/browser/chromeos/dbus/chrome_surface_service_provider_delegate.cc
@@ -0,0 +1,91 @@
+// 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 "chrome/browser/chromeos/dbus/chrome_surface_service_provider_delegate.h"
+
+#include "ash/shell.h"
+#include "ash/surfaces/surface_controller.h"
+#include "ash/surfaces/test_shell_surface_overlay_view.h"
+#include "base/logging.h"
+#include "ui/gfx/gpu_memory_buffer.h"
+
+namespace chromeos {
+namespace {
+
+#define FOURCC(a, b, c, d) \
+ ((static_cast<uint32>(a)) | (static_cast<uint32>(b) << 8) | \
+ (static_cast<uint32>(c) << 16) | (static_cast<uint32>(d) << 24))
+
+#define DRM_FORMAT_ABGR8888 FOURCC('A', 'B', '2', '4')
+
+bool IsSupportedFormat(uint32 format) {
+ switch (format) {
+ case DRM_FORMAT_ABGR8888:
+ return true;
+ default:
+ return false;
+ }
+}
+
+gfx::BufferFormat BufferFormat(uint32 format) {
+ switch (format) {
+ case DRM_FORMAT_ABGR8888:
+ return gfx::BufferFormat::RGBA_8888;
+ default:
+ NOTREACHED();
+ return gfx::BufferFormat::RGBA_8888;
+ }
+}
+
+} // namespace
+
+ChromeSurfaceServiceProviderDelegate::ChromeSurfaceServiceProviderDelegate()
+ : attached_test_shell_surface_buffer_id_(0) {}
+
+ChromeSurfaceServiceProviderDelegate::~ChromeSurfaceServiceProviderDelegate() {}
+
+void ChromeSurfaceServiceProviderDelegate::CreatePrimeBuffer(
+ uint32 id,
+ base::ScopedFD fd,
+ int32 width,
+ int32 height,
+ uint32 format,
+ int32 stride,
+ const CreateBufferCallback& callback) {
+ if (!IsSupportedFormat(format)) {
+ LOG(ERROR) << "Failed to create prime buffer. Unsupported format 0x"
+ << std::hex << format;
+ callback.Run(false);
+ return;
+ }
+
+ gfx::GpuMemoryBufferHandle handle;
+ handle.type = gfx::OZONE_NATIVE_PIXMAP;
+ handle.native_pixmap_handle.fd = base::FileDescriptor(fd.Pass());
+ handle.native_pixmap_handle.stride = stride;
+ ash::Shell::GetInstance()
+ ->surface_controller()
+ ->CreateGraphicsBufferFromGpuMemoryBufferHandle(
+ id, handle, gfx::Size(width, height), BufferFormat(format), callback);
+}
+
+void ChromeSurfaceServiceProviderDelegate::DestroyBuffer(uint32 id) {
+ ash::Shell::GetInstance()->surface_controller()->DestroyGraphicsBuffer(id);
+}
+
+void ChromeSurfaceServiceProviderDelegate::AttachBufferToTestShellSurface(
+ uint32 buffer_id,
+ const base::Closure& released_callback) {
+ ash::Shell::GetInstance()
+ ->surface_controller()
+ ->AttachGraphicsBufferToTestShellSurface(buffer_id, released_callback);
+
+ // Show overlay view when an initial buffer is attached.
+ if (!attached_test_shell_surface_buffer_id_)
+ ash::TestShellSurfaceOverlayView::Show();
+
+ attached_test_shell_surface_buffer_id_ = buffer_id;
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698