Line data Source code
1 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
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 GFX_CONTEXTSTATETRACKER_H
7 : #define GFX_CONTEXTSTATETRACKER_H
8 :
9 : #include "GLTypes.h"
10 : #include "mozilla/TimeStamp.h"
11 : #include "nsTArray.h"
12 : #include <string.h>
13 :
14 : namespace mozilla {
15 : namespace gl {
16 : class GLContext;
17 : } // namespace gl
18 :
19 : /**
20 : * This class tracks the state of the context for debugging and profiling.
21 : * Each section pushes a new stack entry and must be matched by an end section.
22 : * All nested section must be ended before ending a parent section.
23 : */
24 0 : class ContextStateTracker {
25 : public:
26 0 : ContextStateTracker() {}
27 :
28 : private:
29 :
30 : bool IsProfiling() { return true; }
31 :
32 : protected:
33 : typedef GLuint TimerQueryHandle;
34 :
35 : class ContextState {
36 : public:
37 0 : explicit ContextState(const char* aSectionName)
38 0 : : mSectionName(aSectionName)
39 0 : {}
40 :
41 : const char* mSectionName;
42 : mozilla::TimeStamp mCpuTimeStart;
43 : mozilla::TimeStamp mCpuTimeEnd;
44 : TimerQueryHandle mStartQueryHandle;
45 : };
46 :
47 0 : ContextState& Top() {
48 0 : MOZ_ASSERT(mSectionStack.Length());
49 0 : return mSectionStack[mSectionStack.Length() - 1];
50 : }
51 :
52 : nsTArray<ContextState> mCompletedSections;
53 : nsTArray<ContextState> mSectionStack;
54 : };
55 :
56 : /*
57 : class ID3D11DeviceContext;
58 :
59 : class ContextStateTrackerD3D11 final : public ContextStateTracker {
60 : public:
61 : // TODO Implement me
62 : void PushD3D11Section(ID3D11DeviceContext* aCtxt, const char* aSectionName) {}
63 : void PopD3D11Section(ID3D11DeviceContext* aCtxt, const char* aSectionName) {}
64 : void DestroyD3D11(ID3D11DeviceContext* aCtxt) {}
65 :
66 : private:
67 : void Flush();
68 : };
69 : */
70 :
71 0 : class ContextStateTrackerOGL final : public ContextStateTracker {
72 : typedef mozilla::gl::GLContext GLContext;
73 : public:
74 : void PushOGLSection(GLContext* aGL, const char* aSectionName);
75 : void PopOGLSection(GLContext* aGL, const char* aSectionName);
76 : void DestroyOGL(GLContext* aGL);
77 : private:
78 : void Flush(GLContext* aGL);
79 : };
80 :
81 : } // namespace mozilla
82 :
83 : #endif
84 :
|