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