|
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "DrawEventRecorder.h" |
|
7 #include "PathRecording.h" |
|
8 |
|
9 namespace mozilla { |
|
10 namespace gfx { |
|
11 |
|
12 using namespace std; |
|
13 |
|
14 const uint32_t kMagicInt = 0xc001feed; |
|
15 |
|
16 DrawEventRecorderPrivate::DrawEventRecorderPrivate(std::ostream *aStream) |
|
17 : mOutputStream(aStream) |
|
18 { |
|
19 } |
|
20 |
|
21 void |
|
22 DrawEventRecorderPrivate::RecordEvent(const RecordedEvent &aEvent) |
|
23 { |
|
24 WriteElement(*mOutputStream, aEvent.mType); |
|
25 |
|
26 aEvent.RecordToStream(*mOutputStream); |
|
27 |
|
28 Flush(); |
|
29 } |
|
30 |
|
31 DrawEventRecorderFile::DrawEventRecorderFile(const char *aFilename) |
|
32 : DrawEventRecorderPrivate(nullptr) |
|
33 , mOutputFile(aFilename, ofstream::binary) |
|
34 { |
|
35 mOutputStream = &mOutputFile; |
|
36 |
|
37 WriteElement(*mOutputStream, kMagicInt); |
|
38 WriteElement(*mOutputStream, kMajorRevision); |
|
39 WriteElement(*mOutputStream, kMinorRevision); |
|
40 } |
|
41 |
|
42 DrawEventRecorderFile::~DrawEventRecorderFile() |
|
43 { |
|
44 mOutputFile.close(); |
|
45 } |
|
46 |
|
47 void |
|
48 DrawEventRecorderFile::Flush() |
|
49 { |
|
50 mOutputFile.flush(); |
|
51 } |
|
52 |
|
53 } |
|
54 } |