| 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 #include "components/arc/bitmap/bitmap_struct_traits.h" | 5 #include "components/arc/bitmap/bitmap_struct_traits.h" |
| 6 | 6 |
| 7 namespace mojo { | 7 namespace mojo { |
| 8 | 8 |
| 9 bool StructTraits<arc::mojom::ArcBitmapDataView, SkBitmap>:: | 9 bool StructTraits<arc::mojom::ArcBitmapDataView, SkBitmap>:: |
| 10 Read(arc::mojom::ArcBitmapDataView data, SkBitmap* out) { | 10 Read(arc::mojom::ArcBitmapDataView data, SkBitmap* out) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // doesn't copy and |data| and |bitmap| share the buffer. | 23 // doesn't copy and |data| and |bitmap| share the buffer. |
| 24 SkBitmap bitmap; | 24 SkBitmap bitmap; |
| 25 if (!bitmap.installPixels(info, | 25 if (!bitmap.installPixels(info, |
| 26 const_cast<uint8_t*>(pixel_data.data()), | 26 const_cast<uint8_t*>(pixel_data.data()), |
| 27 info.minRowBytes())) { | 27 info.minRowBytes())) { |
| 28 // Error in installing pixels. | 28 // Error in installing pixels. |
| 29 return false; | 29 return false; |
| 30 } | 30 } |
| 31 | 31 |
| 32 // Copy the pixels with converting color type. | 32 // Copy the pixels with converting color type. |
| 33 return bitmap.copyTo(out, kN32_SkColorType); | 33 SkImageInfo image_info = info.makeColorType(kN32_SkColorType); |
| 34 return out->tryAllocPixels(image_info) && |
| 35 bitmap.readPixels(image_info, out->getPixels(), out->rowBytes(), 0, 0); |
| 34 } | 36 } |
| 35 | 37 |
| 36 } // namespace mojo | 38 } // namespace mojo |
| OLD | NEW |