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

Unified Diff: ui/gfx/image/mojo/image_skia_struct_traits.h

Issue 2770693002: ash: HiDPI user avatar for SessionController (Closed)
Patch Set: fix gn check 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/image/mojo/image_skia_struct_traits.h
diff --git a/ui/gfx/image/mojo/image_skia_struct_traits.h b/ui/gfx/image/mojo/image_skia_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..6fdcf6e106508550e04121d355ac33625f1700ca
--- /dev/null
+++ b/ui/gfx/image/mojo/image_skia_struct_traits.h
@@ -0,0 +1,65 @@
+// Copyright 2017 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.
+
+#ifndef UI_GFX_IMAGE_MOJO_IMAGE_SKIA_STRUCT_TRAITS_H_
+#define UI_GFX_IMAGE_MOJO_IMAGE_SKIA_STRUCT_TRAITS_H_
+
+#include <stdint.h>
+
+#include <vector>
+
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/gfx/image/image_skia.h"
+#include "ui/gfx/image/image_skia_rep.h"
+#include "ui/gfx/image/mojo/image_skia.mojom-shared.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<gfx::mojom::ImageSkiaRepDataView, gfx::ImageSkiaRep> {
+ struct Context {
+ Context();
+ ~Context();
+
+ mojo::ScopedSharedBufferHandle shared_buffer_handle;
+ uint32_t buffer_byte_size = 0;
+ };
+
+ static void* SetUpContext(const gfx::ImageSkiaRep& input);
+ static void TearDownContext(const gfx::ImageSkiaRep& input, void* context);
+ static mojo::ScopedSharedBufferHandle shared_buffer_handle(
+ const gfx::ImageSkiaRep& input,
+ void* context);
+ static uint32_t buffer_byte_size(const gfx::ImageSkiaRep& input,
+ void* context);
+ static float scale(const gfx::ImageSkiaRep& input) { return input.scale(); }
+
+ static bool IsNull(const gfx::ImageSkiaRep& input) {
+ return input.sk_bitmap().drawsNothing();
msw 2017/03/23 20:47:52 nit: use ImageSkiaRep::is_null() or input.sk_bitma
xiyuan 2017/03/24 05:45:21 is_null does not check empty bitmap (0x0 image). d
+ }
+ static void SetToNull(gfx::ImageSkiaRep* out) { *out = gfx::ImageSkiaRep(); }
+
+ static bool Read(gfx::mojom::ImageSkiaRepDataView data,
+ gfx::ImageSkiaRep* out);
+};
+
+template <>
+struct StructTraits<gfx::mojom::ImageSkiaDataView, gfx::ImageSkia> {
+ static void* SetUpContext(const gfx::ImageSkia& input);
+ static void TearDownContext(const gfx::ImageSkia& input, void* context);
+ static const std::vector<gfx::ImageSkiaRep>& image_reps(
+ const gfx::ImageSkia& input,
+ void* context);
+
+ static bool IsNull(const gfx::ImageSkia& input) {
+ return input.image_reps().empty();
msw 2017/03/23 20:47:52 q: I wonder if it's always safe to call this; imag
xiyuan 2017/03/24 05:45:22 CanRead() only fails if ImageSkia is not marked as
+ }
+ static void SetToNull(gfx::ImageSkia* out) { *out = gfx::ImageSkia(); }
+
+ static bool Read(gfx::mojom::ImageSkiaDataView data, gfx::ImageSkia* out);
+};
+
+} // namespace mojo
+
+#endif // UI_GFX_IMAGE_MOJO_IMAGE_SKIA_STRUCT_TRAITS_H_

Powered by Google App Engine
This is Rietveld 408576698