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

Unified Diff: components/arc/video_accelerator/video_accelerator_struct_traits.h

Issue 2513973002: Use mojo typemap to simplify the code using DmabufPlane (Closed)
Patch Set: Addressed comments Created 4 years, 1 month 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: components/arc/video_accelerator/video_accelerator_struct_traits.h
diff --git a/components/arc/video_accelerator/video_accelerator_struct_traits.h b/components/arc/video_accelerator/video_accelerator_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..6d49e5dc65e42cc8ac230939d168d2eb25d3758b
--- /dev/null
+++ b/components/arc/video_accelerator/video_accelerator_struct_traits.h
@@ -0,0 +1,38 @@
+// 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 COMPONENT_ARC_COMMON_VIDEO_ACCELERATOR_STRUCT_TRAITS_H_
+#define COMPONENT_ARC_COMMON_VIDEO_ACCELERATOR_STRUCT_TRAITS_H_
+
+#include "components/arc/common/video_accelerator.mojom.h"
+#include "components/arc/video_accelerator/video_accelerator.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<arc::mojom::ArcVideoAcceleratorDmabufPlaneDataView,
+ arc::ArcVideoAcceleratorDmabufPlane> {
+ static uint32_t offset(const arc::ArcVideoAcceleratorDmabufPlane& r) {
+ return r.offset;
dcheng 2016/12/01 01:30:50 Perhaps DCHECK(r.offset > 0)
yoshiki 2016/12/06 16:48:34 I believe this can be 0. Added DCHECK(r.offset >=
+ }
+ static uint32_t stride(const arc::ArcVideoAcceleratorDmabufPlane& r) {
Luis Héctor Chávez 2016/11/30 17:57:01 nit: blank line before, for consistency.
yoshiki 2016/12/06 16:48:34 Done.
+ return r.stride;
dcheng 2016/12/01 01:30:50 Ditto
yoshiki 2016/12/06 16:48:34 Done.
+ }
+
+ static bool Read(arc::mojom::ArcVideoAcceleratorDmabufPlaneDataView data,
+ arc::ArcVideoAcceleratorDmabufPlane* out) {
+ if (data.offset() < 0 || data.stride() < 0) {
dcheng 2016/12/01 01:30:50 Nit: please out-of-line this to a .cc file
yoshiki 2016/12/06 16:48:33 Done.
+ // Invalid offset/stride.
+ return false;
Yusuke Sato 2016/11/30 18:08:34 qq: How is the false return handled? The original
dcheng 2016/12/01 01:30:50 When StructTraits::Read() returns false, the messa
Yusuke Sato 2016/12/01 02:23:08 Got it, thanks!
+ }
+
+ out->offset = data.offset();
+ out->stride = data.stride();
+ return true;
+ }
+};
+
+} // namespace arc
Luis Héctor Chávez 2016/11/30 17:57:01 nit: namespace mojo
yoshiki 2016/12/06 16:48:34 Done.
+
+#endif // COMPONENT_ARC_COMMON_VIDEO_ACCELERATOR_STRUCT_TRAITS_H_

Powered by Google App Engine
This is Rietveld 408576698