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::GenRenderbuffers(GLsizei n, GLuint* renderbuffers) { 38 for (GLsizei i = 0; i < n; ++i) { 39 renderbuffers[i] = test_context_->createRenderbuffer(); 40 } 41} 42 43void TestGLES2Interface::GenQueriesEXT(GLsizei n, GLuint* queries) { 44 for (GLsizei i = 0; i < n; ++i) { 45 queries[i] = test_context_->createQueryEXT(); 46 } 47} 48 49void TestGLES2Interface::DeleteTextures(GLsizei n, const GLuint* textures) { 50 for (GLsizei i = 0; i < n; ++i) { 51 test_context_->deleteTexture(textures[i]); 52 } 53} 54 55void TestGLES2Interface::DeleteBuffers(GLsizei n, const GLuint* buffers) { 56 for (GLsizei i = 0; i < n; ++i) { 57 test_context_->deleteBuffer(buffers[i]); 58 } 59} 60 61void TestGLES2Interface::DeleteFramebuffers(GLsizei n, 62 const GLuint* framebuffers) { 63 for (GLsizei i = 0; i < n; ++i) { 64 test_context_->deleteFramebuffer(framebuffers[i]); 65 } 66} 67 68void TestGLES2Interface::DeleteQueriesEXT(GLsizei n, const GLuint* queries) { 69 for (GLsizei i = 0; i < n; ++i) { 70 test_context_->deleteQueryEXT(queries[i]); 71 } 72} 73 74GLuint TestGLES2Interface::CreateShader(GLenum type) { 75 return test_context_->createShader(type); 76} 77 78GLuint TestGLES2Interface::CreateProgram() { 79 return test_context_->createProgram(); 80} 81 82void TestGLES2Interface::BindTexture(GLenum target, GLuint texture) { 83 test_context_->bindTexture(target, texture); 84} 85 86void TestGLES2Interface::GetIntegerv(GLenum pname, GLint* params) { 87 test_context_->getIntegerv(pname, params); 88} 89 90void TestGLES2Interface::GetShaderiv(GLuint shader, 91 GLenum pname, 92 GLint* params) { 93 test_context_->getShaderiv(shader, pname, params); 94} 95 96void TestGLES2Interface::GetProgramiv(GLuint program, 97 GLenum pname, 98 GLint* params) { 99 test_context_->getProgramiv(program, pname, params); 100} 101 102void TestGLES2Interface::GetShaderPrecisionFormat(GLenum shadertype, 103 GLenum precisiontype, 104 GLint* range, 105 GLint* precision) { 106 test_context_->getShaderPrecisionFormat( 107 shadertype, precisiontype, range, precision); 108} 109 110void TestGLES2Interface::Viewport(GLint x, 111 GLint y, 112 GLsizei width, 113 GLsizei height) { 114 test_context_->viewport(x, y, width, height); 115} 116 117void TestGLES2Interface::ActiveTexture(GLenum target) { 118 test_context_->activeTexture(target); 119} 120 121void TestGLES2Interface::UseProgram(GLuint program) { 122 test_context_->useProgram(program); 123} 124 125GLenum TestGLES2Interface::CheckFramebufferStatus(GLenum target) { 126 return test_context_->checkFramebufferStatus(target); 127} 128 129void TestGLES2Interface::Scissor(GLint x, 130 GLint y, 131 GLsizei width, 132 GLsizei height) { 133 test_context_->scissor(x, y, width, height); 134} 135 136void TestGLES2Interface::DrawElements(GLenum mode, 137 GLsizei count, 138 GLenum type, 139 const void* indices) { 140 test_context_->drawElements( 141 mode, count, type, reinterpret_cast<intptr_t>(indices)); 142} 143 144void TestGLES2Interface::ClearColor(GLclampf red, 145 GLclampf green, 146 GLclampf blue, 147 GLclampf alpha) { 148 test_context_->clearColor(red, green, blue, alpha); 149} 150 151void TestGLES2Interface::ClearStencil(GLint s) { 152 test_context_->clearStencil(s); 153} 154 155void TestGLES2Interface::Clear(GLbitfield mask) { test_context_->clear(mask); } 156 157void TestGLES2Interface::Flush() { test_context_->flush(); } 158 159void TestGLES2Interface::Finish() { test_context_->finish(); } 160 161void TestGLES2Interface::ShallowFlushCHROMIUM() { 162 test_context_->shallowFlushCHROMIUM(); 163} 164 165void TestGLES2Interface::Enable(GLenum cap) { test_context_->enable(cap); } 166 167void TestGLES2Interface::Disable(GLenum cap) { test_context_->disable(cap); } 168 169void TestGLES2Interface::BindRenderbuffer(GLenum target, GLuint buffer) { 170 test_context_->bindRenderbuffer(target, buffer); 171} 172 173void TestGLES2Interface::BindFramebuffer(GLenum target, GLuint buffer) { 174 test_context_->bindFramebuffer(target, buffer); 175} 176 177void TestGLES2Interface::BindBuffer(GLenum target, GLuint buffer) { 178 test_context_->bindBuffer(target, buffer); 179} 180 181void TestGLES2Interface::TexImage2D(GLenum target, 182 GLint level, 183 GLint internalformat, 184 GLsizei width, 185 GLsizei height, 186 GLint border, 187 GLenum format, 188 GLenum type, 189 const void* pixels) { 190 test_context_->texImage2D(target, 191 level, 192 internalformat, 193 width, 194 height, 195 border, 196 format, 197 type, 198 pixels); 199} 200 201void TestGLES2Interface::TexSubImage2D(GLenum target, 202 GLint level, 203 GLint xoffset, 204 GLint yoffset, 205 GLsizei width, 206 GLsizei height, 207 GLenum format, 208 GLenum type, 209 const void* pixels) { 210 test_context_->texSubImage2D( 211 target, level, xoffset, yoffset, width, height, format, type, pixels); 212} 213 214void TestGLES2Interface::TexStorage2DEXT(GLenum target, 215 GLsizei levels, 216 GLenum internalformat, 217 GLsizei width, 218 GLsizei height) { 219 test_context_->texStorage2DEXT(target, levels, internalformat, width, height); 220} 221 222void TestGLES2Interface::TexImageIOSurface2DCHROMIUM(GLenum target, 223 GLsizei width, 224 GLsizei height, 225 GLuint io_surface_id, 226 GLuint plane) { 227 test_context_->texImageIOSurface2DCHROMIUM( 228 target, width, height, io_surface_id, plane); 229} 230 231void TestGLES2Interface::TexParameteri(GLenum target, 232 GLenum pname, 233 GLint param) { 234 test_context_->texParameteri(target, pname, param); 235} 236 237void TestGLES2Interface::FramebufferRenderbuffer(GLenum target, 238 GLenum attachment, 239 GLenum renderbuffertarget, 240 GLuint renderbuffer) { 241 test_context_->framebufferRenderbuffer( 242 target, attachment, renderbuffertarget, renderbuffer); 243} 244void TestGLES2Interface::FramebufferTexture2D(GLenum target, 245 GLenum attachment, 246 GLenum textarget, 247 GLuint texture, 248 GLint level) { 249 test_context_->framebufferTexture2D( 250 target, attachment, textarget, texture, level); 251} 252 253void TestGLES2Interface::RenderbufferStorage(GLenum target, 254 GLenum internalformat, 255 GLsizei width, 256 GLsizei height) { 257 test_context_->renderbufferStorage(target, internalformat, width, height); 258} 259 260void TestGLES2Interface::AsyncTexImage2DCHROMIUM(GLenum target, 261 GLint level, 262 GLenum internalformat, 263 GLsizei width, 264 GLsizei height, 265 GLint border, 266 GLenum format, 267 GLenum type, 268 const void* pixels) { 269 test_context_->asyncTexImage2DCHROMIUM(target, 270 level, 271 internalformat, 272 width, 273 height, 274 border, 275 format, 276 type, 277 pixels); 278} 279 280void TestGLES2Interface::AsyncTexSubImage2DCHROMIUM(GLenum target, 281 GLint level, 282 GLint xoffset, 283 GLint yoffset, 284 GLsizei width, 285 GLsizei height, 286 GLenum format, 287 GLenum type, 288 const void* pixels) { 289 test_context_->asyncTexSubImage2DCHROMIUM( 290 target, level, xoffset, yoffset, width, height, format, type, pixels); 291} 292 293void TestGLES2Interface::CompressedTexImage2D(GLenum target, 294 GLint level, 295 GLenum internalformat, 296 GLsizei width, 297 GLsizei height, 298 GLint border, 299 GLsizei image_size, 300 const void* data) { 301 test_context_->compressedTexImage2D( 302 target, level, internalformat, width, height, border, image_size, data); 303} 304 305void TestGLES2Interface::WaitAsyncTexImage2DCHROMIUM(GLenum target) { 306 test_context_->waitAsyncTexImage2DCHROMIUM(target); 307} 308 309GLuint TestGLES2Interface::CreateImageCHROMIUM(GLsizei width, 310 GLsizei height, 311 GLenum internalformat, 312 GLenum usage) { 313 return test_context_->createImageCHROMIUM( 314 width, height, internalformat, usage); 315} 316 317void TestGLES2Interface::DestroyImageCHROMIUM(GLuint image_id) { 318 test_context_->destroyImageCHROMIUM(image_id); 319} 320 321void* TestGLES2Interface::MapImageCHROMIUM(GLuint image_id) { 322 return test_context_->mapImageCHROMIUM(image_id); 323} 324 325void TestGLES2Interface::GetImageParameterivCHROMIUM(GLuint image_id, 326 GLenum pname, 327 GLint* params) { 328 test_context_->getImageParameterivCHROMIUM(image_id, pname, params); 329} 330 331void TestGLES2Interface::UnmapImageCHROMIUM(GLuint image_id) { 332 test_context_->unmapImageCHROMIUM(image_id); 333} 334 335void TestGLES2Interface::BindTexImage2DCHROMIUM(GLenum target, GLint image_id) { 336 test_context_->bindTexImage2DCHROMIUM(target, image_id); 337} 338 339void TestGLES2Interface::ReleaseTexImage2DCHROMIUM(GLenum target, 340 GLint image_id) { 341 test_context_->releaseTexImage2DCHROMIUM(target, image_id); 342} 343 344void* TestGLES2Interface::MapBufferCHROMIUM(GLuint target, GLenum access) { 345 return test_context_->mapBufferCHROMIUM(target, access); 346} 347 348GLboolean TestGLES2Interface::UnmapBufferCHROMIUM(GLuint target) { 349 return test_context_->unmapBufferCHROMIUM(target); 350} 351 352void TestGLES2Interface::BufferData(GLenum target, 353 GLsizeiptr size, 354 const void* data, 355 GLenum usage) { 356 test_context_->bufferData(target, size, data, usage); 357} 358 359void TestGLES2Interface::WaitSyncPointCHROMIUM(GLuint sync_point) { 360 test_context_->waitSyncPoint(sync_point); 361} 362 363GLuint TestGLES2Interface::InsertSyncPointCHROMIUM() { 364 return test_context_->insertSyncPoint(); 365} 366 367void TestGLES2Interface::BeginQueryEXT(GLenum target, GLuint id) { 368 test_context_->beginQueryEXT(target, id); 369} 370 371void TestGLES2Interface::EndQueryEXT(GLenum target) { 372 test_context_->endQueryEXT(target); 373} 374 375void TestGLES2Interface::GetQueryObjectuivEXT(GLuint id, 376 GLenum pname, 377 GLuint* params) { 378 test_context_->getQueryObjectuivEXT(id, pname, params); 379} 380 381void TestGLES2Interface::DiscardFramebufferEXT(GLenum target, 382 GLsizei count, 383 const GLenum* attachments) { 384 test_context_->discardFramebufferEXT(target, count, attachments); 385} 386 387void TestGLES2Interface::GenMailboxCHROMIUM(GLbyte* mailbox) { 388 test_context_->genMailboxCHROMIUM(mailbox); 389} 390 391void TestGLES2Interface::ProduceTextureCHROMIUM(GLenum target, 392 const GLbyte* mailbox) { 393 test_context_->produceTextureCHROMIUM(target, mailbox); 394} 395 396void TestGLES2Interface::ProduceTextureDirectCHROMIUM(GLuint texture, 397 GLenum target, 398 const GLbyte* mailbox) { 399 test_context_->produceTextureDirectCHROMIUM(texture, target, mailbox); 400} 401 402void TestGLES2Interface::ConsumeTextureCHROMIUM(GLenum target, 403 const GLbyte* mailbox) { 404 test_context_->consumeTextureCHROMIUM(target, mailbox); 405} 406 407GLuint TestGLES2Interface::CreateAndConsumeTextureCHROMIUM( 408 GLenum target, 409 const GLbyte* mailbox) { 410 return test_context_->createAndConsumeTextureCHROMIUM(target, mailbox); 411} 412 413void TestGLES2Interface::ResizeCHROMIUM(GLuint width, 414 GLuint height, 415 float device_scale) { 416 test_context_->reshapeWithScaleFactor(width, height, device_scale); 417} 418 419void TestGLES2Interface::LoseContextCHROMIUM(GLenum current, GLenum other) { 420 test_context_->loseContextCHROMIUM(current, other); 421} 422 423} // namespace cc 424