Home | History | Annotate | Download | only in test
      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/fake_web_graphics_context_3d.h"
      6 
      7 #include "base/logging.h"
      8 #include "third_party/khronos/GLES2/gl2.h"
      9 
     10 using blink::WGC3Dboolean;
     11 using blink::WGC3Denum;
     12 using blink::WGC3Dsizei;
     13 using blink::WebGLId;
     14 using blink::WebGraphicsContext3D;
     15 
     16 namespace cc {
     17 
     18 FakeWebGraphicsContext3D::FakeWebGraphicsContext3D()
     19     : blink::WebGraphicsContext3D() {
     20 }
     21 
     22 FakeWebGraphicsContext3D::~FakeWebGraphicsContext3D() {
     23 }
     24 
     25 bool FakeWebGraphicsContext3D::makeContextCurrent() {
     26   return true;
     27 }
     28 
     29 bool FakeWebGraphicsContext3D::isGLES2Compliant() {
     30   return false;
     31 }
     32 
     33 WebGLId FakeWebGraphicsContext3D::getPlatformTextureId() {
     34   return 0;
     35 }
     36 
     37 bool FakeWebGraphicsContext3D::isContextLost() {
     38   return false;
     39 }
     40 
     41 void* FakeWebGraphicsContext3D::mapBufferSubDataCHROMIUM(
     42     WGC3Denum target,
     43     blink::WGC3Dintptr offset,
     44     blink::WGC3Dsizeiptr size,
     45     WGC3Denum access) {
     46   return 0;
     47 }
     48 
     49 void* FakeWebGraphicsContext3D::mapTexSubImage2DCHROMIUM(
     50     WGC3Denum target,
     51     blink::WGC3Dint level,
     52     blink::WGC3Dint xoffset,
     53     blink::WGC3Dint yoffset,
     54     blink::WGC3Dsizei width,
     55     blink::WGC3Dsizei height,
     56     WGC3Denum format,
     57     WGC3Denum type,
     58     WGC3Denum access) {
     59   return 0;
     60 }
     61 
     62 blink::WebString FakeWebGraphicsContext3D::getRequestableExtensionsCHROMIUM() {
     63   return blink::WebString();
     64 }
     65 
     66 WGC3Denum FakeWebGraphicsContext3D::checkFramebufferStatus(
     67     WGC3Denum target) {
     68   return GL_FRAMEBUFFER_COMPLETE;
     69 }
     70 
     71 bool FakeWebGraphicsContext3D::getActiveAttrib(
     72     WebGLId program,
     73     blink::WGC3Duint index,
     74     ActiveInfo&) {
     75   return false;
     76 }
     77 
     78 bool FakeWebGraphicsContext3D::getActiveUniform(
     79     WebGLId program,
     80     blink::WGC3Duint index,
     81     ActiveInfo&) {
     82   return false;
     83 }
     84 
     85 blink::WGC3Dint FakeWebGraphicsContext3D::getAttribLocation(
     86     WebGLId program,
     87     const blink::WGC3Dchar* name) {
     88   return 0;
     89 }
     90 
     91 WebGraphicsContext3D::Attributes
     92     FakeWebGraphicsContext3D::getContextAttributes() {
     93   return WebGraphicsContext3D::Attributes();
     94 }
     95 
     96 WGC3Denum FakeWebGraphicsContext3D::getError() {
     97   return 0;
     98 }
     99 
    100 void FakeWebGraphicsContext3D::getIntegerv(
    101     WGC3Denum pname,
    102     blink::WGC3Dint* value) {
    103   if (pname == GL_MAX_TEXTURE_SIZE)
    104     *value = 1024;
    105   else if (pname == GL_ACTIVE_TEXTURE)
    106     *value = GL_TEXTURE0;
    107 }
    108 
    109 void FakeWebGraphicsContext3D::getProgramiv(
    110     WebGLId program,
    111     WGC3Denum pname,
    112     blink::WGC3Dint* value) {
    113   if (pname == GL_LINK_STATUS)
    114     *value = 1;
    115 }
    116 
    117 blink::WebString FakeWebGraphicsContext3D::getProgramInfoLog(
    118     WebGLId program) {
    119   return blink::WebString();
    120 }
    121 
    122 void FakeWebGraphicsContext3D::getShaderiv(
    123     WebGLId shader,
    124     WGC3Denum pname,
    125     blink::WGC3Dint* value) {
    126   if (pname == GL_COMPILE_STATUS)
    127     *value = 1;
    128 }
    129 
    130 blink::WebString FakeWebGraphicsContext3D::getShaderInfoLog(
    131     WebGLId shader) {
    132   return blink::WebString();
    133 }
    134 
    135 void FakeWebGraphicsContext3D::getShaderPrecisionFormat(
    136     blink::WGC3Denum shadertype,
    137     blink::WGC3Denum precisiontype,
    138     blink::WGC3Dint* range,
    139     blink::WGC3Dint* precision) {
    140   // Return the minimum precision requirements of the GLES specificatin.
    141   switch (precisiontype) {
    142     case GL_LOW_INT:
    143       range[0] = 8;
    144       range[1] = 8;
    145       *precision = 0;
    146       break;
    147     case GL_MEDIUM_INT:
    148       range[0] = 10;
    149       range[1] = 10;
    150       *precision = 0;
    151       break;
    152     case GL_HIGH_INT:
    153       range[0] = 16;
    154       range[1] = 16;
    155       *precision = 0;
    156       break;
    157     case GL_LOW_FLOAT:
    158       range[0] = 8;
    159       range[1] = 8;
    160       *precision = 8;
    161       break;
    162     case GL_MEDIUM_FLOAT:
    163       range[0] = 14;
    164       range[1] = 14;
    165       *precision = 10;
    166       break;
    167     case GL_HIGH_FLOAT:
    168       range[0] = 62;
    169       range[1] = 62;
    170       *precision = 16;
    171       break;
    172     default:
    173       NOTREACHED();
    174       break;
    175   }
    176 }
    177 
    178 blink::WebString FakeWebGraphicsContext3D::getShaderSource(
    179     WebGLId shader) {
    180   return blink::WebString();
    181 }
    182 
    183 blink::WebString FakeWebGraphicsContext3D::getString(WGC3Denum name) {
    184   return blink::WebString();
    185 }
    186 
    187 blink::WGC3Dint FakeWebGraphicsContext3D::getUniformLocation(
    188     WebGLId program,
    189     const blink::WGC3Dchar* name) {
    190   return 0;
    191 }
    192 
    193 blink::WGC3Dsizeiptr FakeWebGraphicsContext3D::getVertexAttribOffset(
    194     blink::WGC3Duint index,
    195     WGC3Denum pname) {
    196   return 0;
    197 }
    198 
    199 WGC3Dboolean FakeWebGraphicsContext3D::isBuffer(
    200     WebGLId buffer) {
    201   return false;
    202 }
    203 
    204 WGC3Dboolean FakeWebGraphicsContext3D::isEnabled(
    205     WGC3Denum cap) {
    206   return false;
    207 }
    208 
    209 WGC3Dboolean FakeWebGraphicsContext3D::isFramebuffer(
    210     WebGLId framebuffer) {
    211   return false;
    212 }
    213 
    214 WGC3Dboolean FakeWebGraphicsContext3D::isProgram(
    215     WebGLId program) {
    216   return false;
    217 }
    218 
    219 WGC3Dboolean FakeWebGraphicsContext3D::isRenderbuffer(
    220     WebGLId renderbuffer) {
    221   return false;
    222 }
    223 
    224 WGC3Dboolean FakeWebGraphicsContext3D::isShader(
    225     WebGLId shader) {
    226   return false;
    227 }
    228 
    229 WGC3Dboolean FakeWebGraphicsContext3D::isTexture(
    230     WebGLId texture) {
    231   return false;
    232 }
    233 
    234 void FakeWebGraphicsContext3D::genBuffers(WGC3Dsizei count, WebGLId* ids) {
    235   for (int i = 0; i < count; ++i)
    236     ids[i] = 1;
    237 }
    238 
    239 void FakeWebGraphicsContext3D::genFramebuffers(
    240     WGC3Dsizei count, WebGLId* ids) {
    241   for (int i = 0; i < count; ++i)
    242     ids[i] = 1;
    243 }
    244 
    245 void FakeWebGraphicsContext3D::genRenderbuffers(
    246     WGC3Dsizei count, WebGLId* ids) {
    247   for (int i = 0; i < count; ++i)
    248     ids[i] = 1;
    249 }
    250 
    251 void FakeWebGraphicsContext3D::genTextures(WGC3Dsizei count, WebGLId* ids) {
    252   for (int i = 0; i < count; ++i)
    253     ids[i] = 1;
    254 }
    255 
    256 void FakeWebGraphicsContext3D::deleteBuffers(WGC3Dsizei count, WebGLId* ids) {
    257 }
    258 
    259 void FakeWebGraphicsContext3D::deleteFramebuffers(
    260     WGC3Dsizei count, WebGLId* ids) {
    261 }
    262 
    263 void FakeWebGraphicsContext3D::deleteRenderbuffers(
    264     WGC3Dsizei count, WebGLId* ids) {
    265 }
    266 
    267 void FakeWebGraphicsContext3D::deleteTextures(WGC3Dsizei count, WebGLId* ids) {
    268 }
    269 
    270 WebGLId FakeWebGraphicsContext3D::createBuffer() {
    271   return 1;
    272 }
    273 
    274 WebGLId FakeWebGraphicsContext3D::createFramebuffer() {
    275   return 1;
    276 }
    277 
    278 WebGLId FakeWebGraphicsContext3D::createRenderbuffer() {
    279   return 1;
    280 }
    281 
    282 WebGLId FakeWebGraphicsContext3D::createTexture() {
    283   return 1;
    284 }
    285 
    286 void FakeWebGraphicsContext3D::deleteBuffer(blink::WebGLId id) {
    287 }
    288 
    289 void FakeWebGraphicsContext3D::deleteFramebuffer(blink::WebGLId id) {
    290 }
    291 
    292 void FakeWebGraphicsContext3D::deleteRenderbuffer(blink::WebGLId id) {
    293 }
    294 
    295 void FakeWebGraphicsContext3D::deleteTexture(WebGLId texture_id) {
    296 }
    297 
    298 WebGLId FakeWebGraphicsContext3D::createProgram() {
    299   return 1;
    300 }
    301 
    302 WebGLId FakeWebGraphicsContext3D::createShader(WGC3Denum) {
    303   return 1;
    304 }
    305 
    306 void FakeWebGraphicsContext3D::deleteProgram(blink::WebGLId id) {
    307 }
    308 
    309 void FakeWebGraphicsContext3D::deleteShader(blink::WebGLId id) {
    310 }
    311 
    312 void FakeWebGraphicsContext3D::attachShader(WebGLId program, WebGLId shader) {
    313 }
    314 
    315 void FakeWebGraphicsContext3D::useProgram(WebGLId program) {
    316 }
    317 
    318 void FakeWebGraphicsContext3D::bindBuffer(WGC3Denum target, WebGLId buffer) {
    319 }
    320 
    321 void FakeWebGraphicsContext3D::bindFramebuffer(
    322     WGC3Denum target, WebGLId framebuffer) {
    323 }
    324 
    325 void FakeWebGraphicsContext3D::bindRenderbuffer(
    326       WGC3Denum target, WebGLId renderbuffer) {
    327 }
    328 
    329 void FakeWebGraphicsContext3D::bindTexture(
    330     WGC3Denum target, WebGLId texture_id) {
    331 }
    332 
    333 WebGLId FakeWebGraphicsContext3D::createQueryEXT() {
    334   return 1;
    335 }
    336 
    337 WGC3Dboolean FakeWebGraphicsContext3D::isQueryEXT(WebGLId query) {
    338   return true;
    339 }
    340 
    341 void FakeWebGraphicsContext3D::endQueryEXT(blink::WGC3Denum target) {
    342 }
    343 
    344 void FakeWebGraphicsContext3D::getQueryObjectuivEXT(
    345     blink::WebGLId query,
    346     blink::WGC3Denum pname,
    347     blink::WGC3Duint* params) {
    348 }
    349 
    350 void FakeWebGraphicsContext3D::setContextLostCallback(
    351     WebGraphicsContextLostCallback* callback) {
    352 }
    353 
    354 void FakeWebGraphicsContext3D::loseContextCHROMIUM(WGC3Denum current,
    355                                                    WGC3Denum other) {
    356 }
    357 
    358 blink::WGC3Duint FakeWebGraphicsContext3D::createImageCHROMIUM(
    359      blink::WGC3Dsizei width, blink::WGC3Dsizei height,
    360      blink::WGC3Denum internalformat) {
    361   return 0;
    362 }
    363 
    364 void* FakeWebGraphicsContext3D::mapImageCHROMIUM(blink::WGC3Duint image_id,
    365                                                  blink::WGC3Denum access) {
    366   return 0;
    367 }
    368 
    369 }  // namespace cc
    370