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

Unified Diff: skia/public/interfaces/image_filter_struct_traits.cc

Issue 2040233002: Implement sk_sp<SkImageFilter> StructTraits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't build StructTraitsTest on iOS Created 4 years, 6 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: skia/public/interfaces/image_filter_struct_traits.cc
diff --git a/skia/public/interfaces/image_filter_struct_traits.cc b/skia/public/interfaces/image_filter_struct_traits.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b21d6d41f9aa1fd237d4732c33b140c87bfb23c4
--- /dev/null
+++ b/skia/public/interfaces/image_filter_struct_traits.cc
@@ -0,0 +1,50 @@
+// 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 "skia/public/interfaces/image_filter_struct_traits.h"
+
+namespace mojo {
+
+ImageFilterBuffer::ImageFilterBuffer() {}
+
+ImageFilterBuffer::ImageFilterBuffer(const ImageFilterBuffer& other) = default;
+
+ImageFilterBuffer::~ImageFilterBuffer() = default;
+
+// static
+size_t ArrayTraits<ImageFilterBuffer>::GetSize(const ImageFilterBuffer& b) {
+ return b.data->size();
+}
+
+// static
+uint8_t* ArrayTraits<ImageFilterBuffer>::GetData(ImageFilterBuffer& b) {
+ return static_cast<uint8_t*>(b.data->writable_data());
+}
+
+// static
+const uint8_t* ArrayTraits<ImageFilterBuffer>::GetData(
+ const ImageFilterBuffer& b) {
+ return b.data->bytes();
+}
+
+// static
+uint8_t& ArrayTraits<ImageFilterBuffer>::GetAt(ImageFilterBuffer& b, size_t i) {
+ return *(static_cast<uint8_t*>(b.data->writable_data()) + i);
+}
+
+// static
+const uint8_t& ArrayTraits<ImageFilterBuffer>::GetAt(const ImageFilterBuffer& b,
+ size_t i) {
+ return *(b.data->bytes() + i);
+}
+
+// static
+bool ArrayTraits<ImageFilterBuffer>::Resize(ImageFilterBuffer& b, size_t size) {
+ if (b.data)
+ return size == b.data->size();
+ b.data = SkData::MakeUninitialized(size);
+ return true;
+}
+
+} // namespace mojo
« no previous file with comments | « skia/public/interfaces/image_filter_struct_traits.h ('k') | skia/public/interfaces/test/struct_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698