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

Unified Diff: components/arc/bitmap/bitmap_type_converters.cc

Issue 1883473002: arc: Support more types of notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: components/arc/bitmap/bitmap_type_converters.cc
diff --git a/components/arc/bitmap/bitmap_type_converters.cc b/components/arc/bitmap/bitmap_type_converters.cc
new file mode 100644
index 0000000000000000000000000000000000000000..45e7d707b96942986a557f2127b1b9579ec30f08
--- /dev/null
+++ b/components/arc/bitmap/bitmap_type_converters.cc
@@ -0,0 +1,32 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/arc/bitmap/bitmap_type_converters.h"
+
+namespace mojo {
+
+SkBitmap TypeConverter<SkBitmap, arc::mojom::ArcBitmapPtr>::Convert(
+ const arc::mojom::ArcBitmapPtr& arcBitmap) {
+ if (arcBitmap.is_null())
+ return SkBitmap();
+
+ // Create the SkBitmap object which wraps the arc bitmap pixels.
+ SkBitmap bitmap;
+ if (!bitmap.installPixels(
+ SkImageInfo::Make(arcBitmap->width, arcBitmap->height,
dcheng 2016/04/27 01:04:09 I'd suggest something more like this (since we sho
yoshiki 2016/04/28 18:43:21 Done.
+ kRGBA_8888_SkColorType, kPremul_SkAlphaType),
+ const_cast<uint8_t*>(arcBitmap->pixel_data.storage().data()),
+ arcBitmap->width * 4)) {
+ return SkBitmap();
+ }
+
+ // Copy the pixels with converting color type.
+ SkBitmap nativeColorBitmap;
+ if (!bitmap.copyTo(&nativeColorBitmap, kN32_SkColorType))
+ return SkBitmap();
+
+ return nativeColorBitmap;
+}
+
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698