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

Side by Side Diff: ui/gfx/mojo/icc_profile_struct_traits.cc

Issue 2502703002: Add more robust gfx::ColorSpace<->gfx::ICCProfile conversion (Closed)
Patch Set: Clean up includes 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 unified diff | Download patch
« no previous file with comments | « ui/gfx/mojo/icc_profile_struct_traits.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ui/gfx/mojo/icc_profile_struct_traits.h" 5 #include "ui/gfx/mojo/icc_profile_struct_traits.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "mojo/public/cpp/bindings/string_data_view.h" 9 #include "mojo/public/cpp/bindings/string_data_view.h"
10 10
11 namespace mojo { 11 namespace mojo {
12 12
13 using Traits = StructTraits<gfx::mojom::ICCProfileDataView, gfx::ICCProfile>; 13 using Traits = StructTraits<gfx::mojom::ICCProfileDataView, gfx::ICCProfile>;
14 14
15 // static 15 // static
16 bool Traits::Read(gfx::mojom::ICCProfileDataView data, gfx::ICCProfile* out) { 16 bool Traits::Read(gfx::mojom::ICCProfileDataView data, gfx::ICCProfile* out) {
17 out->valid_ = data.valid(); 17 if (!data.ReadType(&out->type_))
18 return false;
19 if (!data.ReadColorSpace(&out->color_space_))
20 return false;
18 out->id_ = data.id(); 21 out->id_ = data.id();
19 22
20 mojo::StringDataView view; 23 mojo::StringDataView view;
21 data.GetDataDataView(&view); 24 data.GetDataDataView(&view);
22 out->data_.resize(view.size()); 25 out->data_.resize(view.size());
23 std::copy(view.storage(), view.storage() + view.size(), out->data_.begin()); 26 std::copy(view.storage(), view.storage() + view.size(), out->data_.begin());
24 return true; 27 return true;
25 } 28 }
26 29
27 } // namespace mojo 30 } // namespace mojo
OLDNEW
« no previous file with comments | « ui/gfx/mojo/icc_profile_struct_traits.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698