| OLD | NEW | 
|   1 // Copyright 2016 The Chromium Authors. All rights reserved. |   1 // Copyright 2016 The Chromium Authors. All rights reserved. | 
|   2 // Use of this source code is governed by a BSD-style license that can be |   2 // Use of this source code is governed by a BSD-style license that can be | 
|   3 // found in the LICENSE file. |   3 // found in the LICENSE file. | 
|   4  |   4  | 
|   5 #ifndef CC_IPC_SURFACE_ID_STRUCT_TRAITS_H_ |   5 #ifndef CC_IPC_SURFACE_ID_STRUCT_TRAITS_H_ | 
|   6 #define CC_IPC_SURFACE_ID_STRUCT_TRAITS_H_ |   6 #define CC_IPC_SURFACE_ID_STRUCT_TRAITS_H_ | 
|   7  |   7  | 
|   8 #include "cc/ipc/frame_sink_id_struct_traits.h" |   8 #include "cc/ipc/frame_sink_id_struct_traits.h" | 
 |   9 #include "cc/ipc/local_frame_id_struct_traits.h" | 
|   9 #include "cc/ipc/surface_id.mojom-shared.h" |  10 #include "cc/ipc/surface_id.mojom-shared.h" | 
|  10 #include "cc/surfaces/frame_sink_id.h" |  11 #include "cc/surfaces/frame_sink_id.h" | 
|  11 #include "cc/surfaces/surface_id.h" |  12 #include "cc/surfaces/surface_id.h" | 
|  12  |  13  | 
|  13 namespace mojo { |  14 namespace mojo { | 
|  14  |  15  | 
|  15 template <> |  16 template <> | 
|  16 struct StructTraits<cc::mojom::SurfaceIdDataView, cc::SurfaceId> { |  17 struct StructTraits<cc::mojom::SurfaceIdDataView, cc::SurfaceId> { | 
|  17   static const cc::FrameSinkId& frame_sink_id(const cc::SurfaceId& id) { |  18   static const cc::FrameSinkId& frame_sink_id(const cc::SurfaceId& id) { | 
|  18     return id.frame_sink_id(); |  19     return id.frame_sink_id(); | 
|  19   } |  20   } | 
|  20  |  21  | 
|  21   static uint32_t local_id(const cc::SurfaceId& id) { return id.local_id(); } |  22   static const cc::LocalFrameId& local_frame_id(const cc::SurfaceId& id) { | 
|  22  |  23     return id.local_frame_id(); | 
|  23   static uint64_t nonce(const cc::SurfaceId& id) { return id.nonce(); } |  24   } | 
|  24  |  25  | 
|  25   static bool Read(cc::mojom::SurfaceIdDataView data, cc::SurfaceId* out) { |  26   static bool Read(cc::mojom::SurfaceIdDataView data, cc::SurfaceId* out) { | 
|  26     cc::FrameSinkId frame_sink_id; |  27     cc::FrameSinkId frame_sink_id; | 
|  27     if (!data.ReadFrameSinkId(&frame_sink_id)) |  28     if (!data.ReadFrameSinkId(&frame_sink_id)) | 
|  28       return false; |  29       return false; | 
|  29     *out = cc::SurfaceId(frame_sink_id, data.local_id(), data.nonce()); |  30  | 
 |  31     cc::LocalFrameId local_frame_id; | 
 |  32     if (!data.ReadLocalFrameId(&local_frame_id)) | 
 |  33       return false; | 
 |  34  | 
 |  35     *out = cc::SurfaceId(frame_sink_id, local_frame_id); | 
|  30     return true; |  36     return true; | 
|  31   } |  37   } | 
|  32 }; |  38 }; | 
|  33  |  39  | 
|  34 }  // namespace mojo |  40 }  // namespace mojo | 
|  35  |  41  | 
|  36 #endif  // CC_IPC_SURFACE_ID_STRUCT_TRAITS_H_ |  42 #endif  // CC_IPC_SURFACE_ID_STRUCT_TRAITS_H_ | 
| OLD | NEW |