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

Side by Side Diff: ash/public/cpp/shelf_struct_traits.cc

Issue 2750463009: mash: Fix ShelfItem mojo struct; add enums and traits. (Closed)
Patch Set: Address comment. 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 | « ash/public/cpp/shelf_struct_traits.h ('k') | ash/public/cpp/shelf_struct_traits_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ash/public/cpp/shelf_struct_traits.h"
6
7 #include "mojo/common/common_custom_types_struct_traits.h"
8 #include "skia/public/interfaces/bitmap_skbitmap_struct_traits.h"
9 #include "ui/gfx/image/image_skia.h"
10
11 namespace mojo {
12
13 using ShelfItemStructTraits =
14 StructTraits<ash::mojom::ShelfItemDataView, ash::ShelfItem>;
15
16 // static
17 const SkBitmap& ShelfItemStructTraits::image(const ash::ShelfItem& i) {
18 // TODO(crbug.com/655874): Remove this when we have a gfx::Image[Skia] mojom.
19 static const SkBitmap kNullSkBitmap;
20 return i.image.isNull() ? kNullSkBitmap : *i.image.bitmap();
21 }
22
23 // static
24 bool ShelfItemStructTraits::Read(ash::mojom::ShelfItemDataView data,
25 ash::ShelfItem* out) {
26 SkBitmap image;
27 if (!data.ReadType(&out->type) || !data.ReadImage(&image) ||
28 !data.ReadStatus(&out->status) || !data.ReadAppId(&out->app_id) ||
29 !data.ReadTitle(&out->title)) {
30 return false;
31 }
32 out->id = data.shelf_id();
33 // TODO(crbug.com/655874): Support high-dpi images via gfx::Image[Skia] mojom.
34 out->image = gfx::ImageSkia::CreateFrom1xBitmap(image);
35 out->shows_tooltip = data.shows_tooltip();
36 out->pinned_by_policy = data.pinned_by_policy();
37 return true;
38 }
39
40 } // namespace mojo
OLDNEW
« no previous file with comments | « ash/public/cpp/shelf_struct_traits.h ('k') | ash/public/cpp/shelf_struct_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698