gfx/2d/DrawEventRecorder.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/2d/DrawEventRecorder.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,81 @@
     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 +#ifndef MOZILLA_GFX_DRAWEVENTRECORDER_H_
    1.10 +#define MOZILLA_GFX_DRAWEVENTRECORDER_H_
    1.11 +
    1.12 +#include "2D.h"
    1.13 +#include "RecordedEvent.h"
    1.14 +#include <ostream>
    1.15 +#include <fstream>
    1.16 +
    1.17 +#if defined(_MSC_VER)
    1.18 +#include <hash_set>
    1.19 +#else
    1.20 +#include <set>
    1.21 +#endif
    1.22 +
    1.23 +namespace mozilla {
    1.24 +namespace gfx {
    1.25 +
    1.26 +class PathRecording;
    1.27 +
    1.28 +class DrawEventRecorderPrivate : public DrawEventRecorder
    1.29 +{
    1.30 +public:
    1.31 +  MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawEventRecorderPrivate)
    1.32 +  DrawEventRecorderPrivate(std::ostream *aStream);
    1.33 +  virtual ~DrawEventRecorderPrivate() { }
    1.34 +
    1.35 +  void RecordEvent(const RecordedEvent &aEvent);
    1.36 +  void WritePath(const PathRecording *aPath);
    1.37 +
    1.38 +  void AddStoredPath(const ReferencePtr aPath) {
    1.39 +    mStoredPaths.insert(aPath);
    1.40 +  }
    1.41 +
    1.42 +  void RemoveStoredPath(const ReferencePtr aPath) {
    1.43 +    mStoredPaths.erase(aPath);
    1.44 +  }
    1.45 +
    1.46 +  bool HasStoredPath(const ReferencePtr aPath) {
    1.47 +    if (mStoredPaths.find(aPath) != mStoredPaths.end()) {
    1.48 +      return true;
    1.49 +    }
    1.50 +    return false;
    1.51 +  }
    1.52 +
    1.53 +protected:
    1.54 +  std::ostream *mOutputStream;
    1.55 +
    1.56 +  virtual void Flush() = 0;
    1.57 +
    1.58 +#if defined(_MSC_VER)
    1.59 +  typedef stdext::hash_set<const void*> ObjectSet;
    1.60 +#else
    1.61 +  typedef std::set<const void*> ObjectSet;
    1.62 +#endif
    1.63 +
    1.64 +  ObjectSet mStoredPaths;
    1.65 +  ObjectSet mStoredScaledFonts;
    1.66 +};
    1.67 +
    1.68 +class DrawEventRecorderFile : public DrawEventRecorderPrivate
    1.69 +{
    1.70 +public:
    1.71 +  MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawEventRecorderFile)
    1.72 +  DrawEventRecorderFile(const char *aFilename);
    1.73 +  ~DrawEventRecorderFile();
    1.74 +
    1.75 +private:
    1.76 +  virtual void Flush();
    1.77 +
    1.78 +  std::ofstream mOutputFile;
    1.79 +};
    1.80 +
    1.81 +}
    1.82 +}
    1.83 +
    1.84 +#endif /* MOZILLA_GFX_DRAWEVENTRECORDER_H_ */

mercurial