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

Unified Diff: gpu/ipc/common/mailbox_struct_traits.h

Issue 2019833002: Implement StructTraits for various cc and gpu types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nit Created 4 years, 7 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: gpu/ipc/common/mailbox_struct_traits.h
diff --git a/gpu/ipc/common/mailbox_struct_traits.h b/gpu/ipc/common/mailbox_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..700e19249c607fff0fd86276c5b3df49244a6a38
--- /dev/null
+++ b/gpu/ipc/common/mailbox_struct_traits.h
@@ -0,0 +1,42 @@
+// Copyright 2016 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.
+
+#ifndef GPU_IPC_COMMON_MAILBOX_STRUCT_TRAITS_H_
+#define GPU_IPC_COMMON_MAILBOX_STRUCT_TRAITS_H_
+
+#include "gpu/command_buffer/common/mailbox.h"
+#include "gpu/ipc/common/mailbox.mojom.h"
+#include "mojo/public/cpp/bindings/array_traits.h"
+
+namespace mojo {
+
+// A buffer used to read bytes directly from MailboxDataView to gpu::Mailbox
+// name.
+struct MailboxName {
+ int8_t* data;
+};
+
+// ArrayTraits needed for ReadName use with MailboxName.
+template <>
+struct ArrayTraits<MailboxName> {
+ using Element = int8_t;
+ static bool IsNull(const MailboxName& b);
+ static void SetToNull(MailboxName* b);
+ static size_t GetSize(const MailboxName& b);
+ static int8_t* GetData(MailboxName& b);
+ static const int8_t* GetData(const MailboxName& b);
+ static int8_t* GetAt(MailboxName& b, size_t i);
+ static const int8_t* GetAt(const MailboxName& b, size_t i);
+ static void Resize(MailboxName& b, size_t size);
+};
+
+template <>
+struct StructTraits<gpu::mojom::Mailbox, gpu::Mailbox> {
+ static MailboxName name(const gpu::Mailbox& mailbox);
+ static bool Read(gpu::mojom::MailboxDataView data, gpu::Mailbox* out);
+};
+
+} // namespace mojo
+
+#endif // GPU_IPC_COMMON_MAILBOX_STRUCT_TRAITS_H_

Powered by Google App Engine
This is Rietveld 408576698