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::GenRenderbuffers(GLsizei n
, GLuint
* renderbuffers
) {
38 for (GLsizei i
= 0; i
< n
; ++i
) {
39 renderbuffers
[i
] = test_context_
->createRenderbuffer();
43 void TestGLES2Interface::GenQueriesEXT(GLsizei n
, GLuint
* queries
) {
44 for (GLsizei i
= 0; i
< n
; ++i
) {
45 queries
[i
] = test_context_
->createQueryEXT();
49 void TestGLES2Interface::DeleteTextures(GLsizei n
, const GLuint
* textures
) {
50 for (GLsizei i
= 0; i
< n
; ++i
) {
51 test_context_
->deleteTexture(textures
[i
]);
55 void TestGLES2Interface::DeleteBuffers(GLsizei n
, const GLuint
* buffers
) {
56 for (GLsizei i
= 0; i
< n
; ++i
) {
57 test_context_
->deleteBuffer(buffers
[i
]);
61 void TestGLES2Interface::DeleteFramebuffers(GLsizei n
,
62 const GLuint
* framebuffers
) {
63 for (GLsizei i
= 0; i
< n
; ++i
) {
64 test_context_
->deleteFramebuffer(framebuffers
[i
]);
68 void TestGLES2Interface::DeleteQueriesEXT(GLsizei n
, const GLuint
* queries
) {
69 for (GLsizei i
= 0; i
< n
; ++i
) {
70 test_context_
->deleteQueryEXT(queries
[i
]);
74 GLuint
TestGLES2Interface::CreateShader(GLenum type
) {
75 return test_context_
->createShader(type
);
78 GLuint
TestGLES2Interface::CreateProgram() {
79 return test_context_
->createProgram();
82 void TestGLES2Interface::BindTexture(GLenum target
, GLuint texture
) {
83 test_context_
->bindTexture(target
, texture
);
86 void TestGLES2Interface::GetIntegerv(GLenum pname
, GLint
* params
) {
87 test_context_
->getIntegerv(pname
, params
);
90 void TestGLES2Interface::GetShaderiv(GLuint shader
,
93 test_context_
->getShaderiv(shader
, pname
, params
);
96 void TestGLES2Interface::GetProgramiv(GLuint program
,
99 test_context_
->getProgramiv(program
, pname
, params
);
102 void TestGLES2Interface::GetShaderPrecisionFormat(GLenum shadertype
,
103 GLenum precisiontype
,
106 test_context_
->getShaderPrecisionFormat(
107 shadertype
, precisiontype
, range
, precision
);
110 void TestGLES2Interface::Viewport(GLint x
,
114 test_context_
->viewport(x
, y
, width
, height
);
117 void TestGLES2Interface::ActiveTexture(GLenum target
) {
118 test_context_
->activeTexture(target
);
121 void TestGLES2Interface::UseProgram(GLuint program
) {
122 test_context_
->useProgram(program
);
125 GLenum
TestGLES2Interface::CheckFramebufferStatus(GLenum target
) {
126 return test_context_
->checkFramebufferStatus(target
);
129 void TestGLES2Interface::Scissor(GLint x
,
133 test_context_
->scissor(x
, y
, width
, height
);
136 void TestGLES2Interface::DrawElements(GLenum mode
,
139 const void* indices
) {
140 test_context_
->drawElements(
141 mode
, count
, type
, reinterpret_cast<intptr_t>(indices
));
144 void TestGLES2Interface::ClearColor(GLclampf red
,
148 test_context_
->clearColor(red
, green
, blue
, alpha
);
151 void TestGLES2Interface::ClearStencil(GLint s
) {
152 test_context_
->clearStencil(s
);
155 void TestGLES2Interface::Clear(GLbitfield mask
) { test_context_
->clear(mask
); }
157 void TestGLES2Interface::Flush() { test_context_
->flush(); }
159 void TestGLES2Interface::Finish() { test_context_
->finish(); }
161 void TestGLES2Interface::ShallowFlushCHROMIUM() {
162 test_context_
->shallowFlushCHROMIUM();
165 void TestGLES2Interface::Enable(GLenum cap
) { test_context_
->enable(cap
); }
167 void TestGLES2Interface::Disable(GLenum cap
) { test_context_
->disable(cap
); }
169 void TestGLES2Interface::BindRenderbuffer(GLenum target
, GLuint buffer
) {
170 test_context_
->bindRenderbuffer(target
, buffer
);
173 void TestGLES2Interface::BindFramebuffer(GLenum target
, GLuint buffer
) {
174 test_context_
->bindFramebuffer(target
, buffer
);
177 void TestGLES2Interface::BindBuffer(GLenum target
, GLuint buffer
) {
178 test_context_
->bindBuffer(target
, buffer
);
181 void TestGLES2Interface::PixelStorei(GLenum pname
, GLint param
) {
182 test_context_
->pixelStorei(pname
, param
);
185 void TestGLES2Interface::TexImage2D(GLenum target
,
187 GLint internalformat
,
193 const void* pixels
) {
194 test_context_
->texImage2D(target
,
205 void TestGLES2Interface::TexSubImage2D(GLenum target
,
213 const void* pixels
) {
214 test_context_
->texSubImage2D(
215 target
, level
, xoffset
, yoffset
, width
, height
, format
, type
, pixels
);
218 void TestGLES2Interface::TexStorage2DEXT(GLenum target
,
220 GLenum internalformat
,
223 test_context_
->texStorage2DEXT(target
, levels
, internalformat
, width
, height
);
226 void TestGLES2Interface::TexImageIOSurface2DCHROMIUM(GLenum target
,
229 GLuint io_surface_id
,
231 test_context_
->texImageIOSurface2DCHROMIUM(
232 target
, width
, height
, io_surface_id
, plane
);
235 void TestGLES2Interface::TexParameteri(GLenum target
,
238 test_context_
->texParameteri(target
, pname
, param
);
241 void TestGLES2Interface::FramebufferRenderbuffer(GLenum target
,
243 GLenum renderbuffertarget
,
244 GLuint renderbuffer
) {
245 test_context_
->framebufferRenderbuffer(
246 target
, attachment
, renderbuffertarget
, renderbuffer
);
248 void TestGLES2Interface::FramebufferTexture2D(GLenum target
,
253 test_context_
->framebufferTexture2D(
254 target
, attachment
, textarget
, texture
, level
);
257 void TestGLES2Interface::RenderbufferStorage(GLenum target
,
258 GLenum internalformat
,
261 test_context_
->renderbufferStorage(target
, internalformat
, width
, height
);
264 void TestGLES2Interface::AsyncTexImage2DCHROMIUM(GLenum target
,
266 GLenum internalformat
,
272 const void* pixels
) {
273 test_context_
->asyncTexImage2DCHROMIUM(target
,
284 void TestGLES2Interface::AsyncTexSubImage2DCHROMIUM(GLenum target
,
292 const void* pixels
) {
293 test_context_
->asyncTexSubImage2DCHROMIUM(
294 target
, level
, xoffset
, yoffset
, width
, height
, format
, type
, pixels
);
297 void TestGLES2Interface::CompressedTexImage2D(GLenum target
,
299 GLenum internalformat
,
305 test_context_
->compressedTexImage2D(
306 target
, level
, internalformat
, width
, height
, border
, image_size
, data
);
309 void TestGLES2Interface::WaitAsyncTexImage2DCHROMIUM(GLenum target
) {
310 test_context_
->waitAsyncTexImage2DCHROMIUM(target
);
313 GLuint
TestGLES2Interface::CreateImageCHROMIUM(ClientBuffer buffer
,
316 GLenum internalformat
) {
317 return test_context_
->createImageCHROMIUM(
318 buffer
, width
, height
, internalformat
);
321 void TestGLES2Interface::DestroyImageCHROMIUM(GLuint image_id
) {
322 test_context_
->destroyImageCHROMIUM(image_id
);
325 GLuint
TestGLES2Interface::CreateGpuMemoryBufferImageCHROMIUM(
328 GLenum internalformat
,
330 return test_context_
->createGpuMemoryBufferImageCHROMIUM(
331 width
, height
, internalformat
, usage
);
334 void TestGLES2Interface::BindTexImage2DCHROMIUM(GLenum target
, GLint image_id
) {
335 test_context_
->bindTexImage2DCHROMIUM(target
, image_id
);
338 void TestGLES2Interface::ReleaseTexImage2DCHROMIUM(GLenum target
,
340 test_context_
->releaseTexImage2DCHROMIUM(target
, image_id
);
343 void* TestGLES2Interface::MapBufferCHROMIUM(GLuint target
, GLenum access
) {
344 return test_context_
->mapBufferCHROMIUM(target
, access
);
347 GLboolean
TestGLES2Interface::UnmapBufferCHROMIUM(GLuint target
) {
348 return test_context_
->unmapBufferCHROMIUM(target
);
351 void TestGLES2Interface::BufferData(GLenum target
,
355 test_context_
->bufferData(target
, size
, data
, usage
);
358 void TestGLES2Interface::WaitSyncPointCHROMIUM(GLuint sync_point
) {
359 test_context_
->waitSyncPoint(sync_point
);
362 GLuint
TestGLES2Interface::InsertSyncPointCHROMIUM() {
363 return test_context_
->insertSyncPoint();
366 void TestGLES2Interface::BeginQueryEXT(GLenum target
, GLuint id
) {
367 test_context_
->beginQueryEXT(target
, id
);
370 void TestGLES2Interface::EndQueryEXT(GLenum target
) {
371 test_context_
->endQueryEXT(target
);
374 void TestGLES2Interface::GetQueryObjectuivEXT(GLuint id
,
377 test_context_
->getQueryObjectuivEXT(id
, pname
, params
);
380 void TestGLES2Interface::DiscardFramebufferEXT(GLenum target
,
382 const GLenum
* attachments
) {
383 test_context_
->discardFramebufferEXT(target
, count
, attachments
);
386 void TestGLES2Interface::GenMailboxCHROMIUM(GLbyte
* mailbox
) {
387 test_context_
->genMailboxCHROMIUM(mailbox
);
390 void TestGLES2Interface::ProduceTextureCHROMIUM(GLenum target
,
391 const GLbyte
* mailbox
) {
392 test_context_
->produceTextureCHROMIUM(target
, mailbox
);
395 void TestGLES2Interface::ProduceTextureDirectCHROMIUM(GLuint texture
,
397 const GLbyte
* mailbox
) {
398 test_context_
->produceTextureDirectCHROMIUM(texture
, target
, mailbox
);
401 void TestGLES2Interface::ConsumeTextureCHROMIUM(GLenum target
,
402 const GLbyte
* mailbox
) {
403 test_context_
->consumeTextureCHROMIUM(target
, mailbox
);
406 GLuint
TestGLES2Interface::CreateAndConsumeTextureCHROMIUM(
408 const GLbyte
* mailbox
) {
409 return test_context_
->createAndConsumeTextureCHROMIUM(target
, mailbox
);
412 void TestGLES2Interface::ResizeCHROMIUM(GLuint width
,
414 float device_scale
) {
415 test_context_
->reshapeWithScaleFactor(width
, height
, device_scale
);
418 void TestGLES2Interface::LoseContextCHROMIUM(GLenum current
, GLenum other
) {
419 test_context_
->loseContextCHROMIUM(current
, other
);