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

Unified Diff: cc/ipc/copy_output_result_struct_traits.h

Issue 2659703002: Implemented StructTraits for cc::CopyOutputResult (Closed)
Patch Set: c Created 3 years, 11 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: cc/ipc/copy_output_result_struct_traits.h
diff --git a/cc/ipc/copy_output_result_struct_traits.h b/cc/ipc/copy_output_result_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..5c60651abe9e69337e4ebadce0a296d5da1f7776
--- /dev/null
+++ b/cc/ipc/copy_output_result_struct_traits.h
@@ -0,0 +1,41 @@
+// Copyright 2017 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 CC_IPC_COPY_OUTPUT_RESULT_STRUCT_TRAITS_H_
+#define CC_IPC_COPY_OUTPUT_RESULT_STRUCT_TRAITS_H_
+
+#include "cc/ipc/copy_output_result.mojom-shared.h"
+#include "cc/output/copy_output_result.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<cc::mojom::CopyOutputResultDataView, cc::CopyOutputResult> {
+ static const gfx::Size& size(const cc::CopyOutputResult& result) {
+ return result.size_;
+ }
+
+ static const SkBitmap& bitmap(const cc::CopyOutputResult& result) {
+ static SkBitmap null_bitmap;
vmpstr 2017/01/31 21:32:19 nit: empty_bitmap
Ken Rockot(use gerrit already) 2017/01/31 21:46:20 Per the ongoing discussion linked earlier, please
Saman Sami 2017/02/01 15:51:57 Done.
Saman Sami 2017/02/01 15:51:57 This is a null bitmap though. IsNull() returns tru
Ken Rockot(use gerrit already) 2017/02/01 16:04:55 And perhaps more importantly, IsNull() returns tru
+ if (!result.bitmap_)
+ return null_bitmap;
+ return *result.bitmap_;
+ }
+
+ static const cc::TextureMailbox& texture_mailbox(
+ const cc::CopyOutputResult& result) {
+ return result.texture_mailbox_;
+ }
+
+ static bool Read(cc::mojom::CopyOutputResultDataView data,
Ken Rockot(use gerrit already) 2017/01/31 21:46:20 nit: (sorry, overlooked this earlier) Please defin
Saman Sami 2017/02/01 15:51:57 Done.
+ cc::CopyOutputResult* out) {
+ out->bitmap_ = base::MakeUnique<SkBitmap>();
+ return data.ReadSize(&out->size_) && data.ReadBitmap(out->bitmap_.get()) &&
+ data.ReadTextureMailbox(&out->texture_mailbox_);
+ }
+};
+
+} // namespace mojo
+
+#endif // CC_IPC_COPY_OUTPUT_RESULT_STRUCT_TRAITS_H_

Powered by Google App Engine
This is Rietveld 408576698