Extension syncing: Introduce a NeedsSync pref
[chromium-blink-merge.git] / ui / gl / gpu_timing_fake.h
blob82deea9294a39317d11d85463f83ee501f81af7f
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_
8 #include <map>
9 #include <set>
11 #include "ui/gl/gl_bindings.h"
13 namespace gfx {
14 class MockGLInterface;
16 class GPUTimingFake {
17 public:
18 GPUTimingFake();
19 ~GPUTimingFake();
21 void Reset();
23 // Used to set the current GPU time queries will return.
24 void SetCurrentGLTime(GLint64 current_time);
26 // Used to signal a disjoint occurred for disjoint timer queries.
27 void SetDisjoint();
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);
34 // GPUTimer fake queries which can only be called once per setup.
35 void ExpectGPUTimeStampQuery(MockGLInterface& gl, bool elapsed_query);
36 void ExpectGPUTimerQuery(MockGLInterface& gl, bool elapsed_query);
37 void ExpectOffsetCalculationQuery(MockGLInterface& gl);
38 void ExpectNoOffsetCalculationQuery(MockGLInterface& gl);
40 // Fake GL Functions.
41 void FakeGLGenQueries(GLsizei n, GLuint* ids);
42 void FakeGLDeleteQueries(GLsizei n, const GLuint* ids);
43 void FakeGLBeginQuery(GLenum target, GLuint id);
44 void FakeGLEndQuery(GLenum target);
45 void FakeGLGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params);
46 void FakeGLQueryCounter(GLuint id, GLenum target);
47 void FakeGLGetInteger64v(GLenum pname, GLint64 * data);
48 void FakeGLGetQueryObjectui64v(GLuint id, GLenum pname, GLuint64* params);
49 void FakeGLGetIntegerv(GLenum pname, GLint* params);
50 GLenum FakeGLGetError();
52 protected:
53 bool disjointed_ = false;
54 GLint64 current_time_ = 0;
55 GLuint next_query_id_ = 0;
56 std::set<GLuint> allocated_queries_;
57 struct QueryResult {
58 enum QueryResultType {
59 kQueryResultType_Invalid,
60 kQueryResultType_TimeStamp,
61 kQueryResultType_Elapsed
62 } type_ = kQueryResultType_Invalid;
63 GLint64 begin_time_ = 0;
64 GLint64 value_ = 0;
66 std::map<GLuint, QueryResult> query_results_;
67 struct ElapsedQuery {
68 bool active_ = false;
69 GLuint query_id_ = 0;
70 GLint64 begin_time_ = 0;
72 void Reset() {
73 active_ = false;
74 query_id_ = 0;
75 begin_time_ = 0;
78 ElapsedQuery current_elapsed_query_;
81 } // namespace gfx
83 #endif // UI_GL_GPU_TIMING_FAKE_H_