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.
5 #include "cc/test/test_gles2_interface.h"
7 #include "base/logging.h"
8 #include "cc/test/test_web_graphics_context_3d.h"
12 TestGLES2Interface::TestGLES2Interface(TestWebGraphicsContext3D
* test_context
)
13 : test_context_(test_context
) {
14 DCHECK(test_context_
);
17 TestGLES2Interface::~TestGLES2Interface() {}
19 void TestGLES2Interface::GenTextures(GLsizei n
, GLuint
* textures
) {
20 for (GLsizei i
= 0; i
< n
; ++i
) {
21 textures
[i
] = test_context_
->createTexture();
25 void TestGLES2Interface::GenBuffers(GLsizei n
, GLuint
* buffers
) {
26 for (GLsizei i
= 0; i
< n
; ++i
) {
27 buffers
[i
] = test_context_
->createBuffer();
31 void TestGLES2Interface::GenFramebuffers(GLsizei n
, GLuint
* framebuffers
) {
32 for (GLsizei i
= 0; i
< n
; ++i
) {
33 framebuffers
[i
] = test_context_
->createFramebuffer();
37 void TestGLES2Interface::GenQueriesEXT(GLsizei n
, GLuint
* queries
) {
38 for (GLsizei i
= 0; i
< n
; ++i
) {
39 queries
[i
] = test_context_
->createQueryEXT();
43 void TestGLES2Interface::DeleteTextures(GLsizei n
, const GLuint
* textures
) {
44 for (GLsizei i
= 0; i
< n
; ++i
) {
45 test_context_
->deleteTexture(textures
[i
]);
49 void TestGLES2Interface::DeleteBuffers(GLsizei n
, const GLuint
* buffers
) {
50 for (GLsizei i
= 0; i
< n
; ++i
) {
51 test_context_
->deleteBuffer(buffers
[i
]);
55 void TestGLES2Interface::DeleteFramebuffers(GLsizei n
,
56 const GLuint
* framebuffers
) {
57 for (GLsizei i
= 0; i
< n
; ++i
) {
58 test_context_
->deleteFramebuffer(framebuffers
[i
]);
62 void TestGLES2Interface::DeleteQueriesEXT(GLsizei n
, const GLuint
* queries
) {
63 for (GLsizei i
= 0; i
< n
; ++i
) {
64 test_context_
->deleteQueryEXT(queries
[i
]);
68 GLuint
TestGLES2Interface::CreateShader(GLenum type
) {
69 return test_context_
->createShader(type
);
72 GLuint
TestGLES2Interface::CreateProgram() {
73 return test_context_
->createProgram();
76 void TestGLES2Interface::BindTexture(GLenum target
, GLuint texture
) {
77 test_context_
->bindTexture(target
, texture
);
80 void TestGLES2Interface::GetIntegerv(GLenum pname
, GLint
* params
) {
81 test_context_
->getIntegerv(pname
, params
);
84 void TestGLES2Interface::GetShaderiv(GLuint shader
,
87 test_context_
->getShaderiv(shader
, pname
, params
);
90 void TestGLES2Interface::GetProgramiv(GLuint program
,
93 test_context_
->getProgramiv(program
, pname
, params
);
96 void TestGLES2Interface::GetShaderPrecisionFormat(GLenum shadertype
,
100 test_context_
->getShaderPrecisionFormat(
101 shadertype
, precisiontype
, range
, precision
);
104 void TestGLES2Interface::Viewport(GLint x
,
108 test_context_
->viewport(x
, y
, width
, height
);
111 void TestGLES2Interface::ActiveTexture(GLenum target
) {
112 test_context_
->activeTexture(target
);
115 void TestGLES2Interface::UseProgram(GLuint program
) {
116 test_context_
->useProgram(program
);
119 GLenum
TestGLES2Interface::CheckFramebufferStatus(GLenum target
) {
120 return test_context_
->checkFramebufferStatus(target
);
123 void TestGLES2Interface::Scissor(GLint x
,
127 test_context_
->scissor(x
, y
, width
, height
);
130 void TestGLES2Interface::DrawElements(GLenum mode
,
133 const void* indices
) {
134 test_context_
->drawElements(
135 mode
, count
, type
, reinterpret_cast<intptr_t>(indices
));
138 void TestGLES2Interface::ClearColor(GLclampf red
,
142 test_context_
->clearColor(red
, green
, blue
, alpha
);
145 void TestGLES2Interface::ClearStencil(GLint s
) {
146 test_context_
->clearStencil(s
);
149 void TestGLES2Interface::Clear(GLbitfield mask
) { test_context_
->clear(mask
); }
151 void TestGLES2Interface::Flush() { test_context_
->flush(); }
153 void TestGLES2Interface::Finish() { test_context_
->finish(); }
155 void TestGLES2Interface::ShallowFlushCHROMIUM() {
156 test_context_
->shallowFlushCHROMIUM();
159 void TestGLES2Interface::Enable(GLenum cap
) { test_context_
->enable(cap
); }
161 void TestGLES2Interface::Disable(GLenum cap
) { test_context_
->disable(cap
); }
163 void TestGLES2Interface::BindFramebuffer(GLenum target
, GLuint buffer
) {
164 test_context_
->bindFramebuffer(target
, buffer
);
167 void TestGLES2Interface::BindBuffer(GLenum target
, GLuint buffer
) {
168 test_context_
->bindBuffer(target
, buffer
);
171 void TestGLES2Interface::TexImage2D(GLenum target
,
173 GLint internalformat
,
179 const void* pixels
) {
180 test_context_
->texImage2D(target
,
191 void TestGLES2Interface::TexSubImage2D(GLenum target
,
199 const void* pixels
) {
200 test_context_
->texSubImage2D(
201 target
, level
, xoffset
, yoffset
, width
, height
, format
, type
, pixels
);
204 void TestGLES2Interface::TexStorage2DEXT(GLenum target
,
206 GLenum internalformat
,
209 test_context_
->texStorage2DEXT(target
, levels
, internalformat
, width
, height
);
212 void TestGLES2Interface::TexImageIOSurface2DCHROMIUM(GLenum target
,
215 GLuint io_surface_id
,
217 test_context_
->texImageIOSurface2DCHROMIUM(
218 target
, width
, height
, io_surface_id
, plane
);
221 void TestGLES2Interface::TexParameteri(GLenum target
,
224 test_context_
->texParameteri(target
, pname
, param
);
227 void TestGLES2Interface::AsyncTexImage2DCHROMIUM(GLenum target
,
229 GLenum internalformat
,
235 const void* pixels
) {
236 test_context_
->asyncTexImage2DCHROMIUM(target
,
247 void TestGLES2Interface::AsyncTexSubImage2DCHROMIUM(GLenum target
,
255 const void* pixels
) {
256 test_context_
->asyncTexSubImage2DCHROMIUM(
257 target
, level
, xoffset
, yoffset
, width
, height
, format
, type
, pixels
);
260 void TestGLES2Interface::CompressedTexImage2D(GLenum target
,
262 GLenum internalformat
,
268 test_context_
->compressedTexImage2D(
269 target
, level
, internalformat
, width
, height
, border
, image_size
, data
);
272 void TestGLES2Interface::WaitAsyncTexImage2DCHROMIUM(GLenum target
) {
273 test_context_
->waitAsyncTexImage2DCHROMIUM(target
);
276 GLuint
TestGLES2Interface::CreateImageCHROMIUM(GLsizei width
,
278 GLenum internalformat
,
280 return test_context_
->createImageCHROMIUM(
281 width
, height
, internalformat
, usage
);
284 void TestGLES2Interface::DestroyImageCHROMIUM(GLuint image_id
) {
285 test_context_
->destroyImageCHROMIUM(image_id
);
288 void* TestGLES2Interface::MapImageCHROMIUM(GLuint image_id
) {
289 return test_context_
->mapImageCHROMIUM(image_id
);
292 void TestGLES2Interface::GetImageParameterivCHROMIUM(GLuint image_id
,
295 test_context_
->getImageParameterivCHROMIUM(image_id
, pname
, params
);
298 void TestGLES2Interface::UnmapImageCHROMIUM(GLuint image_id
) {
299 test_context_
->unmapImageCHROMIUM(image_id
);
302 void TestGLES2Interface::BindTexImage2DCHROMIUM(GLenum target
, GLint image_id
) {
303 test_context_
->bindTexImage2DCHROMIUM(target
, image_id
);
306 void TestGLES2Interface::ReleaseTexImage2DCHROMIUM(GLenum target
,
308 test_context_
->releaseTexImage2DCHROMIUM(target
, image_id
);
311 void* TestGLES2Interface::MapBufferCHROMIUM(GLuint target
, GLenum access
) {
312 return test_context_
->mapBufferCHROMIUM(target
, access
);
315 GLboolean
TestGLES2Interface::UnmapBufferCHROMIUM(GLuint target
) {
316 return test_context_
->unmapBufferCHROMIUM(target
);
319 void TestGLES2Interface::BufferData(GLenum target
,
323 test_context_
->bufferData(target
, size
, data
, usage
);
326 void TestGLES2Interface::WaitSyncPointCHROMIUM(GLuint sync_point
) {
327 test_context_
->waitSyncPoint(sync_point
);
330 GLuint
TestGLES2Interface::InsertSyncPointCHROMIUM() {
331 return test_context_
->insertSyncPoint();
334 void TestGLES2Interface::BeginQueryEXT(GLenum target
, GLuint id
) {
335 test_context_
->beginQueryEXT(target
, id
);
338 void TestGLES2Interface::EndQueryEXT(GLenum target
) {
339 test_context_
->endQueryEXT(target
);
342 void TestGLES2Interface::GetQueryObjectuivEXT(GLuint id
,
345 test_context_
->getQueryObjectuivEXT(id
, pname
, params
);
348 void TestGLES2Interface::DiscardFramebufferEXT(GLenum target
,
350 const GLenum
* attachments
) {
351 test_context_
->discardFramebufferEXT(target
, count
, attachments
);
354 void TestGLES2Interface::GenMailboxCHROMIUM(GLbyte
* mailbox
) {
355 test_context_
->genMailboxCHROMIUM(mailbox
);
358 void TestGLES2Interface::ProduceTextureCHROMIUM(GLenum target
,
359 const GLbyte
* mailbox
) {
360 test_context_
->produceTextureCHROMIUM(target
, mailbox
);
363 void TestGLES2Interface::ProduceTextureDirectCHROMIUM(GLuint texture
,
365 const GLbyte
* mailbox
) {
366 test_context_
->produceTextureDirectCHROMIUM(texture
, target
, mailbox
);
369 void TestGLES2Interface::ConsumeTextureCHROMIUM(GLenum target
,
370 const GLbyte
* mailbox
) {
371 test_context_
->consumeTextureCHROMIUM(target
, mailbox
);
374 GLuint
TestGLES2Interface::CreateAndConsumeTextureCHROMIUM(
376 const GLbyte
* mailbox
) {
377 return test_context_
->createAndConsumeTextureCHROMIUM(target
, mailbox
);
380 void TestGLES2Interface::ResizeCHROMIUM(GLuint width
,
382 float device_scale
) {
383 test_context_
->reshapeWithScaleFactor(width
, height
, device_scale
);
386 void TestGLES2Interface::LoseContextCHROMIUM(GLenum current
, GLenum other
) {
387 test_context_
->loseContextCHROMIUM(current
, other
);