1 // Generated Code - DO NOT EDIT !!
2 // generated by 'emugen'
3 
4 
5 #include <string.h>
6 #include "renderControl_opcodes.h"
7 
8 #include "renderControl_enc.h"
9 
10 
11 #include <stdio.h>
12 
13 namespace {
14 
enc_unsupported()15 void enc_unsupported()
16 {
17 	ALOGE("Function is unsupported\n");
18 }
19 
rcGetRendererVersion_enc(void * self)20 GLint rcGetRendererVersion_enc(void *self )
21 {
22 
23 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
24 	IOStream *stream = ctx->m_stream;
25 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
26 	bool useChecksum = checksumCalculator->getVersion() > 0;
27 
28 	 unsigned char *ptr;
29 	 unsigned char *buf;
30 	 const size_t sizeWithoutChecksum = 8;
31 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
32 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
33 	buf = stream->alloc(totalSize);
34 	ptr = buf;
35 	int tmp = OP_rcGetRendererVersion;memcpy(ptr, &tmp, 4); ptr += 4;
36 	memcpy(ptr, &totalSize, 4);  ptr += 4;
37 
38 
39 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
40 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
41 
42 
43 	GLint retval;
44 	stream->readback(&retval, 4);
45 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
46 	if (useChecksum) {
47 		unsigned char *checksumBufPtr = NULL;
48 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
49 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
50 		stream->readback(checksumBufPtr, checksumSize);
51 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
52 			ALOGE("rcGetRendererVersion: GL communication error, please report this issue to b.android.com.\n");
53 			abort();
54 		}
55 	}
56 	return retval;
57 }
58 
rcGetEGLVersion_enc(void * self,EGLint * major,EGLint * minor)59 EGLint rcGetEGLVersion_enc(void *self , EGLint* major, EGLint* minor)
60 {
61 
62 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
63 	IOStream *stream = ctx->m_stream;
64 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
65 	bool useChecksum = checksumCalculator->getVersion() > 0;
66 
67 	const unsigned int __size_major =  sizeof(EGLint);
68 	const unsigned int __size_minor =  sizeof(EGLint);
69 	 unsigned char *ptr;
70 	 unsigned char *buf;
71 	 const size_t sizeWithoutChecksum = 8 + 0 + 0 + 2*4;
72 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
73 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
74 	buf = stream->alloc(totalSize);
75 	ptr = buf;
76 	int tmp = OP_rcGetEGLVersion;memcpy(ptr, &tmp, 4); ptr += 4;
77 	memcpy(ptr, &totalSize, 4);  ptr += 4;
78 
79 	*(unsigned int *)(ptr) = __size_major; ptr += 4;
80 	*(unsigned int *)(ptr) = __size_minor; ptr += 4;
81 
82 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
83 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
84 
85 	stream->readback(major, __size_major);
86 	if (useChecksum) checksumCalculator->addBuffer(major, __size_major);
87 	stream->readback(minor, __size_minor);
88 	if (useChecksum) checksumCalculator->addBuffer(minor, __size_minor);
89 
90 	EGLint retval;
91 	stream->readback(&retval, 4);
92 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
93 	if (useChecksum) {
94 		unsigned char *checksumBufPtr = NULL;
95 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
96 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
97 		stream->readback(checksumBufPtr, checksumSize);
98 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
99 			ALOGE("rcGetEGLVersion: GL communication error, please report this issue to b.android.com.\n");
100 			abort();
101 		}
102 	}
103 	return retval;
104 }
105 
rcQueryEGLString_enc(void * self,EGLenum name,void * buffer,EGLint bufferSize)106 EGLint rcQueryEGLString_enc(void *self , EGLenum name, void* buffer, EGLint bufferSize)
107 {
108 
109 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
110 	IOStream *stream = ctx->m_stream;
111 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
112 	bool useChecksum = checksumCalculator->getVersion() > 0;
113 
114 	const unsigned int __size_buffer =  bufferSize;
115 	 unsigned char *ptr;
116 	 unsigned char *buf;
117 	 const size_t sizeWithoutChecksum = 8 + 4 + 0 + 4 + 1*4;
118 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
119 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
120 	buf = stream->alloc(totalSize);
121 	ptr = buf;
122 	int tmp = OP_rcQueryEGLString;memcpy(ptr, &tmp, 4); ptr += 4;
123 	memcpy(ptr, &totalSize, 4);  ptr += 4;
124 
125 		memcpy(ptr, &name, 4); ptr += 4;
126 	*(unsigned int *)(ptr) = __size_buffer; ptr += 4;
127 		memcpy(ptr, &bufferSize, 4); ptr += 4;
128 
129 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
130 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
131 
132 	stream->readback(buffer, __size_buffer);
133 	if (useChecksum) checksumCalculator->addBuffer(buffer, __size_buffer);
134 
135 	EGLint retval;
136 	stream->readback(&retval, 4);
137 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
138 	if (useChecksum) {
139 		unsigned char *checksumBufPtr = NULL;
140 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
141 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
142 		stream->readback(checksumBufPtr, checksumSize);
143 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
144 			ALOGE("rcQueryEGLString: GL communication error, please report this issue to b.android.com.\n");
145 			abort();
146 		}
147 	}
148 	return retval;
149 }
150 
rcGetGLString_enc(void * self,EGLenum name,void * buffer,EGLint bufferSize)151 EGLint rcGetGLString_enc(void *self , EGLenum name, void* buffer, EGLint bufferSize)
152 {
153 
154 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
155 	IOStream *stream = ctx->m_stream;
156 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
157 	bool useChecksum = checksumCalculator->getVersion() > 0;
158 
159 	const unsigned int __size_buffer =  bufferSize;
160 	 unsigned char *ptr;
161 	 unsigned char *buf;
162 	 const size_t sizeWithoutChecksum = 8 + 4 + 0 + 4 + 1*4;
163 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
164 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
165 	buf = stream->alloc(totalSize);
166 	ptr = buf;
167 	int tmp = OP_rcGetGLString;memcpy(ptr, &tmp, 4); ptr += 4;
168 	memcpy(ptr, &totalSize, 4);  ptr += 4;
169 
170 		memcpy(ptr, &name, 4); ptr += 4;
171 	*(unsigned int *)(ptr) = __size_buffer; ptr += 4;
172 		memcpy(ptr, &bufferSize, 4); ptr += 4;
173 
174 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
175 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
176 
177 	stream->readback(buffer, __size_buffer);
178 	if (useChecksum) checksumCalculator->addBuffer(buffer, __size_buffer);
179 
180 	EGLint retval;
181 	stream->readback(&retval, 4);
182 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
183 	if (useChecksum) {
184 		unsigned char *checksumBufPtr = NULL;
185 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
186 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
187 		stream->readback(checksumBufPtr, checksumSize);
188 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
189 			ALOGE("rcGetGLString: GL communication error, please report this issue to b.android.com.\n");
190 			abort();
191 		}
192 	}
193 	return retval;
194 }
195 
rcGetNumConfigs_enc(void * self,uint32_t * numAttribs)196 EGLint rcGetNumConfigs_enc(void *self , uint32_t* numAttribs)
197 {
198 
199 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
200 	IOStream *stream = ctx->m_stream;
201 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
202 	bool useChecksum = checksumCalculator->getVersion() > 0;
203 
204 	const unsigned int __size_numAttribs =  sizeof(uint32_t);
205 	 unsigned char *ptr;
206 	 unsigned char *buf;
207 	 const size_t sizeWithoutChecksum = 8 + 0 + 1*4;
208 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
209 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
210 	buf = stream->alloc(totalSize);
211 	ptr = buf;
212 	int tmp = OP_rcGetNumConfigs;memcpy(ptr, &tmp, 4); ptr += 4;
213 	memcpy(ptr, &totalSize, 4);  ptr += 4;
214 
215 	*(unsigned int *)(ptr) = __size_numAttribs; ptr += 4;
216 
217 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
218 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
219 
220 	stream->readback(numAttribs, __size_numAttribs);
221 	if (useChecksum) checksumCalculator->addBuffer(numAttribs, __size_numAttribs);
222 
223 	EGLint retval;
224 	stream->readback(&retval, 4);
225 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
226 	if (useChecksum) {
227 		unsigned char *checksumBufPtr = NULL;
228 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
229 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
230 		stream->readback(checksumBufPtr, checksumSize);
231 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
232 			ALOGE("rcGetNumConfigs: GL communication error, please report this issue to b.android.com.\n");
233 			abort();
234 		}
235 	}
236 	return retval;
237 }
238 
rcGetConfigs_enc(void * self,uint32_t bufSize,GLuint * buffer)239 EGLint rcGetConfigs_enc(void *self , uint32_t bufSize, GLuint* buffer)
240 {
241 
242 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
243 	IOStream *stream = ctx->m_stream;
244 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
245 	bool useChecksum = checksumCalculator->getVersion() > 0;
246 
247 	const unsigned int __size_buffer =  bufSize;
248 	 unsigned char *ptr;
249 	 unsigned char *buf;
250 	 const size_t sizeWithoutChecksum = 8 + 4 + 0 + 1*4;
251 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
252 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
253 	buf = stream->alloc(totalSize);
254 	ptr = buf;
255 	int tmp = OP_rcGetConfigs;memcpy(ptr, &tmp, 4); ptr += 4;
256 	memcpy(ptr, &totalSize, 4);  ptr += 4;
257 
258 		memcpy(ptr, &bufSize, 4); ptr += 4;
259 	*(unsigned int *)(ptr) = __size_buffer; ptr += 4;
260 
261 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
262 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
263 
264 	stream->readback(buffer, __size_buffer);
265 	if (useChecksum) checksumCalculator->addBuffer(buffer, __size_buffer);
266 
267 	EGLint retval;
268 	stream->readback(&retval, 4);
269 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
270 	if (useChecksum) {
271 		unsigned char *checksumBufPtr = NULL;
272 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
273 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
274 		stream->readback(checksumBufPtr, checksumSize);
275 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
276 			ALOGE("rcGetConfigs: GL communication error, please report this issue to b.android.com.\n");
277 			abort();
278 		}
279 	}
280 	return retval;
281 }
282 
rcChooseConfig_enc(void * self,EGLint * attribs,uint32_t attribs_size,uint32_t * configs,uint32_t configs_size)283 EGLint rcChooseConfig_enc(void *self , EGLint* attribs, uint32_t attribs_size, uint32_t* configs, uint32_t configs_size)
284 {
285 
286 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
287 	IOStream *stream = ctx->m_stream;
288 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
289 	bool useChecksum = checksumCalculator->getVersion() > 0;
290 
291 	const unsigned int __size_attribs =  attribs_size;
292 	const unsigned int __size_configs = ((configs != NULL) ?  configs_size*sizeof(uint32_t) : 0);
293 	 unsigned char *ptr;
294 	 unsigned char *buf;
295 	 const size_t sizeWithoutChecksum = 8 + __size_attribs + 4 + 0 + 4 + 2*4;
296 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
297 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
298 	buf = stream->alloc(totalSize);
299 	ptr = buf;
300 	int tmp = OP_rcChooseConfig;memcpy(ptr, &tmp, 4); ptr += 4;
301 	memcpy(ptr, &totalSize, 4);  ptr += 4;
302 
303 	*(unsigned int *)(ptr) = __size_attribs; ptr += 4;
304 	memcpy(ptr, attribs, __size_attribs);ptr += __size_attribs;
305 		memcpy(ptr, &attribs_size, 4); ptr += 4;
306 	*(unsigned int *)(ptr) = __size_configs; ptr += 4;
307 		memcpy(ptr, &configs_size, 4); ptr += 4;
308 
309 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
310 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
311 
312 	if (configs != NULL) {
313 		stream->readback(configs, __size_configs);
314 		if (useChecksum) checksumCalculator->addBuffer(configs, __size_configs);
315 	}
316 
317 	EGLint retval;
318 	stream->readback(&retval, 4);
319 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
320 	if (useChecksum) {
321 		unsigned char *checksumBufPtr = NULL;
322 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
323 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
324 		stream->readback(checksumBufPtr, checksumSize);
325 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
326 			ALOGE("rcChooseConfig: GL communication error, please report this issue to b.android.com.\n");
327 			abort();
328 		}
329 	}
330 	return retval;
331 }
332 
rcGetFBParam_enc(void * self,EGLint param)333 EGLint rcGetFBParam_enc(void *self , EGLint param)
334 {
335 
336 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
337 	IOStream *stream = ctx->m_stream;
338 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
339 	bool useChecksum = checksumCalculator->getVersion() > 0;
340 
341 	 unsigned char *ptr;
342 	 unsigned char *buf;
343 	 const size_t sizeWithoutChecksum = 8 + 4;
344 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
345 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
346 	buf = stream->alloc(totalSize);
347 	ptr = buf;
348 	int tmp = OP_rcGetFBParam;memcpy(ptr, &tmp, 4); ptr += 4;
349 	memcpy(ptr, &totalSize, 4);  ptr += 4;
350 
351 		memcpy(ptr, &param, 4); ptr += 4;
352 
353 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
354 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
355 
356 
357 	EGLint retval;
358 	stream->readback(&retval, 4);
359 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
360 	if (useChecksum) {
361 		unsigned char *checksumBufPtr = NULL;
362 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
363 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
364 		stream->readback(checksumBufPtr, checksumSize);
365 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
366 			ALOGE("rcGetFBParam: GL communication error, please report this issue to b.android.com.\n");
367 			abort();
368 		}
369 	}
370 	return retval;
371 }
372 
rcCreateContext_enc(void * self,uint32_t config,uint32_t share,uint32_t glVersion)373 uint32_t rcCreateContext_enc(void *self , uint32_t config, uint32_t share, uint32_t glVersion)
374 {
375 
376 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
377 	IOStream *stream = ctx->m_stream;
378 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
379 	bool useChecksum = checksumCalculator->getVersion() > 0;
380 
381 	 unsigned char *ptr;
382 	 unsigned char *buf;
383 	 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4;
384 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
385 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
386 	buf = stream->alloc(totalSize);
387 	ptr = buf;
388 	int tmp = OP_rcCreateContext;memcpy(ptr, &tmp, 4); ptr += 4;
389 	memcpy(ptr, &totalSize, 4);  ptr += 4;
390 
391 		memcpy(ptr, &config, 4); ptr += 4;
392 		memcpy(ptr, &share, 4); ptr += 4;
393 		memcpy(ptr, &glVersion, 4); ptr += 4;
394 
395 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
396 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
397 
398 
399 	uint32_t retval;
400 	stream->readback(&retval, 4);
401 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
402 	if (useChecksum) {
403 		unsigned char *checksumBufPtr = NULL;
404 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
405 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
406 		stream->readback(checksumBufPtr, checksumSize);
407 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
408 			ALOGE("rcCreateContext: GL communication error, please report this issue to b.android.com.\n");
409 			abort();
410 		}
411 	}
412 	return retval;
413 }
414 
rcDestroyContext_enc(void * self,uint32_t context)415 void rcDestroyContext_enc(void *self , uint32_t context)
416 {
417 
418 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
419 	IOStream *stream = ctx->m_stream;
420 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
421 	bool useChecksum = checksumCalculator->getVersion() > 0;
422 
423 	 unsigned char *ptr;
424 	 unsigned char *buf;
425 	 const size_t sizeWithoutChecksum = 8 + 4;
426 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
427 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
428 	buf = stream->alloc(totalSize);
429 	ptr = buf;
430 	int tmp = OP_rcDestroyContext;memcpy(ptr, &tmp, 4); ptr += 4;
431 	memcpy(ptr, &totalSize, 4);  ptr += 4;
432 
433 		memcpy(ptr, &context, 4); ptr += 4;
434 
435 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
436 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
437 
438 }
439 
rcCreateWindowSurface_enc(void * self,uint32_t config,uint32_t width,uint32_t height)440 uint32_t rcCreateWindowSurface_enc(void *self , uint32_t config, uint32_t width, uint32_t height)
441 {
442 
443 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
444 	IOStream *stream = ctx->m_stream;
445 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
446 	bool useChecksum = checksumCalculator->getVersion() > 0;
447 
448 	 unsigned char *ptr;
449 	 unsigned char *buf;
450 	 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4;
451 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
452 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
453 	buf = stream->alloc(totalSize);
454 	ptr = buf;
455 	int tmp = OP_rcCreateWindowSurface;memcpy(ptr, &tmp, 4); ptr += 4;
456 	memcpy(ptr, &totalSize, 4);  ptr += 4;
457 
458 		memcpy(ptr, &config, 4); ptr += 4;
459 		memcpy(ptr, &width, 4); ptr += 4;
460 		memcpy(ptr, &height, 4); ptr += 4;
461 
462 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
463 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
464 
465 
466 	uint32_t retval;
467 	stream->readback(&retval, 4);
468 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
469 	if (useChecksum) {
470 		unsigned char *checksumBufPtr = NULL;
471 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
472 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
473 		stream->readback(checksumBufPtr, checksumSize);
474 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
475 			ALOGE("rcCreateWindowSurface: GL communication error, please report this issue to b.android.com.\n");
476 			abort();
477 		}
478 	}
479 	return retval;
480 }
481 
rcDestroyWindowSurface_enc(void * self,uint32_t windowSurface)482 void rcDestroyWindowSurface_enc(void *self , uint32_t windowSurface)
483 {
484 
485 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
486 	IOStream *stream = ctx->m_stream;
487 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
488 	bool useChecksum = checksumCalculator->getVersion() > 0;
489 
490 	 unsigned char *ptr;
491 	 unsigned char *buf;
492 	 const size_t sizeWithoutChecksum = 8 + 4;
493 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
494 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
495 	buf = stream->alloc(totalSize);
496 	ptr = buf;
497 	int tmp = OP_rcDestroyWindowSurface;memcpy(ptr, &tmp, 4); ptr += 4;
498 	memcpy(ptr, &totalSize, 4);  ptr += 4;
499 
500 		memcpy(ptr, &windowSurface, 4); ptr += 4;
501 
502 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
503 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
504 
505 }
506 
rcCreateColorBuffer_enc(void * self,uint32_t width,uint32_t height,GLenum internalFormat)507 uint32_t rcCreateColorBuffer_enc(void *self , uint32_t width, uint32_t height, GLenum internalFormat)
508 {
509 
510 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
511 	IOStream *stream = ctx->m_stream;
512 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
513 	bool useChecksum = checksumCalculator->getVersion() > 0;
514 
515 	 unsigned char *ptr;
516 	 unsigned char *buf;
517 	 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4;
518 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
519 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
520 	buf = stream->alloc(totalSize);
521 	ptr = buf;
522 	int tmp = OP_rcCreateColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
523 	memcpy(ptr, &totalSize, 4);  ptr += 4;
524 
525 		memcpy(ptr, &width, 4); ptr += 4;
526 		memcpy(ptr, &height, 4); ptr += 4;
527 		memcpy(ptr, &internalFormat, 4); ptr += 4;
528 
529 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
530 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
531 
532 
533 	uint32_t retval;
534 	stream->readback(&retval, 4);
535 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
536 	if (useChecksum) {
537 		unsigned char *checksumBufPtr = NULL;
538 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
539 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
540 		stream->readback(checksumBufPtr, checksumSize);
541 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
542 			ALOGE("rcCreateColorBuffer: GL communication error, please report this issue to b.android.com.\n");
543 			abort();
544 		}
545 	}
546 	return retval;
547 }
548 
rcOpenColorBuffer_enc(void * self,uint32_t colorbuffer)549 void rcOpenColorBuffer_enc(void *self , uint32_t colorbuffer)
550 {
551 
552 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
553 	IOStream *stream = ctx->m_stream;
554 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
555 	bool useChecksum = checksumCalculator->getVersion() > 0;
556 
557 	 unsigned char *ptr;
558 	 unsigned char *buf;
559 	 const size_t sizeWithoutChecksum = 8 + 4;
560 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
561 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
562 	buf = stream->alloc(totalSize);
563 	ptr = buf;
564 	int tmp = OP_rcOpenColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
565 	memcpy(ptr, &totalSize, 4);  ptr += 4;
566 
567 		memcpy(ptr, &colorbuffer, 4); ptr += 4;
568 
569 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
570 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
571 
572 }
573 
rcCloseColorBuffer_enc(void * self,uint32_t colorbuffer)574 void rcCloseColorBuffer_enc(void *self , uint32_t colorbuffer)
575 {
576 
577 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
578 	IOStream *stream = ctx->m_stream;
579 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
580 	bool useChecksum = checksumCalculator->getVersion() > 0;
581 
582 	 unsigned char *ptr;
583 	 unsigned char *buf;
584 	 const size_t sizeWithoutChecksum = 8 + 4;
585 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
586 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
587 	buf = stream->alloc(totalSize);
588 	ptr = buf;
589 	int tmp = OP_rcCloseColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
590 	memcpy(ptr, &totalSize, 4);  ptr += 4;
591 
592 		memcpy(ptr, &colorbuffer, 4); ptr += 4;
593 
594 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
595 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
596 
597 	stream->flush();
598 }
599 
rcSetWindowColorBuffer_enc(void * self,uint32_t windowSurface,uint32_t colorBuffer)600 void rcSetWindowColorBuffer_enc(void *self , uint32_t windowSurface, uint32_t colorBuffer)
601 {
602 
603 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
604 	IOStream *stream = ctx->m_stream;
605 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
606 	bool useChecksum = checksumCalculator->getVersion() > 0;
607 
608 	 unsigned char *ptr;
609 	 unsigned char *buf;
610 	 const size_t sizeWithoutChecksum = 8 + 4 + 4;
611 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
612 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
613 	buf = stream->alloc(totalSize);
614 	ptr = buf;
615 	int tmp = OP_rcSetWindowColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
616 	memcpy(ptr, &totalSize, 4);  ptr += 4;
617 
618 		memcpy(ptr, &windowSurface, 4); ptr += 4;
619 		memcpy(ptr, &colorBuffer, 4); ptr += 4;
620 
621 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
622 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
623 
624 }
625 
rcFlushWindowColorBuffer_enc(void * self,uint32_t windowSurface)626 int rcFlushWindowColorBuffer_enc(void *self , uint32_t windowSurface)
627 {
628 
629 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
630 	IOStream *stream = ctx->m_stream;
631 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
632 	bool useChecksum = checksumCalculator->getVersion() > 0;
633 
634 	 unsigned char *ptr;
635 	 unsigned char *buf;
636 	 const size_t sizeWithoutChecksum = 8 + 4;
637 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
638 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
639 	buf = stream->alloc(totalSize);
640 	ptr = buf;
641 	int tmp = OP_rcFlushWindowColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
642 	memcpy(ptr, &totalSize, 4);  ptr += 4;
643 
644 		memcpy(ptr, &windowSurface, 4); ptr += 4;
645 
646 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
647 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
648 
649 
650 	int retval;
651 	stream->readback(&retval, 4);
652 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
653 	if (useChecksum) {
654 		unsigned char *checksumBufPtr = NULL;
655 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
656 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
657 		stream->readback(checksumBufPtr, checksumSize);
658 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
659 			ALOGE("rcFlushWindowColorBuffer: GL communication error, please report this issue to b.android.com.\n");
660 			abort();
661 		}
662 	}
663 	return retval;
664 }
665 
rcMakeCurrent_enc(void * self,uint32_t context,uint32_t drawSurf,uint32_t readSurf)666 EGLint rcMakeCurrent_enc(void *self , uint32_t context, uint32_t drawSurf, uint32_t readSurf)
667 {
668 
669 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
670 	IOStream *stream = ctx->m_stream;
671 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
672 	bool useChecksum = checksumCalculator->getVersion() > 0;
673 
674 	 unsigned char *ptr;
675 	 unsigned char *buf;
676 	 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4;
677 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
678 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
679 	buf = stream->alloc(totalSize);
680 	ptr = buf;
681 	int tmp = OP_rcMakeCurrent;memcpy(ptr, &tmp, 4); ptr += 4;
682 	memcpy(ptr, &totalSize, 4);  ptr += 4;
683 
684 		memcpy(ptr, &context, 4); ptr += 4;
685 		memcpy(ptr, &drawSurf, 4); ptr += 4;
686 		memcpy(ptr, &readSurf, 4); ptr += 4;
687 
688 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
689 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
690 
691 
692 	EGLint retval;
693 	stream->readback(&retval, 4);
694 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
695 	if (useChecksum) {
696 		unsigned char *checksumBufPtr = NULL;
697 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
698 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
699 		stream->readback(checksumBufPtr, checksumSize);
700 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
701 			ALOGE("rcMakeCurrent: GL communication error, please report this issue to b.android.com.\n");
702 			abort();
703 		}
704 	}
705 	return retval;
706 }
707 
rcFBPost_enc(void * self,uint32_t colorBuffer)708 void rcFBPost_enc(void *self , uint32_t colorBuffer)
709 {
710 
711 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
712 	IOStream *stream = ctx->m_stream;
713 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
714 	bool useChecksum = checksumCalculator->getVersion() > 0;
715 
716 	 unsigned char *ptr;
717 	 unsigned char *buf;
718 	 const size_t sizeWithoutChecksum = 8 + 4;
719 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
720 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
721 	buf = stream->alloc(totalSize);
722 	ptr = buf;
723 	int tmp = OP_rcFBPost;memcpy(ptr, &tmp, 4); ptr += 4;
724 	memcpy(ptr, &totalSize, 4);  ptr += 4;
725 
726 		memcpy(ptr, &colorBuffer, 4); ptr += 4;
727 
728 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
729 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
730 
731 }
732 
rcFBSetSwapInterval_enc(void * self,EGLint interval)733 void rcFBSetSwapInterval_enc(void *self , EGLint interval)
734 {
735 
736 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
737 	IOStream *stream = ctx->m_stream;
738 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
739 	bool useChecksum = checksumCalculator->getVersion() > 0;
740 
741 	 unsigned char *ptr;
742 	 unsigned char *buf;
743 	 const size_t sizeWithoutChecksum = 8 + 4;
744 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
745 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
746 	buf = stream->alloc(totalSize);
747 	ptr = buf;
748 	int tmp = OP_rcFBSetSwapInterval;memcpy(ptr, &tmp, 4); ptr += 4;
749 	memcpy(ptr, &totalSize, 4);  ptr += 4;
750 
751 		memcpy(ptr, &interval, 4); ptr += 4;
752 
753 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
754 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
755 
756 }
757 
rcBindTexture_enc(void * self,uint32_t colorBuffer)758 void rcBindTexture_enc(void *self , uint32_t colorBuffer)
759 {
760 
761 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
762 	IOStream *stream = ctx->m_stream;
763 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
764 	bool useChecksum = checksumCalculator->getVersion() > 0;
765 
766 	 unsigned char *ptr;
767 	 unsigned char *buf;
768 	 const size_t sizeWithoutChecksum = 8 + 4;
769 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
770 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
771 	buf = stream->alloc(totalSize);
772 	ptr = buf;
773 	int tmp = OP_rcBindTexture;memcpy(ptr, &tmp, 4); ptr += 4;
774 	memcpy(ptr, &totalSize, 4);  ptr += 4;
775 
776 		memcpy(ptr, &colorBuffer, 4); ptr += 4;
777 
778 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
779 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
780 
781 }
782 
rcBindRenderbuffer_enc(void * self,uint32_t colorBuffer)783 void rcBindRenderbuffer_enc(void *self , uint32_t colorBuffer)
784 {
785 
786 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
787 	IOStream *stream = ctx->m_stream;
788 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
789 	bool useChecksum = checksumCalculator->getVersion() > 0;
790 
791 	 unsigned char *ptr;
792 	 unsigned char *buf;
793 	 const size_t sizeWithoutChecksum = 8 + 4;
794 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
795 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
796 	buf = stream->alloc(totalSize);
797 	ptr = buf;
798 	int tmp = OP_rcBindRenderbuffer;memcpy(ptr, &tmp, 4); ptr += 4;
799 	memcpy(ptr, &totalSize, 4);  ptr += 4;
800 
801 		memcpy(ptr, &colorBuffer, 4); ptr += 4;
802 
803 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
804 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
805 
806 }
807 
rcColorBufferCacheFlush_enc(void * self,uint32_t colorbuffer,EGLint postCount,int forRead)808 EGLint rcColorBufferCacheFlush_enc(void *self , uint32_t colorbuffer, EGLint postCount, int forRead)
809 {
810 
811 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
812 	IOStream *stream = ctx->m_stream;
813 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
814 	bool useChecksum = checksumCalculator->getVersion() > 0;
815 
816 	 unsigned char *ptr;
817 	 unsigned char *buf;
818 	 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4;
819 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
820 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
821 	buf = stream->alloc(totalSize);
822 	ptr = buf;
823 	int tmp = OP_rcColorBufferCacheFlush;memcpy(ptr, &tmp, 4); ptr += 4;
824 	memcpy(ptr, &totalSize, 4);  ptr += 4;
825 
826 		memcpy(ptr, &colorbuffer, 4); ptr += 4;
827 		memcpy(ptr, &postCount, 4); ptr += 4;
828 		memcpy(ptr, &forRead, 4); ptr += 4;
829 
830 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
831 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
832 
833 
834 	EGLint retval;
835 	stream->readback(&retval, 4);
836 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
837 	if (useChecksum) {
838 		unsigned char *checksumBufPtr = NULL;
839 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
840 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
841 		stream->readback(checksumBufPtr, checksumSize);
842 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
843 			ALOGE("rcColorBufferCacheFlush: GL communication error, please report this issue to b.android.com.\n");
844 			abort();
845 		}
846 	}
847 	return retval;
848 }
849 
rcReadColorBuffer_enc(void * self,uint32_t colorbuffer,GLint x,GLint y,GLint width,GLint height,GLenum format,GLenum type,void * pixels)850 void rcReadColorBuffer_enc(void *self , uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels)
851 {
852 
853 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
854 	IOStream *stream = ctx->m_stream;
855 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
856 	bool useChecksum = checksumCalculator->getVersion() > 0;
857 
858 	const unsigned int __size_pixels =  (((glUtilsPixelBitSize(format, type) * width) >> 3) * height);
859 	 unsigned char *ptr;
860 	 unsigned char *buf;
861 	 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 0 + 1*4;
862 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
863 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
864 	buf = stream->alloc(totalSize);
865 	ptr = buf;
866 	int tmp = OP_rcReadColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
867 	memcpy(ptr, &totalSize, 4);  ptr += 4;
868 
869 		memcpy(ptr, &colorbuffer, 4); ptr += 4;
870 		memcpy(ptr, &x, 4); ptr += 4;
871 		memcpy(ptr, &y, 4); ptr += 4;
872 		memcpy(ptr, &width, 4); ptr += 4;
873 		memcpy(ptr, &height, 4); ptr += 4;
874 		memcpy(ptr, &format, 4); ptr += 4;
875 		memcpy(ptr, &type, 4); ptr += 4;
876 	*(unsigned int *)(ptr) = __size_pixels; ptr += 4;
877 
878 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
879 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
880 
881 	stream->readback(pixels, __size_pixels);
882 	if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels);
883 	if (useChecksum) {
884 		unsigned char *checksumBufPtr = NULL;
885 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
886 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
887 		stream->readback(checksumBufPtr, checksumSize);
888 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
889 			ALOGE("rcReadColorBuffer: GL communication error, please report this issue to b.android.com.\n");
890 			abort();
891 		}
892 	}
893 }
894 
rcUpdateColorBuffer_enc(void * self,uint32_t colorbuffer,GLint x,GLint y,GLint width,GLint height,GLenum format,GLenum type,void * pixels)895 int rcUpdateColorBuffer_enc(void *self , uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels)
896 {
897 
898 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
899 	IOStream *stream = ctx->m_stream;
900 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
901 	bool useChecksum = checksumCalculator->getVersion() > 0;
902 
903 	const unsigned int __size_pixels =  (((glUtilsPixelBitSize(format, type) * width) >> 3) * height);
904 	 unsigned char *ptr;
905 	 unsigned char *buf;
906 	 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4;
907 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
908 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
909 	buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
910 	ptr = buf;
911 	int tmp = OP_rcUpdateColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
912 	memcpy(ptr, &totalSize, 4);  ptr += 4;
913 
914 		memcpy(ptr, &colorbuffer, 4); ptr += 4;
915 		memcpy(ptr, &x, 4); ptr += 4;
916 		memcpy(ptr, &y, 4); ptr += 4;
917 		memcpy(ptr, &width, 4); ptr += 4;
918 		memcpy(ptr, &height, 4); ptr += 4;
919 		memcpy(ptr, &format, 4); ptr += 4;
920 		memcpy(ptr, &type, 4); ptr += 4;
921 
922 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
923 	stream->flush();
924 	stream->writeFully(&__size_pixels,4);
925 	if (useChecksum) checksumCalculator->addBuffer(&__size_pixels,4);
926 		stream->writeFully(pixels, __size_pixels);
927 		if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels);
928 	buf = stream->alloc(checksumSize);
929 	if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize);
930 
931 
932 	int retval;
933 	stream->readback(&retval, 4);
934 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
935 	if (useChecksum) {
936 		unsigned char *checksumBufPtr = NULL;
937 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
938 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
939 		stream->readback(checksumBufPtr, checksumSize);
940 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
941 			ALOGE("rcUpdateColorBuffer: GL communication error, please report this issue to b.android.com.\n");
942 			abort();
943 		}
944 	}
945 	return retval;
946 }
947 
rcOpenColorBuffer2_enc(void * self,uint32_t colorbuffer)948 int rcOpenColorBuffer2_enc(void *self , uint32_t colorbuffer)
949 {
950 
951 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
952 	IOStream *stream = ctx->m_stream;
953 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
954 	bool useChecksum = checksumCalculator->getVersion() > 0;
955 
956 	 unsigned char *ptr;
957 	 unsigned char *buf;
958 	 const size_t sizeWithoutChecksum = 8 + 4;
959 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
960 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
961 	buf = stream->alloc(totalSize);
962 	ptr = buf;
963 	int tmp = OP_rcOpenColorBuffer2;memcpy(ptr, &tmp, 4); ptr += 4;
964 	memcpy(ptr, &totalSize, 4);  ptr += 4;
965 
966 		memcpy(ptr, &colorbuffer, 4); ptr += 4;
967 
968 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
969 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
970 
971 
972 	int retval;
973 	stream->readback(&retval, 4);
974 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
975 	if (useChecksum) {
976 		unsigned char *checksumBufPtr = NULL;
977 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
978 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
979 		stream->readback(checksumBufPtr, checksumSize);
980 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
981 			ALOGE("rcOpenColorBuffer2: GL communication error, please report this issue to b.android.com.\n");
982 			abort();
983 		}
984 	}
985 	return retval;
986 }
987 
rcCreateClientImage_enc(void * self,uint32_t context,EGLenum target,GLuint buffer)988 uint32_t rcCreateClientImage_enc(void *self , uint32_t context, EGLenum target, GLuint buffer)
989 {
990 
991 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
992 	IOStream *stream = ctx->m_stream;
993 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
994 	bool useChecksum = checksumCalculator->getVersion() > 0;
995 
996 	 unsigned char *ptr;
997 	 unsigned char *buf;
998 	 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 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_rcCreateClientImage;memcpy(ptr, &tmp, 4); ptr += 4;
1004 	memcpy(ptr, &totalSize, 4);  ptr += 4;
1005 
1006 		memcpy(ptr, &context, 4); ptr += 4;
1007 		memcpy(ptr, &target, 4); ptr += 4;
1008 		memcpy(ptr, &buffer, 4); ptr += 4;
1009 
1010 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1011 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1012 
1013 
1014 	uint32_t retval;
1015 	stream->readback(&retval, 4);
1016 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
1017 	if (useChecksum) {
1018 		unsigned char *checksumBufPtr = NULL;
1019 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
1020 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
1021 		stream->readback(checksumBufPtr, checksumSize);
1022 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
1023 			ALOGE("rcCreateClientImage: GL communication error, please report this issue to b.android.com.\n");
1024 			abort();
1025 		}
1026 	}
1027 	return retval;
1028 }
1029 
rcDestroyClientImage_enc(void * self,uint32_t image)1030 int rcDestroyClientImage_enc(void *self , uint32_t image)
1031 {
1032 
1033 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
1034 	IOStream *stream = ctx->m_stream;
1035 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1036 	bool useChecksum = checksumCalculator->getVersion() > 0;
1037 
1038 	 unsigned char *ptr;
1039 	 unsigned char *buf;
1040 	 const size_t sizeWithoutChecksum = 8 + 4;
1041 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
1042 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1043 	buf = stream->alloc(totalSize);
1044 	ptr = buf;
1045 	int tmp = OP_rcDestroyClientImage;memcpy(ptr, &tmp, 4); ptr += 4;
1046 	memcpy(ptr, &totalSize, 4);  ptr += 4;
1047 
1048 		memcpy(ptr, &image, 4); ptr += 4;
1049 
1050 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1051 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1052 
1053 
1054 	int retval;
1055 	stream->readback(&retval, 4);
1056 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
1057 	if (useChecksum) {
1058 		unsigned char *checksumBufPtr = NULL;
1059 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
1060 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
1061 		stream->readback(checksumBufPtr, checksumSize);
1062 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
1063 			ALOGE("rcDestroyClientImage: GL communication error, please report this issue to b.android.com.\n");
1064 			abort();
1065 		}
1066 	}
1067 	return retval;
1068 }
1069 
rcSelectChecksumHelper_enc(void * self,uint32_t newProtocol,uint32_t reserved)1070 void rcSelectChecksumHelper_enc(void *self , uint32_t newProtocol, uint32_t reserved)
1071 {
1072 
1073 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
1074 	IOStream *stream = ctx->m_stream;
1075 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1076 	bool useChecksum = checksumCalculator->getVersion() > 0;
1077 
1078 	 unsigned char *ptr;
1079 	 unsigned char *buf;
1080 	 const size_t sizeWithoutChecksum = 8 + 4 + 4;
1081 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
1082 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1083 	buf = stream->alloc(totalSize);
1084 	ptr = buf;
1085 	int tmp = OP_rcSelectChecksumHelper;memcpy(ptr, &tmp, 4); ptr += 4;
1086 	memcpy(ptr, &totalSize, 4);  ptr += 4;
1087 
1088 		memcpy(ptr, &newProtocol, 4); ptr += 4;
1089 		memcpy(ptr, &reserved, 4); ptr += 4;
1090 
1091 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1092 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1093 
1094 }
1095 
rcCreateSyncKHR_enc(void * self,EGLenum type,EGLint * attribs,uint32_t num_attribs,int destroy_when_signaled,uint64_t * glsync_out,uint64_t * syncthread_out)1096 void rcCreateSyncKHR_enc(void *self , EGLenum type, EGLint* attribs, uint32_t num_attribs, int destroy_when_signaled, uint64_t* glsync_out, uint64_t* syncthread_out)
1097 {
1098 
1099 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
1100 	IOStream *stream = ctx->m_stream;
1101 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1102 	bool useChecksum = checksumCalculator->getVersion() > 0;
1103 
1104 	const unsigned int __size_attribs =  num_attribs;
1105 	const unsigned int __size_glsync_out =  sizeof(uint64_t);
1106 	const unsigned int __size_syncthread_out =  sizeof(uint64_t);
1107 	 unsigned char *ptr;
1108 	 unsigned char *buf;
1109 	 const size_t sizeWithoutChecksum = 8 + 4 + __size_attribs + 4 + 4 + 0 + 0 + 3*4;
1110 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
1111 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1112 	buf = stream->alloc(totalSize);
1113 	ptr = buf;
1114 	int tmp = OP_rcCreateSyncKHR;memcpy(ptr, &tmp, 4); ptr += 4;
1115 	memcpy(ptr, &totalSize, 4);  ptr += 4;
1116 
1117 		memcpy(ptr, &type, 4); ptr += 4;
1118 	*(unsigned int *)(ptr) = __size_attribs; ptr += 4;
1119 	memcpy(ptr, attribs, __size_attribs);ptr += __size_attribs;
1120 		memcpy(ptr, &num_attribs, 4); ptr += 4;
1121 		memcpy(ptr, &destroy_when_signaled, 4); ptr += 4;
1122 	*(unsigned int *)(ptr) = __size_glsync_out; ptr += 4;
1123 	*(unsigned int *)(ptr) = __size_syncthread_out; ptr += 4;
1124 
1125 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1126 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1127 
1128 	stream->readback(glsync_out, __size_glsync_out);
1129 	if (useChecksum) checksumCalculator->addBuffer(glsync_out, __size_glsync_out);
1130 	stream->readback(syncthread_out, __size_syncthread_out);
1131 	if (useChecksum) checksumCalculator->addBuffer(syncthread_out, __size_syncthread_out);
1132 	if (useChecksum) {
1133 		unsigned char *checksumBufPtr = NULL;
1134 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
1135 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
1136 		stream->readback(checksumBufPtr, checksumSize);
1137 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
1138 			ALOGE("rcCreateSyncKHR: GL communication error, please report this issue to b.android.com.\n");
1139 			abort();
1140 		}
1141 	}
1142 }
1143 
rcClientWaitSyncKHR_enc(void * self,uint64_t sync,EGLint flags,uint64_t timeout)1144 EGLint rcClientWaitSyncKHR_enc(void *self , uint64_t sync, EGLint flags, uint64_t timeout)
1145 {
1146 
1147 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
1148 	IOStream *stream = ctx->m_stream;
1149 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1150 	bool useChecksum = checksumCalculator->getVersion() > 0;
1151 
1152 	 unsigned char *ptr;
1153 	 unsigned char *buf;
1154 	 const size_t sizeWithoutChecksum = 8 + 8 + 4 + 8;
1155 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
1156 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1157 	buf = stream->alloc(totalSize);
1158 	ptr = buf;
1159 	int tmp = OP_rcClientWaitSyncKHR;memcpy(ptr, &tmp, 4); ptr += 4;
1160 	memcpy(ptr, &totalSize, 4);  ptr += 4;
1161 
1162 		memcpy(ptr, &sync, 8); ptr += 8;
1163 		memcpy(ptr, &flags, 4); ptr += 4;
1164 		memcpy(ptr, &timeout, 8); ptr += 8;
1165 
1166 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1167 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1168 
1169 
1170 	EGLint retval;
1171 	stream->readback(&retval, 4);
1172 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
1173 	if (useChecksum) {
1174 		unsigned char *checksumBufPtr = NULL;
1175 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
1176 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
1177 		stream->readback(checksumBufPtr, checksumSize);
1178 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
1179 			ALOGE("rcClientWaitSyncKHR: GL communication error, please report this issue to b.android.com.\n");
1180 			abort();
1181 		}
1182 	}
1183 	return retval;
1184 }
1185 
rcFlushWindowColorBufferAsync_enc(void * self,uint32_t windowSurface)1186 void rcFlushWindowColorBufferAsync_enc(void *self , uint32_t windowSurface)
1187 {
1188 
1189 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
1190 	IOStream *stream = ctx->m_stream;
1191 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1192 	bool useChecksum = checksumCalculator->getVersion() > 0;
1193 
1194 	 unsigned char *ptr;
1195 	 unsigned char *buf;
1196 	 const size_t sizeWithoutChecksum = 8 + 4;
1197 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
1198 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1199 	buf = stream->alloc(totalSize);
1200 	ptr = buf;
1201 	int tmp = OP_rcFlushWindowColorBufferAsync;memcpy(ptr, &tmp, 4); ptr += 4;
1202 	memcpy(ptr, &totalSize, 4);  ptr += 4;
1203 
1204 		memcpy(ptr, &windowSurface, 4); ptr += 4;
1205 
1206 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1207 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1208 
1209 }
1210 
rcDestroySyncKHR_enc(void * self,uint64_t sync)1211 int rcDestroySyncKHR_enc(void *self , uint64_t sync)
1212 {
1213 
1214 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
1215 	IOStream *stream = ctx->m_stream;
1216 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1217 	bool useChecksum = checksumCalculator->getVersion() > 0;
1218 
1219 	 unsigned char *ptr;
1220 	 unsigned char *buf;
1221 	 const size_t sizeWithoutChecksum = 8 + 8;
1222 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
1223 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1224 	buf = stream->alloc(totalSize);
1225 	ptr = buf;
1226 	int tmp = OP_rcDestroySyncKHR;memcpy(ptr, &tmp, 4); ptr += 4;
1227 	memcpy(ptr, &totalSize, 4);  ptr += 4;
1228 
1229 		memcpy(ptr, &sync, 8); ptr += 8;
1230 
1231 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1232 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1233 
1234 
1235 	int retval;
1236 	stream->readback(&retval, 4);
1237 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
1238 	if (useChecksum) {
1239 		unsigned char *checksumBufPtr = NULL;
1240 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
1241 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
1242 		stream->readback(checksumBufPtr, checksumSize);
1243 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
1244 			ALOGE("rcDestroySyncKHR: GL communication error, please report this issue to b.android.com.\n");
1245 			abort();
1246 		}
1247 	}
1248 	return retval;
1249 }
1250 
rcSetPuid_enc(void * self,uint64_t puid)1251 void rcSetPuid_enc(void *self , uint64_t puid)
1252 {
1253 
1254 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
1255 	IOStream *stream = ctx->m_stream;
1256 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1257 	bool useChecksum = checksumCalculator->getVersion() > 0;
1258 
1259 	 unsigned char *ptr;
1260 	 unsigned char *buf;
1261 	 const size_t sizeWithoutChecksum = 8 + 8;
1262 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
1263 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1264 	buf = stream->alloc(totalSize);
1265 	ptr = buf;
1266 	int tmp = OP_rcSetPuid;memcpy(ptr, &tmp, 4); ptr += 4;
1267 	memcpy(ptr, &totalSize, 4);  ptr += 4;
1268 
1269 		memcpy(ptr, &puid, 8); ptr += 8;
1270 
1271 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1272 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1273 
1274 }
1275 
rcUpdateColorBufferDMA_enc(void * self,uint32_t colorbuffer,GLint x,GLint y,GLint width,GLint height,GLenum format,GLenum type,void * pixels,uint32_t pixels_size)1276 int rcUpdateColorBufferDMA_enc(void *self , uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels, uint32_t pixels_size)
1277 {
1278 
1279 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
1280 	IOStream *stream = ctx->m_stream;
1281 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1282 	bool useChecksum = checksumCalculator->getVersion() > 0;
1283 
1284 	const unsigned int __size_pixels =  pixels_size;
1285 	 unsigned char *ptr;
1286 	 unsigned char *buf;
1287 	 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 8 + 4 + 1*4;
1288 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
1289 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1290 	buf = stream->alloc(totalSize);
1291 	ptr = buf;
1292 	int tmp = OP_rcUpdateColorBufferDMA;memcpy(ptr, &tmp, 4); ptr += 4;
1293 	memcpy(ptr, &totalSize, 4);  ptr += 4;
1294 
1295 		memcpy(ptr, &colorbuffer, 4); ptr += 4;
1296 		memcpy(ptr, &x, 4); ptr += 4;
1297 		memcpy(ptr, &y, 4); ptr += 4;
1298 		memcpy(ptr, &width, 4); ptr += 4;
1299 		memcpy(ptr, &height, 4); ptr += 4;
1300 		memcpy(ptr, &format, 4); ptr += 4;
1301 		memcpy(ptr, &type, 4); ptr += 4;
1302 	*(uint64_t *)(ptr) = ctx->lockAndWriteDma(pixels, __size_pixels); ptr += 8;
1303 		memcpy(ptr, &pixels_size, 4); ptr += 4;
1304 
1305 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1306 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1307 
1308 
1309 	int retval;
1310 	stream->readback(&retval, 4);
1311 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
1312 	if (useChecksum) {
1313 		unsigned char *checksumBufPtr = NULL;
1314 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
1315 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
1316 		stream->readback(checksumBufPtr, checksumSize);
1317 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
1318 			ALOGE("rcUpdateColorBufferDMA: GL communication error, please report this issue to b.android.com.\n");
1319 			abort();
1320 		}
1321 	}
1322 	return retval;
1323 }
1324 
rcCreateColorBufferDMA_enc(void * self,uint32_t width,uint32_t height,GLenum internalFormat,int frameworkFormat)1325 uint32_t rcCreateColorBufferDMA_enc(void *self , uint32_t width, uint32_t height, GLenum internalFormat, int frameworkFormat)
1326 {
1327 
1328 	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
1329 	IOStream *stream = ctx->m_stream;
1330 	ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
1331 	bool useChecksum = checksumCalculator->getVersion() > 0;
1332 
1333 	 unsigned char *ptr;
1334 	 unsigned char *buf;
1335 	 const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4;
1336 	 const size_t checksumSize = checksumCalculator->checksumByteSize();
1337 	 const size_t totalSize = sizeWithoutChecksum + checksumSize;
1338 	buf = stream->alloc(totalSize);
1339 	ptr = buf;
1340 	int tmp = OP_rcCreateColorBufferDMA;memcpy(ptr, &tmp, 4); ptr += 4;
1341 	memcpy(ptr, &totalSize, 4);  ptr += 4;
1342 
1343 		memcpy(ptr, &width, 4); ptr += 4;
1344 		memcpy(ptr, &height, 4); ptr += 4;
1345 		memcpy(ptr, &internalFormat, 4); ptr += 4;
1346 		memcpy(ptr, &frameworkFormat, 4); ptr += 4;
1347 
1348 	if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
1349 	if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
1350 
1351 
1352 	uint32_t retval;
1353 	stream->readback(&retval, 4);
1354 	if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
1355 	if (useChecksum) {
1356 		unsigned char *checksumBufPtr = NULL;
1357 		unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
1358 		if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
1359 		stream->readback(checksumBufPtr, checksumSize);
1360 		if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
1361 			ALOGE("rcCreateColorBufferDMA: GL communication error, please report this issue to b.android.com.\n");
1362 			abort();
1363 		}
1364 	}
1365 	return retval;
1366 }
1367 
1368 }  // namespace
1369 
renderControl_encoder_context_t(IOStream * stream,ChecksumCalculator * checksumCalculator)1370 renderControl_encoder_context_t::renderControl_encoder_context_t(IOStream *stream, ChecksumCalculator *checksumCalculator)
1371 {
1372 	m_stream = stream;
1373 	m_checksumCalculator = checksumCalculator;
1374 
1375 	this->rcGetRendererVersion = &rcGetRendererVersion_enc;
1376 	this->rcGetEGLVersion = &rcGetEGLVersion_enc;
1377 	this->rcQueryEGLString = &rcQueryEGLString_enc;
1378 	this->rcGetGLString = &rcGetGLString_enc;
1379 	this->rcGetNumConfigs = &rcGetNumConfigs_enc;
1380 	this->rcGetConfigs = &rcGetConfigs_enc;
1381 	this->rcChooseConfig = &rcChooseConfig_enc;
1382 	this->rcGetFBParam = &rcGetFBParam_enc;
1383 	this->rcCreateContext = &rcCreateContext_enc;
1384 	this->rcDestroyContext = &rcDestroyContext_enc;
1385 	this->rcCreateWindowSurface = &rcCreateWindowSurface_enc;
1386 	this->rcDestroyWindowSurface = &rcDestroyWindowSurface_enc;
1387 	this->rcCreateColorBuffer = &rcCreateColorBuffer_enc;
1388 	this->rcOpenColorBuffer = &rcOpenColorBuffer_enc;
1389 	this->rcCloseColorBuffer = &rcCloseColorBuffer_enc;
1390 	this->rcSetWindowColorBuffer = &rcSetWindowColorBuffer_enc;
1391 	this->rcFlushWindowColorBuffer = &rcFlushWindowColorBuffer_enc;
1392 	this->rcMakeCurrent = &rcMakeCurrent_enc;
1393 	this->rcFBPost = &rcFBPost_enc;
1394 	this->rcFBSetSwapInterval = &rcFBSetSwapInterval_enc;
1395 	this->rcBindTexture = &rcBindTexture_enc;
1396 	this->rcBindRenderbuffer = &rcBindRenderbuffer_enc;
1397 	this->rcColorBufferCacheFlush = &rcColorBufferCacheFlush_enc;
1398 	this->rcReadColorBuffer = &rcReadColorBuffer_enc;
1399 	this->rcUpdateColorBuffer = &rcUpdateColorBuffer_enc;
1400 	this->rcOpenColorBuffer2 = &rcOpenColorBuffer2_enc;
1401 	this->rcCreateClientImage = &rcCreateClientImage_enc;
1402 	this->rcDestroyClientImage = &rcDestroyClientImage_enc;
1403 	this->rcSelectChecksumHelper = &rcSelectChecksumHelper_enc;
1404 	this->rcCreateSyncKHR = &rcCreateSyncKHR_enc;
1405 	this->rcClientWaitSyncKHR = &rcClientWaitSyncKHR_enc;
1406 	this->rcFlushWindowColorBufferAsync = &rcFlushWindowColorBufferAsync_enc;
1407 	this->rcDestroySyncKHR = &rcDestroySyncKHR_enc;
1408 	this->rcSetPuid = &rcSetPuid_enc;
1409 	this->rcUpdateColorBufferDMA = &rcUpdateColorBufferDMA_enc;
1410 	this->rcCreateColorBufferDMA = &rcCreateColorBufferDMA_enc;
1411 }
1412 
1413