1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
gpu / command_buffer / service / gles2_cmd_decoder_mock.h [blame]
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file contains the mock GLES2Decoder class.
#ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_MOCK_H_
#define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_MOCK_H_
#include <stdint.h>
#include "base/functional/callback.h"
#include "build/build_config.h"
#include "gpu/command_buffer/common/context_creation_attribs.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/service/shader_translator.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/gfx/geometry/size.h"
namespace gl {
class GLContext;
class GLSurface;
}
namespace gpu {
class QueryManager;
namespace gles2 {
class ContextGroup;
class ErrorState;
class GpuFenceManager;
struct ContextState;
class MockGLES2Decoder : public GLES2Decoder {
public:
MockGLES2Decoder(DecoderClient* client,
CommandBufferServiceBase* command_buffer_service,
Outputter* outputter);
MockGLES2Decoder(const MockGLES2Decoder&) = delete;
MockGLES2Decoder& operator=(const MockGLES2Decoder&) = delete;
~MockGLES2Decoder() override;
base::WeakPtr<DecoderContext> AsWeakPtr() override;
MOCK_METHOD5(Initialize,
gpu::ContextResult(const scoped_refptr<gl::GLSurface>& surface,
const scoped_refptr<gl::GLContext>& context,
bool offscreen,
const DisallowedFeatures& disallowed_features,
const ContextCreationAttribs& attrib_helper));
MOCK_METHOD1(Destroy, void(bool have_context));
MOCK_METHOD1(SetSurface, void(const scoped_refptr<gl::GLSurface>& surface));
MOCK_METHOD0(ReleaseSurface, void());
MOCK_METHOD5(SetDefaultFramebufferSharedImage,
void(const Mailbox& mailbox,
int samples,
bool preserve,
bool needs_depth,
bool needs_stencil));
MOCK_METHOD1(ResizeOffscreenFramebuffer, bool(const gfx::Size& size));
MOCK_METHOD0(MakeCurrent, bool());
MOCK_METHOD1(GetServiceIdForTesting, uint32_t(uint32_t client_id));
MOCK_METHOD0(GetGLES2Util, GLES2Util*());
MOCK_METHOD0(GetGLSurface, gl::GLSurface*());
MOCK_METHOD0(GetGLContext, gl::GLContext*());
MOCK_METHOD0(GetContextGroup, ContextGroup*());
MOCK_CONST_METHOD0(GetFeatureInfo, const FeatureInfo*());
MOCK_METHOD0(GetContextState, const ContextState*());
MOCK_METHOD1(GetTranslator,
scoped_refptr<ShaderTranslatorInterface>(unsigned int type));
MOCK_METHOD0(GetCapabilities, Capabilities());
MOCK_METHOD0(GetGLCapabilities, GLCapabilities());
MOCK_CONST_METHOD0(HasPendingQueries, bool());
MOCK_METHOD1(ProcessPendingQueries, void(bool));
MOCK_CONST_METHOD0(HasMoreIdleWork, bool());
MOCK_METHOD0(PerformIdleWork, void());
MOCK_CONST_METHOD0(HasPollingWork, bool());
MOCK_METHOD0(PerformPollingWork, void());
MOCK_METHOD1(RestoreState, void(const ContextState* prev_state));
MOCK_CONST_METHOD0(RestoreActiveTexture, void());
MOCK_CONST_METHOD1(RestoreAllTextureUnitAndSamplerBindings,
void(const ContextState* state));
MOCK_CONST_METHOD1(
RestoreActiveTextureUnitBinding, void(unsigned int target));
MOCK_METHOD0(RestoreAllExternalTextureBindingsIfNeeded, void());
MOCK_METHOD1(RestoreBufferBinding, void(unsigned int target));
MOCK_CONST_METHOD0(RestoreBufferBindings, void());
MOCK_CONST_METHOD0(RestoreFramebufferBindings, void());
MOCK_CONST_METHOD0(RestoreGlobalState, void());
MOCK_CONST_METHOD0(RestoreProgramBindings, void());
MOCK_METHOD0(RestoreRenderbufferBindings, void());
MOCK_METHOD1(RestoreTextureState, void(unsigned service_id));
MOCK_CONST_METHOD1(RestoreTextureUnitBindings, void(unsigned unit));
MOCK_METHOD1(RestoreVertexAttribArray, void(unsigned index));
MOCK_CONST_METHOD0(RestoreDeviceWindowRectangles, void());
MOCK_CONST_METHOD0(ClearAllAttributes, void());
MOCK_CONST_METHOD0(RestoreAllAttributes, void());
MOCK_METHOD0(GetQueryManager, gpu::QueryManager*());
MOCK_METHOD2(SetQueryCallback, void(unsigned int, base::OnceClosure));
MOCK_METHOD0(CancelAllQueries, void());
MOCK_METHOD0(GetGpuFenceManager, gpu::gles2::GpuFenceManager*());
MOCK_METHOD0(GetFramebufferManager, gpu::gles2::FramebufferManager*());
MOCK_METHOD0(
GetTransformFeedbackManager, gpu::gles2::TransformFeedbackManager*());
MOCK_METHOD0(GetVertexArrayManager, gpu::gles2::VertexArrayManager*());
MOCK_METHOD1(SetIgnoreCachedStateForTest, void(bool ignore));
MOCK_METHOD1(SetForceShaderNameHashingForTest, void(bool force));
MOCK_METHOD1(SetAllowExit, void(bool allow));
MOCK_METHOD4(DoCommands,
error::Error(unsigned int num_commands,
const volatile void* buffer,
int num_entries,
int* entries_processed));
MOCK_METHOD2(GetServiceTextureId,
bool(uint32_t client_texture_id, uint32_t* service_texture_id));
MOCK_METHOD9(ClearLevel,
bool(Texture* texture,
unsigned target,
int level,
unsigned format,
unsigned type,
int x_offset,
int y_offset,
int width,
int height));
MOCK_METHOD6(ClearCompressedTextureLevel,
bool(Texture* texture,
unsigned target,
int level,
unsigned format,
int width,
int height));
MOCK_METHOD7(ClearCompressedTextureLevel3D,
bool(Texture* texture,
unsigned target,
int level,
unsigned format,
int width,
int height,
int depth));
MOCK_METHOD1(IsCompressedTextureFormat,
bool(unsigned format));
MOCK_METHOD8(ClearLevel3D,
bool(Texture* texture,
unsigned target,
int level,
unsigned format,
unsigned type,
int width,
int height,
int depth));
MOCK_METHOD0(GetErrorState, ErrorState *());
MOCK_METHOD0(GetLogger, Logger*());
// Workaround for move-only args in GMock.
MOCK_METHOD1(DoWaitForReadPixels, void(base::OnceClosure* callback));
void WaitForReadPixels(base::OnceClosure callback) override {
DoWaitForReadPixels(&callback);
}
MOCK_CONST_METHOD0(WasContextLost, bool());
MOCK_CONST_METHOD0(WasContextLostByRobustnessExtension, bool());
MOCK_METHOD1(MarkContextLost, void(gpu::error::ContextLostReason reason));
MOCK_METHOD0(CheckResetStatus, bool());
MOCK_METHOD1(
SetCopyTextureResourceManagerForTest,
void(CopyTextureCHROMIUMResourceManager* copy_texture_resource_manager));
MOCK_METHOD1(
SetCopyTexImageBlitterForTest,
void(CopyTexImageResourceManager* copy_texture_resource_manager));
private:
base::WeakPtrFactory<MockGLES2Decoder> weak_ptr_factory_{this};
};
} // namespace gles2
} // namespace gpu
#endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_MOCK_H_