Bug 1374900. Make our low level serialization functions generic over the type of stream. r=lsalzman

This commit is contained in:
Jeff Muizelaar 2017-06-22 16:46:08 -04:00
parent 23c4a6e056
commit 4f96690374
7 changed files with 3092 additions and 2949 deletions

View File

@ -13,6 +13,7 @@
#include "Filters.h"
#include "mozilla/UniquePtr.h"
#include "RecordingTypes.h"
#include "RecordedEventImpl.h"
namespace mozilla {
namespace gfx {

View File

@ -13,6 +13,7 @@
#include "Filters.h"
#include "mozilla/UniquePtr.h"
#include "RecordingTypes.h"
#include "RecordedEventImpl.h"
namespace mozilla {
namespace gfx {

View File

@ -5,6 +5,7 @@
#include "PathRecording.h"
#include "DrawEventRecorder.h"
#include "RecordedEventImpl.h"
namespace mozilla {
namespace gfx {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

3073
gfx/2d/RecordedEventImpl.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -11,28 +11,28 @@
namespace mozilla {
namespace gfx {
template<class T>
template<class S, class T>
struct ElementStreamFormat
{
static void Write(std::ostream &aStream, const T &aElement)
static void Write(S &aStream, const T &aElement)
{
aStream.write(reinterpret_cast<const char*>(&aElement), sizeof(T));
}
static void Read(std::istream &aStream, T &aElement)
static void Read(S &aStream, T &aElement)
{
aStream.read(reinterpret_cast<char *>(&aElement), sizeof(T));
}
};
template<class T>
void WriteElement(std::ostream &aStream, const T &aElement)
template<class S, class T>
void WriteElement(S &aStream, const T &aElement)
{
ElementStreamFormat<T>::Write(aStream, aElement);
ElementStreamFormat<S, T>::Write(aStream, aElement);
}
template<class T>
void ReadElement(std::istream &aStream, T &aElement)
template<class S, class T>
void ReadElement(S &aStream, T &aElement)
{
ElementStreamFormat<T>::Read(aStream, aElement);
ElementStreamFormat<S, T>::Read(aStream, aElement);
}
} // namespace gfx