Update UnusedResources lint suppressions.
[chromium-blink-merge.git] / ui / gl / gpu_timing_fake.h
blob40c93f425765f23d77b0ddde0954ac0d81c8bdf4
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 ExpectGPUTimerQuery(MockGLInterface& gl, bool elapsed_query);
36 void ExpectOffsetCalculationQuery(MockGLInterface& gl);
37 void ExpectNoOffsetCalculationQuery(MockGLInterface& gl);
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 FakeGLGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* 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();
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;
65 std::map<GLuint, QueryResult> query_results_;
66 struct ElapsedQuery {
67 bool active_ = false;
68 GLuint query_id_ = 0;
69 GLint64 begin_time_ = 0;
71 void Reset() {
72 active_ = false;
73 query_id_ = 0;
74 begin_time_ = 0;
77 ElapsedQuery current_elapsed_query_;
80 } // namespace gfx
82 #endif // UI_GL_GPU_TIMING_FAKE_H_