OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_GL_GPU_TIMING_FAKE_H_ | |
6 #define UI_GL_GPU_TIMING_FAKE_H_ | |
7 | |
8 #include <map> | |
9 #include <set> | |
10 | |
11 #include "ui/gl/gl_bindings.h" | |
12 | |
13 namespace gfx { | |
14 class MockGLInterface; | |
15 | |
16 class GPUTimingFakeGLQueries { | |
no sievers
2015/06/09 22:56:41
Can you make the class name match the file name?
David Yen
2015/06/09 23:04:24
Done.
| |
17 public: | |
18 GPUTimingFakeGLQueries(); | |
19 ~GPUTimingFakeGLQueries(); | |
20 | |
21 void Reset(); | |
22 | |
23 // Used to set the current GPU time queries will return. | |
24 void SetCurrentGLTime(GLint64 current_time); | |
25 | |
26 // Used to signal a disjoint occurred for disjoint timer queries. | |
27 void SetDisjoint(); | |
28 | |
29 // GPUTimer fake queries which can be called multiple times. | |
30 void ExpectGetErrorCalls(MockGLInterface& gl); | |
31 void ExpectDisjointCalls(MockGLInterface& gl); | |
32 void ExpectNoDisjointCalls(MockGLInterface& gl); | |
33 | |
34 // GPUTimer fake queries which can only be called once per setup. | |
35 void ExpectGPUTimerQuery(MockGLInterface& gl, bool elapsed_query); | |
36 void ExpectOffsetCalculationQuery(MockGLInterface& gl); | |
37 void ExpectNoOffsetCalculationQuery(MockGLInterface& gl); | |
38 | |
39 // Fake GL Functions. | |
40 void FakeGLGenQueries(GLsizei n, GLuint* ids); | |
41 void FakeGLDeleteQueries(GLsizei n, const GLuint* ids); | |
42 void FakeGLBeginQuery(GLenum target, GLuint id); | |
43 void FakeGLEndQuery(GLenum target); | |
44 void FakeGLGetQueryObjectiv(GLuint id, GLenum pname, GLint* params); | |
45 void FakeGLQueryCounter(GLuint id, GLenum target); | |
46 void FakeGLGetInteger64v(GLenum pname, GLint64 * data); | |
47 void FakeGLGetQueryObjectui64v(GLuint id, GLenum pname, GLuint64* params); | |
48 void FakeGLGetIntegerv(GLenum pname, GLint* params); | |
49 GLenum FakeGLGetError(); | |
50 | |
51 protected: | |
52 bool disjointed_ = false; | |
53 GLint64 current_time_ = 0; | |
54 GLuint next_query_id_ = 0; | |
55 std::set<GLuint> allocated_queries_; | |
56 struct QueryResult { | |
57 enum QueryResultType { | |
58 kQueryResultType_Invalid, | |
59 kQueryResultType_TimeStamp, | |
60 kQueryResultType_Elapsed | |
61 } type_ = kQueryResultType_Invalid; | |
62 GLint64 begin_time_ = 0; | |
63 GLint64 value_ = 0; | |
64 }; | |
65 std::map<GLuint, QueryResult> query_results_; | |
66 struct ElapsedQuery { | |
67 bool active_ = false; | |
68 GLuint query_id_ = 0; | |
69 GLint64 begin_time_ = 0; | |
70 | |
71 void Reset() { | |
72 active_ = false; | |
73 query_id_ = 0; | |
74 begin_time_ = 0; | |
75 } | |
76 }; | |
77 ElapsedQuery current_elapsed_query_; | |
78 }; | |
79 | |
80 } // namespace gfx | |
81 | |
82 #endif // UI_GL_GPU_TIMING_FAKE_H_ | |
OLD | NEW |