Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
mock_gles.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter 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 FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_TEST_MOCK_GLES_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_TEST_MOCK_GLES_H_
7
8#include <memory>
9#include <optional>
10
11#include "gmock/gmock.h"
13
14namespace impeller {
15namespace testing {
16
18
20 public:
21 virtual ~IMockGLESImpl() = default;
22 virtual void DeleteTextures(GLsizei size, const GLuint* queries) {}
23 virtual void GenTextures(GLsizei n, GLuint* textures) {}
24 virtual void BindTexture(GLenum target, GLuint texture) {}
25 virtual void TexImage2D(GLenum target,
26 GLint level,
27 GLint internalformat,
28 GLsizei width,
29 GLsizei height,
30 GLint border,
31 GLenum format,
32 GLenum type,
33 const void* pixels) {}
34 virtual void TexSubImage2D(GLenum target,
35 GLint level,
36 GLint xoffset,
37 GLint yoffset,
38 GLsizei width,
39 GLsizei height,
40 GLenum format,
41 GLenum type,
42 const void* pixels) {}
43 virtual void GenFramebuffers(GLsizei n, GLuint* framebuffers) {}
44 virtual void BindFramebuffer(GLenum target, GLuint framebuffer) {}
45 virtual void FramebufferTexture2D(GLenum target,
46 GLenum attachment,
47 GLenum textarget,
48 GLuint texture,
49 GLint level) {}
50 virtual GLenum CheckFramebufferStatus(GLenum target) {
51 return GL_FRAMEBUFFER_COMPLETE;
52 }
53 virtual void ReadPixels(GLint x,
54 GLint y,
55 GLsizei width,
56 GLsizei height,
57 GLenum format,
58 GLenum type,
59 void* pixels) {}
60 virtual void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers) {}
61 virtual void ObjectLabelKHR(GLenum identifier,
62 GLuint name,
63 GLsizei length,
64 const GLchar* label) {}
65 virtual void Uniform1fv(GLint location, GLsizei count, const GLfloat* value) {
66 }
67 virtual void Uniform2fv(GLint location, GLsizei count, const GLfloat* value) {
68 }
69 virtual void Uniform3fv(GLint location, GLsizei count, const GLfloat* value) {
70 }
71 virtual void Uniform4fv(GLint location, GLsizei count, const GLfloat* value) {
72 }
73 virtual void UniformMatrix2fv(GLint location,
74 GLsizei count,
75 GLboolean transpose,
76 const GLfloat* value) {}
77 virtual void UniformMatrix3fv(GLint location,
78 GLsizei count,
79 GLboolean transpose,
80 const GLfloat* value) {}
81 virtual void UniformMatrix4fv(GLint location,
82 GLsizei count,
83 GLboolean transpose,
84 const GLfloat* value) {}
85 virtual void GenQueriesEXT(GLsizei n, GLuint* ids) {}
86 virtual void BeginQueryEXT(GLenum target, GLuint id) {}
87 virtual void EndQueryEXT(GLuint id) {}
88 virtual void GetQueryObjectuivEXT(GLuint id, GLenum target, GLuint* result) {}
89 virtual void GetQueryObjectui64vEXT(GLuint id,
90 GLenum target,
91 GLuint64* result) {}
92 virtual void DeleteQueriesEXT(GLsizei size, const GLuint* queries) {}
93 virtual void GenBuffers(GLsizei n, GLuint* buffers) {}
94 virtual void DeleteBuffers(GLsizei n, const GLuint* buffers) {}
95 virtual GLboolean IsTexture(GLuint texture) { return true; }
96 virtual void DiscardFramebufferEXT(GLenum target,
97 GLsizei numAttachments,
98 const GLenum* attachments) {};
99 virtual void InvalidateFramebuffer(GLenum target,
100 GLsizei numAttachments,
101 const GLenum* attachments) {};
102 virtual void GetIntegerv(GLenum name, GLint* attachments) {};
103 virtual void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) {}
104};
105
107 public:
110 (GLsizei size, const GLuint* queries),
111 (override));
112 MOCK_METHOD(void, GenTextures, (GLsizei n, GLuint* textures), (override));
113 MOCK_METHOD(void, BindTexture, (GLenum target, GLuint texture), (override));
116 (GLenum target,
117 GLint level,
118 GLint internalformat,
119 GLsizei width,
120 GLsizei height,
121 GLint border,
122 GLenum format,
123 GLenum type,
124 const void* pixels),
125 (override));
128 (GLenum target,
129 GLint level,
130 GLint xoffset,
131 GLint yoffset,
132 GLsizei width,
133 GLsizei height,
134 GLenum format,
135 GLenum type,
136 const void* pixels),
137 (override));
140 (GLsizei n, GLuint* framebuffers),
141 (override));
144 (GLenum target, GLuint framebuffer),
145 (override));
148 (GLenum target,
149 GLenum attachment,
150 GLenum textarget,
151 GLuint texture,
152 GLint level),
153 (override));
154 MOCK_METHOD(GLenum, CheckFramebufferStatus, (GLenum target), (override));
157 (GLint x,
158 GLint y,
159 GLsizei width,
160 GLsizei height,
161 GLenum format,
162 GLenum type,
163 void* pixels),
164 (override));
167 (GLsizei n, const GLuint* framebuffers),
168 (override));
170 void,
172 (GLenum identifier, GLuint name, GLsizei length, const GLchar* label),
173 (override));
176 (GLint location, GLsizei count, const GLfloat* value),
177 (override));
180 (GLint location, GLsizei count, const GLfloat* value),
181 (override));
184 (GLint location, GLsizei count, const GLfloat* value),
185 (override));
188 (GLint location, GLsizei count, const GLfloat* value),
189 (override));
192 (GLint location,
193 GLsizei count,
194 GLboolean transpose,
195 const GLfloat* value),
196 (override));
199 (GLint location,
200 GLsizei count,
201 GLboolean transpose,
202 const GLfloat* value),
203 (override));
206 (GLint location,
207 GLsizei count,
208 GLboolean transpose,
209 const GLfloat* value),
210 (override));
211 MOCK_METHOD(void, GenQueriesEXT, (GLsizei n, GLuint* ids), (override));
212 MOCK_METHOD(void, BeginQueryEXT, (GLenum target, GLuint id), (override));
213 MOCK_METHOD(void, EndQueryEXT, (GLuint id), (override));
216 (GLuint id, GLenum target, GLuint* result),
217 (override));
220 (GLuint id, GLenum target, GLuint64* result),
221 (override));
224 (GLsizei size, const GLuint* queries),
225 (override));
226 MOCK_METHOD(void, GenBuffers, (GLsizei n, GLuint* buffers), (override));
229 (GLsizei n, const GLuint* buffers),
230 (override));
231 MOCK_METHOD(GLboolean, IsTexture, (GLuint texture), (override));
234 (GLenum target,
235 GLsizei numAttachments,
236 const GLenum* attachments),
237 (override));
240 (GLenum target,
241 GLsizei numAttachments,
242 const GLenum* attachments),
243 (override));
244 MOCK_METHOD(void, GetIntegerv, (GLenum name, GLint* value), (override));
246 Viewport,
247 (GLint x, GLint y, GLsizei width, GLsizei height),
248 (override));
249};
250
251/// @brief Provides a mocked version of the |ProcTableGLES| class.
252///
253/// Typically, Open GLES at runtime will be provided the host's GLES bindings
254/// (as function pointers). This class maintains a set of function pointers that
255/// appear to be GLES functions, but are actually just stubs that record
256/// invocations.
257///
258/// See `README.md` for more information.
259class MockGLES final {
260 public:
261 static std::shared_ptr<MockGLES> Init(
262 std::unique_ptr<MockGLESImpl> impl,
263 const std::optional<std::vector<const char*>>& extensions = std::nullopt,
264 const char* version_string = "OpenGL ES 3.0");
265
266 /// @brief Returns an initialized |MockGLES| instance.
267 ///
268 /// This method overwrites mocked global GLES function pointers to record
269 /// invocations on this instance of |MockGLES|. As such, it should only be
270 /// called once per test.
271 static std::shared_ptr<MockGLES> Init(
272 const std::optional<std::vector<const char*>>& extensions = std::nullopt,
273 const char* version_string = "OpenGL ES 3.0",
275
276 /// @brief Returns a configured |ProcTableGLES| instance.
277 const ProcTableGLES& GetProcTable() const { return proc_table_; }
278
279 ~MockGLES();
280
281 IMockGLESImpl* GetImpl() { return impl_.get(); }
282
283 private:
284 friend void RecordGLCall(const char* name);
285 friend void mockGenTextures(GLsizei n, GLuint* textures);
286
288
289 ProcTableGLES proc_table_;
290 std::unique_ptr<IMockGLESImpl> impl_;
291
292 MockGLES(const MockGLES&) = delete;
293
294 MockGLES& operator=(const MockGLES&) = delete;
295};
296
297} // namespace testing
298} // namespace impeller
299
300#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_TEST_MOCK_GLES_H_
std::function< void *(const char *function_name)> Resolver
virtual void GenFramebuffers(GLsizei n, GLuint *framebuffers)
Definition mock_gles.h:43
virtual void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels)
Definition mock_gles.h:34
virtual void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments)
Definition mock_gles.h:99
virtual void Uniform2fv(GLint location, GLsizei count, const GLfloat *value)
Definition mock_gles.h:67
virtual void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
Definition mock_gles.h:81
virtual void GenBuffers(GLsizei n, GLuint *buffers)
Definition mock_gles.h:93
virtual void GetQueryObjectui64vEXT(GLuint id, GLenum target, GLuint64 *result)
Definition mock_gles.h:89
virtual void GetQueryObjectuivEXT(GLuint id, GLenum target, GLuint *result)
Definition mock_gles.h:88
virtual void DeleteQueriesEXT(GLsizei size, const GLuint *queries)
Definition mock_gles.h:92
virtual void DeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
Definition mock_gles.h:60
virtual void ObjectLabelKHR(GLenum identifier, GLuint name, GLsizei length, const GLchar *label)
Definition mock_gles.h:61
virtual void BindTexture(GLenum target, GLuint texture)
Definition mock_gles.h:24
virtual void EndQueryEXT(GLuint id)
Definition mock_gles.h:87
virtual ~IMockGLESImpl()=default
virtual void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
Definition mock_gles.h:77
virtual void DiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum *attachments)
Definition mock_gles.h:96
virtual void DeleteTextures(GLsizei size, const GLuint *queries)
Definition mock_gles.h:22
virtual void GenQueriesEXT(GLsizei n, GLuint *ids)
Definition mock_gles.h:85
virtual void Uniform4fv(GLint location, GLsizei count, const GLfloat *value)
Definition mock_gles.h:71
virtual void BeginQueryEXT(GLenum target, GLuint id)
Definition mock_gles.h:86
virtual void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
Definition mock_gles.h:45
virtual void BindFramebuffer(GLenum target, GLuint framebuffer)
Definition mock_gles.h:44
virtual void GetIntegerv(GLenum name, GLint *attachments)
Definition mock_gles.h:102
virtual void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels)
Definition mock_gles.h:25
virtual GLboolean IsTexture(GLuint texture)
Definition mock_gles.h:95
virtual void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
Definition mock_gles.h:103
virtual void DeleteBuffers(GLsizei n, const GLuint *buffers)
Definition mock_gles.h:94
virtual void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels)
Definition mock_gles.h:53
virtual void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
Definition mock_gles.h:73
virtual void Uniform1fv(GLint location, GLsizei count, const GLfloat *value)
Definition mock_gles.h:65
virtual void Uniform3fv(GLint location, GLsizei count, const GLfloat *value)
Definition mock_gles.h:69
virtual void GenTextures(GLsizei n, GLuint *textures)
Definition mock_gles.h:23
virtual GLenum CheckFramebufferStatus(GLenum target)
Definition mock_gles.h:50
Provides a mocked version of the |ProcTableGLES| class.
Definition mock_gles.h:259
friend void RecordGLCall(const char *name)
static std::shared_ptr< MockGLES > Init(std::unique_ptr< MockGLESImpl > impl, const std::optional< std::vector< const char * > > &extensions=std::nullopt, const char *version_string="OpenGL ES 3.0")
Definition mock_gles.cc:360
friend void mockGenTextures(GLsizei n, GLuint *textures)
Definition mock_gles.cc:236
const ProcTableGLES & GetProcTable() const
Returns a configured |ProcTableGLES| instance.
Definition mock_gles.h:277
IMockGLESImpl * GetImpl()
Definition mock_gles.h:281
MOCK_METHOD(void, UniformMatrix4fv,(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value),(override))
MOCK_METHOD(void, TexImage2D,(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels),(override))
MOCK_METHOD(void, GetQueryObjectuivEXT,(GLuint id, GLenum target, GLuint *result),(override))
MOCK_METHOD(void, GenTextures,(GLsizei n, GLuint *textures),(override))
MOCK_METHOD(void, BeginQueryEXT,(GLenum target, GLuint id),(override))
MOCK_METHOD(void, DeleteBuffers,(GLsizei n, const GLuint *buffers),(override))
MOCK_METHOD(GLboolean, IsTexture,(GLuint texture),(override))
MOCK_METHOD(void, BindTexture,(GLenum target, GLuint texture),(override))
MOCK_METHOD(void, Uniform4fv,(GLint location, GLsizei count, const GLfloat *value),(override))
MOCK_METHOD(void, BindFramebuffer,(GLenum target, GLuint framebuffer),(override))
MOCK_METHOD(void, UniformMatrix2fv,(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value),(override))
MOCK_METHOD(void, UniformMatrix3fv,(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value),(override))
MOCK_METHOD(void, ReadPixels,(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels),(override))
MOCK_METHOD(void, GenFramebuffers,(GLsizei n, GLuint *framebuffers),(override))
MOCK_METHOD(void, EndQueryEXT,(GLuint id),(override))
MOCK_METHOD(void, Uniform2fv,(GLint location, GLsizei count, const GLfloat *value),(override))
MOCK_METHOD(GLenum, CheckFramebufferStatus,(GLenum target),(override))
MOCK_METHOD(void, GenBuffers,(GLsizei n, GLuint *buffers),(override))
MOCK_METHOD(void, FramebufferTexture2D,(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level),(override))
MOCK_METHOD(void, Viewport,(GLint x, GLint y, GLsizei width, GLsizei height),(override))
MOCK_METHOD(void, GetIntegerv,(GLenum name, GLint *value),(override))
MOCK_METHOD(void, Uniform1fv,(GLint location, GLsizei count, const GLfloat *value),(override))
MOCK_METHOD(void, DiscardFramebufferEXT,(GLenum target, GLsizei numAttachments, const GLenum *attachments),(override))
MOCK_METHOD(void, InvalidateFramebuffer,(GLenum target, GLsizei numAttachments, const GLenum *attachments),(override))
MOCK_METHOD(void, Uniform3fv,(GLint location, GLsizei count, const GLfloat *value),(override))
MOCK_METHOD(void, DeleteTextures,(GLsizei size, const GLuint *queries),(override))
MOCK_METHOD(void, DeleteQueriesEXT,(GLsizei size, const GLuint *queries),(override))
MOCK_METHOD(void, TexSubImage2D,(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels),(override))
MOCK_METHOD(void, GenQueriesEXT,(GLsizei n, GLuint *ids),(override))
MOCK_METHOD(void, ObjectLabelKHR,(GLenum identifier, GLuint name, GLsizei length, const GLchar *label),(override))
MOCK_METHOD(void, DeleteFramebuffers,(GLsizei n, const GLuint *framebuffers),(override))
MOCK_METHOD(void, GetQueryObjectui64vEXT,(GLuint id, GLenum target, GLuint64 *result),(override))
uint32_t location
int32_t x
uint32_t * target
size_t length
FlTexture * texture
double y
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27
const ProcTableGLES::Resolver kMockResolverGLES
Definition mock_gles.cc:402
impeller::ShaderType type
int32_t height
int32_t width