|
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 #ifndef MOZILLA_GFX_DRAWEVENTRECORDER_H_ |
|
7 #define MOZILLA_GFX_DRAWEVENTRECORDER_H_ |
|
8 |
|
9 #include "2D.h" |
|
10 #include "RecordedEvent.h" |
|
11 #include <ostream> |
|
12 #include <fstream> |
|
13 |
|
14 #if defined(_MSC_VER) |
|
15 #include <hash_set> |
|
16 #else |
|
17 #include <set> |
|
18 #endif |
|
19 |
|
20 namespace mozilla { |
|
21 namespace gfx { |
|
22 |
|
23 class PathRecording; |
|
24 |
|
25 class DrawEventRecorderPrivate : public DrawEventRecorder |
|
26 { |
|
27 public: |
|
28 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawEventRecorderPrivate) |
|
29 DrawEventRecorderPrivate(std::ostream *aStream); |
|
30 virtual ~DrawEventRecorderPrivate() { } |
|
31 |
|
32 void RecordEvent(const RecordedEvent &aEvent); |
|
33 void WritePath(const PathRecording *aPath); |
|
34 |
|
35 void AddStoredPath(const ReferencePtr aPath) { |
|
36 mStoredPaths.insert(aPath); |
|
37 } |
|
38 |
|
39 void RemoveStoredPath(const ReferencePtr aPath) { |
|
40 mStoredPaths.erase(aPath); |
|
41 } |
|
42 |
|
43 bool HasStoredPath(const ReferencePtr aPath) { |
|
44 if (mStoredPaths.find(aPath) != mStoredPaths.end()) { |
|
45 return true; |
|
46 } |
|
47 return false; |
|
48 } |
|
49 |
|
50 protected: |
|
51 std::ostream *mOutputStream; |
|
52 |
|
53 virtual void Flush() = 0; |
|
54 |
|
55 #if defined(_MSC_VER) |
|
56 typedef stdext::hash_set<const void*> ObjectSet; |
|
57 #else |
|
58 typedef std::set<const void*> ObjectSet; |
|
59 #endif |
|
60 |
|
61 ObjectSet mStoredPaths; |
|
62 ObjectSet mStoredScaledFonts; |
|
63 }; |
|
64 |
|
65 class DrawEventRecorderFile : public DrawEventRecorderPrivate |
|
66 { |
|
67 public: |
|
68 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawEventRecorderFile) |
|
69 DrawEventRecorderFile(const char *aFilename); |
|
70 ~DrawEventRecorderFile(); |
|
71 |
|
72 private: |
|
73 virtual void Flush(); |
|
74 |
|
75 std::ofstream mOutputFile; |
|
76 }; |
|
77 |
|
78 } |
|
79 } |
|
80 |
|
81 #endif /* MOZILLA_GFX_DRAWEVENTRECORDER_H_ */ |