Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / cc / test / fake_web_graphics_context_3d.cc
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 namespace cc {
11
12 FakeWebGraphicsContext3D::FakeWebGraphicsContext3D() {}
13
14 FakeWebGraphicsContext3D::~FakeWebGraphicsContext3D() {}
15
16 bool FakeWebGraphicsContext3D::makeContextCurrent() {
17   return true;
18 }
19
20 bool FakeWebGraphicsContext3D::isGLES2Compliant() {
21   return false;
22 }
23
24 GLuint FakeWebGraphicsContext3D::getPlatformTextureId() {
25   return 0;
26 }
27
28 bool FakeWebGraphicsContext3D::isContextLost() {
29   return false;
30 }
31
32 void* FakeWebGraphicsContext3D::mapBufferSubDataCHROMIUM(
33     GLenum target,
34     GLintptr offset,
35     GLsizeiptr size,
36     GLenum access) {
37   return 0;
38 }
39
40 void* FakeWebGraphicsContext3D::mapTexSubImage2DCHROMIUM(
41     GLenum target,
42     GLint level,
43     GLint xoffset,
44     GLint yoffset,
45     GLsizei width,
46     GLsizei height,
47     GLenum format,
48     GLenum type,
49     GLenum access) {
50   return 0;
51 }
52
53 GLenum FakeWebGraphicsContext3D::checkFramebufferStatus(
54     GLenum target) {
55   return GL_FRAMEBUFFER_COMPLETE;
56 }
57
58 GLint FakeWebGraphicsContext3D::getAttribLocation(
59     GLuint program,
60     const GLchar* name) {
61   return 0;
62 }
63
64 GLenum FakeWebGraphicsContext3D::getError() {
65   return GL_NO_ERROR;
66 }
67
68 void FakeWebGraphicsContext3D::getIntegerv(
69     GLenum pname,
70     GLint* value) {
71   if (pname == GL_MAX_TEXTURE_SIZE)
72     *value = 1024;
73   else if (pname == GL_ACTIVE_TEXTURE)
74     *value = GL_TEXTURE0;
75 }
76
77 void FakeWebGraphicsContext3D::getProgramiv(
78     GLuint program,
79     GLenum pname,
80     GLint* value) {
81   if (pname == GL_LINK_STATUS)
82     *value = 1;
83 }
84
85 void FakeWebGraphicsContext3D::getShaderiv(
86     GLuint shader,
87     GLenum pname,
88     GLint* value) {
89   if (pname == GL_COMPILE_STATUS)
90     *value = 1;
91 }
92
93 void FakeWebGraphicsContext3D::getShaderPrecisionFormat(
94     GLenum shadertype,
95     GLenum precisiontype,
96     GLint* range,
97     GLint* precision) {
98   // Return the minimum precision requirements of the GLES specificatin.
99   switch (precisiontype) {
100     case GL_LOW_INT:
101       range[0] = 8;
102       range[1] = 8;
103       *precision = 0;
104       break;
105     case GL_MEDIUM_INT:
106       range[0] = 10;
107       range[1] = 10;
108       *precision = 0;
109       break;
110     case GL_HIGH_INT:
111       range[0] = 16;
112       range[1] = 16;
113       *precision = 0;
114       break;
115     case GL_LOW_FLOAT:
116       range[0] = 8;
117       range[1] = 8;
118       *precision = 8;
119       break;
120     case GL_MEDIUM_FLOAT:
121       range[0] = 14;
122       range[1] = 14;
123       *precision = 10;
124       break;
125     case GL_HIGH_FLOAT:
126       range[0] = 62;
127       range[1] = 62;
128       *precision = 16;
129       break;
130     default:
131       NOTREACHED();
132       break;
133   }
134 }
135
136 GLint FakeWebGraphicsContext3D::getUniformLocation(
137     GLuint program,
138     const GLchar* name) {
139   return 0;
140 }
141
142 GLsizeiptr FakeWebGraphicsContext3D::getVertexAttribOffset(
143     GLuint index,
144     GLenum pname) {
145   return 0;
146 }
147
148 GLboolean FakeWebGraphicsContext3D::isBuffer(
149     GLuint buffer) {
150   return false;
151 }
152
153 GLboolean FakeWebGraphicsContext3D::isEnabled(
154     GLenum cap) {
155   return false;
156 }
157
158 GLboolean FakeWebGraphicsContext3D::isFramebuffer(
159     GLuint framebuffer) {
160   return false;
161 }
162
163 GLboolean FakeWebGraphicsContext3D::isProgram(
164     GLuint program) {
165   return false;
166 }
167
168 GLboolean FakeWebGraphicsContext3D::isRenderbuffer(
169     GLuint renderbuffer) {
170   return false;
171 }
172
173 GLboolean FakeWebGraphicsContext3D::isShader(
174     GLuint shader) {
175   return false;
176 }
177
178 GLboolean FakeWebGraphicsContext3D::isTexture(
179     GLuint texture) {
180   return false;
181 }
182
183 void FakeWebGraphicsContext3D::genBuffers(GLsizei count, GLuint* ids) {
184   for (int i = 0; i < count; ++i)
185     ids[i] = 1;
186 }
187
188 void FakeWebGraphicsContext3D::genFramebuffers(
189     GLsizei count, GLuint* ids) {
190   for (int i = 0; i < count; ++i)
191     ids[i] = 1;
192 }
193
194 void FakeWebGraphicsContext3D::genRenderbuffers(
195     GLsizei count, GLuint* ids) {
196   for (int i = 0; i < count; ++i)
197     ids[i] = 1;
198 }
199
200 void FakeWebGraphicsContext3D::genTextures(GLsizei count, GLuint* ids) {
201   for (int i = 0; i < count; ++i)
202     ids[i] = 1;
203 }
204
205 void FakeWebGraphicsContext3D::deleteBuffers(GLsizei count, GLuint* ids) {
206 }
207
208 void FakeWebGraphicsContext3D::deleteFramebuffers(
209     GLsizei count, GLuint* ids) {
210 }
211
212 void FakeWebGraphicsContext3D::deleteRenderbuffers(
213     GLsizei count, GLuint* ids) {
214 }
215
216 void FakeWebGraphicsContext3D::deleteTextures(GLsizei count, GLuint* ids) {
217 }
218
219 GLuint FakeWebGraphicsContext3D::createBuffer() {
220   return 1;
221 }
222
223 GLuint FakeWebGraphicsContext3D::createFramebuffer() {
224   return 1;
225 }
226
227 GLuint FakeWebGraphicsContext3D::createRenderbuffer() {
228   return 1;
229 }
230
231 GLuint FakeWebGraphicsContext3D::createTexture() {
232   return 1;
233 }
234
235 void FakeWebGraphicsContext3D::deleteBuffer(GLuint id) {
236 }
237
238 void FakeWebGraphicsContext3D::deleteFramebuffer(GLuint id) {
239 }
240
241 void FakeWebGraphicsContext3D::deleteRenderbuffer(GLuint id) {
242 }
243
244 void FakeWebGraphicsContext3D::deleteTexture(GLuint texture_id) {
245 }
246
247 GLuint FakeWebGraphicsContext3D::createProgram() {
248   return 1;
249 }
250
251 GLuint FakeWebGraphicsContext3D::createShader(GLenum) {
252   return 1;
253 }
254
255 void FakeWebGraphicsContext3D::deleteProgram(GLuint id) {
256 }
257
258 void FakeWebGraphicsContext3D::deleteShader(GLuint id) {
259 }
260
261 void FakeWebGraphicsContext3D::attachShader(GLuint program, GLuint shader) {
262 }
263
264 void FakeWebGraphicsContext3D::useProgram(GLuint program) {
265 }
266
267 void FakeWebGraphicsContext3D::bindBuffer(GLenum target, GLuint buffer) {
268 }
269
270 void FakeWebGraphicsContext3D::bindFramebuffer(
271     GLenum target, GLuint framebuffer) {
272 }
273
274 void FakeWebGraphicsContext3D::bindRenderbuffer(
275       GLenum target, GLuint renderbuffer) {
276 }
277
278 void FakeWebGraphicsContext3D::bindTexture(
279     GLenum target, GLuint texture_id) {
280 }
281
282 GLuint FakeWebGraphicsContext3D::createQueryEXT() {
283   return 1;
284 }
285
286 GLboolean FakeWebGraphicsContext3D::isQueryEXT(GLuint query) {
287   return true;
288 }
289
290 void FakeWebGraphicsContext3D::endQueryEXT(GLenum target) {
291 }
292
293 void FakeWebGraphicsContext3D::getQueryObjectuivEXT(
294     GLuint query,
295     GLenum pname,
296     GLuint* params) {
297 }
298
299 void FakeWebGraphicsContext3D::loseContextCHROMIUM(GLenum current,
300                                                    GLenum other) {
301 }
302
303 GLuint FakeWebGraphicsContext3D::createImageCHROMIUM(
304      GLsizei width, GLsizei height,
305      GLenum internalformat) {
306   return 0;
307 }
308
309 void* FakeWebGraphicsContext3D::mapImageCHROMIUM(GLuint image_id,
310                                                  GLenum access) {
311   return 0;
312 }
313
314 }  // namespace cc