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

Side by Side Diff: cc/ipc/copy_output_result_struct_traits.h

Issue 2659703002: Implemented StructTraits for cc::CopyOutputResult (Closed)
Patch Set: c Created 3 years, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CC_IPC_COPY_OUTPUT_RESULT_STRUCT_TRAITS_H_
6 #define CC_IPC_COPY_OUTPUT_RESULT_STRUCT_TRAITS_H_
7
8 #include "cc/ipc/copy_output_result.mojom-shared.h"
9 #include "cc/output/copy_output_result.h"
10
11 namespace mojo {
12
13 template <>
14 struct StructTraits<cc::mojom::CopyOutputResultDataView, cc::CopyOutputResult> {
15 static const gfx::Size& size(const cc::CopyOutputResult& result) {
16 return result.size_;
17 }
18
19 static const SkBitmap& bitmap(const cc::CopyOutputResult& result) {
20 static SkBitmap null_bitmap_;
Ken Rockot(use gerrit already) 2017/01/31 20:16:35 Non-POD static variables are strictly forbidden by
21 if (!result.bitmap_)
22 return null_bitmap_;
23 return *result.bitmap_;
24 }
25
26 static const cc::TextureMailbox& texture_mailbox(
27 const cc::CopyOutputResult& result) {
28 return result.texture_mailbox_;
29 }
30
31 static bool Read(cc::mojom::CopyOutputResultDataView data,
32 cc::CopyOutputResult* out) {
33 out->bitmap_ = base::MakeUnique<SkBitmap>();
34 return data.ReadSize(&out->size_) && data.ReadBitmap(out->bitmap_.get()) &&
35 data.ReadTextureMailbox(&out->texture_mailbox_);
36 }
37 };
38
39 } // namespace mojo
40
41 #endif // CC_IPC_COPY_OUTPUT_RESULT_STRUCT_TRAITS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698