Bug 1385003 - Use PlainOldDataSerializer for WR struct serialization to avoid getting them out of sync. r=jrmuizel
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 09 Aug 2017 08:07:11 -0400
changeset 373663 2c214b5c0ab9c51e23c670dd3a01765e5a5fccb5
parent 373662 b8502cbb27c08cd362759049dcb506f5956d8b29
child 373664 f5b9bc1d974548f6707d6beb807aecf09ff073c5
push id32308
push userarchaeopteryx@coole-files.de
push dateThu, 10 Aug 2017 15:20:33 +0000
treeherdermozilla-central@5322c03f4c85 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1385003
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1385003 - Use PlainOldDataSerializer for WR struct serialization to avoid getting them out of sync. r=jrmuizel MozReview-Commit-ID: 6x3G0Ik6PJj
gfx/layers/wr/WebRenderMessageUtils.h
--- a/gfx/layers/wr/WebRenderMessageUtils.h
+++ b/gfx/layers/wr/WebRenderMessageUtils.h
@@ -32,185 +32,75 @@ struct ParamTraits<mozilla::wr::ByteBuff
     return ReadParam(aMsg, aIter, &length)
         && aResult->Allocate(length)
         && aMsg->ReadBytesInto(aIter, aResult->mData, length);
   }
 };
 
 template<>
 struct ParamTraits<mozilla::wr::IdNamespace>
+  : public PlainOldDataSerializer<mozilla::wr::IdNamespace>
 {
-  static void
-  Write(Message* aMsg, const mozilla::wr::IdNamespace& aParam)
-  {
-    WriteParam(aMsg, aParam.mHandle);
-  }
-
-  static bool
-  Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::IdNamespace* aResult)
-  {
-    return ReadParam(aMsg, aIter, &aResult->mHandle);
-  }
 };
 
 template<>
 struct ParamTraits<mozilla::wr::ImageKey>
+  : public PlainOldDataSerializer<mozilla::wr::ImageKey>
 {
-  static void
-  Write(Message* aMsg, const mozilla::wr::ImageKey& aParam)
-  {
-    WriteParam(aMsg, aParam.mNamespace);
-    WriteParam(aMsg, aParam.mHandle);
-  }
-
-  static bool
-  Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::ImageKey* aResult)
-  {
-    return ReadParam(aMsg, aIter, &aResult->mNamespace)
-        && ReadParam(aMsg, aIter, &aResult->mHandle);
-  }
 };
 
 template<>
 struct ParamTraits<mozilla::wr::FontKey>
+  : public PlainOldDataSerializer<mozilla::wr::FontKey>
 {
-  static void
-  Write(Message* aMsg, const mozilla::wr::FontKey& aParam)
-  {
-    WriteParam(aMsg, aParam.mNamespace);
-    WriteParam(aMsg, aParam.mHandle);
-  }
-
-  static bool
-  Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::FontKey* aResult)
-  {
-    return ReadParam(aMsg, aIter, &aResult->mNamespace)
-        && ReadParam(aMsg, aIter, &aResult->mHandle);
-  }
 };
 
 template<>
 struct ParamTraits<mozilla::wr::ExternalImageId>
+  : public PlainOldDataSerializer<mozilla::wr::ExternalImageId>
 {
-  static void
-  Write(Message* aMsg, const mozilla::wr::ExternalImageId& aParam)
-  {
-    WriteParam(aMsg, aParam.mHandle);
-  }
-
-  static bool
-  Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::ExternalImageId* aResult)
-  {
-    return ReadParam(aMsg, aIter, &aResult->mHandle);
-  }
 };
 
 template<>
 struct ParamTraits<mozilla::wr::PipelineId>
+  : public PlainOldDataSerializer<mozilla::wr::PipelineId>
 {
-  static void
-  Write(Message* aMsg, const mozilla::wr::PipelineId& aParam)
-  {
-    WriteParam(aMsg, aParam.mNamespace);
-    WriteParam(aMsg, aParam.mHandle);
-  }
-
-  static bool
-  Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::PipelineId* aResult)
-  {
-    return ReadParam(aMsg, aIter, &aResult->mNamespace)
-        && ReadParam(aMsg, aIter, &aResult->mHandle);
-  }
 };
 
 template<>
 struct ParamTraits<mozilla::wr::ImageFormat>
   : public ContiguousEnumSerializer<
         mozilla::wr::ImageFormat,
         mozilla::wr::ImageFormat::Invalid,
         mozilla::wr::ImageFormat::Sentinel>
 {
 };
 
 template<>
 struct ParamTraits<mozilla::wr::LayoutSize>
+  : public PlainOldDataSerializer<mozilla::wr::LayoutSize>
 {
-  static void
-  Write(Message* aMsg, const mozilla::wr::LayoutSize& aParam)
-  {
-    WriteParam(aMsg, aParam.width);
-    WriteParam(aMsg, aParam.height);
-  }
-
-  static bool
-  Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::LayoutSize* aResult)
-  {
-    return ReadParam(aMsg, aIter, &aResult->width)
-        && ReadParam(aMsg, aIter, &aResult->height);
-  }
 };
 
 template<>
 struct ParamTraits<mozilla::wr::LayoutRect>
+  : public PlainOldDataSerializer<mozilla::wr::LayoutRect>
 {
-  static void
-  Write(Message* aMsg, const mozilla::wr::LayoutRect& aParam)
-  {
-    WriteParam(aMsg, aParam.origin.x);
-    WriteParam(aMsg, aParam.origin.y);
-    WriteParam(aMsg, aParam.size.width);
-    WriteParam(aMsg, aParam.size.height);
-  }
-
-  static bool
-  Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::LayoutRect* aResult)
-  {
-    return ReadParam(aMsg, aIter, &aResult->origin.x)
-        && ReadParam(aMsg, aIter, &aResult->origin.y)
-        && ReadParam(aMsg, aIter, &aResult->size.width)
-        && ReadParam(aMsg, aIter, &aResult->size.height);
-  }
 };
 
 template<>
 struct ParamTraits<mozilla::wr::LayoutPoint>
+  : public PlainOldDataSerializer<mozilla::wr::LayoutPoint>
 {
-  static void
-  Write(Message* aMsg, const mozilla::wr::LayoutPoint& aParam)
-  {
-    WriteParam(aMsg, aParam.x);
-    WriteParam(aMsg, aParam.y);
-  }
-
-  static bool
-  Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::LayoutPoint* aResult)
-  {
-    return ReadParam(aMsg, aIter, &aResult->x) &&
-           ReadParam(aMsg, aIter, &aResult->y);
-  }
 };
 
 template<>
 struct ParamTraits<mozilla::wr::WrImageMask>
+  : public PlainOldDataSerializer<mozilla::wr::WrImageMask>
 {
-  static void
-  Write(Message* aMsg, const mozilla::wr::WrImageMask& aParam)
-  {
-    WriteParam(aMsg, aParam.image);
-    WriteParam(aMsg, aParam.rect);
-    WriteParam(aMsg, aParam.repeat);
-  }
-
-  static bool
-  Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::WrImageMask* aResult)
-  {
-    return ReadParam(aMsg, aIter, &aResult->image)
-        && ReadParam(aMsg, aIter, &aResult->rect)
-        && ReadParam(aMsg, aIter, &aResult->repeat);
-  }
 };
 
 template<>
 struct ParamTraits<mozilla::wr::ImageRendering>
   : public ContiguousEnumSerializer<
         mozilla::wr::ImageRendering,
         mozilla::wr::ImageRendering::Auto,
         mozilla::wr::ImageRendering::Sentinel>
@@ -223,27 +113,15 @@ struct ParamTraits<mozilla::wr::MixBlend
         mozilla::wr::MixBlendMode,
         mozilla::wr::MixBlendMode::Normal,
         mozilla::wr::MixBlendMode::Sentinel>
 {
 };
 
 template<>
 struct ParamTraits<mozilla::wr::BuiltDisplayListDescriptor>
+  : public PlainOldDataSerializer<mozilla::wr::BuiltDisplayListDescriptor>
 {
-  static void
-  Write(Message* aMsg, const mozilla::wr::BuiltDisplayListDescriptor& aParam)
-  {
-    WriteParam(aMsg, aParam.builder_start_time);
-    WriteParam(aMsg, aParam.builder_finish_time);
-  }
-
-  static bool
-  Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::BuiltDisplayListDescriptor* aResult)
-  {
-    return ReadParam(aMsg, aIter, &aResult->builder_start_time)
-        && ReadParam(aMsg, aIter, &aResult->builder_finish_time);
-  }
 };
 
 } // namespace IPC
 
 #endif // GFX_WEBRENDERMESSAGEUTILS_H