1 // Generated Code - DO NOT EDIT !!
2 // generated by 'emugen'
3
4
5 #include <memory>
6 #include <string.h>
7 #include "gl2_opcodes.h"
8
9 #include "gl2_enc.h"
10
11
12 #include <stdio.h>
13
14 namespace {
15
enc_unsupported()16 void enc_unsupported()
17 {
18 ALOGE("Function is unsupported\n");
19 }
20
glActiveTexture_enc(void * self,GLenum texture)21 void glActiveTexture_enc(void *self , GLenum texture)
22 {
23
24 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
25 IOStream *stream = ctx->m_stream;
26 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
27 bool useChecksum = checksumCalculator->getVersion() > 0;
28
29 unsigned char *ptr;
30 unsigned char *buf;
31 const size_t sizeWithoutChecksum = 8 + 4;
32 const size_t checksumSize = checksumCalculator->checksumByteSize();
33 const size_t totalSize = sizeWithoutChecksum + checksumSize;
34 buf = stream->alloc(totalSize);
35 ptr = buf;
36 int tmp = OP_glActiveTexture;memcpy(ptr, &tmp, 4); ptr += 4;
37 memcpy(ptr, &totalSize, 4); ptr += 4;
38
39 memcpy(ptr, &texture, 4); ptr += 4;
40
41 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
42 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
43
44 }
45
glAttachShader_enc(void * self,GLuint program,GLuint shader)46 void glAttachShader_enc(void *self , GLuint program, GLuint shader)
47 {
48
49 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
50 IOStream *stream = ctx->m_stream;
51 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
52 bool useChecksum = checksumCalculator->getVersion() > 0;
53
54 unsigned char *ptr;
55 unsigned char *buf;
56 const size_t sizeWithoutChecksum = 8 + 4 + 4;
57 const size_t checksumSize = checksumCalculator->checksumByteSize();
58 const size_t totalSize = sizeWithoutChecksum + checksumSize;
59 buf = stream->alloc(totalSize);
60 ptr = buf;
61 int tmp = OP_glAttachShader;memcpy(ptr, &tmp, 4); ptr += 4;
62 memcpy(ptr, &totalSize, 4); ptr += 4;
63
64 memcpy(ptr, &program, 4); ptr += 4;
65 memcpy(ptr, &shader, 4); ptr += 4;
66
67 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
68 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
69
70 }
71
glBindAttribLocation_enc(void * self,GLuint program,GLuint index,const GLchar * name)72 void glBindAttribLocation_enc(void *self , GLuint program, GLuint index, const GLchar* name)
73 {
74
75 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
76 IOStream *stream = ctx->m_stream;
77 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
78 bool useChecksum = checksumCalculator->getVersion() > 0;
79
80 const unsigned int __size_name = (strlen(name) + 1);
81 unsigned char *ptr;
82 unsigned char *buf;
83 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_name + 1*4;
84 const size_t checksumSize = checksumCalculator->checksumByteSize();
85 const size_t totalSize = sizeWithoutChecksum + checksumSize;
86 buf = stream->alloc(totalSize);
87 ptr = buf;
88 int tmp = OP_glBindAttribLocation;memcpy(ptr, &tmp, 4); ptr += 4;
89 memcpy(ptr, &totalSize, 4); ptr += 4;
90
91 memcpy(ptr, &program, 4); ptr += 4;
92 memcpy(ptr, &index, 4); ptr += 4;
93 *(unsigned int *)(ptr) = __size_name; ptr += 4;
94 memcpy(ptr, name, __size_name);ptr += __size_name;
95
96 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
97 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
98
99 }
100
glBindBuffer_enc(void * self,GLenum target,GLuint buffer)101 void glBindBuffer_enc(void *self , GLenum target, GLuint buffer)
102 {
103
104 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
105 IOStream *stream = ctx->m_stream;
106 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
107 bool useChecksum = checksumCalculator->getVersion() > 0;
108
109 unsigned char *ptr;
110 unsigned char *buf;
111 const size_t sizeWithoutChecksum = 8 + 4 + 4;
112 const size_t checksumSize = checksumCalculator->checksumByteSize();
113 const size_t totalSize = sizeWithoutChecksum + checksumSize;
114 buf = stream->alloc(totalSize);
115 ptr = buf;
116 int tmp = OP_glBindBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
117 memcpy(ptr, &totalSize, 4); ptr += 4;
118
119 memcpy(ptr, &target, 4); ptr += 4;
120 memcpy(ptr, &buffer, 4); ptr += 4;
121
122 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
123 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
124
125 }
126
glBindFramebuffer_enc(void * self,GLenum target,GLuint framebuffer)127 void glBindFramebuffer_enc(void *self , GLenum target, GLuint framebuffer)
128 {
129
130 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
131 IOStream *stream = ctx->m_stream;
132 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
133 bool useChecksum = checksumCalculator->getVersion() > 0;
134
135 unsigned char *ptr;
136 unsigned char *buf;
137 const size_t sizeWithoutChecksum = 8 + 4 + 4;
138 const size_t checksumSize = checksumCalculator->checksumByteSize();
139 const size_t totalSize = sizeWithoutChecksum + checksumSize;
140 buf = stream->alloc(totalSize);
141 ptr = buf;
142 int tmp = OP_glBindFramebuffer;memcpy(ptr, &tmp, 4); ptr += 4;
143 memcpy(ptr, &totalSize, 4); ptr += 4;
144
145 memcpy(ptr, &target, 4); ptr += 4;
146 memcpy(ptr, &framebuffer, 4); ptr += 4;
147
148 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
149 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
150
151 }
152
glBindRenderbuffer_enc(void * self,GLenum target,GLuint renderbuffer)153 void glBindRenderbuffer_enc(void *self , GLenum target, GLuint renderbuffer)
154 {
155
156 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
157 IOStream *stream = ctx->m_stream;
158 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
159 bool useChecksum = checksumCalculator->getVersion() > 0;
160
161 unsigned char *ptr;
162 unsigned char *buf;
163 const size_t sizeWithoutChecksum = 8 + 4 + 4;
164 const size_t checksumSize = checksumCalculator->checksumByteSize();
165 const size_t totalSize = sizeWithoutChecksum + checksumSize;
166 buf = stream->alloc(totalSize);
167 ptr = buf;
168 int tmp = OP_glBindRenderbuffer;memcpy(ptr, &tmp, 4); ptr += 4;
169 memcpy(ptr, &totalSize, 4); ptr += 4;
170
171 memcpy(ptr, &target, 4); ptr += 4;
172 memcpy(ptr, &renderbuffer, 4); ptr += 4;
173
174 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
175 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
176
177 }
178
glBindTexture_enc(void * self,GLenum target,GLuint texture)179 void glBindTexture_enc(void *self , GLenum target, GLuint texture)
180 {
181
182 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
183 IOStream *stream = ctx->m_stream;
184 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
185 bool useChecksum = checksumCalculator->getVersion() > 0;
186
187 unsigned char *ptr;
188 unsigned char *buf;
189 const size_t sizeWithoutChecksum = 8 + 4 + 4;
190 const size_t checksumSize = checksumCalculator->checksumByteSize();
191 const size_t totalSize = sizeWithoutChecksum + checksumSize;
192 buf = stream->alloc(totalSize);
193 ptr = buf;
194 int tmp = OP_glBindTexture;memcpy(ptr, &tmp, 4); ptr += 4;
195 memcpy(ptr, &totalSize, 4); ptr += 4;
196
197 memcpy(ptr, &target, 4); ptr += 4;
198 memcpy(ptr, &texture, 4); ptr += 4;
199
200 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
201 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
202
203 }
204
glBlendColor_enc(void * self,GLclampf red,GLclampf green,GLclampf blue,GLclampf alpha)205 void glBlendColor_enc(void *self , GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
206 {
207
208 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
209 IOStream *stream = ctx->m_stream;
210 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
211 bool useChecksum = checksumCalculator->getVersion() > 0;
212
213 unsigned char *ptr;
214 unsigned char *buf;
215 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4;
216 const size_t checksumSize = checksumCalculator->checksumByteSize();
217 const size_t totalSize = sizeWithoutChecksum + checksumSize;
218 buf = stream->alloc(totalSize);
219 ptr = buf;
220 int tmp = OP_glBlendColor;memcpy(ptr, &tmp, 4); ptr += 4;
221 memcpy(ptr, &totalSize, 4); ptr += 4;
222
223 memcpy(ptr, &red, 4); ptr += 4;
224 memcpy(ptr, &green, 4); ptr += 4;
225 memcpy(ptr, &blue, 4); ptr += 4;
226 memcpy(ptr, &alpha, 4); ptr += 4;
227
228 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
229 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
230
231 }
232
glBlendEquation_enc(void * self,GLenum mode)233 void glBlendEquation_enc(void *self , GLenum mode)
234 {
235
236 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
237 IOStream *stream = ctx->m_stream;
238 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
239 bool useChecksum = checksumCalculator->getVersion() > 0;
240
241 unsigned char *ptr;
242 unsigned char *buf;
243 const size_t sizeWithoutChecksum = 8 + 4;
244 const size_t checksumSize = checksumCalculator->checksumByteSize();
245 const size_t totalSize = sizeWithoutChecksum + checksumSize;
246 buf = stream->alloc(totalSize);
247 ptr = buf;
248 int tmp = OP_glBlendEquation;memcpy(ptr, &tmp, 4); ptr += 4;
249 memcpy(ptr, &totalSize, 4); ptr += 4;
250
251 memcpy(ptr, &mode, 4); ptr += 4;
252
253 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
254 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
255
256 }
257
glBlendEquationSeparate_enc(void * self,GLenum modeRGB,GLenum modeAlpha)258 void glBlendEquationSeparate_enc(void *self , GLenum modeRGB, GLenum modeAlpha)
259 {
260
261 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
262 IOStream *stream = ctx->m_stream;
263 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
264 bool useChecksum = checksumCalculator->getVersion() > 0;
265
266 unsigned char *ptr;
267 unsigned char *buf;
268 const size_t sizeWithoutChecksum = 8 + 4 + 4;
269 const size_t checksumSize = checksumCalculator->checksumByteSize();
270 const size_t totalSize = sizeWithoutChecksum + checksumSize;
271 buf = stream->alloc(totalSize);
272 ptr = buf;
273 int tmp = OP_glBlendEquationSeparate;memcpy(ptr, &tmp, 4); ptr += 4;
274 memcpy(ptr, &totalSize, 4); ptr += 4;
275
276 memcpy(ptr, &modeRGB, 4); ptr += 4;
277 memcpy(ptr, &modeAlpha, 4); ptr += 4;
278
279 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
280 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
281
282 }
283
glBlendFunc_enc(void * self,GLenum sfactor,GLenum dfactor)284 void glBlendFunc_enc(void *self , GLenum sfactor, GLenum dfactor)
285 {
286
287 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
288 IOStream *stream = ctx->m_stream;
289 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
290 bool useChecksum = checksumCalculator->getVersion() > 0;
291
292 unsigned char *ptr;
293 unsigned char *buf;
294 const size_t sizeWithoutChecksum = 8 + 4 + 4;
295 const size_t checksumSize = checksumCalculator->checksumByteSize();
296 const size_t totalSize = sizeWithoutChecksum + checksumSize;
297 buf = stream->alloc(totalSize);
298 ptr = buf;
299 int tmp = OP_glBlendFunc;memcpy(ptr, &tmp, 4); ptr += 4;
300 memcpy(ptr, &totalSize, 4); ptr += 4;
301
302 memcpy(ptr, &sfactor, 4); ptr += 4;
303 memcpy(ptr, &dfactor, 4); ptr += 4;
304
305 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
306 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
307
308 }
309
glBlendFuncSeparate_enc(void * self,GLenum srcRGB,GLenum dstRGB,GLenum srcAlpha,GLenum dstAlpha)310 void glBlendFuncSeparate_enc(void *self , GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
311 {
312
313 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
314 IOStream *stream = ctx->m_stream;
315 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
316 bool useChecksum = checksumCalculator->getVersion() > 0;
317
318 unsigned char *ptr;
319 unsigned char *buf;
320 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4;
321 const size_t checksumSize = checksumCalculator->checksumByteSize();
322 const size_t totalSize = sizeWithoutChecksum + checksumSize;
323 buf = stream->alloc(totalSize);
324 ptr = buf;
325 int tmp = OP_glBlendFuncSeparate;memcpy(ptr, &tmp, 4); ptr += 4;
326 memcpy(ptr, &totalSize, 4); ptr += 4;
327
328 memcpy(ptr, &srcRGB, 4); ptr += 4;
329 memcpy(ptr, &dstRGB, 4); ptr += 4;
330 memcpy(ptr, &srcAlpha, 4); ptr += 4;
331 memcpy(ptr, &dstAlpha, 4); ptr += 4;
332
333 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
334 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
335
336 }
337
glBufferData_enc(void * self,GLenum target,GLsizeiptr size,const GLvoid * data,GLenum usage)338 void glBufferData_enc(void *self , GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
339 {
340
341 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
342 IOStream *stream = ctx->m_stream;
343 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
344 bool useChecksum = checksumCalculator->getVersion() > 0;
345
346 const unsigned int __size_data = ((data != NULL) ? size : 0);
347 unsigned char *ptr;
348 unsigned char *buf;
349 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_data + 4 + 1*4;
350 const size_t checksumSize = checksumCalculator->checksumByteSize();
351 const size_t totalSize = sizeWithoutChecksum + checksumSize;
352 buf = stream->alloc(8 + 4 + 4);
353 ptr = buf;
354 int tmp = OP_glBufferData;memcpy(ptr, &tmp, 4); ptr += 4;
355 memcpy(ptr, &totalSize, 4); ptr += 4;
356
357 memcpy(ptr, &target, 4); ptr += 4;
358 memcpy(ptr, &size, 4); ptr += 4;
359
360 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
361 stream->flush();
362 stream->writeFully(&__size_data,4);
363 if (useChecksum) checksumCalculator->addBuffer(&__size_data,4);
364 if (data != NULL) {
365 stream->writeFully(data, __size_data);
366 if (useChecksum) checksumCalculator->addBuffer(data, __size_data);
367 }
368 buf = stream->alloc(4);
369 ptr = buf;
370 memcpy(ptr, &usage, 4); ptr += 4;
371
372 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
373 buf = stream->alloc(checksumSize);
374 if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize);
375
376 }
377
glBufferSubData_enc(void * self,GLenum target,GLintptr offset,GLsizeiptr size,const GLvoid * data)378 void glBufferSubData_enc(void *self , GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
379 {
380
381 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
382 IOStream *stream = ctx->m_stream;
383 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
384 bool useChecksum = checksumCalculator->getVersion() > 0;
385
386 const unsigned int __size_data = ((data != NULL) ? size : 0);
387 unsigned char *ptr;
388 unsigned char *buf;
389 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + __size_data + 1*4;
390 const size_t checksumSize = checksumCalculator->checksumByteSize();
391 const size_t totalSize = sizeWithoutChecksum + checksumSize;
392 buf = stream->alloc(8 + 4 + 4 + 4);
393 ptr = buf;
394 int tmp = OP_glBufferSubData;memcpy(ptr, &tmp, 4); ptr += 4;
395 memcpy(ptr, &totalSize, 4); ptr += 4;
396
397 memcpy(ptr, &target, 4); ptr += 4;
398 memcpy(ptr, &offset, 4); ptr += 4;
399 memcpy(ptr, &size, 4); ptr += 4;
400
401 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
402 stream->flush();
403 stream->writeFully(&__size_data,4);
404 if (useChecksum) checksumCalculator->addBuffer(&__size_data,4);
405 if (data != NULL) {
406 stream->writeFully(data, __size_data);
407 if (useChecksum) checksumCalculator->addBuffer(data, __size_data);
408 }
409 buf = stream->alloc(checksumSize);
410 if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize);
411
412 }
413
glCheckFramebufferStatus_enc(void * self,GLenum target)414 GLenum glCheckFramebufferStatus_enc(void *self , GLenum target)
415 {
416
417 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
418 IOStream *stream = ctx->m_stream;
419 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
420 bool useChecksum = checksumCalculator->getVersion() > 0;
421
422 unsigned char *ptr;
423 unsigned char *buf;
424 const size_t sizeWithoutChecksum = 8 + 4;
425 const size_t checksumSize = checksumCalculator->checksumByteSize();
426 const size_t totalSize = sizeWithoutChecksum + checksumSize;
427 buf = stream->alloc(totalSize);
428 ptr = buf;
429 int tmp = OP_glCheckFramebufferStatus;memcpy(ptr, &tmp, 4); ptr += 4;
430 memcpy(ptr, &totalSize, 4); ptr += 4;
431
432 memcpy(ptr, &target, 4); ptr += 4;
433
434 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
435 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
436
437
438 GLenum retval;
439 stream->readback(&retval, 4);
440 if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
441 if (useChecksum) {
442 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
443 stream->readback(checksumBuf.get(), checksumSize);
444 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
445 ALOGE("glCheckFramebufferStatus: GL communication error, please report this issue to b.android.com.\n");
446 abort();
447 }
448 }
449 return retval;
450 }
451
glClear_enc(void * self,GLbitfield mask)452 void glClear_enc(void *self , GLbitfield mask)
453 {
454
455 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
456 IOStream *stream = ctx->m_stream;
457 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
458 bool useChecksum = checksumCalculator->getVersion() > 0;
459
460 unsigned char *ptr;
461 unsigned char *buf;
462 const size_t sizeWithoutChecksum = 8 + 4;
463 const size_t checksumSize = checksumCalculator->checksumByteSize();
464 const size_t totalSize = sizeWithoutChecksum + checksumSize;
465 buf = stream->alloc(totalSize);
466 ptr = buf;
467 int tmp = OP_glClear;memcpy(ptr, &tmp, 4); ptr += 4;
468 memcpy(ptr, &totalSize, 4); ptr += 4;
469
470 memcpy(ptr, &mask, 4); ptr += 4;
471
472 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
473 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
474
475 }
476
glClearColor_enc(void * self,GLclampf red,GLclampf green,GLclampf blue,GLclampf alpha)477 void glClearColor_enc(void *self , GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
478 {
479
480 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
481 IOStream *stream = ctx->m_stream;
482 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
483 bool useChecksum = checksumCalculator->getVersion() > 0;
484
485 unsigned char *ptr;
486 unsigned char *buf;
487 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4;
488 const size_t checksumSize = checksumCalculator->checksumByteSize();
489 const size_t totalSize = sizeWithoutChecksum + checksumSize;
490 buf = stream->alloc(totalSize);
491 ptr = buf;
492 int tmp = OP_glClearColor;memcpy(ptr, &tmp, 4); ptr += 4;
493 memcpy(ptr, &totalSize, 4); ptr += 4;
494
495 memcpy(ptr, &red, 4); ptr += 4;
496 memcpy(ptr, &green, 4); ptr += 4;
497 memcpy(ptr, &blue, 4); ptr += 4;
498 memcpy(ptr, &alpha, 4); ptr += 4;
499
500 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
501 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
502
503 }
504
glClearDepthf_enc(void * self,GLclampf depth)505 void glClearDepthf_enc(void *self , GLclampf depth)
506 {
507
508 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
509 IOStream *stream = ctx->m_stream;
510 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
511 bool useChecksum = checksumCalculator->getVersion() > 0;
512
513 unsigned char *ptr;
514 unsigned char *buf;
515 const size_t sizeWithoutChecksum = 8 + 4;
516 const size_t checksumSize = checksumCalculator->checksumByteSize();
517 const size_t totalSize = sizeWithoutChecksum + checksumSize;
518 buf = stream->alloc(totalSize);
519 ptr = buf;
520 int tmp = OP_glClearDepthf;memcpy(ptr, &tmp, 4); ptr += 4;
521 memcpy(ptr, &totalSize, 4); ptr += 4;
522
523 memcpy(ptr, &depth, 4); ptr += 4;
524
525 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
526 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
527
528 }
529
glClearStencil_enc(void * self,GLint s)530 void glClearStencil_enc(void *self , GLint s)
531 {
532
533 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
534 IOStream *stream = ctx->m_stream;
535 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
536 bool useChecksum = checksumCalculator->getVersion() > 0;
537
538 unsigned char *ptr;
539 unsigned char *buf;
540 const size_t sizeWithoutChecksum = 8 + 4;
541 const size_t checksumSize = checksumCalculator->checksumByteSize();
542 const size_t totalSize = sizeWithoutChecksum + checksumSize;
543 buf = stream->alloc(totalSize);
544 ptr = buf;
545 int tmp = OP_glClearStencil;memcpy(ptr, &tmp, 4); ptr += 4;
546 memcpy(ptr, &totalSize, 4); ptr += 4;
547
548 memcpy(ptr, &s, 4); ptr += 4;
549
550 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
551 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
552
553 }
554
glColorMask_enc(void * self,GLboolean red,GLboolean green,GLboolean blue,GLboolean alpha)555 void glColorMask_enc(void *self , GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
556 {
557
558 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
559 IOStream *stream = ctx->m_stream;
560 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
561 bool useChecksum = checksumCalculator->getVersion() > 0;
562
563 unsigned char *ptr;
564 unsigned char *buf;
565 const size_t sizeWithoutChecksum = 8 + 1 + 1 + 1 + 1;
566 const size_t checksumSize = checksumCalculator->checksumByteSize();
567 const size_t totalSize = sizeWithoutChecksum + checksumSize;
568 buf = stream->alloc(totalSize);
569 ptr = buf;
570 int tmp = OP_glColorMask;memcpy(ptr, &tmp, 4); ptr += 4;
571 memcpy(ptr, &totalSize, 4); ptr += 4;
572
573 memcpy(ptr, &red, 1); ptr += 1;
574 memcpy(ptr, &green, 1); ptr += 1;
575 memcpy(ptr, &blue, 1); ptr += 1;
576 memcpy(ptr, &alpha, 1); ptr += 1;
577
578 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
579 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
580
581 }
582
glCompileShader_enc(void * self,GLuint shader)583 void glCompileShader_enc(void *self , GLuint shader)
584 {
585
586 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
587 IOStream *stream = ctx->m_stream;
588 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
589 bool useChecksum = checksumCalculator->getVersion() > 0;
590
591 unsigned char *ptr;
592 unsigned char *buf;
593 const size_t sizeWithoutChecksum = 8 + 4;
594 const size_t checksumSize = checksumCalculator->checksumByteSize();
595 const size_t totalSize = sizeWithoutChecksum + checksumSize;
596 buf = stream->alloc(totalSize);
597 ptr = buf;
598 int tmp = OP_glCompileShader;memcpy(ptr, &tmp, 4); ptr += 4;
599 memcpy(ptr, &totalSize, 4); ptr += 4;
600
601 memcpy(ptr, &shader, 4); ptr += 4;
602
603 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
604 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
605
606 }
607
glCompressedTexImage2D_enc(void * self,GLenum target,GLint level,GLenum internalformat,GLsizei width,GLsizei height,GLint border,GLsizei imageSize,const GLvoid * data)608 void glCompressedTexImage2D_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data)
609 {
610
611 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
612 IOStream *stream = ctx->m_stream;
613 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
614 bool useChecksum = checksumCalculator->getVersion() > 0;
615
616 const unsigned int __size_data = ((data != NULL) ? imageSize : 0);
617 unsigned char *ptr;
618 unsigned char *buf;
619 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_data + 1*4;
620 const size_t checksumSize = checksumCalculator->checksumByteSize();
621 const size_t totalSize = sizeWithoutChecksum + checksumSize;
622 buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
623 ptr = buf;
624 int tmp = OP_glCompressedTexImage2D;memcpy(ptr, &tmp, 4); ptr += 4;
625 memcpy(ptr, &totalSize, 4); ptr += 4;
626
627 memcpy(ptr, &target, 4); ptr += 4;
628 memcpy(ptr, &level, 4); ptr += 4;
629 memcpy(ptr, &internalformat, 4); ptr += 4;
630 memcpy(ptr, &width, 4); ptr += 4;
631 memcpy(ptr, &height, 4); ptr += 4;
632 memcpy(ptr, &border, 4); ptr += 4;
633 memcpy(ptr, &imageSize, 4); ptr += 4;
634
635 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
636 stream->flush();
637 stream->writeFully(&__size_data,4);
638 if (useChecksum) checksumCalculator->addBuffer(&__size_data,4);
639 if (data != NULL) {
640 stream->writeFully(data, __size_data);
641 if (useChecksum) checksumCalculator->addBuffer(data, __size_data);
642 }
643 buf = stream->alloc(checksumSize);
644 if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize);
645
646 }
647
glCompressedTexSubImage2D_enc(void * self,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLsizei imageSize,const GLvoid * data)648 void glCompressedTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data)
649 {
650
651 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
652 IOStream *stream = ctx->m_stream;
653 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
654 bool useChecksum = checksumCalculator->getVersion() > 0;
655
656 const unsigned int __size_data = ((data != NULL) ? imageSize : 0);
657 unsigned char *ptr;
658 unsigned char *buf;
659 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_data + 1*4;
660 const size_t checksumSize = checksumCalculator->checksumByteSize();
661 const size_t totalSize = sizeWithoutChecksum + checksumSize;
662 buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
663 ptr = buf;
664 int tmp = OP_glCompressedTexSubImage2D;memcpy(ptr, &tmp, 4); ptr += 4;
665 memcpy(ptr, &totalSize, 4); ptr += 4;
666
667 memcpy(ptr, &target, 4); ptr += 4;
668 memcpy(ptr, &level, 4); ptr += 4;
669 memcpy(ptr, &xoffset, 4); ptr += 4;
670 memcpy(ptr, &yoffset, 4); ptr += 4;
671 memcpy(ptr, &width, 4); ptr += 4;
672 memcpy(ptr, &height, 4); ptr += 4;
673 memcpy(ptr, &format, 4); ptr += 4;
674 memcpy(ptr, &imageSize, 4); ptr += 4;
675
676 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
677 stream->flush();
678 stream->writeFully(&__size_data,4);
679 if (useChecksum) checksumCalculator->addBuffer(&__size_data,4);
680 if (data != NULL) {
681 stream->writeFully(data, __size_data);
682 if (useChecksum) checksumCalculator->addBuffer(data, __size_data);
683 }
684 buf = stream->alloc(checksumSize);
685 if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize);
686
687 }
688
glCopyTexImage2D_enc(void * self,GLenum target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLsizei height,GLint border)689 void glCopyTexImage2D_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
690 {
691
692 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
693 IOStream *stream = ctx->m_stream;
694 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
695 bool useChecksum = checksumCalculator->getVersion() > 0;
696
697 unsigned char *ptr;
698 unsigned char *buf;
699 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4;
700 const size_t checksumSize = checksumCalculator->checksumByteSize();
701 const size_t totalSize = sizeWithoutChecksum + checksumSize;
702 buf = stream->alloc(totalSize);
703 ptr = buf;
704 int tmp = OP_glCopyTexImage2D;memcpy(ptr, &tmp, 4); ptr += 4;
705 memcpy(ptr, &totalSize, 4); ptr += 4;
706
707 memcpy(ptr, &target, 4); ptr += 4;
708 memcpy(ptr, &level, 4); ptr += 4;
709 memcpy(ptr, &internalformat, 4); ptr += 4;
710 memcpy(ptr, &x, 4); ptr += 4;
711 memcpy(ptr, &y, 4); ptr += 4;
712 memcpy(ptr, &width, 4); ptr += 4;
713 memcpy(ptr, &height, 4); ptr += 4;
714 memcpy(ptr, &border, 4); ptr += 4;
715
716 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
717 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
718
719 }
720
glCopyTexSubImage2D_enc(void * self,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint x,GLint y,GLsizei width,GLsizei height)721 void glCopyTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
722 {
723
724 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
725 IOStream *stream = ctx->m_stream;
726 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
727 bool useChecksum = checksumCalculator->getVersion() > 0;
728
729 unsigned char *ptr;
730 unsigned char *buf;
731 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4;
732 const size_t checksumSize = checksumCalculator->checksumByteSize();
733 const size_t totalSize = sizeWithoutChecksum + checksumSize;
734 buf = stream->alloc(totalSize);
735 ptr = buf;
736 int tmp = OP_glCopyTexSubImage2D;memcpy(ptr, &tmp, 4); ptr += 4;
737 memcpy(ptr, &totalSize, 4); ptr += 4;
738
739 memcpy(ptr, &target, 4); ptr += 4;
740 memcpy(ptr, &level, 4); ptr += 4;
741 memcpy(ptr, &xoffset, 4); ptr += 4;
742 memcpy(ptr, &yoffset, 4); ptr += 4;
743 memcpy(ptr, &x, 4); ptr += 4;
744 memcpy(ptr, &y, 4); ptr += 4;
745 memcpy(ptr, &width, 4); ptr += 4;
746 memcpy(ptr, &height, 4); ptr += 4;
747
748 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
749 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
750
751 }
752
glCreateProgram_enc(void * self)753 GLuint glCreateProgram_enc(void *self )
754 {
755
756 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
757 IOStream *stream = ctx->m_stream;
758 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
759 bool useChecksum = checksumCalculator->getVersion() > 0;
760
761 unsigned char *ptr;
762 unsigned char *buf;
763 const size_t sizeWithoutChecksum = 8;
764 const size_t checksumSize = checksumCalculator->checksumByteSize();
765 const size_t totalSize = sizeWithoutChecksum + checksumSize;
766 buf = stream->alloc(totalSize);
767 ptr = buf;
768 int tmp = OP_glCreateProgram;memcpy(ptr, &tmp, 4); ptr += 4;
769 memcpy(ptr, &totalSize, 4); ptr += 4;
770
771
772 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
773 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
774
775
776 GLuint retval;
777 stream->readback(&retval, 4);
778 if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
779 if (useChecksum) {
780 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
781 stream->readback(checksumBuf.get(), checksumSize);
782 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
783 ALOGE("glCreateProgram: GL communication error, please report this issue to b.android.com.\n");
784 abort();
785 }
786 }
787 return retval;
788 }
789
glCreateShader_enc(void * self,GLenum type)790 GLuint glCreateShader_enc(void *self , GLenum type)
791 {
792
793 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
794 IOStream *stream = ctx->m_stream;
795 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
796 bool useChecksum = checksumCalculator->getVersion() > 0;
797
798 unsigned char *ptr;
799 unsigned char *buf;
800 const size_t sizeWithoutChecksum = 8 + 4;
801 const size_t checksumSize = checksumCalculator->checksumByteSize();
802 const size_t totalSize = sizeWithoutChecksum + checksumSize;
803 buf = stream->alloc(totalSize);
804 ptr = buf;
805 int tmp = OP_glCreateShader;memcpy(ptr, &tmp, 4); ptr += 4;
806 memcpy(ptr, &totalSize, 4); ptr += 4;
807
808 memcpy(ptr, &type, 4); ptr += 4;
809
810 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
811 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
812
813
814 GLuint retval;
815 stream->readback(&retval, 4);
816 if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
817 if (useChecksum) {
818 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
819 stream->readback(checksumBuf.get(), checksumSize);
820 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
821 ALOGE("glCreateShader: GL communication error, please report this issue to b.android.com.\n");
822 abort();
823 }
824 }
825 return retval;
826 }
827
glCullFace_enc(void * self,GLenum mode)828 void glCullFace_enc(void *self , GLenum mode)
829 {
830
831 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
832 IOStream *stream = ctx->m_stream;
833 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
834 bool useChecksum = checksumCalculator->getVersion() > 0;
835
836 unsigned char *ptr;
837 unsigned char *buf;
838 const size_t sizeWithoutChecksum = 8 + 4;
839 const size_t checksumSize = checksumCalculator->checksumByteSize();
840 const size_t totalSize = sizeWithoutChecksum + checksumSize;
841 buf = stream->alloc(totalSize);
842 ptr = buf;
843 int tmp = OP_glCullFace;memcpy(ptr, &tmp, 4); ptr += 4;
844 memcpy(ptr, &totalSize, 4); ptr += 4;
845
846 memcpy(ptr, &mode, 4); ptr += 4;
847
848 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
849 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
850
851 }
852
glDeleteBuffers_enc(void * self,GLsizei n,const GLuint * buffers)853 void glDeleteBuffers_enc(void *self , GLsizei n, const GLuint* buffers)
854 {
855
856 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
857 IOStream *stream = ctx->m_stream;
858 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
859 bool useChecksum = checksumCalculator->getVersion() > 0;
860
861 const unsigned int __size_buffers = (n * sizeof(GLuint));
862 unsigned char *ptr;
863 unsigned char *buf;
864 const size_t sizeWithoutChecksum = 8 + 4 + __size_buffers + 1*4;
865 const size_t checksumSize = checksumCalculator->checksumByteSize();
866 const size_t totalSize = sizeWithoutChecksum + checksumSize;
867 buf = stream->alloc(totalSize);
868 ptr = buf;
869 int tmp = OP_glDeleteBuffers;memcpy(ptr, &tmp, 4); ptr += 4;
870 memcpy(ptr, &totalSize, 4); ptr += 4;
871
872 memcpy(ptr, &n, 4); ptr += 4;
873 *(unsigned int *)(ptr) = __size_buffers; ptr += 4;
874 memcpy(ptr, buffers, __size_buffers);ptr += __size_buffers;
875
876 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
877 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
878
879 }
880
glDeleteFramebuffers_enc(void * self,GLsizei n,const GLuint * framebuffers)881 void glDeleteFramebuffers_enc(void *self , GLsizei n, const GLuint* framebuffers)
882 {
883
884 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
885 IOStream *stream = ctx->m_stream;
886 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
887 bool useChecksum = checksumCalculator->getVersion() > 0;
888
889 const unsigned int __size_framebuffers = (n * sizeof(GLuint));
890 unsigned char *ptr;
891 unsigned char *buf;
892 const size_t sizeWithoutChecksum = 8 + 4 + __size_framebuffers + 1*4;
893 const size_t checksumSize = checksumCalculator->checksumByteSize();
894 const size_t totalSize = sizeWithoutChecksum + checksumSize;
895 buf = stream->alloc(totalSize);
896 ptr = buf;
897 int tmp = OP_glDeleteFramebuffers;memcpy(ptr, &tmp, 4); ptr += 4;
898 memcpy(ptr, &totalSize, 4); ptr += 4;
899
900 memcpy(ptr, &n, 4); ptr += 4;
901 *(unsigned int *)(ptr) = __size_framebuffers; ptr += 4;
902 memcpy(ptr, framebuffers, __size_framebuffers);ptr += __size_framebuffers;
903
904 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
905 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
906
907 }
908
glDeleteProgram_enc(void * self,GLuint program)909 void glDeleteProgram_enc(void *self , GLuint program)
910 {
911
912 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
913 IOStream *stream = ctx->m_stream;
914 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
915 bool useChecksum = checksumCalculator->getVersion() > 0;
916
917 unsigned char *ptr;
918 unsigned char *buf;
919 const size_t sizeWithoutChecksum = 8 + 4;
920 const size_t checksumSize = checksumCalculator->checksumByteSize();
921 const size_t totalSize = sizeWithoutChecksum + checksumSize;
922 buf = stream->alloc(totalSize);
923 ptr = buf;
924 int tmp = OP_glDeleteProgram;memcpy(ptr, &tmp, 4); ptr += 4;
925 memcpy(ptr, &totalSize, 4); ptr += 4;
926
927 memcpy(ptr, &program, 4); ptr += 4;
928
929 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
930 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
931
932 }
933
glDeleteRenderbuffers_enc(void * self,GLsizei n,const GLuint * renderbuffers)934 void glDeleteRenderbuffers_enc(void *self , GLsizei n, const GLuint* renderbuffers)
935 {
936
937 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
938 IOStream *stream = ctx->m_stream;
939 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
940 bool useChecksum = checksumCalculator->getVersion() > 0;
941
942 const unsigned int __size_renderbuffers = (n * sizeof(GLuint));
943 unsigned char *ptr;
944 unsigned char *buf;
945 const size_t sizeWithoutChecksum = 8 + 4 + __size_renderbuffers + 1*4;
946 const size_t checksumSize = checksumCalculator->checksumByteSize();
947 const size_t totalSize = sizeWithoutChecksum + checksumSize;
948 buf = stream->alloc(totalSize);
949 ptr = buf;
950 int tmp = OP_glDeleteRenderbuffers;memcpy(ptr, &tmp, 4); ptr += 4;
951 memcpy(ptr, &totalSize, 4); ptr += 4;
952
953 memcpy(ptr, &n, 4); ptr += 4;
954 *(unsigned int *)(ptr) = __size_renderbuffers; ptr += 4;
955 memcpy(ptr, renderbuffers, __size_renderbuffers);ptr += __size_renderbuffers;
956
957 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
958 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
959
960 }
961
glDeleteShader_enc(void * self,GLuint shader)962 void glDeleteShader_enc(void *self , GLuint shader)
963 {
964
965 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
966 IOStream *stream = ctx->m_stream;
967 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
968 bool useChecksum = checksumCalculator->getVersion() > 0;
969
970 unsigned char *ptr;
971 unsigned char *buf;
972 const size_t sizeWithoutChecksum = 8 + 4;
973 const size_t checksumSize = checksumCalculator->checksumByteSize();
974 const size_t totalSize = sizeWithoutChecksum + checksumSize;
975 buf = stream->alloc(totalSize);
976 ptr = buf;
977 int tmp = OP_glDeleteShader;memcpy(ptr, &tmp, 4); ptr += 4;
978 memcpy(ptr, &totalSize, 4); ptr += 4;
979
980 memcpy(ptr, &shader, 4); ptr += 4;
981
982 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
983 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
984
985 }
986
glDeleteTextures_enc(void * self,GLsizei n,const GLuint * textures)987 void glDeleteTextures_enc(void *self , GLsizei n, const GLuint* textures)
988 {
989
990 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
991 IOStream *stream = ctx->m_stream;
992 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
993 bool useChecksum = checksumCalculator->getVersion() > 0;
994
995 const unsigned int __size_textures = (n * sizeof(GLuint));
996 unsigned char *ptr;
997 unsigned char *buf;
998 const size_t sizeWithoutChecksum = 8 + 4 + __size_textures + 1*4;
999 const size_t checksumSize = checksumCalculator->checksumByteSize();
1000 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1001 buf = stream->alloc(totalSize);
1002 ptr = buf;
1003 int tmp = OP_glDeleteTextures;memcpy(ptr, &tmp, 4); ptr += 4;
1004 memcpy(ptr, &totalSize, 4); ptr += 4;
1005
1006 memcpy(ptr, &n, 4); ptr += 4;
1007 *(unsigned int *)(ptr) = __size_textures; ptr += 4;
1008 memcpy(ptr, textures, __size_textures);ptr += __size_textures;
1009
1010 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1011 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1012
1013 }
1014
glDepthFunc_enc(void * self,GLenum func)1015 void glDepthFunc_enc(void *self , GLenum func)
1016 {
1017
1018 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1019 IOStream *stream = ctx->m_stream;
1020 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1021 bool useChecksum = checksumCalculator->getVersion() > 0;
1022
1023 unsigned char *ptr;
1024 unsigned char *buf;
1025 const size_t sizeWithoutChecksum = 8 + 4;
1026 const size_t checksumSize = checksumCalculator->checksumByteSize();
1027 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1028 buf = stream->alloc(totalSize);
1029 ptr = buf;
1030 int tmp = OP_glDepthFunc;memcpy(ptr, &tmp, 4); ptr += 4;
1031 memcpy(ptr, &totalSize, 4); ptr += 4;
1032
1033 memcpy(ptr, &func, 4); ptr += 4;
1034
1035 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1036 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1037
1038 }
1039
glDepthMask_enc(void * self,GLboolean flag)1040 void glDepthMask_enc(void *self , GLboolean flag)
1041 {
1042
1043 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1044 IOStream *stream = ctx->m_stream;
1045 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1046 bool useChecksum = checksumCalculator->getVersion() > 0;
1047
1048 unsigned char *ptr;
1049 unsigned char *buf;
1050 const size_t sizeWithoutChecksum = 8 + 1;
1051 const size_t checksumSize = checksumCalculator->checksumByteSize();
1052 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1053 buf = stream->alloc(totalSize);
1054 ptr = buf;
1055 int tmp = OP_glDepthMask;memcpy(ptr, &tmp, 4); ptr += 4;
1056 memcpy(ptr, &totalSize, 4); ptr += 4;
1057
1058 memcpy(ptr, &flag, 1); ptr += 1;
1059
1060 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1061 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1062
1063 }
1064
glDepthRangef_enc(void * self,GLclampf zNear,GLclampf zFar)1065 void glDepthRangef_enc(void *self , GLclampf zNear, GLclampf zFar)
1066 {
1067
1068 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1069 IOStream *stream = ctx->m_stream;
1070 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1071 bool useChecksum = checksumCalculator->getVersion() > 0;
1072
1073 unsigned char *ptr;
1074 unsigned char *buf;
1075 const size_t sizeWithoutChecksum = 8 + 4 + 4;
1076 const size_t checksumSize = checksumCalculator->checksumByteSize();
1077 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1078 buf = stream->alloc(totalSize);
1079 ptr = buf;
1080 int tmp = OP_glDepthRangef;memcpy(ptr, &tmp, 4); ptr += 4;
1081 memcpy(ptr, &totalSize, 4); ptr += 4;
1082
1083 memcpy(ptr, &zNear, 4); ptr += 4;
1084 memcpy(ptr, &zFar, 4); ptr += 4;
1085
1086 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1087 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1088
1089 }
1090
glDetachShader_enc(void * self,GLuint program,GLuint shader)1091 void glDetachShader_enc(void *self , GLuint program, GLuint shader)
1092 {
1093
1094 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1095 IOStream *stream = ctx->m_stream;
1096 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1097 bool useChecksum = checksumCalculator->getVersion() > 0;
1098
1099 unsigned char *ptr;
1100 unsigned char *buf;
1101 const size_t sizeWithoutChecksum = 8 + 4 + 4;
1102 const size_t checksumSize = checksumCalculator->checksumByteSize();
1103 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1104 buf = stream->alloc(totalSize);
1105 ptr = buf;
1106 int tmp = OP_glDetachShader;memcpy(ptr, &tmp, 4); ptr += 4;
1107 memcpy(ptr, &totalSize, 4); ptr += 4;
1108
1109 memcpy(ptr, &program, 4); ptr += 4;
1110 memcpy(ptr, &shader, 4); ptr += 4;
1111
1112 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1113 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1114
1115 }
1116
glDisable_enc(void * self,GLenum cap)1117 void glDisable_enc(void *self , GLenum cap)
1118 {
1119
1120 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1121 IOStream *stream = ctx->m_stream;
1122 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1123 bool useChecksum = checksumCalculator->getVersion() > 0;
1124
1125 unsigned char *ptr;
1126 unsigned char *buf;
1127 const size_t sizeWithoutChecksum = 8 + 4;
1128 const size_t checksumSize = checksumCalculator->checksumByteSize();
1129 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1130 buf = stream->alloc(totalSize);
1131 ptr = buf;
1132 int tmp = OP_glDisable;memcpy(ptr, &tmp, 4); ptr += 4;
1133 memcpy(ptr, &totalSize, 4); ptr += 4;
1134
1135 memcpy(ptr, &cap, 4); ptr += 4;
1136
1137 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1138 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1139
1140 }
1141
glDisableVertexAttribArray_enc(void * self,GLuint index)1142 void glDisableVertexAttribArray_enc(void *self , GLuint index)
1143 {
1144
1145 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1146 IOStream *stream = ctx->m_stream;
1147 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1148 bool useChecksum = checksumCalculator->getVersion() > 0;
1149
1150 unsigned char *ptr;
1151 unsigned char *buf;
1152 const size_t sizeWithoutChecksum = 8 + 4;
1153 const size_t checksumSize = checksumCalculator->checksumByteSize();
1154 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1155 buf = stream->alloc(totalSize);
1156 ptr = buf;
1157 int tmp = OP_glDisableVertexAttribArray;memcpy(ptr, &tmp, 4); ptr += 4;
1158 memcpy(ptr, &totalSize, 4); ptr += 4;
1159
1160 memcpy(ptr, &index, 4); ptr += 4;
1161
1162 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1163 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1164
1165 }
1166
glDrawArrays_enc(void * self,GLenum mode,GLint first,GLsizei count)1167 void glDrawArrays_enc(void *self , GLenum mode, GLint first, GLsizei count)
1168 {
1169
1170 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1171 IOStream *stream = ctx->m_stream;
1172 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1173 bool useChecksum = checksumCalculator->getVersion() > 0;
1174
1175 unsigned char *ptr;
1176 unsigned char *buf;
1177 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4;
1178 const size_t checksumSize = checksumCalculator->checksumByteSize();
1179 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1180 buf = stream->alloc(totalSize);
1181 ptr = buf;
1182 int tmp = OP_glDrawArrays;memcpy(ptr, &tmp, 4); ptr += 4;
1183 memcpy(ptr, &totalSize, 4); ptr += 4;
1184
1185 memcpy(ptr, &mode, 4); ptr += 4;
1186 memcpy(ptr, &first, 4); ptr += 4;
1187 memcpy(ptr, &count, 4); ptr += 4;
1188
1189 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1190 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1191
1192 }
1193
glEnable_enc(void * self,GLenum cap)1194 void glEnable_enc(void *self , GLenum cap)
1195 {
1196
1197 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1198 IOStream *stream = ctx->m_stream;
1199 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1200 bool useChecksum = checksumCalculator->getVersion() > 0;
1201
1202 unsigned char *ptr;
1203 unsigned char *buf;
1204 const size_t sizeWithoutChecksum = 8 + 4;
1205 const size_t checksumSize = checksumCalculator->checksumByteSize();
1206 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1207 buf = stream->alloc(totalSize);
1208 ptr = buf;
1209 int tmp = OP_glEnable;memcpy(ptr, &tmp, 4); ptr += 4;
1210 memcpy(ptr, &totalSize, 4); ptr += 4;
1211
1212 memcpy(ptr, &cap, 4); ptr += 4;
1213
1214 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1215 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1216
1217 }
1218
glEnableVertexAttribArray_enc(void * self,GLuint index)1219 void glEnableVertexAttribArray_enc(void *self , GLuint index)
1220 {
1221
1222 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1223 IOStream *stream = ctx->m_stream;
1224 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1225 bool useChecksum = checksumCalculator->getVersion() > 0;
1226
1227 unsigned char *ptr;
1228 unsigned char *buf;
1229 const size_t sizeWithoutChecksum = 8 + 4;
1230 const size_t checksumSize = checksumCalculator->checksumByteSize();
1231 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1232 buf = stream->alloc(totalSize);
1233 ptr = buf;
1234 int tmp = OP_glEnableVertexAttribArray;memcpy(ptr, &tmp, 4); ptr += 4;
1235 memcpy(ptr, &totalSize, 4); ptr += 4;
1236
1237 memcpy(ptr, &index, 4); ptr += 4;
1238
1239 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1240 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1241
1242 }
1243
glFinish_enc(void * self)1244 void glFinish_enc(void *self )
1245 {
1246
1247 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1248 IOStream *stream = ctx->m_stream;
1249 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1250 bool useChecksum = checksumCalculator->getVersion() > 0;
1251
1252 unsigned char *ptr;
1253 unsigned char *buf;
1254 const size_t sizeWithoutChecksum = 8;
1255 const size_t checksumSize = checksumCalculator->checksumByteSize();
1256 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1257 buf = stream->alloc(totalSize);
1258 ptr = buf;
1259 int tmp = OP_glFinish;memcpy(ptr, &tmp, 4); ptr += 4;
1260 memcpy(ptr, &totalSize, 4); ptr += 4;
1261
1262
1263 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1264 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1265
1266 }
1267
glFlush_enc(void * self)1268 void glFlush_enc(void *self )
1269 {
1270
1271 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1272 IOStream *stream = ctx->m_stream;
1273 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1274 bool useChecksum = checksumCalculator->getVersion() > 0;
1275
1276 unsigned char *ptr;
1277 unsigned char *buf;
1278 const size_t sizeWithoutChecksum = 8;
1279 const size_t checksumSize = checksumCalculator->checksumByteSize();
1280 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1281 buf = stream->alloc(totalSize);
1282 ptr = buf;
1283 int tmp = OP_glFlush;memcpy(ptr, &tmp, 4); ptr += 4;
1284 memcpy(ptr, &totalSize, 4); ptr += 4;
1285
1286
1287 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1288 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1289
1290 }
1291
glFramebufferRenderbuffer_enc(void * self,GLenum target,GLenum attachment,GLenum renderbuffertarget,GLuint renderbuffer)1292 void glFramebufferRenderbuffer_enc(void *self , GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
1293 {
1294
1295 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1296 IOStream *stream = ctx->m_stream;
1297 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1298 bool useChecksum = checksumCalculator->getVersion() > 0;
1299
1300 unsigned char *ptr;
1301 unsigned char *buf;
1302 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4;
1303 const size_t checksumSize = checksumCalculator->checksumByteSize();
1304 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1305 buf = stream->alloc(totalSize);
1306 ptr = buf;
1307 int tmp = OP_glFramebufferRenderbuffer;memcpy(ptr, &tmp, 4); ptr += 4;
1308 memcpy(ptr, &totalSize, 4); ptr += 4;
1309
1310 memcpy(ptr, &target, 4); ptr += 4;
1311 memcpy(ptr, &attachment, 4); ptr += 4;
1312 memcpy(ptr, &renderbuffertarget, 4); ptr += 4;
1313 memcpy(ptr, &renderbuffer, 4); ptr += 4;
1314
1315 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1316 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1317
1318 }
1319
glFramebufferTexture2D_enc(void * self,GLenum target,GLenum attachment,GLenum textarget,GLuint texture,GLint level)1320 void glFramebufferTexture2D_enc(void *self , GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
1321 {
1322
1323 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1324 IOStream *stream = ctx->m_stream;
1325 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1326 bool useChecksum = checksumCalculator->getVersion() > 0;
1327
1328 unsigned char *ptr;
1329 unsigned char *buf;
1330 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4;
1331 const size_t checksumSize = checksumCalculator->checksumByteSize();
1332 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1333 buf = stream->alloc(totalSize);
1334 ptr = buf;
1335 int tmp = OP_glFramebufferTexture2D;memcpy(ptr, &tmp, 4); ptr += 4;
1336 memcpy(ptr, &totalSize, 4); ptr += 4;
1337
1338 memcpy(ptr, &target, 4); ptr += 4;
1339 memcpy(ptr, &attachment, 4); ptr += 4;
1340 memcpy(ptr, &textarget, 4); ptr += 4;
1341 memcpy(ptr, &texture, 4); ptr += 4;
1342 memcpy(ptr, &level, 4); ptr += 4;
1343
1344 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1345 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1346
1347 }
1348
glFrontFace_enc(void * self,GLenum mode)1349 void glFrontFace_enc(void *self , GLenum mode)
1350 {
1351
1352 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1353 IOStream *stream = ctx->m_stream;
1354 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1355 bool useChecksum = checksumCalculator->getVersion() > 0;
1356
1357 unsigned char *ptr;
1358 unsigned char *buf;
1359 const size_t sizeWithoutChecksum = 8 + 4;
1360 const size_t checksumSize = checksumCalculator->checksumByteSize();
1361 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1362 buf = stream->alloc(totalSize);
1363 ptr = buf;
1364 int tmp = OP_glFrontFace;memcpy(ptr, &tmp, 4); ptr += 4;
1365 memcpy(ptr, &totalSize, 4); ptr += 4;
1366
1367 memcpy(ptr, &mode, 4); ptr += 4;
1368
1369 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1370 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1371
1372 }
1373
glGenBuffers_enc(void * self,GLsizei n,GLuint * buffers)1374 void glGenBuffers_enc(void *self , GLsizei n, GLuint* buffers)
1375 {
1376
1377 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1378 IOStream *stream = ctx->m_stream;
1379 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1380 bool useChecksum = checksumCalculator->getVersion() > 0;
1381
1382 const unsigned int __size_buffers = (n * sizeof(GLuint));
1383 unsigned char *ptr;
1384 unsigned char *buf;
1385 const size_t sizeWithoutChecksum = 8 + 4 + __size_buffers + 1*4;
1386 const size_t checksumSize = checksumCalculator->checksumByteSize();
1387 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1388 buf = stream->alloc(totalSize);
1389 ptr = buf;
1390 int tmp = OP_glGenBuffers;memcpy(ptr, &tmp, 4); ptr += 4;
1391 memcpy(ptr, &totalSize, 4); ptr += 4;
1392
1393 memcpy(ptr, &n, 4); ptr += 4;
1394 *(unsigned int *)(ptr) = __size_buffers; ptr += 4;
1395
1396 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1397 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1398
1399 stream->readback(buffers, __size_buffers);
1400 if (useChecksum) checksumCalculator->addBuffer(buffers, __size_buffers);
1401 if (useChecksum) {
1402 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
1403 stream->readback(checksumBuf.get(), checksumSize);
1404 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
1405 ALOGE("glGenBuffers: GL communication error, please report this issue to b.android.com.\n");
1406 abort();
1407 }
1408 }
1409 }
1410
glGenerateMipmap_enc(void * self,GLenum target)1411 void glGenerateMipmap_enc(void *self , GLenum target)
1412 {
1413
1414 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1415 IOStream *stream = ctx->m_stream;
1416 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1417 bool useChecksum = checksumCalculator->getVersion() > 0;
1418
1419 unsigned char *ptr;
1420 unsigned char *buf;
1421 const size_t sizeWithoutChecksum = 8 + 4;
1422 const size_t checksumSize = checksumCalculator->checksumByteSize();
1423 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1424 buf = stream->alloc(totalSize);
1425 ptr = buf;
1426 int tmp = OP_glGenerateMipmap;memcpy(ptr, &tmp, 4); ptr += 4;
1427 memcpy(ptr, &totalSize, 4); ptr += 4;
1428
1429 memcpy(ptr, &target, 4); ptr += 4;
1430
1431 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1432 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1433
1434 }
1435
glGenFramebuffers_enc(void * self,GLsizei n,GLuint * framebuffers)1436 void glGenFramebuffers_enc(void *self , GLsizei n, GLuint* framebuffers)
1437 {
1438
1439 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1440 IOStream *stream = ctx->m_stream;
1441 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1442 bool useChecksum = checksumCalculator->getVersion() > 0;
1443
1444 const unsigned int __size_framebuffers = (n * sizeof(GLuint));
1445 unsigned char *ptr;
1446 unsigned char *buf;
1447 const size_t sizeWithoutChecksum = 8 + 4 + __size_framebuffers + 1*4;
1448 const size_t checksumSize = checksumCalculator->checksumByteSize();
1449 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1450 buf = stream->alloc(totalSize);
1451 ptr = buf;
1452 int tmp = OP_glGenFramebuffers;memcpy(ptr, &tmp, 4); ptr += 4;
1453 memcpy(ptr, &totalSize, 4); ptr += 4;
1454
1455 memcpy(ptr, &n, 4); ptr += 4;
1456 *(unsigned int *)(ptr) = __size_framebuffers; ptr += 4;
1457
1458 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1459 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1460
1461 stream->readback(framebuffers, __size_framebuffers);
1462 if (useChecksum) checksumCalculator->addBuffer(framebuffers, __size_framebuffers);
1463 if (useChecksum) {
1464 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
1465 stream->readback(checksumBuf.get(), checksumSize);
1466 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
1467 ALOGE("glGenFramebuffers: GL communication error, please report this issue to b.android.com.\n");
1468 abort();
1469 }
1470 }
1471 }
1472
glGenRenderbuffers_enc(void * self,GLsizei n,GLuint * renderbuffers)1473 void glGenRenderbuffers_enc(void *self , GLsizei n, GLuint* renderbuffers)
1474 {
1475
1476 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1477 IOStream *stream = ctx->m_stream;
1478 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1479 bool useChecksum = checksumCalculator->getVersion() > 0;
1480
1481 const unsigned int __size_renderbuffers = (n * sizeof(GLuint));
1482 unsigned char *ptr;
1483 unsigned char *buf;
1484 const size_t sizeWithoutChecksum = 8 + 4 + __size_renderbuffers + 1*4;
1485 const size_t checksumSize = checksumCalculator->checksumByteSize();
1486 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1487 buf = stream->alloc(totalSize);
1488 ptr = buf;
1489 int tmp = OP_glGenRenderbuffers;memcpy(ptr, &tmp, 4); ptr += 4;
1490 memcpy(ptr, &totalSize, 4); ptr += 4;
1491
1492 memcpy(ptr, &n, 4); ptr += 4;
1493 *(unsigned int *)(ptr) = __size_renderbuffers; ptr += 4;
1494
1495 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1496 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1497
1498 stream->readback(renderbuffers, __size_renderbuffers);
1499 if (useChecksum) checksumCalculator->addBuffer(renderbuffers, __size_renderbuffers);
1500 if (useChecksum) {
1501 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
1502 stream->readback(checksumBuf.get(), checksumSize);
1503 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
1504 ALOGE("glGenRenderbuffers: GL communication error, please report this issue to b.android.com.\n");
1505 abort();
1506 }
1507 }
1508 }
1509
glGenTextures_enc(void * self,GLsizei n,GLuint * textures)1510 void glGenTextures_enc(void *self , GLsizei n, GLuint* textures)
1511 {
1512
1513 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1514 IOStream *stream = ctx->m_stream;
1515 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1516 bool useChecksum = checksumCalculator->getVersion() > 0;
1517
1518 const unsigned int __size_textures = (n * sizeof(GLuint));
1519 unsigned char *ptr;
1520 unsigned char *buf;
1521 const size_t sizeWithoutChecksum = 8 + 4 + __size_textures + 1*4;
1522 const size_t checksumSize = checksumCalculator->checksumByteSize();
1523 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1524 buf = stream->alloc(totalSize);
1525 ptr = buf;
1526 int tmp = OP_glGenTextures;memcpy(ptr, &tmp, 4); ptr += 4;
1527 memcpy(ptr, &totalSize, 4); ptr += 4;
1528
1529 memcpy(ptr, &n, 4); ptr += 4;
1530 *(unsigned int *)(ptr) = __size_textures; ptr += 4;
1531
1532 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1533 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1534
1535 stream->readback(textures, __size_textures);
1536 if (useChecksum) checksumCalculator->addBuffer(textures, __size_textures);
1537 if (useChecksum) {
1538 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
1539 stream->readback(checksumBuf.get(), checksumSize);
1540 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
1541 ALOGE("glGenTextures: GL communication error, please report this issue to b.android.com.\n");
1542 abort();
1543 }
1544 }
1545 }
1546
glGetActiveAttrib_enc(void * self,GLuint program,GLuint index,GLsizei bufsize,GLsizei * length,GLint * size,GLenum * type,GLchar * name)1547 void glGetActiveAttrib_enc(void *self , GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
1548 {
1549
1550 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1551 IOStream *stream = ctx->m_stream;
1552 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1553 bool useChecksum = checksumCalculator->getVersion() > 0;
1554
1555 const unsigned int __size_length = ((length != NULL) ? (sizeof(GLsizei)) : 0);
1556 const unsigned int __size_size = ((size != NULL) ? (sizeof(GLint)) : 0);
1557 const unsigned int __size_type = ((type != NULL) ? (sizeof(GLenum)) : 0);
1558 const unsigned int __size_name = ((name != NULL) ? bufsize : 0);
1559 unsigned char *ptr;
1560 unsigned char *buf;
1561 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + __size_length + __size_size + __size_type + __size_name + 4*4;
1562 const size_t checksumSize = checksumCalculator->checksumByteSize();
1563 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1564 buf = stream->alloc(totalSize);
1565 ptr = buf;
1566 int tmp = OP_glGetActiveAttrib;memcpy(ptr, &tmp, 4); ptr += 4;
1567 memcpy(ptr, &totalSize, 4); ptr += 4;
1568
1569 memcpy(ptr, &program, 4); ptr += 4;
1570 memcpy(ptr, &index, 4); ptr += 4;
1571 memcpy(ptr, &bufsize, 4); ptr += 4;
1572 *(unsigned int *)(ptr) = __size_length; ptr += 4;
1573 *(unsigned int *)(ptr) = __size_size; ptr += 4;
1574 *(unsigned int *)(ptr) = __size_type; ptr += 4;
1575 *(unsigned int *)(ptr) = __size_name; ptr += 4;
1576
1577 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1578 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1579
1580 if (length != NULL) {
1581 stream->readback(length, __size_length);
1582 if (useChecksum) checksumCalculator->addBuffer(length, __size_length);
1583 }
1584 if (size != NULL) {
1585 stream->readback(size, __size_size);
1586 if (useChecksum) checksumCalculator->addBuffer(size, __size_size);
1587 }
1588 if (type != NULL) {
1589 stream->readback(type, __size_type);
1590 if (useChecksum) checksumCalculator->addBuffer(type, __size_type);
1591 }
1592 if (name != NULL) {
1593 stream->readback(name, __size_name);
1594 if (useChecksum) checksumCalculator->addBuffer(name, __size_name);
1595 }
1596 if (useChecksum) {
1597 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
1598 stream->readback(checksumBuf.get(), checksumSize);
1599 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
1600 ALOGE("glGetActiveAttrib: GL communication error, please report this issue to b.android.com.\n");
1601 abort();
1602 }
1603 }
1604 }
1605
glGetActiveUniform_enc(void * self,GLuint program,GLuint index,GLsizei bufsize,GLsizei * length,GLint * size,GLenum * type,GLchar * name)1606 void glGetActiveUniform_enc(void *self , GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
1607 {
1608
1609 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1610 IOStream *stream = ctx->m_stream;
1611 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1612 bool useChecksum = checksumCalculator->getVersion() > 0;
1613
1614 const unsigned int __size_length = ((length != NULL) ? (sizeof(GLsizei)) : 0);
1615 const unsigned int __size_size = ((size != NULL) ? (sizeof(GLint)) : 0);
1616 const unsigned int __size_type = ((type != NULL) ? (sizeof(GLenum)) : 0);
1617 const unsigned int __size_name = ((name != NULL) ? bufsize : 0);
1618 unsigned char *ptr;
1619 unsigned char *buf;
1620 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + __size_length + __size_size + __size_type + __size_name + 4*4;
1621 const size_t checksumSize = checksumCalculator->checksumByteSize();
1622 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1623 buf = stream->alloc(totalSize);
1624 ptr = buf;
1625 int tmp = OP_glGetActiveUniform;memcpy(ptr, &tmp, 4); ptr += 4;
1626 memcpy(ptr, &totalSize, 4); ptr += 4;
1627
1628 memcpy(ptr, &program, 4); ptr += 4;
1629 memcpy(ptr, &index, 4); ptr += 4;
1630 memcpy(ptr, &bufsize, 4); ptr += 4;
1631 *(unsigned int *)(ptr) = __size_length; ptr += 4;
1632 *(unsigned int *)(ptr) = __size_size; ptr += 4;
1633 *(unsigned int *)(ptr) = __size_type; ptr += 4;
1634 *(unsigned int *)(ptr) = __size_name; ptr += 4;
1635
1636 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1637 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1638
1639 if (length != NULL) {
1640 stream->readback(length, __size_length);
1641 if (useChecksum) checksumCalculator->addBuffer(length, __size_length);
1642 }
1643 if (size != NULL) {
1644 stream->readback(size, __size_size);
1645 if (useChecksum) checksumCalculator->addBuffer(size, __size_size);
1646 }
1647 if (type != NULL) {
1648 stream->readback(type, __size_type);
1649 if (useChecksum) checksumCalculator->addBuffer(type, __size_type);
1650 }
1651 if (name != NULL) {
1652 stream->readback(name, __size_name);
1653 if (useChecksum) checksumCalculator->addBuffer(name, __size_name);
1654 }
1655 if (useChecksum) {
1656 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
1657 stream->readback(checksumBuf.get(), checksumSize);
1658 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
1659 ALOGE("glGetActiveUniform: GL communication error, please report this issue to b.android.com.\n");
1660 abort();
1661 }
1662 }
1663 }
1664
glGetAttachedShaders_enc(void * self,GLuint program,GLsizei maxcount,GLsizei * count,GLuint * shaders)1665 void glGetAttachedShaders_enc(void *self , GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
1666 {
1667
1668 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1669 IOStream *stream = ctx->m_stream;
1670 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1671 bool useChecksum = checksumCalculator->getVersion() > 0;
1672
1673 const unsigned int __size_count = ((count != NULL) ? (sizeof(GLsizei)) : 0);
1674 const unsigned int __size_shaders = (maxcount*sizeof(GLuint));
1675 unsigned char *ptr;
1676 unsigned char *buf;
1677 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_count + __size_shaders + 2*4;
1678 const size_t checksumSize = checksumCalculator->checksumByteSize();
1679 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1680 buf = stream->alloc(totalSize);
1681 ptr = buf;
1682 int tmp = OP_glGetAttachedShaders;memcpy(ptr, &tmp, 4); ptr += 4;
1683 memcpy(ptr, &totalSize, 4); ptr += 4;
1684
1685 memcpy(ptr, &program, 4); ptr += 4;
1686 memcpy(ptr, &maxcount, 4); ptr += 4;
1687 *(unsigned int *)(ptr) = __size_count; ptr += 4;
1688 *(unsigned int *)(ptr) = __size_shaders; ptr += 4;
1689
1690 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1691 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1692
1693 if (count != NULL) {
1694 stream->readback(count, __size_count);
1695 if (useChecksum) checksumCalculator->addBuffer(count, __size_count);
1696 }
1697 stream->readback(shaders, __size_shaders);
1698 if (useChecksum) checksumCalculator->addBuffer(shaders, __size_shaders);
1699 if (useChecksum) {
1700 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
1701 stream->readback(checksumBuf.get(), checksumSize);
1702 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
1703 ALOGE("glGetAttachedShaders: GL communication error, please report this issue to b.android.com.\n");
1704 abort();
1705 }
1706 }
1707 }
1708
glGetAttribLocation_enc(void * self,GLuint program,const GLchar * name)1709 int glGetAttribLocation_enc(void *self , GLuint program, const GLchar* name)
1710 {
1711
1712 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1713 IOStream *stream = ctx->m_stream;
1714 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1715 bool useChecksum = checksumCalculator->getVersion() > 0;
1716
1717 const unsigned int __size_name = (strlen(name) + 1);
1718 unsigned char *ptr;
1719 unsigned char *buf;
1720 const size_t sizeWithoutChecksum = 8 + 4 + __size_name + 1*4;
1721 const size_t checksumSize = checksumCalculator->checksumByteSize();
1722 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1723 buf = stream->alloc(totalSize);
1724 ptr = buf;
1725 int tmp = OP_glGetAttribLocation;memcpy(ptr, &tmp, 4); ptr += 4;
1726 memcpy(ptr, &totalSize, 4); ptr += 4;
1727
1728 memcpy(ptr, &program, 4); ptr += 4;
1729 *(unsigned int *)(ptr) = __size_name; ptr += 4;
1730 memcpy(ptr, name, __size_name);ptr += __size_name;
1731
1732 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1733 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1734
1735
1736 int retval;
1737 stream->readback(&retval, 4);
1738 if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
1739 if (useChecksum) {
1740 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
1741 stream->readback(checksumBuf.get(), checksumSize);
1742 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
1743 ALOGE("glGetAttribLocation: GL communication error, please report this issue to b.android.com.\n");
1744 abort();
1745 }
1746 }
1747 return retval;
1748 }
1749
glGetBooleanv_enc(void * self,GLenum pname,GLboolean * params)1750 void glGetBooleanv_enc(void *self , GLenum pname, GLboolean* params)
1751 {
1752
1753 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1754 IOStream *stream = ctx->m_stream;
1755 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1756 bool useChecksum = checksumCalculator->getVersion() > 0;
1757
1758 const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLboolean));
1759 unsigned char *ptr;
1760 unsigned char *buf;
1761 const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4;
1762 const size_t checksumSize = checksumCalculator->checksumByteSize();
1763 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1764 buf = stream->alloc(totalSize);
1765 ptr = buf;
1766 int tmp = OP_glGetBooleanv;memcpy(ptr, &tmp, 4); ptr += 4;
1767 memcpy(ptr, &totalSize, 4); ptr += 4;
1768
1769 memcpy(ptr, &pname, 4); ptr += 4;
1770 *(unsigned int *)(ptr) = __size_params; ptr += 4;
1771
1772 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1773 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1774
1775 stream->readback(params, __size_params);
1776 if (useChecksum) checksumCalculator->addBuffer(params, __size_params);
1777 if (useChecksum) {
1778 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
1779 stream->readback(checksumBuf.get(), checksumSize);
1780 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
1781 ALOGE("glGetBooleanv: GL communication error, please report this issue to b.android.com.\n");
1782 abort();
1783 }
1784 }
1785 }
1786
glGetBufferParameteriv_enc(void * self,GLenum target,GLenum pname,GLint * params)1787 void glGetBufferParameteriv_enc(void *self , GLenum target, GLenum pname, GLint* params)
1788 {
1789
1790 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1791 IOStream *stream = ctx->m_stream;
1792 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1793 bool useChecksum = checksumCalculator->getVersion() > 0;
1794
1795 const unsigned int __size_params = (sizeof(GLint));
1796 unsigned char *ptr;
1797 unsigned char *buf;
1798 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4;
1799 const size_t checksumSize = checksumCalculator->checksumByteSize();
1800 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1801 buf = stream->alloc(totalSize);
1802 ptr = buf;
1803 int tmp = OP_glGetBufferParameteriv;memcpy(ptr, &tmp, 4); ptr += 4;
1804 memcpy(ptr, &totalSize, 4); ptr += 4;
1805
1806 memcpy(ptr, &target, 4); ptr += 4;
1807 memcpy(ptr, &pname, 4); ptr += 4;
1808 *(unsigned int *)(ptr) = __size_params; ptr += 4;
1809
1810 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1811 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1812
1813 stream->readback(params, __size_params);
1814 if (useChecksum) checksumCalculator->addBuffer(params, __size_params);
1815 if (useChecksum) {
1816 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
1817 stream->readback(checksumBuf.get(), checksumSize);
1818 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
1819 ALOGE("glGetBufferParameteriv: GL communication error, please report this issue to b.android.com.\n");
1820 abort();
1821 }
1822 }
1823 }
1824
glGetError_enc(void * self)1825 GLenum glGetError_enc(void *self )
1826 {
1827
1828 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1829 IOStream *stream = ctx->m_stream;
1830 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1831 bool useChecksum = checksumCalculator->getVersion() > 0;
1832
1833 unsigned char *ptr;
1834 unsigned char *buf;
1835 const size_t sizeWithoutChecksum = 8;
1836 const size_t checksumSize = checksumCalculator->checksumByteSize();
1837 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1838 buf = stream->alloc(totalSize);
1839 ptr = buf;
1840 int tmp = OP_glGetError;memcpy(ptr, &tmp, 4); ptr += 4;
1841 memcpy(ptr, &totalSize, 4); ptr += 4;
1842
1843
1844 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1845 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1846
1847
1848 GLenum retval;
1849 stream->readback(&retval, 4);
1850 if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
1851 if (useChecksum) {
1852 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
1853 stream->readback(checksumBuf.get(), checksumSize);
1854 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
1855 ALOGE("glGetError: GL communication error, please report this issue to b.android.com.\n");
1856 abort();
1857 }
1858 }
1859 return retval;
1860 }
1861
glGetFloatv_enc(void * self,GLenum pname,GLfloat * params)1862 void glGetFloatv_enc(void *self , GLenum pname, GLfloat* params)
1863 {
1864
1865 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1866 IOStream *stream = ctx->m_stream;
1867 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1868 bool useChecksum = checksumCalculator->getVersion() > 0;
1869
1870 const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat));
1871 unsigned char *ptr;
1872 unsigned char *buf;
1873 const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4;
1874 const size_t checksumSize = checksumCalculator->checksumByteSize();
1875 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1876 buf = stream->alloc(totalSize);
1877 ptr = buf;
1878 int tmp = OP_glGetFloatv;memcpy(ptr, &tmp, 4); ptr += 4;
1879 memcpy(ptr, &totalSize, 4); ptr += 4;
1880
1881 memcpy(ptr, &pname, 4); ptr += 4;
1882 *(unsigned int *)(ptr) = __size_params; ptr += 4;
1883
1884 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1885 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1886
1887 stream->readback(params, __size_params);
1888 if (useChecksum) checksumCalculator->addBuffer(params, __size_params);
1889 if (useChecksum) {
1890 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
1891 stream->readback(checksumBuf.get(), checksumSize);
1892 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
1893 ALOGE("glGetFloatv: GL communication error, please report this issue to b.android.com.\n");
1894 abort();
1895 }
1896 }
1897 }
1898
glGetFramebufferAttachmentParameteriv_enc(void * self,GLenum target,GLenum attachment,GLenum pname,GLint * params)1899 void glGetFramebufferAttachmentParameteriv_enc(void *self , GLenum target, GLenum attachment, GLenum pname, GLint* params)
1900 {
1901
1902 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1903 IOStream *stream = ctx->m_stream;
1904 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1905 bool useChecksum = checksumCalculator->getVersion() > 0;
1906
1907 const unsigned int __size_params = (sizeof(GLint));
1908 unsigned char *ptr;
1909 unsigned char *buf;
1910 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + __size_params + 1*4;
1911 const size_t checksumSize = checksumCalculator->checksumByteSize();
1912 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1913 buf = stream->alloc(totalSize);
1914 ptr = buf;
1915 int tmp = OP_glGetFramebufferAttachmentParameteriv;memcpy(ptr, &tmp, 4); ptr += 4;
1916 memcpy(ptr, &totalSize, 4); ptr += 4;
1917
1918 memcpy(ptr, &target, 4); ptr += 4;
1919 memcpy(ptr, &attachment, 4); ptr += 4;
1920 memcpy(ptr, &pname, 4); ptr += 4;
1921 *(unsigned int *)(ptr) = __size_params; ptr += 4;
1922
1923 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1924 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1925
1926 stream->readback(params, __size_params);
1927 if (useChecksum) checksumCalculator->addBuffer(params, __size_params);
1928 if (useChecksum) {
1929 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
1930 stream->readback(checksumBuf.get(), checksumSize);
1931 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
1932 ALOGE("glGetFramebufferAttachmentParameteriv: GL communication error, please report this issue to b.android.com.\n");
1933 abort();
1934 }
1935 }
1936 }
1937
glGetIntegerv_enc(void * self,GLenum pname,GLint * params)1938 void glGetIntegerv_enc(void *self , GLenum pname, GLint* params)
1939 {
1940
1941 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1942 IOStream *stream = ctx->m_stream;
1943 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1944 bool useChecksum = checksumCalculator->getVersion() > 0;
1945
1946 const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLint));
1947 unsigned char *ptr;
1948 unsigned char *buf;
1949 const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4;
1950 const size_t checksumSize = checksumCalculator->checksumByteSize();
1951 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1952 buf = stream->alloc(totalSize);
1953 ptr = buf;
1954 int tmp = OP_glGetIntegerv;memcpy(ptr, &tmp, 4); ptr += 4;
1955 memcpy(ptr, &totalSize, 4); ptr += 4;
1956
1957 memcpy(ptr, &pname, 4); ptr += 4;
1958 *(unsigned int *)(ptr) = __size_params; ptr += 4;
1959
1960 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1961 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1962
1963 stream->readback(params, __size_params);
1964 if (useChecksum) checksumCalculator->addBuffer(params, __size_params);
1965 if (useChecksum) {
1966 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
1967 stream->readback(checksumBuf.get(), checksumSize);
1968 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
1969 ALOGE("glGetIntegerv: GL communication error, please report this issue to b.android.com.\n");
1970 abort();
1971 }
1972 }
1973 }
1974
glGetProgramiv_enc(void * self,GLuint program,GLenum pname,GLint * params)1975 void glGetProgramiv_enc(void *self , GLuint program, GLenum pname, GLint* params)
1976 {
1977
1978 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
1979 IOStream *stream = ctx->m_stream;
1980 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1981 bool useChecksum = checksumCalculator->getVersion() > 0;
1982
1983 const unsigned int __size_params = sizeof(GLint);
1984 unsigned char *ptr;
1985 unsigned char *buf;
1986 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4;
1987 const size_t checksumSize = checksumCalculator->checksumByteSize();
1988 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1989 buf = stream->alloc(totalSize);
1990 ptr = buf;
1991 int tmp = OP_glGetProgramiv;memcpy(ptr, &tmp, 4); ptr += 4;
1992 memcpy(ptr, &totalSize, 4); ptr += 4;
1993
1994 memcpy(ptr, &program, 4); ptr += 4;
1995 memcpy(ptr, &pname, 4); ptr += 4;
1996 *(unsigned int *)(ptr) = __size_params; ptr += 4;
1997
1998 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1999 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2000
2001 stream->readback(params, __size_params);
2002 if (useChecksum) checksumCalculator->addBuffer(params, __size_params);
2003 if (useChecksum) {
2004 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2005 stream->readback(checksumBuf.get(), checksumSize);
2006 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2007 ALOGE("glGetProgramiv: GL communication error, please report this issue to b.android.com.\n");
2008 abort();
2009 }
2010 }
2011 }
2012
glGetProgramInfoLog_enc(void * self,GLuint program,GLsizei bufsize,GLsizei * length,GLchar * infolog)2013 void glGetProgramInfoLog_enc(void *self , GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
2014 {
2015
2016 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2017 IOStream *stream = ctx->m_stream;
2018 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2019 bool useChecksum = checksumCalculator->getVersion() > 0;
2020
2021 const unsigned int __size_length = ((length != NULL) ? sizeof(GLsizei) : 0);
2022 const unsigned int __size_infolog = bufsize;
2023 unsigned char *ptr;
2024 unsigned char *buf;
2025 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_length + __size_infolog + 2*4;
2026 const size_t checksumSize = checksumCalculator->checksumByteSize();
2027 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2028 buf = stream->alloc(totalSize);
2029 ptr = buf;
2030 int tmp = OP_glGetProgramInfoLog;memcpy(ptr, &tmp, 4); ptr += 4;
2031 memcpy(ptr, &totalSize, 4); ptr += 4;
2032
2033 memcpy(ptr, &program, 4); ptr += 4;
2034 memcpy(ptr, &bufsize, 4); ptr += 4;
2035 *(unsigned int *)(ptr) = __size_length; ptr += 4;
2036 *(unsigned int *)(ptr) = __size_infolog; ptr += 4;
2037
2038 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2039 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2040
2041 if (length != NULL) {
2042 stream->readback(length, __size_length);
2043 if (useChecksum) checksumCalculator->addBuffer(length, __size_length);
2044 }
2045 stream->readback(infolog, __size_infolog);
2046 if (useChecksum) checksumCalculator->addBuffer(infolog, __size_infolog);
2047 if (useChecksum) {
2048 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2049 stream->readback(checksumBuf.get(), checksumSize);
2050 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2051 ALOGE("glGetProgramInfoLog: GL communication error, please report this issue to b.android.com.\n");
2052 abort();
2053 }
2054 }
2055 }
2056
glGetRenderbufferParameteriv_enc(void * self,GLenum target,GLenum pname,GLint * params)2057 void glGetRenderbufferParameteriv_enc(void *self , GLenum target, GLenum pname, GLint* params)
2058 {
2059
2060 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2061 IOStream *stream = ctx->m_stream;
2062 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2063 bool useChecksum = checksumCalculator->getVersion() > 0;
2064
2065 const unsigned int __size_params = sizeof(GLint);
2066 unsigned char *ptr;
2067 unsigned char *buf;
2068 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4;
2069 const size_t checksumSize = checksumCalculator->checksumByteSize();
2070 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2071 buf = stream->alloc(totalSize);
2072 ptr = buf;
2073 int tmp = OP_glGetRenderbufferParameteriv;memcpy(ptr, &tmp, 4); ptr += 4;
2074 memcpy(ptr, &totalSize, 4); ptr += 4;
2075
2076 memcpy(ptr, &target, 4); ptr += 4;
2077 memcpy(ptr, &pname, 4); ptr += 4;
2078 *(unsigned int *)(ptr) = __size_params; ptr += 4;
2079
2080 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2081 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2082
2083 stream->readback(params, __size_params);
2084 if (useChecksum) checksumCalculator->addBuffer(params, __size_params);
2085 if (useChecksum) {
2086 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2087 stream->readback(checksumBuf.get(), checksumSize);
2088 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2089 ALOGE("glGetRenderbufferParameteriv: GL communication error, please report this issue to b.android.com.\n");
2090 abort();
2091 }
2092 }
2093 }
2094
glGetShaderiv_enc(void * self,GLuint shader,GLenum pname,GLint * params)2095 void glGetShaderiv_enc(void *self , GLuint shader, GLenum pname, GLint* params)
2096 {
2097
2098 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2099 IOStream *stream = ctx->m_stream;
2100 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2101 bool useChecksum = checksumCalculator->getVersion() > 0;
2102
2103 const unsigned int __size_params = sizeof(GLint);
2104 unsigned char *ptr;
2105 unsigned char *buf;
2106 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4;
2107 const size_t checksumSize = checksumCalculator->checksumByteSize();
2108 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2109 buf = stream->alloc(totalSize);
2110 ptr = buf;
2111 int tmp = OP_glGetShaderiv;memcpy(ptr, &tmp, 4); ptr += 4;
2112 memcpy(ptr, &totalSize, 4); ptr += 4;
2113
2114 memcpy(ptr, &shader, 4); ptr += 4;
2115 memcpy(ptr, &pname, 4); ptr += 4;
2116 *(unsigned int *)(ptr) = __size_params; ptr += 4;
2117
2118 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2119 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2120
2121 stream->readback(params, __size_params);
2122 if (useChecksum) checksumCalculator->addBuffer(params, __size_params);
2123 if (useChecksum) {
2124 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2125 stream->readback(checksumBuf.get(), checksumSize);
2126 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2127 ALOGE("glGetShaderiv: GL communication error, please report this issue to b.android.com.\n");
2128 abort();
2129 }
2130 }
2131 }
2132
glGetShaderInfoLog_enc(void * self,GLuint shader,GLsizei bufsize,GLsizei * length,GLchar * infolog)2133 void glGetShaderInfoLog_enc(void *self , GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
2134 {
2135
2136 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2137 IOStream *stream = ctx->m_stream;
2138 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2139 bool useChecksum = checksumCalculator->getVersion() > 0;
2140
2141 const unsigned int __size_length = ((length != NULL) ? (sizeof(GLsizei)) : 0);
2142 const unsigned int __size_infolog = bufsize;
2143 unsigned char *ptr;
2144 unsigned char *buf;
2145 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_length + __size_infolog + 2*4;
2146 const size_t checksumSize = checksumCalculator->checksumByteSize();
2147 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2148 buf = stream->alloc(totalSize);
2149 ptr = buf;
2150 int tmp = OP_glGetShaderInfoLog;memcpy(ptr, &tmp, 4); ptr += 4;
2151 memcpy(ptr, &totalSize, 4); ptr += 4;
2152
2153 memcpy(ptr, &shader, 4); ptr += 4;
2154 memcpy(ptr, &bufsize, 4); ptr += 4;
2155 *(unsigned int *)(ptr) = __size_length; ptr += 4;
2156 *(unsigned int *)(ptr) = __size_infolog; ptr += 4;
2157
2158 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2159 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2160
2161 if (length != NULL) {
2162 stream->readback(length, __size_length);
2163 if (useChecksum) checksumCalculator->addBuffer(length, __size_length);
2164 }
2165 stream->readback(infolog, __size_infolog);
2166 if (useChecksum) checksumCalculator->addBuffer(infolog, __size_infolog);
2167 if (useChecksum) {
2168 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2169 stream->readback(checksumBuf.get(), checksumSize);
2170 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2171 ALOGE("glGetShaderInfoLog: GL communication error, please report this issue to b.android.com.\n");
2172 abort();
2173 }
2174 }
2175 }
2176
glGetShaderPrecisionFormat_enc(void * self,GLenum shadertype,GLenum precisiontype,GLint * range,GLint * precision)2177 void glGetShaderPrecisionFormat_enc(void *self , GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
2178 {
2179
2180 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2181 IOStream *stream = ctx->m_stream;
2182 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2183 bool useChecksum = checksumCalculator->getVersion() > 0;
2184
2185 const unsigned int __size_range = (2 * sizeof(GLint));
2186 const unsigned int __size_precision = (sizeof(GLint));
2187 unsigned char *ptr;
2188 unsigned char *buf;
2189 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_range + __size_precision + 2*4;
2190 const size_t checksumSize = checksumCalculator->checksumByteSize();
2191 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2192 buf = stream->alloc(totalSize);
2193 ptr = buf;
2194 int tmp = OP_glGetShaderPrecisionFormat;memcpy(ptr, &tmp, 4); ptr += 4;
2195 memcpy(ptr, &totalSize, 4); ptr += 4;
2196
2197 memcpy(ptr, &shadertype, 4); ptr += 4;
2198 memcpy(ptr, &precisiontype, 4); ptr += 4;
2199 *(unsigned int *)(ptr) = __size_range; ptr += 4;
2200 *(unsigned int *)(ptr) = __size_precision; ptr += 4;
2201
2202 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2203 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2204
2205 stream->readback(range, __size_range);
2206 if (useChecksum) checksumCalculator->addBuffer(range, __size_range);
2207 stream->readback(precision, __size_precision);
2208 if (useChecksum) checksumCalculator->addBuffer(precision, __size_precision);
2209 if (useChecksum) {
2210 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2211 stream->readback(checksumBuf.get(), checksumSize);
2212 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2213 ALOGE("glGetShaderPrecisionFormat: GL communication error, please report this issue to b.android.com.\n");
2214 abort();
2215 }
2216 }
2217 }
2218
glGetShaderSource_enc(void * self,GLuint shader,GLsizei bufsize,GLsizei * length,GLchar * source)2219 void glGetShaderSource_enc(void *self , GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
2220 {
2221
2222 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2223 IOStream *stream = ctx->m_stream;
2224 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2225 bool useChecksum = checksumCalculator->getVersion() > 0;
2226
2227 const unsigned int __size_length = ((length != NULL) ? (sizeof(GLsizei)) : 0);
2228 const unsigned int __size_source = bufsize;
2229 unsigned char *ptr;
2230 unsigned char *buf;
2231 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_length + __size_source + 2*4;
2232 const size_t checksumSize = checksumCalculator->checksumByteSize();
2233 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2234 buf = stream->alloc(totalSize);
2235 ptr = buf;
2236 int tmp = OP_glGetShaderSource;memcpy(ptr, &tmp, 4); ptr += 4;
2237 memcpy(ptr, &totalSize, 4); ptr += 4;
2238
2239 memcpy(ptr, &shader, 4); ptr += 4;
2240 memcpy(ptr, &bufsize, 4); ptr += 4;
2241 *(unsigned int *)(ptr) = __size_length; ptr += 4;
2242 *(unsigned int *)(ptr) = __size_source; ptr += 4;
2243
2244 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2245 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2246
2247 if (length != NULL) {
2248 stream->readback(length, __size_length);
2249 if (useChecksum) checksumCalculator->addBuffer(length, __size_length);
2250 }
2251 stream->readback(source, __size_source);
2252 if (useChecksum) checksumCalculator->addBuffer(source, __size_source);
2253 if (useChecksum) {
2254 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2255 stream->readback(checksumBuf.get(), checksumSize);
2256 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2257 ALOGE("glGetShaderSource: GL communication error, please report this issue to b.android.com.\n");
2258 abort();
2259 }
2260 }
2261 }
2262
glGetTexParameterfv_enc(void * self,GLenum target,GLenum pname,GLfloat * params)2263 void glGetTexParameterfv_enc(void *self , GLenum target, GLenum pname, GLfloat* params)
2264 {
2265
2266 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2267 IOStream *stream = ctx->m_stream;
2268 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2269 bool useChecksum = checksumCalculator->getVersion() > 0;
2270
2271 const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat));
2272 unsigned char *ptr;
2273 unsigned char *buf;
2274 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4;
2275 const size_t checksumSize = checksumCalculator->checksumByteSize();
2276 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2277 buf = stream->alloc(totalSize);
2278 ptr = buf;
2279 int tmp = OP_glGetTexParameterfv;memcpy(ptr, &tmp, 4); ptr += 4;
2280 memcpy(ptr, &totalSize, 4); ptr += 4;
2281
2282 memcpy(ptr, &target, 4); ptr += 4;
2283 memcpy(ptr, &pname, 4); ptr += 4;
2284 *(unsigned int *)(ptr) = __size_params; ptr += 4;
2285
2286 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2287 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2288
2289 stream->readback(params, __size_params);
2290 if (useChecksum) checksumCalculator->addBuffer(params, __size_params);
2291 if (useChecksum) {
2292 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2293 stream->readback(checksumBuf.get(), checksumSize);
2294 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2295 ALOGE("glGetTexParameterfv: GL communication error, please report this issue to b.android.com.\n");
2296 abort();
2297 }
2298 }
2299 }
2300
glGetTexParameteriv_enc(void * self,GLenum target,GLenum pname,GLint * params)2301 void glGetTexParameteriv_enc(void *self , GLenum target, GLenum pname, GLint* params)
2302 {
2303
2304 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2305 IOStream *stream = ctx->m_stream;
2306 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2307 bool useChecksum = checksumCalculator->getVersion() > 0;
2308
2309 const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLint));
2310 unsigned char *ptr;
2311 unsigned char *buf;
2312 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4;
2313 const size_t checksumSize = checksumCalculator->checksumByteSize();
2314 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2315 buf = stream->alloc(totalSize);
2316 ptr = buf;
2317 int tmp = OP_glGetTexParameteriv;memcpy(ptr, &tmp, 4); ptr += 4;
2318 memcpy(ptr, &totalSize, 4); ptr += 4;
2319
2320 memcpy(ptr, &target, 4); ptr += 4;
2321 memcpy(ptr, &pname, 4); ptr += 4;
2322 *(unsigned int *)(ptr) = __size_params; ptr += 4;
2323
2324 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2325 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2326
2327 stream->readback(params, __size_params);
2328 if (useChecksum) checksumCalculator->addBuffer(params, __size_params);
2329 if (useChecksum) {
2330 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2331 stream->readback(checksumBuf.get(), checksumSize);
2332 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2333 ALOGE("glGetTexParameteriv: GL communication error, please report this issue to b.android.com.\n");
2334 abort();
2335 }
2336 }
2337 }
2338
glGetUniformfv_enc(void * self,GLuint program,GLint location,GLfloat * params)2339 void glGetUniformfv_enc(void *self , GLuint program, GLint location, GLfloat* params)
2340 {
2341
2342 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2343 IOStream *stream = ctx->m_stream;
2344 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2345 bool useChecksum = checksumCalculator->getVersion() > 0;
2346
2347 const unsigned int __size_params = glSizeof(glesv2_enc::uniformType(self, program, location));
2348 unsigned char *ptr;
2349 unsigned char *buf;
2350 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4;
2351 const size_t checksumSize = checksumCalculator->checksumByteSize();
2352 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2353 buf = stream->alloc(totalSize);
2354 ptr = buf;
2355 int tmp = OP_glGetUniformfv;memcpy(ptr, &tmp, 4); ptr += 4;
2356 memcpy(ptr, &totalSize, 4); ptr += 4;
2357
2358 memcpy(ptr, &program, 4); ptr += 4;
2359 memcpy(ptr, &location, 4); ptr += 4;
2360 *(unsigned int *)(ptr) = __size_params; ptr += 4;
2361
2362 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2363 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2364
2365 stream->readback(params, __size_params);
2366 if (useChecksum) checksumCalculator->addBuffer(params, __size_params);
2367 if (useChecksum) {
2368 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2369 stream->readback(checksumBuf.get(), checksumSize);
2370 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2371 ALOGE("glGetUniformfv: GL communication error, please report this issue to b.android.com.\n");
2372 abort();
2373 }
2374 }
2375 }
2376
glGetUniformiv_enc(void * self,GLuint program,GLint location,GLint * params)2377 void glGetUniformiv_enc(void *self , GLuint program, GLint location, GLint* params)
2378 {
2379
2380 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2381 IOStream *stream = ctx->m_stream;
2382 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2383 bool useChecksum = checksumCalculator->getVersion() > 0;
2384
2385 const unsigned int __size_params = glSizeof(glesv2_enc::uniformType(self, program, location));
2386 unsigned char *ptr;
2387 unsigned char *buf;
2388 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4;
2389 const size_t checksumSize = checksumCalculator->checksumByteSize();
2390 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2391 buf = stream->alloc(totalSize);
2392 ptr = buf;
2393 int tmp = OP_glGetUniformiv;memcpy(ptr, &tmp, 4); ptr += 4;
2394 memcpy(ptr, &totalSize, 4); ptr += 4;
2395
2396 memcpy(ptr, &program, 4); ptr += 4;
2397 memcpy(ptr, &location, 4); ptr += 4;
2398 *(unsigned int *)(ptr) = __size_params; ptr += 4;
2399
2400 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2401 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2402
2403 stream->readback(params, __size_params);
2404 if (useChecksum) checksumCalculator->addBuffer(params, __size_params);
2405 if (useChecksum) {
2406 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2407 stream->readback(checksumBuf.get(), checksumSize);
2408 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2409 ALOGE("glGetUniformiv: GL communication error, please report this issue to b.android.com.\n");
2410 abort();
2411 }
2412 }
2413 }
2414
glGetUniformLocation_enc(void * self,GLuint program,const GLchar * name)2415 int glGetUniformLocation_enc(void *self , GLuint program, const GLchar* name)
2416 {
2417
2418 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2419 IOStream *stream = ctx->m_stream;
2420 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2421 bool useChecksum = checksumCalculator->getVersion() > 0;
2422
2423 const unsigned int __size_name = (strlen(name) + 1);
2424 unsigned char *ptr;
2425 unsigned char *buf;
2426 const size_t sizeWithoutChecksum = 8 + 4 + __size_name + 1*4;
2427 const size_t checksumSize = checksumCalculator->checksumByteSize();
2428 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2429 buf = stream->alloc(totalSize);
2430 ptr = buf;
2431 int tmp = OP_glGetUniformLocation;memcpy(ptr, &tmp, 4); ptr += 4;
2432 memcpy(ptr, &totalSize, 4); ptr += 4;
2433
2434 memcpy(ptr, &program, 4); ptr += 4;
2435 *(unsigned int *)(ptr) = __size_name; ptr += 4;
2436 memcpy(ptr, name, __size_name);ptr += __size_name;
2437
2438 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2439 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2440
2441
2442 int retval;
2443 stream->readback(&retval, 4);
2444 if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
2445 if (useChecksum) {
2446 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2447 stream->readback(checksumBuf.get(), checksumSize);
2448 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2449 ALOGE("glGetUniformLocation: GL communication error, please report this issue to b.android.com.\n");
2450 abort();
2451 }
2452 }
2453 return retval;
2454 }
2455
glGetVertexAttribfv_enc(void * self,GLuint index,GLenum pname,GLfloat * params)2456 void glGetVertexAttribfv_enc(void *self , GLuint index, GLenum pname, GLfloat* params)
2457 {
2458
2459 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2460 IOStream *stream = ctx->m_stream;
2461 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2462 bool useChecksum = checksumCalculator->getVersion() > 0;
2463
2464 const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat));
2465 unsigned char *ptr;
2466 unsigned char *buf;
2467 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4;
2468 const size_t checksumSize = checksumCalculator->checksumByteSize();
2469 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2470 buf = stream->alloc(totalSize);
2471 ptr = buf;
2472 int tmp = OP_glGetVertexAttribfv;memcpy(ptr, &tmp, 4); ptr += 4;
2473 memcpy(ptr, &totalSize, 4); ptr += 4;
2474
2475 memcpy(ptr, &index, 4); ptr += 4;
2476 memcpy(ptr, &pname, 4); ptr += 4;
2477 *(unsigned int *)(ptr) = __size_params; ptr += 4;
2478
2479 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2480 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2481
2482 stream->readback(params, __size_params);
2483 if (useChecksum) checksumCalculator->addBuffer(params, __size_params);
2484 if (useChecksum) {
2485 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2486 stream->readback(checksumBuf.get(), checksumSize);
2487 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2488 ALOGE("glGetVertexAttribfv: GL communication error, please report this issue to b.android.com.\n");
2489 abort();
2490 }
2491 }
2492 }
2493
glGetVertexAttribiv_enc(void * self,GLuint index,GLenum pname,GLint * params)2494 void glGetVertexAttribiv_enc(void *self , GLuint index, GLenum pname, GLint* params)
2495 {
2496
2497 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2498 IOStream *stream = ctx->m_stream;
2499 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2500 bool useChecksum = checksumCalculator->getVersion() > 0;
2501
2502 const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLint));
2503 unsigned char *ptr;
2504 unsigned char *buf;
2505 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4;
2506 const size_t checksumSize = checksumCalculator->checksumByteSize();
2507 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2508 buf = stream->alloc(totalSize);
2509 ptr = buf;
2510 int tmp = OP_glGetVertexAttribiv;memcpy(ptr, &tmp, 4); ptr += 4;
2511 memcpy(ptr, &totalSize, 4); ptr += 4;
2512
2513 memcpy(ptr, &index, 4); ptr += 4;
2514 memcpy(ptr, &pname, 4); ptr += 4;
2515 *(unsigned int *)(ptr) = __size_params; ptr += 4;
2516
2517 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2518 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2519
2520 stream->readback(params, __size_params);
2521 if (useChecksum) checksumCalculator->addBuffer(params, __size_params);
2522 if (useChecksum) {
2523 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2524 stream->readback(checksumBuf.get(), checksumSize);
2525 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2526 ALOGE("glGetVertexAttribiv: GL communication error, please report this issue to b.android.com.\n");
2527 abort();
2528 }
2529 }
2530 }
2531
glHint_enc(void * self,GLenum target,GLenum mode)2532 void glHint_enc(void *self , GLenum target, GLenum mode)
2533 {
2534
2535 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2536 IOStream *stream = ctx->m_stream;
2537 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2538 bool useChecksum = checksumCalculator->getVersion() > 0;
2539
2540 unsigned char *ptr;
2541 unsigned char *buf;
2542 const size_t sizeWithoutChecksum = 8 + 4 + 4;
2543 const size_t checksumSize = checksumCalculator->checksumByteSize();
2544 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2545 buf = stream->alloc(totalSize);
2546 ptr = buf;
2547 int tmp = OP_glHint;memcpy(ptr, &tmp, 4); ptr += 4;
2548 memcpy(ptr, &totalSize, 4); ptr += 4;
2549
2550 memcpy(ptr, &target, 4); ptr += 4;
2551 memcpy(ptr, &mode, 4); ptr += 4;
2552
2553 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2554 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2555
2556 }
2557
glIsBuffer_enc(void * self,GLuint buffer)2558 GLboolean glIsBuffer_enc(void *self , GLuint buffer)
2559 {
2560
2561 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2562 IOStream *stream = ctx->m_stream;
2563 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2564 bool useChecksum = checksumCalculator->getVersion() > 0;
2565
2566 unsigned char *ptr;
2567 unsigned char *buf;
2568 const size_t sizeWithoutChecksum = 8 + 4;
2569 const size_t checksumSize = checksumCalculator->checksumByteSize();
2570 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2571 buf = stream->alloc(totalSize);
2572 ptr = buf;
2573 int tmp = OP_glIsBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
2574 memcpy(ptr, &totalSize, 4); ptr += 4;
2575
2576 memcpy(ptr, &buffer, 4); ptr += 4;
2577
2578 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2579 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2580
2581
2582 GLboolean retval;
2583 stream->readback(&retval, 1);
2584 if (useChecksum) checksumCalculator->addBuffer(&retval, 1);
2585 if (useChecksum) {
2586 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2587 stream->readback(checksumBuf.get(), checksumSize);
2588 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2589 ALOGE("glIsBuffer: GL communication error, please report this issue to b.android.com.\n");
2590 abort();
2591 }
2592 }
2593 return retval;
2594 }
2595
glIsEnabled_enc(void * self,GLenum cap)2596 GLboolean glIsEnabled_enc(void *self , GLenum cap)
2597 {
2598
2599 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2600 IOStream *stream = ctx->m_stream;
2601 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2602 bool useChecksum = checksumCalculator->getVersion() > 0;
2603
2604 unsigned char *ptr;
2605 unsigned char *buf;
2606 const size_t sizeWithoutChecksum = 8 + 4;
2607 const size_t checksumSize = checksumCalculator->checksumByteSize();
2608 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2609 buf = stream->alloc(totalSize);
2610 ptr = buf;
2611 int tmp = OP_glIsEnabled;memcpy(ptr, &tmp, 4); ptr += 4;
2612 memcpy(ptr, &totalSize, 4); ptr += 4;
2613
2614 memcpy(ptr, &cap, 4); ptr += 4;
2615
2616 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2617 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2618
2619
2620 GLboolean retval;
2621 stream->readback(&retval, 1);
2622 if (useChecksum) checksumCalculator->addBuffer(&retval, 1);
2623 if (useChecksum) {
2624 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2625 stream->readback(checksumBuf.get(), checksumSize);
2626 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2627 ALOGE("glIsEnabled: GL communication error, please report this issue to b.android.com.\n");
2628 abort();
2629 }
2630 }
2631 return retval;
2632 }
2633
glIsFramebuffer_enc(void * self,GLuint framebuffer)2634 GLboolean glIsFramebuffer_enc(void *self , GLuint framebuffer)
2635 {
2636
2637 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2638 IOStream *stream = ctx->m_stream;
2639 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2640 bool useChecksum = checksumCalculator->getVersion() > 0;
2641
2642 unsigned char *ptr;
2643 unsigned char *buf;
2644 const size_t sizeWithoutChecksum = 8 + 4;
2645 const size_t checksumSize = checksumCalculator->checksumByteSize();
2646 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2647 buf = stream->alloc(totalSize);
2648 ptr = buf;
2649 int tmp = OP_glIsFramebuffer;memcpy(ptr, &tmp, 4); ptr += 4;
2650 memcpy(ptr, &totalSize, 4); ptr += 4;
2651
2652 memcpy(ptr, &framebuffer, 4); ptr += 4;
2653
2654 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2655 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2656
2657
2658 GLboolean retval;
2659 stream->readback(&retval, 1);
2660 if (useChecksum) checksumCalculator->addBuffer(&retval, 1);
2661 if (useChecksum) {
2662 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2663 stream->readback(checksumBuf.get(), checksumSize);
2664 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2665 ALOGE("glIsFramebuffer: GL communication error, please report this issue to b.android.com.\n");
2666 abort();
2667 }
2668 }
2669 return retval;
2670 }
2671
glIsProgram_enc(void * self,GLuint program)2672 GLboolean glIsProgram_enc(void *self , GLuint program)
2673 {
2674
2675 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2676 IOStream *stream = ctx->m_stream;
2677 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2678 bool useChecksum = checksumCalculator->getVersion() > 0;
2679
2680 unsigned char *ptr;
2681 unsigned char *buf;
2682 const size_t sizeWithoutChecksum = 8 + 4;
2683 const size_t checksumSize = checksumCalculator->checksumByteSize();
2684 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2685 buf = stream->alloc(totalSize);
2686 ptr = buf;
2687 int tmp = OP_glIsProgram;memcpy(ptr, &tmp, 4); ptr += 4;
2688 memcpy(ptr, &totalSize, 4); ptr += 4;
2689
2690 memcpy(ptr, &program, 4); ptr += 4;
2691
2692 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2693 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2694
2695
2696 GLboolean retval;
2697 stream->readback(&retval, 1);
2698 if (useChecksum) checksumCalculator->addBuffer(&retval, 1);
2699 if (useChecksum) {
2700 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2701 stream->readback(checksumBuf.get(), checksumSize);
2702 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2703 ALOGE("glIsProgram: GL communication error, please report this issue to b.android.com.\n");
2704 abort();
2705 }
2706 }
2707 return retval;
2708 }
2709
glIsRenderbuffer_enc(void * self,GLuint renderbuffer)2710 GLboolean glIsRenderbuffer_enc(void *self , GLuint renderbuffer)
2711 {
2712
2713 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2714 IOStream *stream = ctx->m_stream;
2715 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2716 bool useChecksum = checksumCalculator->getVersion() > 0;
2717
2718 unsigned char *ptr;
2719 unsigned char *buf;
2720 const size_t sizeWithoutChecksum = 8 + 4;
2721 const size_t checksumSize = checksumCalculator->checksumByteSize();
2722 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2723 buf = stream->alloc(totalSize);
2724 ptr = buf;
2725 int tmp = OP_glIsRenderbuffer;memcpy(ptr, &tmp, 4); ptr += 4;
2726 memcpy(ptr, &totalSize, 4); ptr += 4;
2727
2728 memcpy(ptr, &renderbuffer, 4); ptr += 4;
2729
2730 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2731 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2732
2733
2734 GLboolean retval;
2735 stream->readback(&retval, 1);
2736 if (useChecksum) checksumCalculator->addBuffer(&retval, 1);
2737 if (useChecksum) {
2738 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2739 stream->readback(checksumBuf.get(), checksumSize);
2740 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2741 ALOGE("glIsRenderbuffer: GL communication error, please report this issue to b.android.com.\n");
2742 abort();
2743 }
2744 }
2745 return retval;
2746 }
2747
glIsShader_enc(void * self,GLuint shader)2748 GLboolean glIsShader_enc(void *self , GLuint shader)
2749 {
2750
2751 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2752 IOStream *stream = ctx->m_stream;
2753 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2754 bool useChecksum = checksumCalculator->getVersion() > 0;
2755
2756 unsigned char *ptr;
2757 unsigned char *buf;
2758 const size_t sizeWithoutChecksum = 8 + 4;
2759 const size_t checksumSize = checksumCalculator->checksumByteSize();
2760 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2761 buf = stream->alloc(totalSize);
2762 ptr = buf;
2763 int tmp = OP_glIsShader;memcpy(ptr, &tmp, 4); ptr += 4;
2764 memcpy(ptr, &totalSize, 4); ptr += 4;
2765
2766 memcpy(ptr, &shader, 4); ptr += 4;
2767
2768 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2769 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2770
2771
2772 GLboolean retval;
2773 stream->readback(&retval, 1);
2774 if (useChecksum) checksumCalculator->addBuffer(&retval, 1);
2775 if (useChecksum) {
2776 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2777 stream->readback(checksumBuf.get(), checksumSize);
2778 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2779 ALOGE("glIsShader: GL communication error, please report this issue to b.android.com.\n");
2780 abort();
2781 }
2782 }
2783 return retval;
2784 }
2785
glIsTexture_enc(void * self,GLuint texture)2786 GLboolean glIsTexture_enc(void *self , GLuint texture)
2787 {
2788
2789 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2790 IOStream *stream = ctx->m_stream;
2791 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2792 bool useChecksum = checksumCalculator->getVersion() > 0;
2793
2794 unsigned char *ptr;
2795 unsigned char *buf;
2796 const size_t sizeWithoutChecksum = 8 + 4;
2797 const size_t checksumSize = checksumCalculator->checksumByteSize();
2798 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2799 buf = stream->alloc(totalSize);
2800 ptr = buf;
2801 int tmp = OP_glIsTexture;memcpy(ptr, &tmp, 4); ptr += 4;
2802 memcpy(ptr, &totalSize, 4); ptr += 4;
2803
2804 memcpy(ptr, &texture, 4); ptr += 4;
2805
2806 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2807 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2808
2809
2810 GLboolean retval;
2811 stream->readback(&retval, 1);
2812 if (useChecksum) checksumCalculator->addBuffer(&retval, 1);
2813 if (useChecksum) {
2814 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2815 stream->readback(checksumBuf.get(), checksumSize);
2816 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2817 ALOGE("glIsTexture: GL communication error, please report this issue to b.android.com.\n");
2818 abort();
2819 }
2820 }
2821 return retval;
2822 }
2823
glLineWidth_enc(void * self,GLfloat width)2824 void glLineWidth_enc(void *self , GLfloat width)
2825 {
2826
2827 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2828 IOStream *stream = ctx->m_stream;
2829 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2830 bool useChecksum = checksumCalculator->getVersion() > 0;
2831
2832 unsigned char *ptr;
2833 unsigned char *buf;
2834 const size_t sizeWithoutChecksum = 8 + 4;
2835 const size_t checksumSize = checksumCalculator->checksumByteSize();
2836 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2837 buf = stream->alloc(totalSize);
2838 ptr = buf;
2839 int tmp = OP_glLineWidth;memcpy(ptr, &tmp, 4); ptr += 4;
2840 memcpy(ptr, &totalSize, 4); ptr += 4;
2841
2842 memcpy(ptr, &width, 4); ptr += 4;
2843
2844 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2845 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2846
2847 }
2848
glLinkProgram_enc(void * self,GLuint program)2849 void glLinkProgram_enc(void *self , GLuint program)
2850 {
2851
2852 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2853 IOStream *stream = ctx->m_stream;
2854 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2855 bool useChecksum = checksumCalculator->getVersion() > 0;
2856
2857 unsigned char *ptr;
2858 unsigned char *buf;
2859 const size_t sizeWithoutChecksum = 8 + 4;
2860 const size_t checksumSize = checksumCalculator->checksumByteSize();
2861 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2862 buf = stream->alloc(totalSize);
2863 ptr = buf;
2864 int tmp = OP_glLinkProgram;memcpy(ptr, &tmp, 4); ptr += 4;
2865 memcpy(ptr, &totalSize, 4); ptr += 4;
2866
2867 memcpy(ptr, &program, 4); ptr += 4;
2868
2869 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2870 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2871
2872 }
2873
glPixelStorei_enc(void * self,GLenum pname,GLint param)2874 void glPixelStorei_enc(void *self , GLenum pname, GLint param)
2875 {
2876
2877 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2878 IOStream *stream = ctx->m_stream;
2879 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2880 bool useChecksum = checksumCalculator->getVersion() > 0;
2881
2882 unsigned char *ptr;
2883 unsigned char *buf;
2884 const size_t sizeWithoutChecksum = 8 + 4 + 4;
2885 const size_t checksumSize = checksumCalculator->checksumByteSize();
2886 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2887 buf = stream->alloc(totalSize);
2888 ptr = buf;
2889 int tmp = OP_glPixelStorei;memcpy(ptr, &tmp, 4); ptr += 4;
2890 memcpy(ptr, &totalSize, 4); ptr += 4;
2891
2892 memcpy(ptr, &pname, 4); ptr += 4;
2893 memcpy(ptr, ¶m, 4); ptr += 4;
2894
2895 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2896 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2897
2898 }
2899
glPolygonOffset_enc(void * self,GLfloat factor,GLfloat units)2900 void glPolygonOffset_enc(void *self , GLfloat factor, GLfloat units)
2901 {
2902
2903 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2904 IOStream *stream = ctx->m_stream;
2905 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2906 bool useChecksum = checksumCalculator->getVersion() > 0;
2907
2908 unsigned char *ptr;
2909 unsigned char *buf;
2910 const size_t sizeWithoutChecksum = 8 + 4 + 4;
2911 const size_t checksumSize = checksumCalculator->checksumByteSize();
2912 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2913 buf = stream->alloc(totalSize);
2914 ptr = buf;
2915 int tmp = OP_glPolygonOffset;memcpy(ptr, &tmp, 4); ptr += 4;
2916 memcpy(ptr, &totalSize, 4); ptr += 4;
2917
2918 memcpy(ptr, &factor, 4); ptr += 4;
2919 memcpy(ptr, &units, 4); ptr += 4;
2920
2921 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2922 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2923
2924 }
2925
glReadPixels_enc(void * self,GLint x,GLint y,GLsizei width,GLsizei height,GLenum format,GLenum type,GLvoid * pixels)2926 void glReadPixels_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
2927 {
2928
2929 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2930 IOStream *stream = ctx->m_stream;
2931 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2932 bool useChecksum = checksumCalculator->getVersion() > 0;
2933
2934 const unsigned int __size_pixels = glesv2_enc::pixelDataSize(self, width, height, format, type, 1);
2935 unsigned char *ptr;
2936 unsigned char *buf;
2937 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4;
2938 const size_t checksumSize = checksumCalculator->checksumByteSize();
2939 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2940 buf = stream->alloc(totalSize);
2941 ptr = buf;
2942 int tmp = OP_glReadPixels;memcpy(ptr, &tmp, 4); ptr += 4;
2943 memcpy(ptr, &totalSize, 4); ptr += 4;
2944
2945 memcpy(ptr, &x, 4); ptr += 4;
2946 memcpy(ptr, &y, 4); ptr += 4;
2947 memcpy(ptr, &width, 4); ptr += 4;
2948 memcpy(ptr, &height, 4); ptr += 4;
2949 memcpy(ptr, &format, 4); ptr += 4;
2950 memcpy(ptr, &type, 4); ptr += 4;
2951 *(unsigned int *)(ptr) = __size_pixels; ptr += 4;
2952
2953 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2954 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2955
2956 stream->readback(pixels, __size_pixels);
2957 if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels);
2958 if (useChecksum) {
2959 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
2960 stream->readback(checksumBuf.get(), checksumSize);
2961 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
2962 ALOGE("glReadPixels: GL communication error, please report this issue to b.android.com.\n");
2963 abort();
2964 }
2965 }
2966 }
2967
glReleaseShaderCompiler_enc(void * self)2968 void glReleaseShaderCompiler_enc(void *self )
2969 {
2970
2971 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2972 IOStream *stream = ctx->m_stream;
2973 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2974 bool useChecksum = checksumCalculator->getVersion() > 0;
2975
2976 unsigned char *ptr;
2977 unsigned char *buf;
2978 const size_t sizeWithoutChecksum = 8;
2979 const size_t checksumSize = checksumCalculator->checksumByteSize();
2980 const size_t totalSize = sizeWithoutChecksum + checksumSize;
2981 buf = stream->alloc(totalSize);
2982 ptr = buf;
2983 int tmp = OP_glReleaseShaderCompiler;memcpy(ptr, &tmp, 4); ptr += 4;
2984 memcpy(ptr, &totalSize, 4); ptr += 4;
2985
2986
2987 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
2988 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
2989
2990 }
2991
glRenderbufferStorage_enc(void * self,GLenum target,GLenum internalformat,GLsizei width,GLsizei height)2992 void glRenderbufferStorage_enc(void *self , GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
2993 {
2994
2995 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
2996 IOStream *stream = ctx->m_stream;
2997 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
2998 bool useChecksum = checksumCalculator->getVersion() > 0;
2999
3000 unsigned char *ptr;
3001 unsigned char *buf;
3002 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4;
3003 const size_t checksumSize = checksumCalculator->checksumByteSize();
3004 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3005 buf = stream->alloc(totalSize);
3006 ptr = buf;
3007 int tmp = OP_glRenderbufferStorage;memcpy(ptr, &tmp, 4); ptr += 4;
3008 memcpy(ptr, &totalSize, 4); ptr += 4;
3009
3010 memcpy(ptr, &target, 4); ptr += 4;
3011 memcpy(ptr, &internalformat, 4); ptr += 4;
3012 memcpy(ptr, &width, 4); ptr += 4;
3013 memcpy(ptr, &height, 4); ptr += 4;
3014
3015 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3016 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3017
3018 }
3019
glSampleCoverage_enc(void * self,GLclampf value,GLboolean invert)3020 void glSampleCoverage_enc(void *self , GLclampf value, GLboolean invert)
3021 {
3022
3023 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3024 IOStream *stream = ctx->m_stream;
3025 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3026 bool useChecksum = checksumCalculator->getVersion() > 0;
3027
3028 unsigned char *ptr;
3029 unsigned char *buf;
3030 const size_t sizeWithoutChecksum = 8 + 4 + 1;
3031 const size_t checksumSize = checksumCalculator->checksumByteSize();
3032 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3033 buf = stream->alloc(totalSize);
3034 ptr = buf;
3035 int tmp = OP_glSampleCoverage;memcpy(ptr, &tmp, 4); ptr += 4;
3036 memcpy(ptr, &totalSize, 4); ptr += 4;
3037
3038 memcpy(ptr, &value, 4); ptr += 4;
3039 memcpy(ptr, &invert, 1); ptr += 1;
3040
3041 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3042 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3043
3044 }
3045
glScissor_enc(void * self,GLint x,GLint y,GLsizei width,GLsizei height)3046 void glScissor_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height)
3047 {
3048
3049 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3050 IOStream *stream = ctx->m_stream;
3051 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3052 bool useChecksum = checksumCalculator->getVersion() > 0;
3053
3054 unsigned char *ptr;
3055 unsigned char *buf;
3056 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4;
3057 const size_t checksumSize = checksumCalculator->checksumByteSize();
3058 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3059 buf = stream->alloc(totalSize);
3060 ptr = buf;
3061 int tmp = OP_glScissor;memcpy(ptr, &tmp, 4); ptr += 4;
3062 memcpy(ptr, &totalSize, 4); ptr += 4;
3063
3064 memcpy(ptr, &x, 4); ptr += 4;
3065 memcpy(ptr, &y, 4); ptr += 4;
3066 memcpy(ptr, &width, 4); ptr += 4;
3067 memcpy(ptr, &height, 4); ptr += 4;
3068
3069 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3070 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3071
3072 }
3073
glStencilFunc_enc(void * self,GLenum func,GLint ref,GLuint mask)3074 void glStencilFunc_enc(void *self , GLenum func, GLint ref, GLuint mask)
3075 {
3076
3077 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3078 IOStream *stream = ctx->m_stream;
3079 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3080 bool useChecksum = checksumCalculator->getVersion() > 0;
3081
3082 unsigned char *ptr;
3083 unsigned char *buf;
3084 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4;
3085 const size_t checksumSize = checksumCalculator->checksumByteSize();
3086 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3087 buf = stream->alloc(totalSize);
3088 ptr = buf;
3089 int tmp = OP_glStencilFunc;memcpy(ptr, &tmp, 4); ptr += 4;
3090 memcpy(ptr, &totalSize, 4); ptr += 4;
3091
3092 memcpy(ptr, &func, 4); ptr += 4;
3093 memcpy(ptr, &ref, 4); ptr += 4;
3094 memcpy(ptr, &mask, 4); ptr += 4;
3095
3096 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3097 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3098
3099 }
3100
glStencilFuncSeparate_enc(void * self,GLenum face,GLenum func,GLint ref,GLuint mask)3101 void glStencilFuncSeparate_enc(void *self , GLenum face, GLenum func, GLint ref, GLuint mask)
3102 {
3103
3104 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3105 IOStream *stream = ctx->m_stream;
3106 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3107 bool useChecksum = checksumCalculator->getVersion() > 0;
3108
3109 unsigned char *ptr;
3110 unsigned char *buf;
3111 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4;
3112 const size_t checksumSize = checksumCalculator->checksumByteSize();
3113 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3114 buf = stream->alloc(totalSize);
3115 ptr = buf;
3116 int tmp = OP_glStencilFuncSeparate;memcpy(ptr, &tmp, 4); ptr += 4;
3117 memcpy(ptr, &totalSize, 4); ptr += 4;
3118
3119 memcpy(ptr, &face, 4); ptr += 4;
3120 memcpy(ptr, &func, 4); ptr += 4;
3121 memcpy(ptr, &ref, 4); ptr += 4;
3122 memcpy(ptr, &mask, 4); ptr += 4;
3123
3124 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3125 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3126
3127 }
3128
glStencilMask_enc(void * self,GLuint mask)3129 void glStencilMask_enc(void *self , GLuint mask)
3130 {
3131
3132 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3133 IOStream *stream = ctx->m_stream;
3134 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3135 bool useChecksum = checksumCalculator->getVersion() > 0;
3136
3137 unsigned char *ptr;
3138 unsigned char *buf;
3139 const size_t sizeWithoutChecksum = 8 + 4;
3140 const size_t checksumSize = checksumCalculator->checksumByteSize();
3141 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3142 buf = stream->alloc(totalSize);
3143 ptr = buf;
3144 int tmp = OP_glStencilMask;memcpy(ptr, &tmp, 4); ptr += 4;
3145 memcpy(ptr, &totalSize, 4); ptr += 4;
3146
3147 memcpy(ptr, &mask, 4); ptr += 4;
3148
3149 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3150 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3151
3152 }
3153
glStencilMaskSeparate_enc(void * self,GLenum face,GLuint mask)3154 void glStencilMaskSeparate_enc(void *self , GLenum face, GLuint mask)
3155 {
3156
3157 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3158 IOStream *stream = ctx->m_stream;
3159 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3160 bool useChecksum = checksumCalculator->getVersion() > 0;
3161
3162 unsigned char *ptr;
3163 unsigned char *buf;
3164 const size_t sizeWithoutChecksum = 8 + 4 + 4;
3165 const size_t checksumSize = checksumCalculator->checksumByteSize();
3166 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3167 buf = stream->alloc(totalSize);
3168 ptr = buf;
3169 int tmp = OP_glStencilMaskSeparate;memcpy(ptr, &tmp, 4); ptr += 4;
3170 memcpy(ptr, &totalSize, 4); ptr += 4;
3171
3172 memcpy(ptr, &face, 4); ptr += 4;
3173 memcpy(ptr, &mask, 4); ptr += 4;
3174
3175 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3176 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3177
3178 }
3179
glStencilOp_enc(void * self,GLenum fail,GLenum zfail,GLenum zpass)3180 void glStencilOp_enc(void *self , GLenum fail, GLenum zfail, GLenum zpass)
3181 {
3182
3183 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3184 IOStream *stream = ctx->m_stream;
3185 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3186 bool useChecksum = checksumCalculator->getVersion() > 0;
3187
3188 unsigned char *ptr;
3189 unsigned char *buf;
3190 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4;
3191 const size_t checksumSize = checksumCalculator->checksumByteSize();
3192 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3193 buf = stream->alloc(totalSize);
3194 ptr = buf;
3195 int tmp = OP_glStencilOp;memcpy(ptr, &tmp, 4); ptr += 4;
3196 memcpy(ptr, &totalSize, 4); ptr += 4;
3197
3198 memcpy(ptr, &fail, 4); ptr += 4;
3199 memcpy(ptr, &zfail, 4); ptr += 4;
3200 memcpy(ptr, &zpass, 4); ptr += 4;
3201
3202 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3203 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3204
3205 }
3206
glStencilOpSeparate_enc(void * self,GLenum face,GLenum fail,GLenum zfail,GLenum zpass)3207 void glStencilOpSeparate_enc(void *self , GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
3208 {
3209
3210 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3211 IOStream *stream = ctx->m_stream;
3212 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3213 bool useChecksum = checksumCalculator->getVersion() > 0;
3214
3215 unsigned char *ptr;
3216 unsigned char *buf;
3217 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4;
3218 const size_t checksumSize = checksumCalculator->checksumByteSize();
3219 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3220 buf = stream->alloc(totalSize);
3221 ptr = buf;
3222 int tmp = OP_glStencilOpSeparate;memcpy(ptr, &tmp, 4); ptr += 4;
3223 memcpy(ptr, &totalSize, 4); ptr += 4;
3224
3225 memcpy(ptr, &face, 4); ptr += 4;
3226 memcpy(ptr, &fail, 4); ptr += 4;
3227 memcpy(ptr, &zfail, 4); ptr += 4;
3228 memcpy(ptr, &zpass, 4); ptr += 4;
3229
3230 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3231 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3232
3233 }
3234
glTexImage2D_enc(void * self,GLenum target,GLint level,GLint internalformat,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,const GLvoid * pixels)3235 void glTexImage2D_enc(void *self , GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
3236 {
3237
3238 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3239 IOStream *stream = ctx->m_stream;
3240 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3241 bool useChecksum = checksumCalculator->getVersion() > 0;
3242
3243 const unsigned int __size_pixels = ((pixels != NULL) ? glesv2_enc::pixelDataSize(self, width, height, format, type, 0) : 0);
3244 unsigned char *ptr;
3245 unsigned char *buf;
3246 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4;
3247 const size_t checksumSize = checksumCalculator->checksumByteSize();
3248 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3249 buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
3250 ptr = buf;
3251 int tmp = OP_glTexImage2D;memcpy(ptr, &tmp, 4); ptr += 4;
3252 memcpy(ptr, &totalSize, 4); ptr += 4;
3253
3254 memcpy(ptr, &target, 4); ptr += 4;
3255 memcpy(ptr, &level, 4); ptr += 4;
3256 memcpy(ptr, &internalformat, 4); ptr += 4;
3257 memcpy(ptr, &width, 4); ptr += 4;
3258 memcpy(ptr, &height, 4); ptr += 4;
3259 memcpy(ptr, &border, 4); ptr += 4;
3260 memcpy(ptr, &format, 4); ptr += 4;
3261 memcpy(ptr, &type, 4); ptr += 4;
3262
3263 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3264 stream->flush();
3265 stream->writeFully(&__size_pixels,4);
3266 if (useChecksum) checksumCalculator->addBuffer(&__size_pixels,4);
3267 if (pixels != NULL) {
3268 stream->writeFully(pixels, __size_pixels);
3269 if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels);
3270 }
3271 buf = stream->alloc(checksumSize);
3272 if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize);
3273
3274 }
3275
glTexParameterf_enc(void * self,GLenum target,GLenum pname,GLfloat param)3276 void glTexParameterf_enc(void *self , GLenum target, GLenum pname, GLfloat param)
3277 {
3278
3279 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3280 IOStream *stream = ctx->m_stream;
3281 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3282 bool useChecksum = checksumCalculator->getVersion() > 0;
3283
3284 unsigned char *ptr;
3285 unsigned char *buf;
3286 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4;
3287 const size_t checksumSize = checksumCalculator->checksumByteSize();
3288 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3289 buf = stream->alloc(totalSize);
3290 ptr = buf;
3291 int tmp = OP_glTexParameterf;memcpy(ptr, &tmp, 4); ptr += 4;
3292 memcpy(ptr, &totalSize, 4); ptr += 4;
3293
3294 memcpy(ptr, &target, 4); ptr += 4;
3295 memcpy(ptr, &pname, 4); ptr += 4;
3296 memcpy(ptr, ¶m, 4); ptr += 4;
3297
3298 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3299 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3300
3301 }
3302
glTexParameterfv_enc(void * self,GLenum target,GLenum pname,const GLfloat * params)3303 void glTexParameterfv_enc(void *self , GLenum target, GLenum pname, const GLfloat* params)
3304 {
3305
3306 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3307 IOStream *stream = ctx->m_stream;
3308 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3309 bool useChecksum = checksumCalculator->getVersion() > 0;
3310
3311 const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat));
3312 unsigned char *ptr;
3313 unsigned char *buf;
3314 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4;
3315 const size_t checksumSize = checksumCalculator->checksumByteSize();
3316 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3317 buf = stream->alloc(totalSize);
3318 ptr = buf;
3319 int tmp = OP_glTexParameterfv;memcpy(ptr, &tmp, 4); ptr += 4;
3320 memcpy(ptr, &totalSize, 4); ptr += 4;
3321
3322 memcpy(ptr, &target, 4); ptr += 4;
3323 memcpy(ptr, &pname, 4); ptr += 4;
3324 *(unsigned int *)(ptr) = __size_params; ptr += 4;
3325 memcpy(ptr, params, __size_params);ptr += __size_params;
3326
3327 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3328 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3329
3330 }
3331
glTexParameteri_enc(void * self,GLenum target,GLenum pname,GLint param)3332 void glTexParameteri_enc(void *self , GLenum target, GLenum pname, GLint param)
3333 {
3334
3335 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3336 IOStream *stream = ctx->m_stream;
3337 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3338 bool useChecksum = checksumCalculator->getVersion() > 0;
3339
3340 unsigned char *ptr;
3341 unsigned char *buf;
3342 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4;
3343 const size_t checksumSize = checksumCalculator->checksumByteSize();
3344 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3345 buf = stream->alloc(totalSize);
3346 ptr = buf;
3347 int tmp = OP_glTexParameteri;memcpy(ptr, &tmp, 4); ptr += 4;
3348 memcpy(ptr, &totalSize, 4); ptr += 4;
3349
3350 memcpy(ptr, &target, 4); ptr += 4;
3351 memcpy(ptr, &pname, 4); ptr += 4;
3352 memcpy(ptr, ¶m, 4); ptr += 4;
3353
3354 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3355 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3356
3357 }
3358
glTexParameteriv_enc(void * self,GLenum target,GLenum pname,const GLint * params)3359 void glTexParameteriv_enc(void *self , GLenum target, GLenum pname, const GLint* params)
3360 {
3361
3362 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3363 IOStream *stream = ctx->m_stream;
3364 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3365 bool useChecksum = checksumCalculator->getVersion() > 0;
3366
3367 const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLint));
3368 unsigned char *ptr;
3369 unsigned char *buf;
3370 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4;
3371 const size_t checksumSize = checksumCalculator->checksumByteSize();
3372 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3373 buf = stream->alloc(totalSize);
3374 ptr = buf;
3375 int tmp = OP_glTexParameteriv;memcpy(ptr, &tmp, 4); ptr += 4;
3376 memcpy(ptr, &totalSize, 4); ptr += 4;
3377
3378 memcpy(ptr, &target, 4); ptr += 4;
3379 memcpy(ptr, &pname, 4); ptr += 4;
3380 *(unsigned int *)(ptr) = __size_params; ptr += 4;
3381 memcpy(ptr, params, __size_params);ptr += __size_params;
3382
3383 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3384 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3385
3386 }
3387
glTexSubImage2D_enc(void * self,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLenum type,const GLvoid * pixels)3388 void glTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels)
3389 {
3390
3391 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3392 IOStream *stream = ctx->m_stream;
3393 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3394 bool useChecksum = checksumCalculator->getVersion() > 0;
3395
3396 const unsigned int __size_pixels = ((pixels != NULL) ? glesv2_enc::pixelDataSize(self, width, height, format, type, 0) : 0);
3397 unsigned char *ptr;
3398 unsigned char *buf;
3399 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4;
3400 const size_t checksumSize = checksumCalculator->checksumByteSize();
3401 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3402 buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
3403 ptr = buf;
3404 int tmp = OP_glTexSubImage2D;memcpy(ptr, &tmp, 4); ptr += 4;
3405 memcpy(ptr, &totalSize, 4); ptr += 4;
3406
3407 memcpy(ptr, &target, 4); ptr += 4;
3408 memcpy(ptr, &level, 4); ptr += 4;
3409 memcpy(ptr, &xoffset, 4); ptr += 4;
3410 memcpy(ptr, &yoffset, 4); ptr += 4;
3411 memcpy(ptr, &width, 4); ptr += 4;
3412 memcpy(ptr, &height, 4); ptr += 4;
3413 memcpy(ptr, &format, 4); ptr += 4;
3414 memcpy(ptr, &type, 4); ptr += 4;
3415
3416 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3417 stream->flush();
3418 stream->writeFully(&__size_pixels,4);
3419 if (useChecksum) checksumCalculator->addBuffer(&__size_pixels,4);
3420 if (pixels != NULL) {
3421 stream->writeFully(pixels, __size_pixels);
3422 if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels);
3423 }
3424 buf = stream->alloc(checksumSize);
3425 if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize);
3426
3427 }
3428
glUniform1f_enc(void * self,GLint location,GLfloat x)3429 void glUniform1f_enc(void *self , GLint location, GLfloat x)
3430 {
3431
3432 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3433 IOStream *stream = ctx->m_stream;
3434 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3435 bool useChecksum = checksumCalculator->getVersion() > 0;
3436
3437 unsigned char *ptr;
3438 unsigned char *buf;
3439 const size_t sizeWithoutChecksum = 8 + 4 + 4;
3440 const size_t checksumSize = checksumCalculator->checksumByteSize();
3441 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3442 buf = stream->alloc(totalSize);
3443 ptr = buf;
3444 int tmp = OP_glUniform1f;memcpy(ptr, &tmp, 4); ptr += 4;
3445 memcpy(ptr, &totalSize, 4); ptr += 4;
3446
3447 memcpy(ptr, &location, 4); ptr += 4;
3448 memcpy(ptr, &x, 4); ptr += 4;
3449
3450 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3451 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3452
3453 }
3454
glUniform1fv_enc(void * self,GLint location,GLsizei count,const GLfloat * v)3455 void glUniform1fv_enc(void *self , GLint location, GLsizei count, const GLfloat* v)
3456 {
3457
3458 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3459 IOStream *stream = ctx->m_stream;
3460 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3461 bool useChecksum = checksumCalculator->getVersion() > 0;
3462
3463 const unsigned int __size_v = (count * sizeof(GLfloat));
3464 unsigned char *ptr;
3465 unsigned char *buf;
3466 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_v + 1*4;
3467 const size_t checksumSize = checksumCalculator->checksumByteSize();
3468 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3469 buf = stream->alloc(totalSize);
3470 ptr = buf;
3471 int tmp = OP_glUniform1fv;memcpy(ptr, &tmp, 4); ptr += 4;
3472 memcpy(ptr, &totalSize, 4); ptr += 4;
3473
3474 memcpy(ptr, &location, 4); ptr += 4;
3475 memcpy(ptr, &count, 4); ptr += 4;
3476 *(unsigned int *)(ptr) = __size_v; ptr += 4;
3477 memcpy(ptr, v, __size_v);ptr += __size_v;
3478
3479 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3480 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3481
3482 }
3483
glUniform1i_enc(void * self,GLint location,GLint x)3484 void glUniform1i_enc(void *self , GLint location, GLint x)
3485 {
3486
3487 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3488 IOStream *stream = ctx->m_stream;
3489 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3490 bool useChecksum = checksumCalculator->getVersion() > 0;
3491
3492 unsigned char *ptr;
3493 unsigned char *buf;
3494 const size_t sizeWithoutChecksum = 8 + 4 + 4;
3495 const size_t checksumSize = checksumCalculator->checksumByteSize();
3496 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3497 buf = stream->alloc(totalSize);
3498 ptr = buf;
3499 int tmp = OP_glUniform1i;memcpy(ptr, &tmp, 4); ptr += 4;
3500 memcpy(ptr, &totalSize, 4); ptr += 4;
3501
3502 memcpy(ptr, &location, 4); ptr += 4;
3503 memcpy(ptr, &x, 4); ptr += 4;
3504
3505 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3506 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3507
3508 }
3509
glUniform1iv_enc(void * self,GLint location,GLsizei count,const GLint * v)3510 void glUniform1iv_enc(void *self , GLint location, GLsizei count, const GLint* v)
3511 {
3512
3513 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3514 IOStream *stream = ctx->m_stream;
3515 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3516 bool useChecksum = checksumCalculator->getVersion() > 0;
3517
3518 const unsigned int __size_v = (count * sizeof(GLint));
3519 unsigned char *ptr;
3520 unsigned char *buf;
3521 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_v + 1*4;
3522 const size_t checksumSize = checksumCalculator->checksumByteSize();
3523 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3524 buf = stream->alloc(totalSize);
3525 ptr = buf;
3526 int tmp = OP_glUniform1iv;memcpy(ptr, &tmp, 4); ptr += 4;
3527 memcpy(ptr, &totalSize, 4); ptr += 4;
3528
3529 memcpy(ptr, &location, 4); ptr += 4;
3530 memcpy(ptr, &count, 4); ptr += 4;
3531 *(unsigned int *)(ptr) = __size_v; ptr += 4;
3532 memcpy(ptr, v, __size_v);ptr += __size_v;
3533
3534 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3535 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3536
3537 }
3538
glUniform2f_enc(void * self,GLint location,GLfloat x,GLfloat y)3539 void glUniform2f_enc(void *self , GLint location, GLfloat x, GLfloat y)
3540 {
3541
3542 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3543 IOStream *stream = ctx->m_stream;
3544 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3545 bool useChecksum = checksumCalculator->getVersion() > 0;
3546
3547 unsigned char *ptr;
3548 unsigned char *buf;
3549 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4;
3550 const size_t checksumSize = checksumCalculator->checksumByteSize();
3551 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3552 buf = stream->alloc(totalSize);
3553 ptr = buf;
3554 int tmp = OP_glUniform2f;memcpy(ptr, &tmp, 4); ptr += 4;
3555 memcpy(ptr, &totalSize, 4); ptr += 4;
3556
3557 memcpy(ptr, &location, 4); ptr += 4;
3558 memcpy(ptr, &x, 4); ptr += 4;
3559 memcpy(ptr, &y, 4); ptr += 4;
3560
3561 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3562 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3563
3564 }
3565
glUniform2fv_enc(void * self,GLint location,GLsizei count,const GLfloat * v)3566 void glUniform2fv_enc(void *self , GLint location, GLsizei count, const GLfloat* v)
3567 {
3568
3569 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3570 IOStream *stream = ctx->m_stream;
3571 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3572 bool useChecksum = checksumCalculator->getVersion() > 0;
3573
3574 const unsigned int __size_v = (count * 2 * sizeof(GLfloat));
3575 unsigned char *ptr;
3576 unsigned char *buf;
3577 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_v + 1*4;
3578 const size_t checksumSize = checksumCalculator->checksumByteSize();
3579 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3580 buf = stream->alloc(totalSize);
3581 ptr = buf;
3582 int tmp = OP_glUniform2fv;memcpy(ptr, &tmp, 4); ptr += 4;
3583 memcpy(ptr, &totalSize, 4); ptr += 4;
3584
3585 memcpy(ptr, &location, 4); ptr += 4;
3586 memcpy(ptr, &count, 4); ptr += 4;
3587 *(unsigned int *)(ptr) = __size_v; ptr += 4;
3588 memcpy(ptr, v, __size_v);ptr += __size_v;
3589
3590 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3591 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3592
3593 }
3594
glUniform2i_enc(void * self,GLint location,GLint x,GLint y)3595 void glUniform2i_enc(void *self , GLint location, GLint x, GLint y)
3596 {
3597
3598 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3599 IOStream *stream = ctx->m_stream;
3600 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3601 bool useChecksum = checksumCalculator->getVersion() > 0;
3602
3603 unsigned char *ptr;
3604 unsigned char *buf;
3605 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4;
3606 const size_t checksumSize = checksumCalculator->checksumByteSize();
3607 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3608 buf = stream->alloc(totalSize);
3609 ptr = buf;
3610 int tmp = OP_glUniform2i;memcpy(ptr, &tmp, 4); ptr += 4;
3611 memcpy(ptr, &totalSize, 4); ptr += 4;
3612
3613 memcpy(ptr, &location, 4); ptr += 4;
3614 memcpy(ptr, &x, 4); ptr += 4;
3615 memcpy(ptr, &y, 4); ptr += 4;
3616
3617 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3618 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3619
3620 }
3621
glUniform2iv_enc(void * self,GLint location,GLsizei count,const GLint * v)3622 void glUniform2iv_enc(void *self , GLint location, GLsizei count, const GLint* v)
3623 {
3624
3625 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3626 IOStream *stream = ctx->m_stream;
3627 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3628 bool useChecksum = checksumCalculator->getVersion() > 0;
3629
3630 const unsigned int __size_v = (count * 2 * sizeof(GLint));
3631 unsigned char *ptr;
3632 unsigned char *buf;
3633 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_v + 1*4;
3634 const size_t checksumSize = checksumCalculator->checksumByteSize();
3635 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3636 buf = stream->alloc(totalSize);
3637 ptr = buf;
3638 int tmp = OP_glUniform2iv;memcpy(ptr, &tmp, 4); ptr += 4;
3639 memcpy(ptr, &totalSize, 4); ptr += 4;
3640
3641 memcpy(ptr, &location, 4); ptr += 4;
3642 memcpy(ptr, &count, 4); ptr += 4;
3643 *(unsigned int *)(ptr) = __size_v; ptr += 4;
3644 memcpy(ptr, v, __size_v);ptr += __size_v;
3645
3646 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3647 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3648
3649 }
3650
glUniform3f_enc(void * self,GLint location,GLfloat x,GLfloat y,GLfloat z)3651 void glUniform3f_enc(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z)
3652 {
3653
3654 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3655 IOStream *stream = ctx->m_stream;
3656 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3657 bool useChecksum = checksumCalculator->getVersion() > 0;
3658
3659 unsigned char *ptr;
3660 unsigned char *buf;
3661 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4;
3662 const size_t checksumSize = checksumCalculator->checksumByteSize();
3663 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3664 buf = stream->alloc(totalSize);
3665 ptr = buf;
3666 int tmp = OP_glUniform3f;memcpy(ptr, &tmp, 4); ptr += 4;
3667 memcpy(ptr, &totalSize, 4); ptr += 4;
3668
3669 memcpy(ptr, &location, 4); ptr += 4;
3670 memcpy(ptr, &x, 4); ptr += 4;
3671 memcpy(ptr, &y, 4); ptr += 4;
3672 memcpy(ptr, &z, 4); ptr += 4;
3673
3674 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3675 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3676
3677 }
3678
glUniform3fv_enc(void * self,GLint location,GLsizei count,const GLfloat * v)3679 void glUniform3fv_enc(void *self , GLint location, GLsizei count, const GLfloat* v)
3680 {
3681
3682 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3683 IOStream *stream = ctx->m_stream;
3684 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3685 bool useChecksum = checksumCalculator->getVersion() > 0;
3686
3687 const unsigned int __size_v = (count * 3 * sizeof(GLfloat));
3688 unsigned char *ptr;
3689 unsigned char *buf;
3690 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_v + 1*4;
3691 const size_t checksumSize = checksumCalculator->checksumByteSize();
3692 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3693 buf = stream->alloc(totalSize);
3694 ptr = buf;
3695 int tmp = OP_glUniform3fv;memcpy(ptr, &tmp, 4); ptr += 4;
3696 memcpy(ptr, &totalSize, 4); ptr += 4;
3697
3698 memcpy(ptr, &location, 4); ptr += 4;
3699 memcpy(ptr, &count, 4); ptr += 4;
3700 *(unsigned int *)(ptr) = __size_v; ptr += 4;
3701 memcpy(ptr, v, __size_v);ptr += __size_v;
3702
3703 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3704 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3705
3706 }
3707
glUniform3i_enc(void * self,GLint location,GLint x,GLint y,GLint z)3708 void glUniform3i_enc(void *self , GLint location, GLint x, GLint y, GLint z)
3709 {
3710
3711 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3712 IOStream *stream = ctx->m_stream;
3713 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3714 bool useChecksum = checksumCalculator->getVersion() > 0;
3715
3716 unsigned char *ptr;
3717 unsigned char *buf;
3718 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4;
3719 const size_t checksumSize = checksumCalculator->checksumByteSize();
3720 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3721 buf = stream->alloc(totalSize);
3722 ptr = buf;
3723 int tmp = OP_glUniform3i;memcpy(ptr, &tmp, 4); ptr += 4;
3724 memcpy(ptr, &totalSize, 4); ptr += 4;
3725
3726 memcpy(ptr, &location, 4); ptr += 4;
3727 memcpy(ptr, &x, 4); ptr += 4;
3728 memcpy(ptr, &y, 4); ptr += 4;
3729 memcpy(ptr, &z, 4); ptr += 4;
3730
3731 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3732 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3733
3734 }
3735
glUniform3iv_enc(void * self,GLint location,GLsizei count,const GLint * v)3736 void glUniform3iv_enc(void *self , GLint location, GLsizei count, const GLint* v)
3737 {
3738
3739 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3740 IOStream *stream = ctx->m_stream;
3741 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3742 bool useChecksum = checksumCalculator->getVersion() > 0;
3743
3744 const unsigned int __size_v = (3 * count * sizeof(GLint));
3745 unsigned char *ptr;
3746 unsigned char *buf;
3747 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_v + 1*4;
3748 const size_t checksumSize = checksumCalculator->checksumByteSize();
3749 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3750 buf = stream->alloc(totalSize);
3751 ptr = buf;
3752 int tmp = OP_glUniform3iv;memcpy(ptr, &tmp, 4); ptr += 4;
3753 memcpy(ptr, &totalSize, 4); ptr += 4;
3754
3755 memcpy(ptr, &location, 4); ptr += 4;
3756 memcpy(ptr, &count, 4); ptr += 4;
3757 *(unsigned int *)(ptr) = __size_v; ptr += 4;
3758 memcpy(ptr, v, __size_v);ptr += __size_v;
3759
3760 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3761 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3762
3763 }
3764
glUniform4f_enc(void * self,GLint location,GLfloat x,GLfloat y,GLfloat z,GLfloat w)3765 void glUniform4f_enc(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
3766 {
3767
3768 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3769 IOStream *stream = ctx->m_stream;
3770 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3771 bool useChecksum = checksumCalculator->getVersion() > 0;
3772
3773 unsigned char *ptr;
3774 unsigned char *buf;
3775 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4;
3776 const size_t checksumSize = checksumCalculator->checksumByteSize();
3777 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3778 buf = stream->alloc(totalSize);
3779 ptr = buf;
3780 int tmp = OP_glUniform4f;memcpy(ptr, &tmp, 4); ptr += 4;
3781 memcpy(ptr, &totalSize, 4); ptr += 4;
3782
3783 memcpy(ptr, &location, 4); ptr += 4;
3784 memcpy(ptr, &x, 4); ptr += 4;
3785 memcpy(ptr, &y, 4); ptr += 4;
3786 memcpy(ptr, &z, 4); ptr += 4;
3787 memcpy(ptr, &w, 4); ptr += 4;
3788
3789 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3790 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3791
3792 }
3793
glUniform4fv_enc(void * self,GLint location,GLsizei count,const GLfloat * v)3794 void glUniform4fv_enc(void *self , GLint location, GLsizei count, const GLfloat* v)
3795 {
3796
3797 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3798 IOStream *stream = ctx->m_stream;
3799 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3800 bool useChecksum = checksumCalculator->getVersion() > 0;
3801
3802 const unsigned int __size_v = (4 * count * sizeof(GLfloat));
3803 unsigned char *ptr;
3804 unsigned char *buf;
3805 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_v + 1*4;
3806 const size_t checksumSize = checksumCalculator->checksumByteSize();
3807 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3808 buf = stream->alloc(totalSize);
3809 ptr = buf;
3810 int tmp = OP_glUniform4fv;memcpy(ptr, &tmp, 4); ptr += 4;
3811 memcpy(ptr, &totalSize, 4); ptr += 4;
3812
3813 memcpy(ptr, &location, 4); ptr += 4;
3814 memcpy(ptr, &count, 4); ptr += 4;
3815 *(unsigned int *)(ptr) = __size_v; ptr += 4;
3816 memcpy(ptr, v, __size_v);ptr += __size_v;
3817
3818 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3819 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3820
3821 }
3822
glUniform4i_enc(void * self,GLint location,GLint x,GLint y,GLint z,GLint w)3823 void glUniform4i_enc(void *self , GLint location, GLint x, GLint y, GLint z, GLint w)
3824 {
3825
3826 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3827 IOStream *stream = ctx->m_stream;
3828 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3829 bool useChecksum = checksumCalculator->getVersion() > 0;
3830
3831 unsigned char *ptr;
3832 unsigned char *buf;
3833 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4;
3834 const size_t checksumSize = checksumCalculator->checksumByteSize();
3835 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3836 buf = stream->alloc(totalSize);
3837 ptr = buf;
3838 int tmp = OP_glUniform4i;memcpy(ptr, &tmp, 4); ptr += 4;
3839 memcpy(ptr, &totalSize, 4); ptr += 4;
3840
3841 memcpy(ptr, &location, 4); ptr += 4;
3842 memcpy(ptr, &x, 4); ptr += 4;
3843 memcpy(ptr, &y, 4); ptr += 4;
3844 memcpy(ptr, &z, 4); ptr += 4;
3845 memcpy(ptr, &w, 4); ptr += 4;
3846
3847 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3848 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3849
3850 }
3851
glUniform4iv_enc(void * self,GLint location,GLsizei count,const GLint * v)3852 void glUniform4iv_enc(void *self , GLint location, GLsizei count, const GLint* v)
3853 {
3854
3855 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3856 IOStream *stream = ctx->m_stream;
3857 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3858 bool useChecksum = checksumCalculator->getVersion() > 0;
3859
3860 const unsigned int __size_v = (4 * count * sizeof(GLint));
3861 unsigned char *ptr;
3862 unsigned char *buf;
3863 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_v + 1*4;
3864 const size_t checksumSize = checksumCalculator->checksumByteSize();
3865 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3866 buf = stream->alloc(totalSize);
3867 ptr = buf;
3868 int tmp = OP_glUniform4iv;memcpy(ptr, &tmp, 4); ptr += 4;
3869 memcpy(ptr, &totalSize, 4); ptr += 4;
3870
3871 memcpy(ptr, &location, 4); ptr += 4;
3872 memcpy(ptr, &count, 4); ptr += 4;
3873 *(unsigned int *)(ptr) = __size_v; ptr += 4;
3874 memcpy(ptr, v, __size_v);ptr += __size_v;
3875
3876 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3877 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3878
3879 }
3880
glUniformMatrix2fv_enc(void * self,GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)3881 void glUniformMatrix2fv_enc(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
3882 {
3883
3884 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3885 IOStream *stream = ctx->m_stream;
3886 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3887 bool useChecksum = checksumCalculator->getVersion() > 0;
3888
3889 const unsigned int __size_value = (count * 4 * sizeof(GLfloat));
3890 unsigned char *ptr;
3891 unsigned char *buf;
3892 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 1 + __size_value + 1*4;
3893 const size_t checksumSize = checksumCalculator->checksumByteSize();
3894 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3895 buf = stream->alloc(totalSize);
3896 ptr = buf;
3897 int tmp = OP_glUniformMatrix2fv;memcpy(ptr, &tmp, 4); ptr += 4;
3898 memcpy(ptr, &totalSize, 4); ptr += 4;
3899
3900 memcpy(ptr, &location, 4); ptr += 4;
3901 memcpy(ptr, &count, 4); ptr += 4;
3902 memcpy(ptr, &transpose, 1); ptr += 1;
3903 *(unsigned int *)(ptr) = __size_value; ptr += 4;
3904 memcpy(ptr, value, __size_value);ptr += __size_value;
3905
3906 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3907 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3908
3909 }
3910
glUniformMatrix3fv_enc(void * self,GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)3911 void glUniformMatrix3fv_enc(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
3912 {
3913
3914 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3915 IOStream *stream = ctx->m_stream;
3916 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3917 bool useChecksum = checksumCalculator->getVersion() > 0;
3918
3919 const unsigned int __size_value = (count * 9 * sizeof(GLfloat));
3920 unsigned char *ptr;
3921 unsigned char *buf;
3922 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 1 + __size_value + 1*4;
3923 const size_t checksumSize = checksumCalculator->checksumByteSize();
3924 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3925 buf = stream->alloc(totalSize);
3926 ptr = buf;
3927 int tmp = OP_glUniformMatrix3fv;memcpy(ptr, &tmp, 4); ptr += 4;
3928 memcpy(ptr, &totalSize, 4); ptr += 4;
3929
3930 memcpy(ptr, &location, 4); ptr += 4;
3931 memcpy(ptr, &count, 4); ptr += 4;
3932 memcpy(ptr, &transpose, 1); ptr += 1;
3933 *(unsigned int *)(ptr) = __size_value; ptr += 4;
3934 memcpy(ptr, value, __size_value);ptr += __size_value;
3935
3936 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3937 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3938
3939 }
3940
glUniformMatrix4fv_enc(void * self,GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)3941 void glUniformMatrix4fv_enc(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
3942 {
3943
3944 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3945 IOStream *stream = ctx->m_stream;
3946 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3947 bool useChecksum = checksumCalculator->getVersion() > 0;
3948
3949 const unsigned int __size_value = (count * 16 * sizeof(GLfloat));
3950 unsigned char *ptr;
3951 unsigned char *buf;
3952 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 1 + __size_value + 1*4;
3953 const size_t checksumSize = checksumCalculator->checksumByteSize();
3954 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3955 buf = stream->alloc(totalSize);
3956 ptr = buf;
3957 int tmp = OP_glUniformMatrix4fv;memcpy(ptr, &tmp, 4); ptr += 4;
3958 memcpy(ptr, &totalSize, 4); ptr += 4;
3959
3960 memcpy(ptr, &location, 4); ptr += 4;
3961 memcpy(ptr, &count, 4); ptr += 4;
3962 memcpy(ptr, &transpose, 1); ptr += 1;
3963 *(unsigned int *)(ptr) = __size_value; ptr += 4;
3964 memcpy(ptr, value, __size_value);ptr += __size_value;
3965
3966 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3967 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3968
3969 }
3970
glUseProgram_enc(void * self,GLuint program)3971 void glUseProgram_enc(void *self , GLuint program)
3972 {
3973
3974 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
3975 IOStream *stream = ctx->m_stream;
3976 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
3977 bool useChecksum = checksumCalculator->getVersion() > 0;
3978
3979 unsigned char *ptr;
3980 unsigned char *buf;
3981 const size_t sizeWithoutChecksum = 8 + 4;
3982 const size_t checksumSize = checksumCalculator->checksumByteSize();
3983 const size_t totalSize = sizeWithoutChecksum + checksumSize;
3984 buf = stream->alloc(totalSize);
3985 ptr = buf;
3986 int tmp = OP_glUseProgram;memcpy(ptr, &tmp, 4); ptr += 4;
3987 memcpy(ptr, &totalSize, 4); ptr += 4;
3988
3989 memcpy(ptr, &program, 4); ptr += 4;
3990
3991 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
3992 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
3993
3994 }
3995
glValidateProgram_enc(void * self,GLuint program)3996 void glValidateProgram_enc(void *self , GLuint program)
3997 {
3998
3999 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4000 IOStream *stream = ctx->m_stream;
4001 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4002 bool useChecksum = checksumCalculator->getVersion() > 0;
4003
4004 unsigned char *ptr;
4005 unsigned char *buf;
4006 const size_t sizeWithoutChecksum = 8 + 4;
4007 const size_t checksumSize = checksumCalculator->checksumByteSize();
4008 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4009 buf = stream->alloc(totalSize);
4010 ptr = buf;
4011 int tmp = OP_glValidateProgram;memcpy(ptr, &tmp, 4); ptr += 4;
4012 memcpy(ptr, &totalSize, 4); ptr += 4;
4013
4014 memcpy(ptr, &program, 4); ptr += 4;
4015
4016 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4017 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4018
4019 }
4020
glVertexAttrib1f_enc(void * self,GLuint indx,GLfloat x)4021 void glVertexAttrib1f_enc(void *self , GLuint indx, GLfloat x)
4022 {
4023
4024 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4025 IOStream *stream = ctx->m_stream;
4026 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4027 bool useChecksum = checksumCalculator->getVersion() > 0;
4028
4029 unsigned char *ptr;
4030 unsigned char *buf;
4031 const size_t sizeWithoutChecksum = 8 + 4 + 4;
4032 const size_t checksumSize = checksumCalculator->checksumByteSize();
4033 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4034 buf = stream->alloc(totalSize);
4035 ptr = buf;
4036 int tmp = OP_glVertexAttrib1f;memcpy(ptr, &tmp, 4); ptr += 4;
4037 memcpy(ptr, &totalSize, 4); ptr += 4;
4038
4039 memcpy(ptr, &indx, 4); ptr += 4;
4040 memcpy(ptr, &x, 4); ptr += 4;
4041
4042 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4043 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4044
4045 }
4046
glVertexAttrib1fv_enc(void * self,GLuint indx,const GLfloat * values)4047 void glVertexAttrib1fv_enc(void *self , GLuint indx, const GLfloat* values)
4048 {
4049
4050 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4051 IOStream *stream = ctx->m_stream;
4052 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4053 bool useChecksum = checksumCalculator->getVersion() > 0;
4054
4055 const unsigned int __size_values = (sizeof(GLfloat));
4056 unsigned char *ptr;
4057 unsigned char *buf;
4058 const size_t sizeWithoutChecksum = 8 + 4 + __size_values + 1*4;
4059 const size_t checksumSize = checksumCalculator->checksumByteSize();
4060 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4061 buf = stream->alloc(totalSize);
4062 ptr = buf;
4063 int tmp = OP_glVertexAttrib1fv;memcpy(ptr, &tmp, 4); ptr += 4;
4064 memcpy(ptr, &totalSize, 4); ptr += 4;
4065
4066 memcpy(ptr, &indx, 4); ptr += 4;
4067 *(unsigned int *)(ptr) = __size_values; ptr += 4;
4068 memcpy(ptr, values, __size_values);ptr += __size_values;
4069
4070 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4071 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4072
4073 }
4074
glVertexAttrib2f_enc(void * self,GLuint indx,GLfloat x,GLfloat y)4075 void glVertexAttrib2f_enc(void *self , GLuint indx, GLfloat x, GLfloat y)
4076 {
4077
4078 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4079 IOStream *stream = ctx->m_stream;
4080 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4081 bool useChecksum = checksumCalculator->getVersion() > 0;
4082
4083 unsigned char *ptr;
4084 unsigned char *buf;
4085 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4;
4086 const size_t checksumSize = checksumCalculator->checksumByteSize();
4087 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4088 buf = stream->alloc(totalSize);
4089 ptr = buf;
4090 int tmp = OP_glVertexAttrib2f;memcpy(ptr, &tmp, 4); ptr += 4;
4091 memcpy(ptr, &totalSize, 4); ptr += 4;
4092
4093 memcpy(ptr, &indx, 4); ptr += 4;
4094 memcpy(ptr, &x, 4); ptr += 4;
4095 memcpy(ptr, &y, 4); ptr += 4;
4096
4097 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4098 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4099
4100 }
4101
glVertexAttrib2fv_enc(void * self,GLuint indx,const GLfloat * values)4102 void glVertexAttrib2fv_enc(void *self , GLuint indx, const GLfloat* values)
4103 {
4104
4105 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4106 IOStream *stream = ctx->m_stream;
4107 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4108 bool useChecksum = checksumCalculator->getVersion() > 0;
4109
4110 const unsigned int __size_values = (2 * sizeof(GLfloat));
4111 unsigned char *ptr;
4112 unsigned char *buf;
4113 const size_t sizeWithoutChecksum = 8 + 4 + __size_values + 1*4;
4114 const size_t checksumSize = checksumCalculator->checksumByteSize();
4115 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4116 buf = stream->alloc(totalSize);
4117 ptr = buf;
4118 int tmp = OP_glVertexAttrib2fv;memcpy(ptr, &tmp, 4); ptr += 4;
4119 memcpy(ptr, &totalSize, 4); ptr += 4;
4120
4121 memcpy(ptr, &indx, 4); ptr += 4;
4122 *(unsigned int *)(ptr) = __size_values; ptr += 4;
4123 memcpy(ptr, values, __size_values);ptr += __size_values;
4124
4125 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4126 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4127
4128 }
4129
glVertexAttrib3f_enc(void * self,GLuint indx,GLfloat x,GLfloat y,GLfloat z)4130 void glVertexAttrib3f_enc(void *self , GLuint indx, GLfloat x, GLfloat y, GLfloat z)
4131 {
4132
4133 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4134 IOStream *stream = ctx->m_stream;
4135 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4136 bool useChecksum = checksumCalculator->getVersion() > 0;
4137
4138 unsigned char *ptr;
4139 unsigned char *buf;
4140 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4;
4141 const size_t checksumSize = checksumCalculator->checksumByteSize();
4142 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4143 buf = stream->alloc(totalSize);
4144 ptr = buf;
4145 int tmp = OP_glVertexAttrib3f;memcpy(ptr, &tmp, 4); ptr += 4;
4146 memcpy(ptr, &totalSize, 4); ptr += 4;
4147
4148 memcpy(ptr, &indx, 4); ptr += 4;
4149 memcpy(ptr, &x, 4); ptr += 4;
4150 memcpy(ptr, &y, 4); ptr += 4;
4151 memcpy(ptr, &z, 4); ptr += 4;
4152
4153 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4154 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4155
4156 }
4157
glVertexAttrib3fv_enc(void * self,GLuint indx,const GLfloat * values)4158 void glVertexAttrib3fv_enc(void *self , GLuint indx, const GLfloat* values)
4159 {
4160
4161 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4162 IOStream *stream = ctx->m_stream;
4163 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4164 bool useChecksum = checksumCalculator->getVersion() > 0;
4165
4166 const unsigned int __size_values = (3 * sizeof(GLfloat));
4167 unsigned char *ptr;
4168 unsigned char *buf;
4169 const size_t sizeWithoutChecksum = 8 + 4 + __size_values + 1*4;
4170 const size_t checksumSize = checksumCalculator->checksumByteSize();
4171 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4172 buf = stream->alloc(totalSize);
4173 ptr = buf;
4174 int tmp = OP_glVertexAttrib3fv;memcpy(ptr, &tmp, 4); ptr += 4;
4175 memcpy(ptr, &totalSize, 4); ptr += 4;
4176
4177 memcpy(ptr, &indx, 4); ptr += 4;
4178 *(unsigned int *)(ptr) = __size_values; ptr += 4;
4179 memcpy(ptr, values, __size_values);ptr += __size_values;
4180
4181 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4182 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4183
4184 }
4185
glVertexAttrib4f_enc(void * self,GLuint indx,GLfloat x,GLfloat y,GLfloat z,GLfloat w)4186 void glVertexAttrib4f_enc(void *self , GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4187 {
4188
4189 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4190 IOStream *stream = ctx->m_stream;
4191 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4192 bool useChecksum = checksumCalculator->getVersion() > 0;
4193
4194 unsigned char *ptr;
4195 unsigned char *buf;
4196 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4;
4197 const size_t checksumSize = checksumCalculator->checksumByteSize();
4198 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4199 buf = stream->alloc(totalSize);
4200 ptr = buf;
4201 int tmp = OP_glVertexAttrib4f;memcpy(ptr, &tmp, 4); ptr += 4;
4202 memcpy(ptr, &totalSize, 4); ptr += 4;
4203
4204 memcpy(ptr, &indx, 4); ptr += 4;
4205 memcpy(ptr, &x, 4); ptr += 4;
4206 memcpy(ptr, &y, 4); ptr += 4;
4207 memcpy(ptr, &z, 4); ptr += 4;
4208 memcpy(ptr, &w, 4); ptr += 4;
4209
4210 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4211 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4212
4213 }
4214
glVertexAttrib4fv_enc(void * self,GLuint indx,const GLfloat * values)4215 void glVertexAttrib4fv_enc(void *self , GLuint indx, const GLfloat* values)
4216 {
4217
4218 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4219 IOStream *stream = ctx->m_stream;
4220 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4221 bool useChecksum = checksumCalculator->getVersion() > 0;
4222
4223 const unsigned int __size_values = (4 * sizeof(GLfloat));
4224 unsigned char *ptr;
4225 unsigned char *buf;
4226 const size_t sizeWithoutChecksum = 8 + 4 + __size_values + 1*4;
4227 const size_t checksumSize = checksumCalculator->checksumByteSize();
4228 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4229 buf = stream->alloc(totalSize);
4230 ptr = buf;
4231 int tmp = OP_glVertexAttrib4fv;memcpy(ptr, &tmp, 4); ptr += 4;
4232 memcpy(ptr, &totalSize, 4); ptr += 4;
4233
4234 memcpy(ptr, &indx, 4); ptr += 4;
4235 *(unsigned int *)(ptr) = __size_values; ptr += 4;
4236 memcpy(ptr, values, __size_values);ptr += __size_values;
4237
4238 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4239 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4240
4241 }
4242
glViewport_enc(void * self,GLint x,GLint y,GLsizei width,GLsizei height)4243 void glViewport_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height)
4244 {
4245
4246 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4247 IOStream *stream = ctx->m_stream;
4248 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4249 bool useChecksum = checksumCalculator->getVersion() > 0;
4250
4251 unsigned char *ptr;
4252 unsigned char *buf;
4253 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4;
4254 const size_t checksumSize = checksumCalculator->checksumByteSize();
4255 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4256 buf = stream->alloc(totalSize);
4257 ptr = buf;
4258 int tmp = OP_glViewport;memcpy(ptr, &tmp, 4); ptr += 4;
4259 memcpy(ptr, &totalSize, 4); ptr += 4;
4260
4261 memcpy(ptr, &x, 4); ptr += 4;
4262 memcpy(ptr, &y, 4); ptr += 4;
4263 memcpy(ptr, &width, 4); ptr += 4;
4264 memcpy(ptr, &height, 4); ptr += 4;
4265
4266 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4267 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4268
4269 }
4270
glEGLImageTargetTexture2DOES_enc(void * self,GLenum target,GLeglImageOES image)4271 void glEGLImageTargetTexture2DOES_enc(void *self , GLenum target, GLeglImageOES image)
4272 {
4273
4274 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4275 IOStream *stream = ctx->m_stream;
4276 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4277 bool useChecksum = checksumCalculator->getVersion() > 0;
4278
4279 unsigned char *ptr;
4280 unsigned char *buf;
4281 const size_t sizeWithoutChecksum = 8 + 4 + 4;
4282 const size_t checksumSize = checksumCalculator->checksumByteSize();
4283 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4284 buf = stream->alloc(totalSize);
4285 ptr = buf;
4286 int tmp = OP_glEGLImageTargetTexture2DOES;memcpy(ptr, &tmp, 4); ptr += 4;
4287 memcpy(ptr, &totalSize, 4); ptr += 4;
4288
4289 memcpy(ptr, &target, 4); ptr += 4;
4290 memcpy(ptr, &image, 4); ptr += 4;
4291
4292 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4293 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4294
4295 }
4296
glEGLImageTargetRenderbufferStorageOES_enc(void * self,GLenum target,GLeglImageOES image)4297 void glEGLImageTargetRenderbufferStorageOES_enc(void *self , GLenum target, GLeglImageOES image)
4298 {
4299
4300 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4301 IOStream *stream = ctx->m_stream;
4302 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4303 bool useChecksum = checksumCalculator->getVersion() > 0;
4304
4305 unsigned char *ptr;
4306 unsigned char *buf;
4307 const size_t sizeWithoutChecksum = 8 + 4 + 4;
4308 const size_t checksumSize = checksumCalculator->checksumByteSize();
4309 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4310 buf = stream->alloc(totalSize);
4311 ptr = buf;
4312 int tmp = OP_glEGLImageTargetRenderbufferStorageOES;memcpy(ptr, &tmp, 4); ptr += 4;
4313 memcpy(ptr, &totalSize, 4); ptr += 4;
4314
4315 memcpy(ptr, &target, 4); ptr += 4;
4316 memcpy(ptr, &image, 4); ptr += 4;
4317
4318 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4319 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4320
4321 }
4322
glUnmapBufferOES_enc(void * self,GLenum target)4323 GLboolean glUnmapBufferOES_enc(void *self , GLenum target)
4324 {
4325
4326 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4327 IOStream *stream = ctx->m_stream;
4328 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4329 bool useChecksum = checksumCalculator->getVersion() > 0;
4330
4331 unsigned char *ptr;
4332 unsigned char *buf;
4333 const size_t sizeWithoutChecksum = 8 + 4;
4334 const size_t checksumSize = checksumCalculator->checksumByteSize();
4335 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4336 buf = stream->alloc(totalSize);
4337 ptr = buf;
4338 int tmp = OP_glUnmapBufferOES;memcpy(ptr, &tmp, 4); ptr += 4;
4339 memcpy(ptr, &totalSize, 4); ptr += 4;
4340
4341 memcpy(ptr, &target, 4); ptr += 4;
4342
4343 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4344 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4345
4346
4347 GLboolean retval;
4348 stream->readback(&retval, 1);
4349 if (useChecksum) checksumCalculator->addBuffer(&retval, 1);
4350 if (useChecksum) {
4351 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
4352 stream->readback(checksumBuf.get(), checksumSize);
4353 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
4354 ALOGE("glUnmapBufferOES: GL communication error, please report this issue to b.android.com.\n");
4355 abort();
4356 }
4357 }
4358 return retval;
4359 }
4360
glTexImage3DOES_enc(void * self,GLenum target,GLint level,GLenum internalformat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLenum format,GLenum type,const GLvoid * pixels)4361 void glTexImage3DOES_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
4362 {
4363
4364 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4365 IOStream *stream = ctx->m_stream;
4366 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4367 bool useChecksum = checksumCalculator->getVersion() > 0;
4368
4369 const unsigned int __size_pixels = ((pixels != NULL) ? glesv2_enc::pixelDataSize3D(self, width, height, depth, format, type, 0) : 0);
4370 unsigned char *ptr;
4371 unsigned char *buf;
4372 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4;
4373 const size_t checksumSize = checksumCalculator->checksumByteSize();
4374 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4375 buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
4376 ptr = buf;
4377 int tmp = OP_glTexImage3DOES;memcpy(ptr, &tmp, 4); ptr += 4;
4378 memcpy(ptr, &totalSize, 4); ptr += 4;
4379
4380 memcpy(ptr, &target, 4); ptr += 4;
4381 memcpy(ptr, &level, 4); ptr += 4;
4382 memcpy(ptr, &internalformat, 4); ptr += 4;
4383 memcpy(ptr, &width, 4); ptr += 4;
4384 memcpy(ptr, &height, 4); ptr += 4;
4385 memcpy(ptr, &depth, 4); ptr += 4;
4386 memcpy(ptr, &border, 4); ptr += 4;
4387 memcpy(ptr, &format, 4); ptr += 4;
4388 memcpy(ptr, &type, 4); ptr += 4;
4389
4390 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4391 stream->flush();
4392 stream->writeFully(&__size_pixels,4);
4393 if (useChecksum) checksumCalculator->addBuffer(&__size_pixels,4);
4394 if (pixels != NULL) {
4395 stream->writeFully(pixels, __size_pixels);
4396 if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels);
4397 }
4398 buf = stream->alloc(checksumSize);
4399 if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize);
4400
4401 }
4402
glTexSubImage3DOES_enc(void * self,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLenum type,const GLvoid * pixels)4403 void glTexSubImage3DOES_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
4404 {
4405
4406 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4407 IOStream *stream = ctx->m_stream;
4408 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4409 bool useChecksum = checksumCalculator->getVersion() > 0;
4410
4411 const unsigned int __size_pixels = ((pixels != NULL) ? glesv2_enc::pixelDataSize3D(self, width, height, depth, format, type, 0) : 0);
4412 unsigned char *ptr;
4413 unsigned char *buf;
4414 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4;
4415 const size_t checksumSize = checksumCalculator->checksumByteSize();
4416 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4417 buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
4418 ptr = buf;
4419 int tmp = OP_glTexSubImage3DOES;memcpy(ptr, &tmp, 4); ptr += 4;
4420 memcpy(ptr, &totalSize, 4); ptr += 4;
4421
4422 memcpy(ptr, &target, 4); ptr += 4;
4423 memcpy(ptr, &level, 4); ptr += 4;
4424 memcpy(ptr, &xoffset, 4); ptr += 4;
4425 memcpy(ptr, &yoffset, 4); ptr += 4;
4426 memcpy(ptr, &zoffset, 4); ptr += 4;
4427 memcpy(ptr, &width, 4); ptr += 4;
4428 memcpy(ptr, &height, 4); ptr += 4;
4429 memcpy(ptr, &depth, 4); ptr += 4;
4430 memcpy(ptr, &format, 4); ptr += 4;
4431 memcpy(ptr, &type, 4); ptr += 4;
4432
4433 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4434 stream->flush();
4435 stream->writeFully(&__size_pixels,4);
4436 if (useChecksum) checksumCalculator->addBuffer(&__size_pixels,4);
4437 if (pixels != NULL) {
4438 stream->writeFully(pixels, __size_pixels);
4439 if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels);
4440 }
4441 buf = stream->alloc(checksumSize);
4442 if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize);
4443
4444 }
4445
glCopyTexSubImage3DOES_enc(void * self,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLint x,GLint y,GLsizei width,GLsizei height)4446 void glCopyTexSubImage3DOES_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
4447 {
4448
4449 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4450 IOStream *stream = ctx->m_stream;
4451 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4452 bool useChecksum = checksumCalculator->getVersion() > 0;
4453
4454 unsigned char *ptr;
4455 unsigned char *buf;
4456 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4;
4457 const size_t checksumSize = checksumCalculator->checksumByteSize();
4458 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4459 buf = stream->alloc(totalSize);
4460 ptr = buf;
4461 int tmp = OP_glCopyTexSubImage3DOES;memcpy(ptr, &tmp, 4); ptr += 4;
4462 memcpy(ptr, &totalSize, 4); ptr += 4;
4463
4464 memcpy(ptr, &target, 4); ptr += 4;
4465 memcpy(ptr, &level, 4); ptr += 4;
4466 memcpy(ptr, &xoffset, 4); ptr += 4;
4467 memcpy(ptr, &yoffset, 4); ptr += 4;
4468 memcpy(ptr, &zoffset, 4); ptr += 4;
4469 memcpy(ptr, &x, 4); ptr += 4;
4470 memcpy(ptr, &y, 4); ptr += 4;
4471 memcpy(ptr, &width, 4); ptr += 4;
4472 memcpy(ptr, &height, 4); ptr += 4;
4473
4474 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4475 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4476
4477 }
4478
glCompressedTexImage3DOES_enc(void * self,GLenum target,GLint level,GLenum internalformat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLsizei imageSize,const GLvoid * data)4479 void glCompressedTexImage3DOES_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
4480 {
4481
4482 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4483 IOStream *stream = ctx->m_stream;
4484 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4485 bool useChecksum = checksumCalculator->getVersion() > 0;
4486
4487 const unsigned int __size_data = ((data != NULL) ? imageSize : 0);
4488 unsigned char *ptr;
4489 unsigned char *buf;
4490 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_data + 1*4;
4491 const size_t checksumSize = checksumCalculator->checksumByteSize();
4492 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4493 buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
4494 ptr = buf;
4495 int tmp = OP_glCompressedTexImage3DOES;memcpy(ptr, &tmp, 4); ptr += 4;
4496 memcpy(ptr, &totalSize, 4); ptr += 4;
4497
4498 memcpy(ptr, &target, 4); ptr += 4;
4499 memcpy(ptr, &level, 4); ptr += 4;
4500 memcpy(ptr, &internalformat, 4); ptr += 4;
4501 memcpy(ptr, &width, 4); ptr += 4;
4502 memcpy(ptr, &height, 4); ptr += 4;
4503 memcpy(ptr, &depth, 4); ptr += 4;
4504 memcpy(ptr, &border, 4); ptr += 4;
4505 memcpy(ptr, &imageSize, 4); ptr += 4;
4506
4507 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4508 stream->flush();
4509 stream->writeFully(&__size_data,4);
4510 if (useChecksum) checksumCalculator->addBuffer(&__size_data,4);
4511 if (data != NULL) {
4512 stream->writeFully(data, __size_data);
4513 if (useChecksum) checksumCalculator->addBuffer(data, __size_data);
4514 }
4515 buf = stream->alloc(checksumSize);
4516 if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize);
4517
4518 }
4519
glCompressedTexSubImage3DOES_enc(void * self,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLsizei imageSize,const GLvoid * data)4520 void glCompressedTexSubImage3DOES_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
4521 {
4522
4523 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4524 IOStream *stream = ctx->m_stream;
4525 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4526 bool useChecksum = checksumCalculator->getVersion() > 0;
4527
4528 const unsigned int __size_data = ((data != NULL) ? imageSize : 0);
4529 unsigned char *ptr;
4530 unsigned char *buf;
4531 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_data + 1*4;
4532 const size_t checksumSize = checksumCalculator->checksumByteSize();
4533 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4534 buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
4535 ptr = buf;
4536 int tmp = OP_glCompressedTexSubImage3DOES;memcpy(ptr, &tmp, 4); ptr += 4;
4537 memcpy(ptr, &totalSize, 4); ptr += 4;
4538
4539 memcpy(ptr, &target, 4); ptr += 4;
4540 memcpy(ptr, &level, 4); ptr += 4;
4541 memcpy(ptr, &xoffset, 4); ptr += 4;
4542 memcpy(ptr, &yoffset, 4); ptr += 4;
4543 memcpy(ptr, &zoffset, 4); ptr += 4;
4544 memcpy(ptr, &width, 4); ptr += 4;
4545 memcpy(ptr, &height, 4); ptr += 4;
4546 memcpy(ptr, &depth, 4); ptr += 4;
4547 memcpy(ptr, &format, 4); ptr += 4;
4548 memcpy(ptr, &imageSize, 4); ptr += 4;
4549
4550 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4551 stream->flush();
4552 stream->writeFully(&__size_data,4);
4553 if (useChecksum) checksumCalculator->addBuffer(&__size_data,4);
4554 if (data != NULL) {
4555 stream->writeFully(data, __size_data);
4556 if (useChecksum) checksumCalculator->addBuffer(data, __size_data);
4557 }
4558 buf = stream->alloc(checksumSize);
4559 if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize);
4560
4561 }
4562
glFramebufferTexture3DOES_enc(void * self,GLenum target,GLenum attachment,GLenum textarget,GLuint texture,GLint level,GLint zoffset)4563 void glFramebufferTexture3DOES_enc(void *self , GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset)
4564 {
4565
4566 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4567 IOStream *stream = ctx->m_stream;
4568 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4569 bool useChecksum = checksumCalculator->getVersion() > 0;
4570
4571 unsigned char *ptr;
4572 unsigned char *buf;
4573 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4;
4574 const size_t checksumSize = checksumCalculator->checksumByteSize();
4575 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4576 buf = stream->alloc(totalSize);
4577 ptr = buf;
4578 int tmp = OP_glFramebufferTexture3DOES;memcpy(ptr, &tmp, 4); ptr += 4;
4579 memcpy(ptr, &totalSize, 4); ptr += 4;
4580
4581 memcpy(ptr, &target, 4); ptr += 4;
4582 memcpy(ptr, &attachment, 4); ptr += 4;
4583 memcpy(ptr, &textarget, 4); ptr += 4;
4584 memcpy(ptr, &texture, 4); ptr += 4;
4585 memcpy(ptr, &level, 4); ptr += 4;
4586 memcpy(ptr, &zoffset, 4); ptr += 4;
4587
4588 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4589 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4590
4591 }
4592
glBindVertexArrayOES_enc(void * self,GLuint array)4593 void glBindVertexArrayOES_enc(void *self , GLuint array)
4594 {
4595
4596 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4597 IOStream *stream = ctx->m_stream;
4598 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4599 bool useChecksum = checksumCalculator->getVersion() > 0;
4600
4601 unsigned char *ptr;
4602 unsigned char *buf;
4603 const size_t sizeWithoutChecksum = 8 + 4;
4604 const size_t checksumSize = checksumCalculator->checksumByteSize();
4605 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4606 buf = stream->alloc(totalSize);
4607 ptr = buf;
4608 int tmp = OP_glBindVertexArrayOES;memcpy(ptr, &tmp, 4); ptr += 4;
4609 memcpy(ptr, &totalSize, 4); ptr += 4;
4610
4611 memcpy(ptr, &array, 4); ptr += 4;
4612
4613 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4614 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4615
4616 }
4617
glDeleteVertexArraysOES_enc(void * self,GLsizei n,const GLuint * arrays)4618 void glDeleteVertexArraysOES_enc(void *self , GLsizei n, const GLuint* arrays)
4619 {
4620
4621 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4622 IOStream *stream = ctx->m_stream;
4623 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4624 bool useChecksum = checksumCalculator->getVersion() > 0;
4625
4626 const unsigned int __size_arrays = (n * sizeof(GLuint));
4627 unsigned char *ptr;
4628 unsigned char *buf;
4629 const size_t sizeWithoutChecksum = 8 + 4 + __size_arrays + 1*4;
4630 const size_t checksumSize = checksumCalculator->checksumByteSize();
4631 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4632 buf = stream->alloc(totalSize);
4633 ptr = buf;
4634 int tmp = OP_glDeleteVertexArraysOES;memcpy(ptr, &tmp, 4); ptr += 4;
4635 memcpy(ptr, &totalSize, 4); ptr += 4;
4636
4637 memcpy(ptr, &n, 4); ptr += 4;
4638 *(unsigned int *)(ptr) = __size_arrays; ptr += 4;
4639 memcpy(ptr, arrays, __size_arrays);ptr += __size_arrays;
4640
4641 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4642 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4643
4644 }
4645
glGenVertexArraysOES_enc(void * self,GLsizei n,GLuint * arrays)4646 void glGenVertexArraysOES_enc(void *self , GLsizei n, GLuint* arrays)
4647 {
4648
4649 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4650 IOStream *stream = ctx->m_stream;
4651 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4652 bool useChecksum = checksumCalculator->getVersion() > 0;
4653
4654 const unsigned int __size_arrays = (n * sizeof(GLuint));
4655 unsigned char *ptr;
4656 unsigned char *buf;
4657 const size_t sizeWithoutChecksum = 8 + 4 + __size_arrays + 1*4;
4658 const size_t checksumSize = checksumCalculator->checksumByteSize();
4659 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4660 buf = stream->alloc(totalSize);
4661 ptr = buf;
4662 int tmp = OP_glGenVertexArraysOES;memcpy(ptr, &tmp, 4); ptr += 4;
4663 memcpy(ptr, &totalSize, 4); ptr += 4;
4664
4665 memcpy(ptr, &n, 4); ptr += 4;
4666 *(unsigned int *)(ptr) = __size_arrays; ptr += 4;
4667
4668 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4669 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4670
4671 stream->readback(arrays, __size_arrays);
4672 if (useChecksum) checksumCalculator->addBuffer(arrays, __size_arrays);
4673 if (useChecksum) {
4674 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
4675 stream->readback(checksumBuf.get(), checksumSize);
4676 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
4677 ALOGE("glGenVertexArraysOES: GL communication error, please report this issue to b.android.com.\n");
4678 abort();
4679 }
4680 }
4681 }
4682
glIsVertexArrayOES_enc(void * self,GLuint array)4683 GLboolean glIsVertexArrayOES_enc(void *self , GLuint array)
4684 {
4685
4686 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4687 IOStream *stream = ctx->m_stream;
4688 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4689 bool useChecksum = checksumCalculator->getVersion() > 0;
4690
4691 unsigned char *ptr;
4692 unsigned char *buf;
4693 const size_t sizeWithoutChecksum = 8 + 4;
4694 const size_t checksumSize = checksumCalculator->checksumByteSize();
4695 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4696 buf = stream->alloc(totalSize);
4697 ptr = buf;
4698 int tmp = OP_glIsVertexArrayOES;memcpy(ptr, &tmp, 4); ptr += 4;
4699 memcpy(ptr, &totalSize, 4); ptr += 4;
4700
4701 memcpy(ptr, &array, 4); ptr += 4;
4702
4703 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4704 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4705
4706
4707 GLboolean retval;
4708 stream->readback(&retval, 1);
4709 if (useChecksum) checksumCalculator->addBuffer(&retval, 1);
4710 if (useChecksum) {
4711 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
4712 stream->readback(checksumBuf.get(), checksumSize);
4713 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
4714 ALOGE("glIsVertexArrayOES: GL communication error, please report this issue to b.android.com.\n");
4715 abort();
4716 }
4717 }
4718 return retval;
4719 }
4720
glDiscardFramebufferEXT_enc(void * self,GLenum target,GLsizei numAttachments,const GLenum * attachments)4721 void glDiscardFramebufferEXT_enc(void *self , GLenum target, GLsizei numAttachments, const GLenum* attachments)
4722 {
4723
4724 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4725 IOStream *stream = ctx->m_stream;
4726 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4727 bool useChecksum = checksumCalculator->getVersion() > 0;
4728
4729 const unsigned int __size_attachments = (numAttachments * sizeof(GLenum));
4730 unsigned char *ptr;
4731 unsigned char *buf;
4732 const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_attachments + 1*4;
4733 const size_t checksumSize = checksumCalculator->checksumByteSize();
4734 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4735 buf = stream->alloc(totalSize);
4736 ptr = buf;
4737 int tmp = OP_glDiscardFramebufferEXT;memcpy(ptr, &tmp, 4); ptr += 4;
4738 memcpy(ptr, &totalSize, 4); ptr += 4;
4739
4740 memcpy(ptr, &target, 4); ptr += 4;
4741 memcpy(ptr, &numAttachments, 4); ptr += 4;
4742 *(unsigned int *)(ptr) = __size_attachments; ptr += 4;
4743 memcpy(ptr, attachments, __size_attachments);ptr += __size_attachments;
4744
4745 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4746 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4747
4748 }
4749
glVertexAttribPointerData_enc(void * self,GLuint indx,GLint size,GLenum type,GLboolean normalized,GLsizei stride,void * data,GLuint datalen)4750 void glVertexAttribPointerData_enc(void *self , GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, void* data, GLuint datalen)
4751 {
4752
4753 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4754 IOStream *stream = ctx->m_stream;
4755 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4756 bool useChecksum = checksumCalculator->getVersion() > 0;
4757
4758 const unsigned int __size_data = datalen;
4759 unsigned char *ptr;
4760 unsigned char *buf;
4761 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 1 + 4 + __size_data + 4 + 1*4;
4762 const size_t checksumSize = checksumCalculator->checksumByteSize();
4763 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4764 buf = stream->alloc(totalSize);
4765 ptr = buf;
4766 int tmp = OP_glVertexAttribPointerData;memcpy(ptr, &tmp, 4); ptr += 4;
4767 memcpy(ptr, &totalSize, 4); ptr += 4;
4768
4769 memcpy(ptr, &indx, 4); ptr += 4;
4770 memcpy(ptr, &size, 4); ptr += 4;
4771 memcpy(ptr, &type, 4); ptr += 4;
4772 memcpy(ptr, &normalized, 1); ptr += 1;
4773 memcpy(ptr, &stride, 4); ptr += 4;
4774 *(unsigned int *)(ptr) = __size_data; ptr += 4;
4775 glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen);ptr += __size_data;
4776 memcpy(ptr, &datalen, 4); ptr += 4;
4777
4778 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4779 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4780
4781 }
4782
glVertexAttribPointerOffset_enc(void * self,GLuint indx,GLint size,GLenum type,GLboolean normalized,GLsizei stride,GLuint offset)4783 void glVertexAttribPointerOffset_enc(void *self , GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint offset)
4784 {
4785
4786 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4787 IOStream *stream = ctx->m_stream;
4788 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4789 bool useChecksum = checksumCalculator->getVersion() > 0;
4790
4791 unsigned char *ptr;
4792 unsigned char *buf;
4793 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 1 + 4 + 4;
4794 const size_t checksumSize = checksumCalculator->checksumByteSize();
4795 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4796 buf = stream->alloc(totalSize);
4797 ptr = buf;
4798 int tmp = OP_glVertexAttribPointerOffset;memcpy(ptr, &tmp, 4); ptr += 4;
4799 memcpy(ptr, &totalSize, 4); ptr += 4;
4800
4801 memcpy(ptr, &indx, 4); ptr += 4;
4802 memcpy(ptr, &size, 4); ptr += 4;
4803 memcpy(ptr, &type, 4); ptr += 4;
4804 memcpy(ptr, &normalized, 1); ptr += 1;
4805 memcpy(ptr, &stride, 4); ptr += 4;
4806 memcpy(ptr, &offset, 4); ptr += 4;
4807
4808 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4809 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4810
4811 }
4812
glDrawElementsOffset_enc(void * self,GLenum mode,GLsizei count,GLenum type,GLuint offset)4813 void glDrawElementsOffset_enc(void *self , GLenum mode, GLsizei count, GLenum type, GLuint offset)
4814 {
4815
4816 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4817 IOStream *stream = ctx->m_stream;
4818 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4819 bool useChecksum = checksumCalculator->getVersion() > 0;
4820
4821 unsigned char *ptr;
4822 unsigned char *buf;
4823 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4;
4824 const size_t checksumSize = checksumCalculator->checksumByteSize();
4825 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4826 buf = stream->alloc(totalSize);
4827 ptr = buf;
4828 int tmp = OP_glDrawElementsOffset;memcpy(ptr, &tmp, 4); ptr += 4;
4829 memcpy(ptr, &totalSize, 4); ptr += 4;
4830
4831 memcpy(ptr, &mode, 4); ptr += 4;
4832 memcpy(ptr, &count, 4); ptr += 4;
4833 memcpy(ptr, &type, 4); ptr += 4;
4834 memcpy(ptr, &offset, 4); ptr += 4;
4835
4836 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4837 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4838
4839 }
4840
glDrawElementsData_enc(void * self,GLenum mode,GLsizei count,GLenum type,void * data,GLuint datalen)4841 void glDrawElementsData_enc(void *self , GLenum mode, GLsizei count, GLenum type, void* data, GLuint datalen)
4842 {
4843
4844 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4845 IOStream *stream = ctx->m_stream;
4846 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4847 bool useChecksum = checksumCalculator->getVersion() > 0;
4848
4849 const unsigned int __size_data = datalen;
4850 unsigned char *ptr;
4851 unsigned char *buf;
4852 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + __size_data + 4 + 1*4;
4853 const size_t checksumSize = checksumCalculator->checksumByteSize();
4854 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4855 buf = stream->alloc(totalSize);
4856 ptr = buf;
4857 int tmp = OP_glDrawElementsData;memcpy(ptr, &tmp, 4); ptr += 4;
4858 memcpy(ptr, &totalSize, 4); ptr += 4;
4859
4860 memcpy(ptr, &mode, 4); ptr += 4;
4861 memcpy(ptr, &count, 4); ptr += 4;
4862 memcpy(ptr, &type, 4); ptr += 4;
4863 *(unsigned int *)(ptr) = __size_data; ptr += 4;
4864 memcpy(ptr, data, __size_data);ptr += __size_data;
4865 memcpy(ptr, &datalen, 4); ptr += 4;
4866
4867 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4868 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4869
4870 }
4871
glGetCompressedTextureFormats_enc(void * self,int count,GLint * formats)4872 void glGetCompressedTextureFormats_enc(void *self , int count, GLint* formats)
4873 {
4874
4875 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4876 IOStream *stream = ctx->m_stream;
4877 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4878 bool useChecksum = checksumCalculator->getVersion() > 0;
4879
4880 const unsigned int __size_formats = (count * sizeof(GLint));
4881 unsigned char *ptr;
4882 unsigned char *buf;
4883 const size_t sizeWithoutChecksum = 8 + 4 + __size_formats + 1*4;
4884 const size_t checksumSize = checksumCalculator->checksumByteSize();
4885 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4886 buf = stream->alloc(totalSize);
4887 ptr = buf;
4888 int tmp = OP_glGetCompressedTextureFormats;memcpy(ptr, &tmp, 4); ptr += 4;
4889 memcpy(ptr, &totalSize, 4); ptr += 4;
4890
4891 memcpy(ptr, &count, 4); ptr += 4;
4892 *(unsigned int *)(ptr) = __size_formats; ptr += 4;
4893
4894 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4895 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4896
4897 stream->readback(formats, __size_formats);
4898 if (useChecksum) checksumCalculator->addBuffer(formats, __size_formats);
4899 if (useChecksum) {
4900 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
4901 stream->readback(checksumBuf.get(), checksumSize);
4902 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
4903 ALOGE("glGetCompressedTextureFormats: GL communication error, please report this issue to b.android.com.\n");
4904 abort();
4905 }
4906 }
4907 }
4908
glShaderString_enc(void * self,GLuint shader,const GLchar * string,GLsizei len)4909 void glShaderString_enc(void *self , GLuint shader, const GLchar* string, GLsizei len)
4910 {
4911
4912 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4913 IOStream *stream = ctx->m_stream;
4914 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4915 bool useChecksum = checksumCalculator->getVersion() > 0;
4916
4917 const unsigned int __size_string = len;
4918 unsigned char *ptr;
4919 unsigned char *buf;
4920 const size_t sizeWithoutChecksum = 8 + 4 + __size_string + 4 + 1*4;
4921 const size_t checksumSize = checksumCalculator->checksumByteSize();
4922 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4923 buf = stream->alloc(totalSize);
4924 ptr = buf;
4925 int tmp = OP_glShaderString;memcpy(ptr, &tmp, 4); ptr += 4;
4926 memcpy(ptr, &totalSize, 4); ptr += 4;
4927
4928 memcpy(ptr, &shader, 4); ptr += 4;
4929 *(unsigned int *)(ptr) = __size_string; ptr += 4;
4930 memcpy(ptr, string, __size_string);ptr += __size_string;
4931 memcpy(ptr, &len, 4); ptr += 4;
4932
4933 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4934 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4935
4936 }
4937
glFinishRoundTrip_enc(void * self)4938 int glFinishRoundTrip_enc(void *self )
4939 {
4940
4941 gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self;
4942 IOStream *stream = ctx->m_stream;
4943 ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
4944 bool useChecksum = checksumCalculator->getVersion() > 0;
4945
4946 unsigned char *ptr;
4947 unsigned char *buf;
4948 const size_t sizeWithoutChecksum = 8;
4949 const size_t checksumSize = checksumCalculator->checksumByteSize();
4950 const size_t totalSize = sizeWithoutChecksum + checksumSize;
4951 buf = stream->alloc(totalSize);
4952 ptr = buf;
4953 int tmp = OP_glFinishRoundTrip;memcpy(ptr, &tmp, 4); ptr += 4;
4954 memcpy(ptr, &totalSize, 4); ptr += 4;
4955
4956
4957 if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
4958 if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
4959
4960
4961 int retval;
4962 stream->readback(&retval, 4);
4963 if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
4964 if (useChecksum) {
4965 std::unique_ptr<unsigned char[]> checksumBuf(new unsigned char[checksumSize]);
4966 stream->readback(checksumBuf.get(), checksumSize);
4967 if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {
4968 ALOGE("glFinishRoundTrip: GL communication error, please report this issue to b.android.com.\n");
4969 abort();
4970 }
4971 }
4972 return retval;
4973 }
4974
4975 } // namespace
4976
gl2_encoder_context_t(IOStream * stream,ChecksumCalculator * checksumCalculator)4977 gl2_encoder_context_t::gl2_encoder_context_t(IOStream *stream, ChecksumCalculator *checksumCalculator)
4978 {
4979 m_stream = stream;
4980 m_checksumCalculator = checksumCalculator;
4981
4982 this->glActiveTexture = &glActiveTexture_enc;
4983 this->glAttachShader = &glAttachShader_enc;
4984 this->glBindAttribLocation = &glBindAttribLocation_enc;
4985 this->glBindBuffer = &glBindBuffer_enc;
4986 this->glBindFramebuffer = &glBindFramebuffer_enc;
4987 this->glBindRenderbuffer = &glBindRenderbuffer_enc;
4988 this->glBindTexture = &glBindTexture_enc;
4989 this->glBlendColor = &glBlendColor_enc;
4990 this->glBlendEquation = &glBlendEquation_enc;
4991 this->glBlendEquationSeparate = &glBlendEquationSeparate_enc;
4992 this->glBlendFunc = &glBlendFunc_enc;
4993 this->glBlendFuncSeparate = &glBlendFuncSeparate_enc;
4994 this->glBufferData = &glBufferData_enc;
4995 this->glBufferSubData = &glBufferSubData_enc;
4996 this->glCheckFramebufferStatus = &glCheckFramebufferStatus_enc;
4997 this->glClear = &glClear_enc;
4998 this->glClearColor = &glClearColor_enc;
4999 this->glClearDepthf = &glClearDepthf_enc;
5000 this->glClearStencil = &glClearStencil_enc;
5001 this->glColorMask = &glColorMask_enc;
5002 this->glCompileShader = &glCompileShader_enc;
5003 this->glCompressedTexImage2D = &glCompressedTexImage2D_enc;
5004 this->glCompressedTexSubImage2D = &glCompressedTexSubImage2D_enc;
5005 this->glCopyTexImage2D = &glCopyTexImage2D_enc;
5006 this->glCopyTexSubImage2D = &glCopyTexSubImage2D_enc;
5007 this->glCreateProgram = &glCreateProgram_enc;
5008 this->glCreateShader = &glCreateShader_enc;
5009 this->glCullFace = &glCullFace_enc;
5010 this->glDeleteBuffers = &glDeleteBuffers_enc;
5011 this->glDeleteFramebuffers = &glDeleteFramebuffers_enc;
5012 this->glDeleteProgram = &glDeleteProgram_enc;
5013 this->glDeleteRenderbuffers = &glDeleteRenderbuffers_enc;
5014 this->glDeleteShader = &glDeleteShader_enc;
5015 this->glDeleteTextures = &glDeleteTextures_enc;
5016 this->glDepthFunc = &glDepthFunc_enc;
5017 this->glDepthMask = &glDepthMask_enc;
5018 this->glDepthRangef = &glDepthRangef_enc;
5019 this->glDetachShader = &glDetachShader_enc;
5020 this->glDisable = &glDisable_enc;
5021 this->glDisableVertexAttribArray = &glDisableVertexAttribArray_enc;
5022 this->glDrawArrays = &glDrawArrays_enc;
5023 this->glDrawElements = (glDrawElements_client_proc_t) &enc_unsupported;
5024 this->glEnable = &glEnable_enc;
5025 this->glEnableVertexAttribArray = &glEnableVertexAttribArray_enc;
5026 this->glFinish = &glFinish_enc;
5027 this->glFlush = &glFlush_enc;
5028 this->glFramebufferRenderbuffer = &glFramebufferRenderbuffer_enc;
5029 this->glFramebufferTexture2D = &glFramebufferTexture2D_enc;
5030 this->glFrontFace = &glFrontFace_enc;
5031 this->glGenBuffers = &glGenBuffers_enc;
5032 this->glGenerateMipmap = &glGenerateMipmap_enc;
5033 this->glGenFramebuffers = &glGenFramebuffers_enc;
5034 this->glGenRenderbuffers = &glGenRenderbuffers_enc;
5035 this->glGenTextures = &glGenTextures_enc;
5036 this->glGetActiveAttrib = &glGetActiveAttrib_enc;
5037 this->glGetActiveUniform = &glGetActiveUniform_enc;
5038 this->glGetAttachedShaders = &glGetAttachedShaders_enc;
5039 this->glGetAttribLocation = &glGetAttribLocation_enc;
5040 this->glGetBooleanv = &glGetBooleanv_enc;
5041 this->glGetBufferParameteriv = &glGetBufferParameteriv_enc;
5042 this->glGetError = &glGetError_enc;
5043 this->glGetFloatv = &glGetFloatv_enc;
5044 this->glGetFramebufferAttachmentParameteriv = &glGetFramebufferAttachmentParameteriv_enc;
5045 this->glGetIntegerv = &glGetIntegerv_enc;
5046 this->glGetProgramiv = &glGetProgramiv_enc;
5047 this->glGetProgramInfoLog = &glGetProgramInfoLog_enc;
5048 this->glGetRenderbufferParameteriv = &glGetRenderbufferParameteriv_enc;
5049 this->glGetShaderiv = &glGetShaderiv_enc;
5050 this->glGetShaderInfoLog = &glGetShaderInfoLog_enc;
5051 this->glGetShaderPrecisionFormat = &glGetShaderPrecisionFormat_enc;
5052 this->glGetShaderSource = &glGetShaderSource_enc;
5053 this->glGetString = (glGetString_client_proc_t) &enc_unsupported;
5054 this->glGetTexParameterfv = &glGetTexParameterfv_enc;
5055 this->glGetTexParameteriv = &glGetTexParameteriv_enc;
5056 this->glGetUniformfv = &glGetUniformfv_enc;
5057 this->glGetUniformiv = &glGetUniformiv_enc;
5058 this->glGetUniformLocation = &glGetUniformLocation_enc;
5059 this->glGetVertexAttribfv = &glGetVertexAttribfv_enc;
5060 this->glGetVertexAttribiv = &glGetVertexAttribiv_enc;
5061 this->glGetVertexAttribPointerv = (glGetVertexAttribPointerv_client_proc_t) &enc_unsupported;
5062 this->glHint = &glHint_enc;
5063 this->glIsBuffer = &glIsBuffer_enc;
5064 this->glIsEnabled = &glIsEnabled_enc;
5065 this->glIsFramebuffer = &glIsFramebuffer_enc;
5066 this->glIsProgram = &glIsProgram_enc;
5067 this->glIsRenderbuffer = &glIsRenderbuffer_enc;
5068 this->glIsShader = &glIsShader_enc;
5069 this->glIsTexture = &glIsTexture_enc;
5070 this->glLineWidth = &glLineWidth_enc;
5071 this->glLinkProgram = &glLinkProgram_enc;
5072 this->glPixelStorei = &glPixelStorei_enc;
5073 this->glPolygonOffset = &glPolygonOffset_enc;
5074 this->glReadPixels = &glReadPixels_enc;
5075 this->glReleaseShaderCompiler = &glReleaseShaderCompiler_enc;
5076 this->glRenderbufferStorage = &glRenderbufferStorage_enc;
5077 this->glSampleCoverage = &glSampleCoverage_enc;
5078 this->glScissor = &glScissor_enc;
5079 this->glShaderBinary = (glShaderBinary_client_proc_t) &enc_unsupported;
5080 this->glShaderSource = (glShaderSource_client_proc_t) &enc_unsupported;
5081 this->glStencilFunc = &glStencilFunc_enc;
5082 this->glStencilFuncSeparate = &glStencilFuncSeparate_enc;
5083 this->glStencilMask = &glStencilMask_enc;
5084 this->glStencilMaskSeparate = &glStencilMaskSeparate_enc;
5085 this->glStencilOp = &glStencilOp_enc;
5086 this->glStencilOpSeparate = &glStencilOpSeparate_enc;
5087 this->glTexImage2D = &glTexImage2D_enc;
5088 this->glTexParameterf = &glTexParameterf_enc;
5089 this->glTexParameterfv = &glTexParameterfv_enc;
5090 this->glTexParameteri = &glTexParameteri_enc;
5091 this->glTexParameteriv = &glTexParameteriv_enc;
5092 this->glTexSubImage2D = &glTexSubImage2D_enc;
5093 this->glUniform1f = &glUniform1f_enc;
5094 this->glUniform1fv = &glUniform1fv_enc;
5095 this->glUniform1i = &glUniform1i_enc;
5096 this->glUniform1iv = &glUniform1iv_enc;
5097 this->glUniform2f = &glUniform2f_enc;
5098 this->glUniform2fv = &glUniform2fv_enc;
5099 this->glUniform2i = &glUniform2i_enc;
5100 this->glUniform2iv = &glUniform2iv_enc;
5101 this->glUniform3f = &glUniform3f_enc;
5102 this->glUniform3fv = &glUniform3fv_enc;
5103 this->glUniform3i = &glUniform3i_enc;
5104 this->glUniform3iv = &glUniform3iv_enc;
5105 this->glUniform4f = &glUniform4f_enc;
5106 this->glUniform4fv = &glUniform4fv_enc;
5107 this->glUniform4i = &glUniform4i_enc;
5108 this->glUniform4iv = &glUniform4iv_enc;
5109 this->glUniformMatrix2fv = &glUniformMatrix2fv_enc;
5110 this->glUniformMatrix3fv = &glUniformMatrix3fv_enc;
5111 this->glUniformMatrix4fv = &glUniformMatrix4fv_enc;
5112 this->glUseProgram = &glUseProgram_enc;
5113 this->glValidateProgram = &glValidateProgram_enc;
5114 this->glVertexAttrib1f = &glVertexAttrib1f_enc;
5115 this->glVertexAttrib1fv = &glVertexAttrib1fv_enc;
5116 this->glVertexAttrib2f = &glVertexAttrib2f_enc;
5117 this->glVertexAttrib2fv = &glVertexAttrib2fv_enc;
5118 this->glVertexAttrib3f = &glVertexAttrib3f_enc;
5119 this->glVertexAttrib3fv = &glVertexAttrib3fv_enc;
5120 this->glVertexAttrib4f = &glVertexAttrib4f_enc;
5121 this->glVertexAttrib4fv = &glVertexAttrib4fv_enc;
5122 this->glVertexAttribPointer = (glVertexAttribPointer_client_proc_t) &enc_unsupported;
5123 this->glViewport = &glViewport_enc;
5124 this->glEGLImageTargetTexture2DOES = &glEGLImageTargetTexture2DOES_enc;
5125 this->glEGLImageTargetRenderbufferStorageOES = &glEGLImageTargetRenderbufferStorageOES_enc;
5126 this->glGetProgramBinaryOES = (glGetProgramBinaryOES_client_proc_t) &enc_unsupported;
5127 this->glProgramBinaryOES = (glProgramBinaryOES_client_proc_t) &enc_unsupported;
5128 this->glMapBufferOES = (glMapBufferOES_client_proc_t) &enc_unsupported;
5129 this->glUnmapBufferOES = &glUnmapBufferOES_enc;
5130 this->glTexImage3DOES = &glTexImage3DOES_enc;
5131 this->glTexSubImage3DOES = &glTexSubImage3DOES_enc;
5132 this->glCopyTexSubImage3DOES = &glCopyTexSubImage3DOES_enc;
5133 this->glCompressedTexImage3DOES = &glCompressedTexImage3DOES_enc;
5134 this->glCompressedTexSubImage3DOES = &glCompressedTexSubImage3DOES_enc;
5135 this->glFramebufferTexture3DOES = &glFramebufferTexture3DOES_enc;
5136 this->glBindVertexArrayOES = &glBindVertexArrayOES_enc;
5137 this->glDeleteVertexArraysOES = &glDeleteVertexArraysOES_enc;
5138 this->glGenVertexArraysOES = &glGenVertexArraysOES_enc;
5139 this->glIsVertexArrayOES = &glIsVertexArrayOES_enc;
5140 this->glDiscardFramebufferEXT = &glDiscardFramebufferEXT_enc;
5141 this->glMultiDrawArraysEXT = (glMultiDrawArraysEXT_client_proc_t) &enc_unsupported;
5142 this->glMultiDrawElementsEXT = (glMultiDrawElementsEXT_client_proc_t) &enc_unsupported;
5143 this->glGetPerfMonitorGroupsAMD = (glGetPerfMonitorGroupsAMD_client_proc_t) &enc_unsupported;
5144 this->glGetPerfMonitorCountersAMD = (glGetPerfMonitorCountersAMD_client_proc_t) &enc_unsupported;
5145 this->glGetPerfMonitorGroupStringAMD = (glGetPerfMonitorGroupStringAMD_client_proc_t) &enc_unsupported;
5146 this->glGetPerfMonitorCounterStringAMD = (glGetPerfMonitorCounterStringAMD_client_proc_t) &enc_unsupported;
5147 this->glGetPerfMonitorCounterInfoAMD = (glGetPerfMonitorCounterInfoAMD_client_proc_t) &enc_unsupported;
5148 this->glGenPerfMonitorsAMD = (glGenPerfMonitorsAMD_client_proc_t) &enc_unsupported;
5149 this->glDeletePerfMonitorsAMD = (glDeletePerfMonitorsAMD_client_proc_t) &enc_unsupported;
5150 this->glSelectPerfMonitorCountersAMD = (glSelectPerfMonitorCountersAMD_client_proc_t) &enc_unsupported;
5151 this->glBeginPerfMonitorAMD = (glBeginPerfMonitorAMD_client_proc_t) &enc_unsupported;
5152 this->glEndPerfMonitorAMD = (glEndPerfMonitorAMD_client_proc_t) &enc_unsupported;
5153 this->glGetPerfMonitorCounterDataAMD = (glGetPerfMonitorCounterDataAMD_client_proc_t) &enc_unsupported;
5154 this->glRenderbufferStorageMultisampleIMG = (glRenderbufferStorageMultisampleIMG_client_proc_t) &enc_unsupported;
5155 this->glFramebufferTexture2DMultisampleIMG = (glFramebufferTexture2DMultisampleIMG_client_proc_t) &enc_unsupported;
5156 this->glDeleteFencesNV = (glDeleteFencesNV_client_proc_t) &enc_unsupported;
5157 this->glGenFencesNV = (glGenFencesNV_client_proc_t) &enc_unsupported;
5158 this->glIsFenceNV = (glIsFenceNV_client_proc_t) &enc_unsupported;
5159 this->glTestFenceNV = (glTestFenceNV_client_proc_t) &enc_unsupported;
5160 this->glGetFenceivNV = (glGetFenceivNV_client_proc_t) &enc_unsupported;
5161 this->glFinishFenceNV = (glFinishFenceNV_client_proc_t) &enc_unsupported;
5162 this->glSetFenceNV = (glSetFenceNV_client_proc_t) &enc_unsupported;
5163 this->glCoverageMaskNV = (glCoverageMaskNV_client_proc_t) &enc_unsupported;
5164 this->glCoverageOperationNV = (glCoverageOperationNV_client_proc_t) &enc_unsupported;
5165 this->glGetDriverControlsQCOM = (glGetDriverControlsQCOM_client_proc_t) &enc_unsupported;
5166 this->glGetDriverControlStringQCOM = (glGetDriverControlStringQCOM_client_proc_t) &enc_unsupported;
5167 this->glEnableDriverControlQCOM = (glEnableDriverControlQCOM_client_proc_t) &enc_unsupported;
5168 this->glDisableDriverControlQCOM = (glDisableDriverControlQCOM_client_proc_t) &enc_unsupported;
5169 this->glExtGetTexturesQCOM = (glExtGetTexturesQCOM_client_proc_t) &enc_unsupported;
5170 this->glExtGetBuffersQCOM = (glExtGetBuffersQCOM_client_proc_t) &enc_unsupported;
5171 this->glExtGetRenderbuffersQCOM = (glExtGetRenderbuffersQCOM_client_proc_t) &enc_unsupported;
5172 this->glExtGetFramebuffersQCOM = (glExtGetFramebuffersQCOM_client_proc_t) &enc_unsupported;
5173 this->glExtGetTexLevelParameterivQCOM = (glExtGetTexLevelParameterivQCOM_client_proc_t) &enc_unsupported;
5174 this->glExtTexObjectStateOverrideiQCOM = (glExtTexObjectStateOverrideiQCOM_client_proc_t) &enc_unsupported;
5175 this->glExtGetTexSubImageQCOM = (glExtGetTexSubImageQCOM_client_proc_t) &enc_unsupported;
5176 this->glExtGetBufferPointervQCOM = (glExtGetBufferPointervQCOM_client_proc_t) &enc_unsupported;
5177 this->glExtGetShadersQCOM = (glExtGetShadersQCOM_client_proc_t) &enc_unsupported;
5178 this->glExtGetProgramsQCOM = (glExtGetProgramsQCOM_client_proc_t) &enc_unsupported;
5179 this->glExtIsProgramBinaryQCOM = (glExtIsProgramBinaryQCOM_client_proc_t) &enc_unsupported;
5180 this->glExtGetProgramBinarySourceQCOM = (glExtGetProgramBinarySourceQCOM_client_proc_t) &enc_unsupported;
5181 this->glStartTilingQCOM = (glStartTilingQCOM_client_proc_t) &enc_unsupported;
5182 this->glEndTilingQCOM = (glEndTilingQCOM_client_proc_t) &enc_unsupported;
5183 this->glVertexAttribPointerData = &glVertexAttribPointerData_enc;
5184 this->glVertexAttribPointerOffset = &glVertexAttribPointerOffset_enc;
5185 this->glDrawElementsOffset = &glDrawElementsOffset_enc;
5186 this->glDrawElementsData = &glDrawElementsData_enc;
5187 this->glGetCompressedTextureFormats = &glGetCompressedTextureFormats_enc;
5188 this->glShaderString = &glShaderString_enc;
5189 this->glFinishRoundTrip = &glFinishRoundTrip_enc;
5190 }
5191
5192