Bug 1529677 - Move writing of Event type from RecordEvent() into RecordToStream(). r=bobowen
authorJeff Muizelaar <jrmuizel@gmail.com>
Thu, 21 Feb 2019 11:23:00 +0000
changeset 477751 4793f9c4f13d2589c9322363bc307ffcac501db5
parent 477750 9909cd207cc21bf0de639e211fcfe950690f31a5
child 477752 be11539bd8d89d2490e30bdb5cf242850b283e44
push id113373
push userbobowencode@gmail.com
push dateFri, 07 Jun 2019 11:10:59 +0000
treeherdermozilla-inbound@2195b79ea888 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbobowen
bugs1529677
milestone69.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 1529677 - Move writing of Event type from RecordEvent() into RecordToStream(). r=bobowen
gfx/2d/DrawEventRecorder.cpp
gfx/2d/RecordedEventImpl.h
layout/printing/DrawEventRecorder.cpp
--- a/gfx/2d/DrawEventRecorder.cpp
+++ b/gfx/2d/DrawEventRecorder.cpp
@@ -40,26 +40,22 @@ void DrawEventRecorderPrivate::StoreSour
   UniquePtr<uint8_t[]> sourceData(
       new uint8_t[stride * aSurface->GetSize().height]());
   RecordEvent(RecordedSourceSurfaceCreation(aSurface, sourceData.get(), stride,
                                             aSurface->GetSize(),
                                             aSurface->GetFormat()));
 }
 
 void DrawEventRecorderFile::RecordEvent(const RecordedEvent& aEvent) {
-  WriteElement(mOutputStream, aEvent.mType);
-
   aEvent.RecordToStream(mOutputStream);
 
   Flush();
 }
 
 void DrawEventRecorderMemory::RecordEvent(const RecordedEvent& aEvent) {
-  WriteElement(mOutputStream, aEvent.mType);
-
   aEvent.RecordToStream(mOutputStream);
 }
 
 void DrawEventRecorderMemory::AddDependentSurface(uint64_t aDependencyId) {
   mDependentSurfaces.PutEntry(aDependencyId);
 }
 
 nsTHashtable<nsUint64HashKey>&&
--- a/gfx/2d/RecordedEventImpl.h
+++ b/gfx/2d/RecordedEventImpl.h
@@ -21,26 +21,32 @@ namespace mozilla {
 namespace gfx {
 
 template <class Derived>
 class RecordedEventDerived : public RecordedEvent {
   using RecordedEvent::RecordedEvent;
 
  public:
   void RecordToStream(std::ostream& aStream) const override {
+    WriteElement(aStream, this->mType);
     static_cast<const Derived*>(this)->Record(aStream);
   }
   void RecordToStream(EventStream& aStream) const override {
+    WriteElement(aStream, this->mType);
     static_cast<const Derived*>(this)->Record(aStream);
   }
   void RecordToStream(MemStream& aStream) const override {
     SizeCollector size;
+    WriteElement(size, this->mType);
     static_cast<const Derived*>(this)->Record(size);
+
     aStream.Resize(aStream.mLength + size.mTotalSize);
+
     MemWriter writer(aStream.mData + aStream.mLength - size.mTotalSize);
+    WriteElement(writer, this->mType);
     static_cast<const Derived*>(this)->Record(writer);
   }
 };
 
 template <class Derived>
 class RecordedDrawingEvent : public RecordedEventDerived<Derived> {
  public:
   ReferencePtr GetDestinedDT() override { return mDT; }
--- a/layout/printing/DrawEventRecorder.cpp
+++ b/layout/printing/DrawEventRecorder.cpp
@@ -6,18 +6,16 @@
 
 #include "DrawEventRecorder.h"
 
 namespace mozilla {
 namespace layout {
 
 void DrawEventRecorderPRFileDesc::RecordEvent(
     const gfx::RecordedEvent& aEvent) {
-  WriteElement(mOutputStream, aEvent.GetType());
-
   aEvent.RecordToStream(mOutputStream);
 
   Flush();
 }
 
 DrawEventRecorderPRFileDesc::~DrawEventRecorderPRFileDesc() {
   if (IsOpen()) {
     Close();