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

Side by Side Diff: components/arc/video_accelerator/video_accelerator_struct_traits.cc

Issue 2513973002: Use mojo typemap to simplify the code using DmabufPlane (Closed)
Patch Set: 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
Yusuke Sato 2016/11/29 21:34:28 The implementation doesn't make sense... I guess y
yoshiki 2016/11/30 17:25:44 Yes, this is mistake. Removed.
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 "components/arc/bitmap/bitmap_struct_traits.h"
6
7 namespace mojo {
8
9 bool StructTraits<arc::mojom::ArcVideoAcceleratorDmabufPlaneDataView,
10 ArcVideoAcceleratorDmabufPlane>::
11 Read(arc::mojom::ArcVideoAcceleratorDmabufPlaneDataView data,
12 ArcVideoAcceleratorDmabufPlane* out) {
13 mojo::ArrayDataView<uint8_t> pixel_data;
14 data.GetPixelDataDataView(&pixel_data);
15
16 SkImageInfo info = SkImageInfo::Make(
17 data.width(), data.height(), kRGBA_8888_SkColorType, kPremul_SkAlphaType);
18 if (info.getSafeSize(info.minRowBytes()) > pixel_data.size()) {
19 // Insufficient buffer size.
20 return false;
21 }
22
23 // Create the SkBitmap object which wraps the arc bitmap pixels. This
24 // doesn't copy and |data| and |bitmap| share the buffer.
25 SkBitmap bitmap;
26 if (!bitmap.installPixels(info, const_cast<uint8_t*>(pixel_data.data()),
27 info.minRowBytes())) {
28 // Error in installing pixels.
29 return false;
30 }
31
32 // Copy the pixels with converting color type.
33 return bitmap.copyTo(out, kN32_SkColorType);
34 }
35
36 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698