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.
5 #ifndef UI_GL_GPU_TIMING_FAKE_H_
6 #define UI_GL_GPU_TIMING_FAKE_H_
11 #include "ui/gl/gl_bindings.h"
14 class MockGLInterface
;
23 // Used to set the current GPU time queries will return.
24 static int64_t GetFakeCPUTime(); // Useful for binding for Fake CPU time.
25 void SetCurrentCPUTime(int64_t current_time
);
26 void SetCurrentGLTime(GLint64 current_time
);
27 void SetCPUGLOffset(int64_t offset
);
29 // Used to signal a disjoint occurred for disjoint timer queries.
32 // GPUTimer fake queries which can be called multiple times.
33 void ExpectGetErrorCalls(MockGLInterface
& gl
);
34 void ExpectDisjointCalls(MockGLInterface
& gl
);
35 void ExpectNoDisjointCalls(MockGLInterface
& gl
);
37 // GPUTimer fake queries which can only be called once per setup.
38 void ExpectGPUTimeStampQuery(MockGLInterface
& gl
, bool elapsed_query
);
39 void ExpectGPUTimerQuery(MockGLInterface
& gl
, bool elapsed_query
);
40 void ExpectOffsetCalculationQuery(MockGLInterface
& gl
);
41 void ExpectNoOffsetCalculationQuery(MockGLInterface
& gl
);
44 void FakeGLGenQueries(GLsizei n
, GLuint
* ids
);
45 void FakeGLDeleteQueries(GLsizei n
, const GLuint
* ids
);
46 void FakeGLBeginQuery(GLenum target
, GLuint id
);
47 void FakeGLEndQuery(GLenum target
);
48 void FakeGLGetQueryObjectuiv(GLuint id
, GLenum pname
, GLuint
* params
);
49 void FakeGLQueryCounter(GLuint id
, GLenum target
);
50 void FakeGLGetInteger64v(GLenum pname
, GLint64
* data
);
51 void FakeGLGetQueryObjectui64v(GLuint id
, GLenum pname
, GLuint64
* params
);
52 void FakeGLGetIntegerv(GLenum pname
, GLint
* params
);
53 GLenum
FakeGLGetError();
56 bool disjointed_
= false;
57 static int64_t fake_cpu_time_
;
58 GLint64 current_gl_time_
= 0;
59 int64_t gl_cpu_time_offset_
= 0;
60 GLuint next_query_id_
= 0;
61 std::set
<GLuint
> allocated_queries_
;
63 enum QueryResultType
{
64 kQueryResultType_Invalid
,
65 kQueryResultType_TimeStamp
,
66 kQueryResultType_Elapsed
67 } type_
= kQueryResultType_Invalid
;
68 GLint64 begin_time_
= 0;
71 std::map
<GLuint
, QueryResult
> query_results_
;
75 GLint64 begin_time_
= 0;
83 ElapsedQuery current_elapsed_query_
;
88 #endif // UI_GL_GPU_TIMING_FAKE_H_