michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef MOZILLA_GFX_DRAWEVENTRECORDER_H_ michael@0: #define MOZILLA_GFX_DRAWEVENTRECORDER_H_ michael@0: michael@0: #include "2D.h" michael@0: #include "RecordedEvent.h" michael@0: #include michael@0: #include michael@0: michael@0: #if defined(_MSC_VER) michael@0: #include michael@0: #else michael@0: #include michael@0: #endif michael@0: michael@0: namespace mozilla { michael@0: namespace gfx { michael@0: michael@0: class PathRecording; michael@0: michael@0: class DrawEventRecorderPrivate : public DrawEventRecorder michael@0: { michael@0: public: michael@0: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawEventRecorderPrivate) michael@0: DrawEventRecorderPrivate(std::ostream *aStream); michael@0: virtual ~DrawEventRecorderPrivate() { } michael@0: michael@0: void RecordEvent(const RecordedEvent &aEvent); michael@0: void WritePath(const PathRecording *aPath); michael@0: michael@0: void AddStoredPath(const ReferencePtr aPath) { michael@0: mStoredPaths.insert(aPath); michael@0: } michael@0: michael@0: void RemoveStoredPath(const ReferencePtr aPath) { michael@0: mStoredPaths.erase(aPath); michael@0: } michael@0: michael@0: bool HasStoredPath(const ReferencePtr aPath) { michael@0: if (mStoredPaths.find(aPath) != mStoredPaths.end()) { michael@0: return true; michael@0: } michael@0: return false; michael@0: } michael@0: michael@0: protected: michael@0: std::ostream *mOutputStream; michael@0: michael@0: virtual void Flush() = 0; michael@0: michael@0: #if defined(_MSC_VER) michael@0: typedef stdext::hash_set ObjectSet; michael@0: #else michael@0: typedef std::set ObjectSet; michael@0: #endif michael@0: michael@0: ObjectSet mStoredPaths; michael@0: ObjectSet mStoredScaledFonts; michael@0: }; michael@0: michael@0: class DrawEventRecorderFile : public DrawEventRecorderPrivate michael@0: { michael@0: public: michael@0: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawEventRecorderFile) michael@0: DrawEventRecorderFile(const char *aFilename); michael@0: ~DrawEventRecorderFile(); michael@0: michael@0: private: michael@0: virtual void Flush(); michael@0: michael@0: std::ofstream mOutputFile; michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif /* MOZILLA_GFX_DRAWEVENTRECORDER_H_ */