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"
9 #include "gpu/GLES2/gl2extchromium.h"
13 TestGLES2Interface::TestGLES2Interface(TestWebGraphicsContext3D
* test_context
)
14 : test_context_(test_context
) {
15 DCHECK(test_context_
);
18 TestGLES2Interface::~TestGLES2Interface() {}
20 void TestGLES2Interface::GenTextures(GLsizei n
, GLuint
* textures
) {
21 for (GLsizei i
= 0; i
< n
; ++i
) {
22 textures
[i
] = test_context_
->createTexture();
26 void TestGLES2Interface::GenBuffers(GLsizei n
, GLuint
* buffers
) {
27 for (GLsizei i
= 0; i
< n
; ++i
) {
28 buffers
[i
] = test_context_
->createBuffer();
32 void TestGLES2Interface::GenFramebuffers(GLsizei n
, GLuint
* framebuffers
) {
33 for (GLsizei i
= 0; i
< n
; ++i
) {
34 framebuffers
[i
] = test_context_
->createFramebuffer();
38 void TestGLES2Interface::GenRenderbuffers(GLsizei n
, GLuint
* renderbuffers
) {
39 for (GLsizei i
= 0; i
< n
; ++i
) {
40 renderbuffers
[i
] = test_context_
->createRenderbuffer();
44 void TestGLES2Interface::GenQueriesEXT(GLsizei n
, GLuint
* queries
) {
45 for (GLsizei i
= 0; i
< n
; ++i
) {
46 queries
[i
] = test_context_
->createQueryEXT();
50 void TestGLES2Interface::DeleteTextures(GLsizei n
, const GLuint
* textures
) {
51 for (GLsizei i
= 0; i
< n
; ++i
) {
52 test_context_
->deleteTexture(textures
[i
]);
56 void TestGLES2Interface::DeleteBuffers(GLsizei n
, const GLuint
* buffers
) {
57 for (GLsizei i
= 0; i
< n
; ++i
) {
58 test_context_
->deleteBuffer(buffers
[i
]);
62 void TestGLES2Interface::DeleteFramebuffers(GLsizei n
,
63 const GLuint
* framebuffers
) {
64 for (GLsizei i
= 0; i
< n
; ++i
) {
65 test_context_
->deleteFramebuffer(framebuffers
[i
]);
69 void TestGLES2Interface::DeleteQueriesEXT(GLsizei n
, const GLuint
* queries
) {
70 for (GLsizei i
= 0; i
< n
; ++i
) {
71 test_context_
->deleteQueryEXT(queries
[i
]);
75 GLuint
TestGLES2Interface::CreateShader(GLenum type
) {
76 return test_context_
->createShader(type
);
79 GLuint
TestGLES2Interface::CreateProgram() {
80 return test_context_
->createProgram();
83 void TestGLES2Interface::BindTexture(GLenum target
, GLuint texture
) {
84 test_context_
->bindTexture(target
, texture
);
87 void TestGLES2Interface::GetIntegerv(GLenum pname
, GLint
* params
) {
88 test_context_
->getIntegerv(pname
, params
);
91 void TestGLES2Interface::GetShaderiv(GLuint shader
,
94 test_context_
->getShaderiv(shader
, pname
, params
);
97 void TestGLES2Interface::GetProgramiv(GLuint program
,
100 test_context_
->getProgramiv(program
, pname
, params
);
103 void TestGLES2Interface::GetShaderPrecisionFormat(GLenum shadertype
,
104 GLenum precisiontype
,
107 test_context_
->getShaderPrecisionFormat(
108 shadertype
, precisiontype
, range
, precision
);
111 void TestGLES2Interface::Viewport(GLint x
,
115 test_context_
->viewport(x
, y
, width
, height
);
118 void TestGLES2Interface::ActiveTexture(GLenum target
) {
119 test_context_
->activeTexture(target
);
122 void TestGLES2Interface::UseProgram(GLuint program
) {
123 test_context_
->useProgram(program
);
126 GLenum
TestGLES2Interface::CheckFramebufferStatus(GLenum target
) {
127 return test_context_
->checkFramebufferStatus(target
);
130 void TestGLES2Interface::Scissor(GLint x
,
134 test_context_
->scissor(x
, y
, width
, height
);
137 void TestGLES2Interface::DrawElements(GLenum mode
,
140 const void* indices
) {
141 test_context_
->drawElements(
142 mode
, count
, type
, reinterpret_cast<intptr_t>(indices
));
145 void TestGLES2Interface::ClearColor(GLclampf red
,
149 test_context_
->clearColor(red
, green
, blue
, alpha
);
152 void TestGLES2Interface::ClearStencil(GLint s
) {
153 test_context_
->clearStencil(s
);
156 void TestGLES2Interface::Clear(GLbitfield mask
) { test_context_
->clear(mask
); }
158 void TestGLES2Interface::Flush() { test_context_
->flush(); }
160 void TestGLES2Interface::Finish() { test_context_
->finish(); }
162 void TestGLES2Interface::ShallowFinishCHROMIUM() {
163 test_context_
->shallowFinishCHROMIUM();
166 void TestGLES2Interface::ShallowFlushCHROMIUM() {
167 test_context_
->shallowFlushCHROMIUM();
170 void TestGLES2Interface::Enable(GLenum cap
) { test_context_
->enable(cap
); }
172 void TestGLES2Interface::Disable(GLenum cap
) { test_context_
->disable(cap
); }
174 void TestGLES2Interface::BindRenderbuffer(GLenum target
, GLuint buffer
) {
175 test_context_
->bindRenderbuffer(target
, buffer
);
178 void TestGLES2Interface::BindFramebuffer(GLenum target
, GLuint buffer
) {
179 test_context_
->bindFramebuffer(target
, buffer
);
182 void TestGLES2Interface::BindBuffer(GLenum target
, GLuint buffer
) {
183 test_context_
->bindBuffer(target
, buffer
);
186 void TestGLES2Interface::PixelStorei(GLenum pname
, GLint param
) {
187 test_context_
->pixelStorei(pname
, param
);
190 void TestGLES2Interface::TexImage2D(GLenum target
,
192 GLint internalformat
,
198 const void* pixels
) {
199 test_context_
->texImage2D(target
,
210 void TestGLES2Interface::TexSubImage2D(GLenum target
,
218 const void* pixels
) {
219 test_context_
->texSubImage2D(
220 target
, level
, xoffset
, yoffset
, width
, height
, format
, type
, pixels
);
223 void TestGLES2Interface::TexStorage2DEXT(GLenum target
,
225 GLenum internalformat
,
228 test_context_
->texStorage2DEXT(target
, levels
, internalformat
, width
, height
);
231 void TestGLES2Interface::TexImageIOSurface2DCHROMIUM(GLenum target
,
234 GLuint io_surface_id
,
236 test_context_
->texImageIOSurface2DCHROMIUM(
237 target
, width
, height
, io_surface_id
, plane
);
240 void TestGLES2Interface::TexParameteri(GLenum target
,
243 test_context_
->texParameteri(target
, pname
, param
);
246 void TestGLES2Interface::FramebufferRenderbuffer(GLenum target
,
248 GLenum renderbuffertarget
,
249 GLuint renderbuffer
) {
250 test_context_
->framebufferRenderbuffer(
251 target
, attachment
, renderbuffertarget
, renderbuffer
);
253 void TestGLES2Interface::FramebufferTexture2D(GLenum target
,
258 test_context_
->framebufferTexture2D(
259 target
, attachment
, textarget
, texture
, level
);
262 void TestGLES2Interface::RenderbufferStorage(GLenum target
,
263 GLenum internalformat
,
266 test_context_
->renderbufferStorage(target
, internalformat
, width
, height
);
269 void TestGLES2Interface::AsyncTexImage2DCHROMIUM(GLenum target
,
271 GLenum internalformat
,
277 const void* pixels
) {
278 test_context_
->asyncTexImage2DCHROMIUM(target
,
289 void TestGLES2Interface::AsyncTexSubImage2DCHROMIUM(GLenum target
,
297 const void* pixels
) {
298 test_context_
->asyncTexSubImage2DCHROMIUM(
299 target
, level
, xoffset
, yoffset
, width
, height
, format
, type
, pixels
);
302 void TestGLES2Interface::CompressedTexImage2D(GLenum target
,
304 GLenum internalformat
,
310 test_context_
->compressedTexImage2D(
311 target
, level
, internalformat
, width
, height
, border
, image_size
, data
);
314 void TestGLES2Interface::WaitAsyncTexImage2DCHROMIUM(GLenum target
) {
315 test_context_
->waitAsyncTexImage2DCHROMIUM(target
);
318 GLuint
TestGLES2Interface::CreateImageCHROMIUM(ClientBuffer buffer
,
321 GLenum internalformat
) {
322 return test_context_
->createImageCHROMIUM(
323 buffer
, width
, height
, internalformat
);
326 void TestGLES2Interface::DestroyImageCHROMIUM(GLuint image_id
) {
327 test_context_
->destroyImageCHROMIUM(image_id
);
330 GLuint
TestGLES2Interface::CreateGpuMemoryBufferImageCHROMIUM(
333 GLenum internalformat
,
335 return test_context_
->createGpuMemoryBufferImageCHROMIUM(
336 width
, height
, internalformat
, usage
);
339 void TestGLES2Interface::BindTexImage2DCHROMIUM(GLenum target
, GLint image_id
) {
340 test_context_
->bindTexImage2DCHROMIUM(target
, image_id
);
343 void TestGLES2Interface::ReleaseTexImage2DCHROMIUM(GLenum target
,
345 test_context_
->releaseTexImage2DCHROMIUM(target
, image_id
);
348 void* TestGLES2Interface::MapBufferCHROMIUM(GLuint target
, GLenum access
) {
349 return test_context_
->mapBufferCHROMIUM(target
, access
);
352 GLboolean
TestGLES2Interface::UnmapBufferCHROMIUM(GLuint target
) {
353 return test_context_
->unmapBufferCHROMIUM(target
);
356 void TestGLES2Interface::BufferData(GLenum target
,
360 test_context_
->bufferData(target
, size
, data
, usage
);
363 void TestGLES2Interface::WaitSyncPointCHROMIUM(GLuint sync_point
) {
364 test_context_
->waitSyncPoint(sync_point
);
367 GLuint
TestGLES2Interface::InsertSyncPointCHROMIUM() {
368 return test_context_
->insertSyncPoint();
371 void TestGLES2Interface::BeginQueryEXT(GLenum target
, GLuint id
) {
372 test_context_
->beginQueryEXT(target
, id
);
375 void TestGLES2Interface::EndQueryEXT(GLenum target
) {
376 test_context_
->endQueryEXT(target
);
379 void TestGLES2Interface::GetQueryObjectuivEXT(GLuint id
,
382 test_context_
->getQueryObjectuivEXT(id
, pname
, params
);
385 void TestGLES2Interface::DiscardFramebufferEXT(GLenum target
,
387 const GLenum
* attachments
) {
388 test_context_
->discardFramebufferEXT(target
, count
, attachments
);
391 void TestGLES2Interface::GenMailboxCHROMIUM(GLbyte
* mailbox
) {
392 test_context_
->genMailboxCHROMIUM(mailbox
);
395 void TestGLES2Interface::ProduceTextureCHROMIUM(GLenum target
,
396 const GLbyte
* mailbox
) {
397 test_context_
->produceTextureCHROMIUM(target
, mailbox
);
400 void TestGLES2Interface::ProduceTextureDirectCHROMIUM(GLuint texture
,
402 const GLbyte
* mailbox
) {
403 test_context_
->produceTextureDirectCHROMIUM(texture
, target
, mailbox
);
406 void TestGLES2Interface::ConsumeTextureCHROMIUM(GLenum target
,
407 const GLbyte
* mailbox
) {
408 test_context_
->consumeTextureCHROMIUM(target
, mailbox
);
411 GLuint
TestGLES2Interface::CreateAndConsumeTextureCHROMIUM(
413 const GLbyte
* mailbox
) {
414 return test_context_
->createAndConsumeTextureCHROMIUM(target
, mailbox
);
417 void TestGLES2Interface::ResizeCHROMIUM(GLuint width
,
419 float device_scale
) {
420 test_context_
->reshapeWithScaleFactor(width
, height
, device_scale
);
423 void TestGLES2Interface::LoseContextCHROMIUM(GLenum current
, GLenum other
) {
424 test_context_
->loseContextCHROMIUM(current
, other
);
427 GLenum
TestGLES2Interface::GetGraphicsResetStatusKHR() {
428 if (test_context_
->isContextLost())
429 return GL_UNKNOWN_CONTEXT_RESET_KHR
;