1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/2d/DrawEventRecorder.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "DrawEventRecorder.h" 1.10 +#include "PathRecording.h" 1.11 + 1.12 +namespace mozilla { 1.13 +namespace gfx { 1.14 + 1.15 +using namespace std; 1.16 + 1.17 +const uint32_t kMagicInt = 0xc001feed; 1.18 + 1.19 +DrawEventRecorderPrivate::DrawEventRecorderPrivate(std::ostream *aStream) 1.20 + : mOutputStream(aStream) 1.21 +{ 1.22 +} 1.23 + 1.24 +void 1.25 +DrawEventRecorderPrivate::RecordEvent(const RecordedEvent &aEvent) 1.26 +{ 1.27 + WriteElement(*mOutputStream, aEvent.mType); 1.28 + 1.29 + aEvent.RecordToStream(*mOutputStream); 1.30 + 1.31 + Flush(); 1.32 +} 1.33 + 1.34 +DrawEventRecorderFile::DrawEventRecorderFile(const char *aFilename) 1.35 + : DrawEventRecorderPrivate(nullptr) 1.36 + , mOutputFile(aFilename, ofstream::binary) 1.37 +{ 1.38 + mOutputStream = &mOutputFile; 1.39 + 1.40 + WriteElement(*mOutputStream, kMagicInt); 1.41 + WriteElement(*mOutputStream, kMajorRevision); 1.42 + WriteElement(*mOutputStream, kMinorRevision); 1.43 +} 1.44 + 1.45 +DrawEventRecorderFile::~DrawEventRecorderFile() 1.46 +{ 1.47 + mOutputFile.close(); 1.48 +} 1.49 + 1.50 +void 1.51 +DrawEventRecorderFile::Flush() 1.52 +{ 1.53 + mOutputFile.flush(); 1.54 +} 1.55 + 1.56 +} 1.57 +}