Verified Commit d00655c0 authored by Bob Owen's avatar Bob Owen Committed by Pier Angelo Vendrame
Browse files

Bug 1850072: Initialize RecordedDrawTargetCreation::mHasExistingData. r=jrmuizel

This also specializes ElementStreamFormat for bool.

Differential Revision: https://phabricator.services.mozilla.com/D187794
parent f3caf97d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ class RecordedDrawTargetCreation
  BackendType mBackendType;
  IntRect mRect;
  SurfaceFormat mFormat;
  bool mHasExistingData;
  bool mHasExistingData = false;
  RefPtr<SourceSurface> mExistingData;

 private:
+22 −0
Original line number Diff line number Diff line
@@ -24,6 +24,28 @@ struct ElementStreamFormat {
    aStream.read(reinterpret_cast<char*>(&aElement), sizeof(T));
  }
};
template <class S>
struct ElementStreamFormat<S, bool> {
  static void Write(S& aStream, const bool& aElement) {
    char boolChar = aElement ? '\x01' : '\x00';
    aStream.write(&boolChar, sizeof(boolChar));
  }
  static void Read(S& aStream, bool& aElement) {
    char boolChar;
    aStream.read(&boolChar, sizeof(boolChar));
    switch (boolChar) {
      case '\x00':
        aElement = false;
        break;
      case '\x01':
        aElement = true;
        break;
      default:
        aStream.SetIsBad();
        break;
    }
  }
};

template <class S, class T>
void WriteElement(S& aStream, const T& aElement) {