| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENT_ARC_BITMAP_BITMAP_STRUCT_TRAITS_H_ |
| 6 #define COMPONENT_ARC_BITMAP_BITMAP_STRUCT_TRAITS_H_ |
| 7 |
| 8 #include "components/arc/common/bitmap.mojom.h" |
| 9 #include "third_party/skia/include/core/SkBitmap.h" |
| 10 |
| 11 namespace mojo { |
| 12 |
| 13 template <> |
| 14 struct StructTraits<arc::mojom::ArcBitmapDataView, SkBitmap> { |
| 15 static const mojo::CArray<uint8_t> pixel_data(const SkBitmap& r) { |
| 16 const SkImageInfo& info = r.info(); |
| 17 DCHECK_EQ(info.colorType(), kRGBA_8888_SkColorType); |
| 18 |
| 19 return mojo::CArray<uint8_t>( |
| 20 r.getSize(), r.getSize(), static_cast<uint8_t*>(r.getPixels())); |
| 21 } |
| 22 static uint32_t width(const SkBitmap& r) { return r.width(); } |
| 23 static uint32_t height(const SkBitmap& r) { return r.height(); } |
| 24 |
| 25 static bool Read(arc::mojom::ArcBitmapDataView data, SkBitmap* out); |
| 26 }; |
| 27 |
| 28 } |
| 29 |
| 30 #endif // COMPONENT_ARC_BITMAP_BITMAP_STRUCT_TRAITS_H_ |
| OLD | NEW |