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

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

Issue 2720503008: Add cc::SurfaceInfo::is_valid() (Closed)
Patch Set: Check is_valid() during deserialization Created 3 years, 9 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
« no previous file with comments | « no previous file | cc/layers/surface_layer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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_INFO_STRUCT_TRAITS_H_ 5 #ifndef CC_IPC_SURFACE_INFO_STRUCT_TRAITS_H_
6 #define CC_IPC_SURFACE_INFO_STRUCT_TRAITS_H_ 6 #define CC_IPC_SURFACE_INFO_STRUCT_TRAITS_H_
7 7
8 #include "cc/ipc/surface_info.mojom-shared.h" 8 #include "cc/ipc/surface_info.mojom-shared.h"
9 #include "cc/surfaces/surface_info.h" 9 #include "cc/surfaces/surface_info.h"
10 10
11 namespace mojo { 11 namespace mojo {
12 12
13 template <> 13 template <>
14 struct StructTraits<cc::mojom::SurfaceInfoDataView, cc::SurfaceInfo> { 14 struct StructTraits<cc::mojom::SurfaceInfoDataView, cc::SurfaceInfo> {
15 static const cc::SurfaceId& surface_id(const cc::SurfaceInfo& surface_info) { 15 static const cc::SurfaceId& surface_id(const cc::SurfaceInfo& surface_info) {
16 return surface_info.id(); 16 return surface_info.id();
17 } 17 }
18 18
19 static float device_scale_factor(const cc::SurfaceInfo& surface_info) { 19 static float device_scale_factor(const cc::SurfaceInfo& surface_info) {
20 return surface_info.device_scale_factor(); 20 return surface_info.device_scale_factor();
21 } 21 }
22 22
23 static const gfx::Size& size_in_pixels(const cc::SurfaceInfo& surface_info) { 23 static const gfx::Size& size_in_pixels(const cc::SurfaceInfo& surface_info) {
24 return surface_info.size_in_pixels(); 24 return surface_info.size_in_pixels();
25 } 25 }
26 26
27 static bool Read(cc::mojom::SurfaceInfoDataView data, cc::SurfaceInfo* out) { 27 static bool Read(cc::mojom::SurfaceInfoDataView data, cc::SurfaceInfo* out) {
28 out->device_scale_factor_ = data.device_scale_factor(); 28 out->device_scale_factor_ = data.device_scale_factor();
29 return data.ReadSurfaceId(&out->id_) && 29 return data.ReadSurfaceId(&out->id_) &&
30 data.ReadSizeInPixels(&out->size_in_pixels_); 30 data.ReadSizeInPixels(&out->size_in_pixels_) && out->is_valid();
Fady Samuel 2017/02/28 02:54:32 I'm not sure if compilers are guaranteed to proces
Tom Sepez 2017/02/28 17:52:01 This is fine; sequence points in C occur at the en
31 } 31 }
32 }; 32 };
33 33
34 } // namespace mojo 34 } // namespace mojo
35 35
36 #endif // CC_IPC_SURFACE_INFO_STRUCT_TRAITS_H_ 36 #endif // CC_IPC_SURFACE_INFO_STRUCT_TRAITS_H_
OLDNEW
« no previous file with comments | « no previous file | cc/layers/surface_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698