1// Copyright 2013 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.
4
5#include "cc/test/test_gles2_interface.h"
6
7#include "base/logging.h"
8#include "cc/test/test_web_graphics_context_3d.h"
9
10namespace cc {
11
12TestGLES2Interface::TestGLES2Interface(TestWebGraphicsContext3D* test_context)
13    : test_context_(test_context) {
14  DCHECK(test_context_);
15}
16
17TestGLES2Interface::~TestGLES2Interface() {}
18
19void TestGLES2Interface::GenTextures(GLsizei n, GLuint* textures) {
20  for (GLsizei i = 0; i < n; ++i) {
21    textures[i] = test_context_->createTexture();
22  }
23}
24
25void TestGLES2Interface::GenBuffers(GLsizei n, GLuint* buffers) {
26  for (GLsizei i = 0; i < n; ++i) {
27    buffers[i] = test_context_->createBuffer();
28  }
29}
30
31void TestGLES2Interface::GenFramebuffers(GLsizei n, GLuint* framebuffers) {
32  for (GLsizei i = 0; i < n; ++i) {
33    framebuffers[i] = test_context_->createFramebuffer();
34  }
35}
36
37void TestGLES2Interface::GenQueriesEXT(GLsizei n, GLuint* queries) {
38  for (GLsizei i = 0; i < n; ++i) {
39    queries[i] = test_context_->createQueryEXT();
40  }
41}
42
43void TestGLES2Interface::DeleteTextures(GLsizei n, const GLuint* textures) {
44  for (GLsizei i = 0; i < n; ++i) {
45    test_context_->deleteTexture(textures[i]);
46  }
47}
48
49void TestGLES2Interface::DeleteBuffers(GLsizei n, const GLuint* buffers) {
50  for (GLsizei i = 0; i < n; ++i) {
51    test_context_->deleteBuffer(buffers[i]);
52  }
53}
54
55void TestGLES2Interface::DeleteFramebuffers(GLsizei n,
56                                            const GLuint* framebuffers) {
57  for (GLsizei i = 0; i < n; ++i) {
58    test_context_->deleteFramebuffer(framebuffers[i]);
59  }
60}
61
62void TestGLES2Interface::DeleteQueriesEXT(GLsizei n, const GLuint* queries) {
63  for (GLsizei i = 0; i < n; ++i) {
64    test_context_->deleteQueryEXT(queries[i]);
65  }
66}
67
68GLuint TestGLES2Interface::CreateShader(GLenum type) {
69  return test_context_->createShader(type);
70}
71
72GLuint TestGLES2Interface::CreateProgram() {
73  return test_context_->createProgram();
74}
75
76void TestGLES2Interface::BindTexture(GLenum target, GLuint texture) {
77  test_context_->bindTexture(target, texture);
78}
79
80void TestGLES2Interface::GetIntegerv(GLenum pname, GLint* params) {
81  test_context_->getIntegerv(pname, params);
82}
83
84void TestGLES2Interface::GetShaderiv(GLuint shader,
85                                     GLenum pname,
86                                     GLint* params) {
87  test_context_->getShaderiv(shader, pname, params);
88}
89
90void TestGLES2Interface::GetProgramiv(GLuint program,
91                                      GLenum pname,
92                                      GLint* params) {
93  test_context_->getProgramiv(program, pname, params);
94}
95
96void TestGLES2Interface::GetShaderPrecisionFormat(GLenum shadertype,
97                                                  GLenum precisiontype,
98                                                  GLint* range,
99                                                  GLint* precision) {
100  test_context_->getShaderPrecisionFormat(
101      shadertype, precisiontype, range, precision);
102}
103
104void TestGLES2Interface::Viewport(GLint x,
105                                  GLint y,
106                                  GLsizei width,
107                                  GLsizei height) {
108  test_context_->viewport(x, y, width, height);
109}
110
111void TestGLES2Interface::ActiveTexture(GLenum target) {
112  test_context_->activeTexture(target);
113}
114
115void TestGLES2Interface::UseProgram(GLuint program) {
116  test_context_->useProgram(program);
117}
118
119GLenum TestGLES2Interface::CheckFramebufferStatus(GLenum target) {
120  return test_context_->checkFramebufferStatus(target);
121}
122
123void TestGLES2Interface::Scissor(GLint x,
124                                 GLint y,
125                                 GLsizei width,
126                                 GLsizei height) {
127  test_context_->scissor(x, y, width, height);
128}
129
130void TestGLES2Interface::DrawElements(GLenum mode,
131                                      GLsizei count,
132                                      GLenum type,
133                                      const void* indices) {
134  test_context_->drawElements(
135      mode, count, type, reinterpret_cast<intptr_t>(indices));
136}
137
138void TestGLES2Interface::ClearColor(GLclampf red,
139                                    GLclampf green,
140                                    GLclampf blue,
141                                    GLclampf alpha) {
142  test_context_->clearColor(red, green, blue, alpha);
143}
144
145void TestGLES2Interface::ClearStencil(GLint s) {
146  test_context_->clearStencil(s);
147}
148
149void TestGLES2Interface::Clear(GLbitfield mask) { test_context_->clear(mask); }
150
151void TestGLES2Interface::Flush() { test_context_->flush(); }
152
153void TestGLES2Interface::Finish() { test_context_->finish(); }
154
155void TestGLES2Interface::ShallowFlushCHROMIUM() {
156  test_context_->shallowFlushCHROMIUM();
157}
158
159void TestGLES2Interface::Enable(GLenum cap) { test_context_->enable(cap); }
160
161void TestGLES2Interface::Disable(GLenum cap) { test_context_->disable(cap); }
162
163void TestGLES2Interface::BindFramebuffer(GLenum target, GLuint buffer) {
164  test_context_->bindFramebuffer(target, buffer);
165}
166
167void TestGLES2Interface::BindBuffer(GLenum target, GLuint buffer) {
168  test_context_->bindBuffer(target, buffer);
169}
170
171void TestGLES2Interface::TexImage2D(GLenum target,
172                                    GLint level,
173                                    GLint internalformat,
174                                    GLsizei width,
175                                    GLsizei height,
176                                    GLint border,
177                                    GLenum format,
178                                    GLenum type,
179                                    const void* pixels) {
180  test_context_->texImage2D(target,
181                            level,
182                            internalformat,
183                            width,
184                            height,
185                            border,
186                            format,
187                            type,
188                            pixels);
189}
190
191void TestGLES2Interface::TexSubImage2D(GLenum target,
192                                       GLint level,
193                                       GLint xoffset,
194                                       GLint yoffset,
195                                       GLsizei width,
196                                       GLsizei height,
197                                       GLenum format,
198                                       GLenum type,
199                                       const void* pixels) {
200  test_context_->texSubImage2D(
201      target, level, xoffset, yoffset, width, height, format, type, pixels);
202}
203
204void TestGLES2Interface::TexStorage2DEXT(GLenum target,
205                                         GLsizei levels,
206                                         GLenum internalformat,
207                                         GLsizei width,
208                                         GLsizei height) {
209  test_context_->texStorage2DEXT(target, levels, internalformat, width, height);
210}
211
212void TestGLES2Interface::TexImageIOSurface2DCHROMIUM(GLenum target,
213                                                     GLsizei width,
214                                                     GLsizei height,
215                                                     GLuint io_surface_id,
216                                                     GLuint plane) {
217  test_context_->texImageIOSurface2DCHROMIUM(
218      target, width, height, io_surface_id, plane);
219}
220
221void TestGLES2Interface::TexParameteri(GLenum target,
222                                       GLenum pname,
223                                       GLint param) {
224  test_context_->texParameteri(target, pname, param);
225}
226
227void TestGLES2Interface::AsyncTexImage2DCHROMIUM(GLenum target,
228                                                 GLint level,
229                                                 GLint internalformat,
230                                                 GLsizei width,
231                                                 GLsizei height,
232                                                 GLint border,
233                                                 GLenum format,
234                                                 GLenum type,
235                                                 const void* pixels) {
236  test_context_->asyncTexImage2DCHROMIUM(target,
237                                         level,
238                                         internalformat,
239                                         width,
240                                         height,
241                                         border,
242                                         format,
243                                         type,
244                                         pixels);
245}
246
247void TestGLES2Interface::AsyncTexSubImage2DCHROMIUM(GLenum target,
248                                                    GLint level,
249                                                    GLint xoffset,
250                                                    GLint yoffset,
251                                                    GLsizei width,
252                                                    GLsizei height,
253                                                    GLenum format,
254                                                    GLenum type,
255                                                    const void* pixels) {
256  test_context_->asyncTexSubImage2DCHROMIUM(
257      target, level, xoffset, yoffset, width, height, format, type, pixels);
258}
259
260void TestGLES2Interface::CompressedTexImage2D(GLenum target,
261                                              GLint level,
262                                              GLenum internalformat,
263                                              GLsizei width,
264                                              GLsizei height,
265                                              GLint border,
266                                              GLsizei image_size,
267                                              const void* data) {
268  test_context_->compressedTexImage2D(
269      target, level, internalformat, width, height, border, image_size, data);
270}
271
272void TestGLES2Interface::WaitAsyncTexImage2DCHROMIUM(GLenum target) {
273  test_context_->waitAsyncTexImage2DCHROMIUM(target);
274}
275
276GLuint TestGLES2Interface::CreateImageCHROMIUM(GLsizei width,
277                                               GLsizei height,
278                                               GLenum internalformat) {
279  return test_context_->createImageCHROMIUM(width, height, internalformat);
280}
281
282void TestGLES2Interface::DestroyImageCHROMIUM(GLuint image_id) {
283  test_context_->destroyImageCHROMIUM(image_id);
284}
285
286void* TestGLES2Interface::MapImageCHROMIUM(GLuint image_id, GLenum access) {
287  return test_context_->mapImageCHROMIUM(image_id, access);
288}
289
290void TestGLES2Interface::GetImageParameterivCHROMIUM(GLuint image_id,
291                                                     GLenum pname,
292                                                     GLint* params) {
293  test_context_->getImageParameterivCHROMIUM(image_id, pname, params);
294}
295
296void TestGLES2Interface::UnmapImageCHROMIUM(GLuint image_id) {
297  test_context_->unmapImageCHROMIUM(image_id);
298}
299
300void TestGLES2Interface::BindTexImage2DCHROMIUM(GLenum target, GLint image_id) {
301  test_context_->bindTexImage2DCHROMIUM(target, image_id);
302}
303
304void TestGLES2Interface::ReleaseTexImage2DCHROMIUM(GLenum target,
305                                                   GLint image_id) {
306  test_context_->releaseTexImage2DCHROMIUM(target, image_id);
307}
308
309void* TestGLES2Interface::MapBufferCHROMIUM(GLuint target, GLenum access) {
310  return test_context_->mapBufferCHROMIUM(target, access);
311}
312
313GLboolean TestGLES2Interface::UnmapBufferCHROMIUM(GLuint target) {
314  return test_context_->unmapBufferCHROMIUM(target);
315}
316
317void TestGLES2Interface::BufferData(GLenum target,
318                                    GLsizeiptr size,
319                                    const void* data,
320                                    GLenum usage) {
321  test_context_->bufferData(target, size, data, usage);
322}
323
324void TestGLES2Interface::WaitSyncPointCHROMIUM(GLuint sync_point) {
325  test_context_->waitSyncPoint(sync_point);
326}
327
328GLuint TestGLES2Interface::InsertSyncPointCHROMIUM() {
329  return test_context_->insertSyncPoint();
330}
331
332void TestGLES2Interface::BeginQueryEXT(GLenum target, GLuint id) {
333  test_context_->beginQueryEXT(target, id);
334}
335
336void TestGLES2Interface::EndQueryEXT(GLenum target) {
337  test_context_->endQueryEXT(target);
338}
339
340void TestGLES2Interface::GetQueryObjectuivEXT(GLuint id,
341                                              GLenum pname,
342                                              GLuint* params) {
343  test_context_->getQueryObjectuivEXT(id, pname, params);
344}
345
346void TestGLES2Interface::DiscardFramebufferEXT(GLenum target,
347                                               GLsizei count,
348                                               const GLenum* attachments) {
349  test_context_->discardFramebufferEXT(target, count, attachments);
350}
351
352void TestGLES2Interface::GenMailboxCHROMIUM(GLbyte* mailbox) {
353  test_context_->genMailboxCHROMIUM(mailbox);
354}
355
356void TestGLES2Interface::ProduceTextureCHROMIUM(GLenum target,
357                                                const GLbyte* mailbox) {
358  test_context_->produceTextureCHROMIUM(target, mailbox);
359}
360
361void TestGLES2Interface::ConsumeTextureCHROMIUM(GLenum target,
362                                                const GLbyte* mailbox) {
363  test_context_->consumeTextureCHROMIUM(target, mailbox);
364}
365
366}  // namespace cc
367