blob: 1f49ca17570e3a92267a768fccb98d80bebcab2a [file] [log] [blame]
Jason Samsd19f10d2009-05-22 14:03:28 -07001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "rsContext.h"
18
Jason Sams4b962e52009-06-22 17:15:15 -070019#include <GLES/gl.h>
20#include <GLES/glext.h>
21
Jason Samsd19f10d2009-05-22 14:03:28 -070022using namespace android;
23using namespace android::renderscript;
24
25Allocation::Allocation(const Type *type)
26{
27 mPtr = NULL;
28
29 mCpuWrite = false;
30 mCpuRead = false;
31 mGpuWrite = false;
32 mGpuRead = false;
33
34 mReadWriteRatio = 0;
35 mUpdateSize = 0;
36
37 mIsTexture = false;
38 mTextureID = 0;
39
40 mIsVertexBuffer = false;
41 mBufferID = 0;
42
43 mType.set(type);
Jason Sams1bada8c2009-08-09 17:01:55 -070044 rsAssert(type);
Jason Samsd19f10d2009-05-22 14:03:28 -070045 mPtr = malloc(mType->getSizeBytes());
46 if (!mPtr) {
47 LOGE("Allocation::Allocation, alloc failure");
48 }
Jason Samsd19f10d2009-05-22 14:03:28 -070049}
50
51Allocation::~Allocation()
52{
53}
54
55void Allocation::setCpuWritable(bool)
56{
57}
58
59void Allocation::setGpuWritable(bool)
60{
61}
62
63void Allocation::setCpuReadable(bool)
64{
65}
66
67void Allocation::setGpuReadable(bool)
68{
69}
70
71bool Allocation::fixAllocation()
72{
73 return false;
74}
75
76void Allocation::uploadToTexture(uint32_t lodOffset)
77{
78 //rsAssert(!mTextureId);
79 rsAssert(lodOffset < mType->getLODCount());
80
Jason Samse2ae85f2009-06-03 16:04:54 -070081 GLenum type = mType->getElement()->getGLType();
82 GLenum format = mType->getElement()->getGLFormat();
83
84 if (!type || !format) {
85 return;
86 }
87
Jason Samsd19f10d2009-05-22 14:03:28 -070088 if (!mTextureID) {
89 glGenTextures(1, &mTextureID);
90 }
91 glBindTexture(GL_TEXTURE_2D, mTextureID);
92
93 Adapter2D adapt(this);
94 for(uint32_t lod = 0; (lod + lodOffset) < mType->getLODCount(); lod++) {
95 adapt.setLOD(lod+lodOffset);
96
97 uint16_t * ptr = static_cast<uint16_t *>(adapt.getElement(0,0));
Jason Samse2ae85f2009-06-03 16:04:54 -070098 glTexImage2D(GL_TEXTURE_2D, lod, format,
99 adapt.getDimX(), adapt.getDimY(),
100 0, format, type, ptr);
Jason Samsd19f10d2009-05-22 14:03:28 -0700101 }
102}
103
104void Allocation::uploadToBufferObject()
105{
106 rsAssert(!mType->getDimY());
107 rsAssert(!mType->getDimZ());
108
Jason Samsd19f10d2009-05-22 14:03:28 -0700109 if (!mBufferID) {
110 glGenBuffers(1, &mBufferID);
111 }
112 glBindBuffer(GL_ARRAY_BUFFER, mBufferID);
113 glBufferData(GL_ARRAY_BUFFER, mType->getSizeBytes(), getPtr(), GL_DYNAMIC_DRAW);
114 glBindBuffer(GL_ARRAY_BUFFER, 0);
115}
116
Jason Sams1bada8c2009-08-09 17:01:55 -0700117
Jason Sams07ae4062009-08-27 20:23:34 -0700118void Allocation::data(const void *data, uint32_t sizeBytes)
Jason Samsd19f10d2009-05-22 14:03:28 -0700119{
Jason Sams07ae4062009-08-27 20:23:34 -0700120 uint32_t size = mType->getSizeBytes();
121 if (size != sizeBytes) {
122 LOGE("Allocation::data called with mismatched size expected %i, got %i", size, sizeBytes);
123 return;
124 }
125 memcpy(mPtr, data, size);
Jason Samsd19f10d2009-05-22 14:03:28 -0700126}
127
Jason Sams40a29e82009-08-10 14:55:26 -0700128void Allocation::read(void *data)
129{
130 memcpy(data, mPtr, mType->getSizeBytes());
131}
132
Jason Sams07ae4062009-08-27 20:23:34 -0700133void Allocation::subData(uint32_t xoff, uint32_t count, const void *data, uint32_t sizeBytes)
Jason Samsd19f10d2009-05-22 14:03:28 -0700134{
135 uint32_t eSize = mType->getElementSizeBytes();
136 uint8_t * ptr = static_cast<uint8_t *>(mPtr);
137 ptr += eSize * xoff;
Jason Sams07ae4062009-08-27 20:23:34 -0700138 uint32_t size = count * eSize;
139
140 if (size != sizeBytes) {
141 LOGE("Allocation::subData called with mismatched size expected %i, got %i", size, sizeBytes);
142 return;
143 }
144 memcpy(ptr, data, size);
Jason Samsd19f10d2009-05-22 14:03:28 -0700145}
146
Jason Samse2ae85f2009-06-03 16:04:54 -0700147void Allocation::subData(uint32_t xoff, uint32_t yoff,
Jason Sams07ae4062009-08-27 20:23:34 -0700148 uint32_t w, uint32_t h, const void *data, uint32_t sizeBytes)
Jason Samsd19f10d2009-05-22 14:03:28 -0700149{
150 uint32_t eSize = mType->getElementSizeBytes();
151 uint32_t lineSize = eSize * w;
152 uint32_t destW = mType->getDimX();
153
154 const uint8_t *src = static_cast<const uint8_t *>(data);
155 uint8_t *dst = static_cast<uint8_t *>(mPtr);
156 dst += eSize * (xoff + yoff * destW);
Jason Sams07ae4062009-08-27 20:23:34 -0700157
158 if ((lineSize * eSize * h) != sizeBytes) {
159 rsAssert(!"Allocation::subData called with mismatched size");
160 return;
161 }
162
Jason Samsd19f10d2009-05-22 14:03:28 -0700163 for (uint32_t line=yoff; line < (yoff+h); line++) {
164 uint8_t * ptr = static_cast<uint8_t *>(mPtr);
165 memcpy(dst, src, lineSize);
166 src += lineSize;
167 dst += destW * eSize;
168 }
169}
170
171void Allocation::subData(uint32_t xoff, uint32_t yoff, uint32_t zoff,
Jason Sams07ae4062009-08-27 20:23:34 -0700172 uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes)
Jason Samsd19f10d2009-05-22 14:03:28 -0700173{
174}
175
176
177
178/////////////////
Jason Samse2ae85f2009-06-03 16:04:54 -0700179//
Jason Samsd19f10d2009-05-22 14:03:28 -0700180
181
182namespace android {
183namespace renderscript {
184
185RsAllocation rsi_AllocationCreateTyped(Context *rsc, RsType vtype)
186{
187 const Type * type = static_cast<const Type *>(vtype);
188
189 Allocation * alloc = new Allocation(type);
Jason Sams07ae4062009-08-27 20:23:34 -0700190 alloc->incUserRef();
Jason Samsd19f10d2009-05-22 14:03:28 -0700191 return alloc;
192}
193
194RsAllocation rsi_AllocationCreatePredefSized(Context *rsc, RsElementPredefined t, size_t count)
195{
196 RsElement e = rsi_ElementGetPredefined(rsc, t);
197 return rsi_AllocationCreateSized(rsc, e, count);
198}
199
200RsAllocation rsi_AllocationCreateSized(Context *rsc, RsElement e, size_t count)
201{
202 Type * type = new Type();
203 type->setDimX(count);
204 type->setElement(static_cast<Element *>(e));
205 type->compute();
206 return rsi_AllocationCreateTyped(rsc, type);
207}
208
209void rsi_AllocationUploadToTexture(Context *rsc, RsAllocation va, uint32_t baseMipLevel)
210{
211 Allocation *alloc = static_cast<Allocation *>(va);
212 alloc->uploadToTexture(baseMipLevel);
213}
214
215void rsi_AllocationUploadToBufferObject(Context *rsc, RsAllocation va)
216{
217 Allocation *alloc = static_cast<Allocation *>(va);
218 alloc->uploadToBufferObject();
219}
220
Jason Samse2ae85f2009-06-03 16:04:54 -0700221static void mip565(const Adapter2D &out, const Adapter2D &in)
Jason Samsd19f10d2009-05-22 14:03:28 -0700222{
223 uint32_t w = out.getDimX();
224 uint32_t h = out.getDimY();
225
Jason Sams6f5c61c2009-07-28 17:20:11 -0700226 for (uint32_t y=0; y < h; y++) {
Jason Samsd19f10d2009-05-22 14:03:28 -0700227 uint16_t *oPtr = static_cast<uint16_t *>(out.getElement(0, y));
228 const uint16_t *i1 = static_cast<uint16_t *>(in.getElement(0, y*2));
229 const uint16_t *i2 = static_cast<uint16_t *>(in.getElement(0, y*2+1));
230
Jason Sams6f5c61c2009-07-28 17:20:11 -0700231 for (uint32_t x=0; x < w; x++) {
Jason Samse2ae85f2009-06-03 16:04:54 -0700232 *oPtr = rsBoxFilter565(i1[0], i1[1], i2[0], i2[1]);
233 oPtr ++;
234 i1 += 2;
235 i2 += 2;
236 }
237 }
238}
239
240static void mip8888(const Adapter2D &out, const Adapter2D &in)
241{
242 uint32_t w = out.getDimX();
243 uint32_t h = out.getDimY();
244
Jason Sams6f5c61c2009-07-28 17:20:11 -0700245 for (uint32_t y=0; y < h; y++) {
Jason Samse2ae85f2009-06-03 16:04:54 -0700246 uint32_t *oPtr = static_cast<uint32_t *>(out.getElement(0, y));
247 const uint32_t *i1 = static_cast<uint32_t *>(in.getElement(0, y*2));
248 const uint32_t *i2 = static_cast<uint32_t *>(in.getElement(0, y*2+1));
249
Jason Sams6f5c61c2009-07-28 17:20:11 -0700250 for (uint32_t x=0; x < w; x++) {
Jason Samse2ae85f2009-06-03 16:04:54 -0700251 *oPtr = rsBoxFilter8888(i1[0], i1[1], i2[0], i2[1]);
Jason Samsd19f10d2009-05-22 14:03:28 -0700252 oPtr ++;
253 i1 += 2;
254 i2 += 2;
255 }
256 }
Jason Samsd19f10d2009-05-22 14:03:28 -0700257}
258
Jason Sams6f5c61c2009-07-28 17:20:11 -0700259static void mip(const Adapter2D &out, const Adapter2D &in)
260{
261 switch(out.getBaseType()->getElement()->getSizeBits()) {
262 case 32:
263 mip8888(out, in);
264 break;
265 case 16:
266 mip565(out, in);
267 break;
268
269 }
270
271}
Jason Samsd19f10d2009-05-22 14:03:28 -0700272
Jason Samsfe08d992009-05-27 14:45:32 -0700273typedef void (*ElementConverter_t)(void *dst, const void *src, uint32_t count);
274
275static void elementConverter_cpy_16(void *dst, const void *src, uint32_t count)
276{
277 memcpy(dst, src, count * 2);
278}
279static void elementConverter_cpy_8(void *dst, const void *src, uint32_t count)
280{
281 memcpy(dst, src, count);
282}
283static void elementConverter_cpy_32(void *dst, const void *src, uint32_t count)
284{
285 memcpy(dst, src, count * 4);
286}
287
288
289static void elementConverter_888_to_565(void *dst, const void *src, uint32_t count)
290{
291 uint16_t *d = static_cast<uint16_t *>(dst);
292 const uint8_t *s = static_cast<const uint8_t *>(src);
293
294 while(count--) {
295 *d = rs888to565(s[0], s[1], s[2]);
296 d++;
297 s+= 3;
298 }
299}
300
301static void elementConverter_8888_to_565(void *dst, const void *src, uint32_t count)
302{
303 uint16_t *d = static_cast<uint16_t *>(dst);
304 const uint8_t *s = static_cast<const uint8_t *>(src);
305
306 while(count--) {
307 *d = rs888to565(s[0], s[1], s[2]);
308 d++;
309 s+= 4;
310 }
311}
312
313static ElementConverter_t pickConverter(RsElementPredefined dstFmt, RsElementPredefined srcFmt)
314{
Jason Samse2ae85f2009-06-03 16:04:54 -0700315 if ((dstFmt == RS_ELEMENT_RGB_565) &&
Jason Samsfe08d992009-05-27 14:45:32 -0700316 (srcFmt == RS_ELEMENT_RGB_565)) {
317 return elementConverter_cpy_16;
318 }
319
Jason Samse2ae85f2009-06-03 16:04:54 -0700320 if ((dstFmt == RS_ELEMENT_RGB_565) &&
Jason Samsfe08d992009-05-27 14:45:32 -0700321 (srcFmt == RS_ELEMENT_RGB_888)) {
322 return elementConverter_888_to_565;
323 }
324
Jason Samse2ae85f2009-06-03 16:04:54 -0700325 if ((dstFmt == RS_ELEMENT_RGB_565) &&
Jason Samsfe08d992009-05-27 14:45:32 -0700326 (srcFmt == RS_ELEMENT_RGBA_8888)) {
327 return elementConverter_8888_to_565;
328 }
329
Jason Samse2ae85f2009-06-03 16:04:54 -0700330 if ((dstFmt == RS_ELEMENT_RGBA_8888) &&
331 (srcFmt == RS_ELEMENT_RGBA_8888)) {
332 return elementConverter_cpy_32;
333 }
Jason Samsfe08d992009-05-27 14:45:32 -0700334
Jason Samsb0ec1b42009-07-28 12:02:16 -0700335 LOGE("pickConverter, unsuported combo, src %i, dst %i", srcFmt, dstFmt);
Jason Samsfe08d992009-05-27 14:45:32 -0700336 return 0;
337}
338
339
340RsAllocation rsi_AllocationCreateFromBitmap(Context *rsc, uint32_t w, uint32_t h, RsElementPredefined dstFmt, RsElementPredefined srcFmt, bool genMips, const void *data)
341{
Jason Samsb0ec1b42009-07-28 12:02:16 -0700342 rsAssert(!(w & (w-1)));
343 rsAssert(!(h & (h-1)));
344
345 //LOGE("rsi_AllocationCreateFromBitmap %i %i %i %i %i", w, h, dstFmt, srcFmt, genMips);
346 rsi_TypeBegin(rsc, rsi_ElementGetPredefined(rsc, dstFmt));
Jason Samsfe08d992009-05-27 14:45:32 -0700347 rsi_TypeAdd(rsc, RS_DIMENSION_X, w);
348 rsi_TypeAdd(rsc, RS_DIMENSION_Y, h);
349 if (genMips) {
350 rsi_TypeAdd(rsc, RS_DIMENSION_LOD, 1);
351 }
352 RsType type = rsi_TypeCreate(rsc);
353
354 RsAllocation vTexAlloc = rsi_AllocationCreateTyped(rsc, type);
355 Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc);
356 if (texAlloc == NULL) {
357 LOGE("Memory allocation failure");
358 return NULL;
359 }
Jason Sams07ae4062009-08-27 20:23:34 -0700360 texAlloc->incUserRef();
Jason Samsfe08d992009-05-27 14:45:32 -0700361
362 ElementConverter_t cvt = pickConverter(dstFmt, srcFmt);
363 cvt(texAlloc->getPtr(), data, w * h);
364
365 if (genMips) {
366 Adapter2D adapt(texAlloc);
367 Adapter2D adapt2(texAlloc);
368 for(uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) {
369 adapt.setLOD(lod);
370 adapt2.setLOD(lod + 1);
Jason Sams6f5c61c2009-07-28 17:20:11 -0700371 mip(adapt2, adapt);
Jason Samsfe08d992009-05-27 14:45:32 -0700372 }
373 }
374
375 return texAlloc;
376}
377
Jason Samsb0ec1b42009-07-28 12:02:16 -0700378static uint32_t fmtToBits(RsElementPredefined fmt)
379{
380 return 16;
381}
382
383RsAllocation rsi_AllocationCreateFromBitmapBoxed(Context *rsc, uint32_t w, uint32_t h, RsElementPredefined dstFmt, RsElementPredefined srcFmt, bool genMips, const void *data)
384{
385 uint32_t w2 = rsHigherPow2(w);
386 uint32_t h2 = rsHigherPow2(h);
387
388 if ((w2 == w) && (h2 == h)) {
389 return rsi_AllocationCreateFromBitmap(rsc, w, h, dstFmt, srcFmt, genMips, data);
390 }
391
392 uint32_t bpp = fmtToBits(srcFmt) >> 3;
393 size_t size = w2 * h2 * bpp;
394 uint8_t *tmp = static_cast<uint8_t *>(malloc(size));
395 memset(tmp, 0, size);
396
397 const uint8_t * src = static_cast<const uint8_t *>(data);
398 for (uint32_t y = 0; y < h; y++) {
Jason Samsfaf15202009-07-29 20:55:44 -0700399 uint8_t * ydst = &tmp[(y + ((h2 - h) >> 1)) * w2 * bpp];
Jason Samsb0ec1b42009-07-28 12:02:16 -0700400 memcpy(&ydst[(w2 - w) >> 1], src, w * bpp);
Jason Samsfaf15202009-07-29 20:55:44 -0700401 src += w * bpp;
Jason Samsb0ec1b42009-07-28 12:02:16 -0700402 }
403
404 RsAllocation ret = rsi_AllocationCreateFromBitmap(rsc, w2, h2, dstFmt, srcFmt, genMips, tmp);
405 free(tmp);
406 return ret;
407
408
409
410
411}
412
413
Jason Samsfe08d992009-05-27 14:45:32 -0700414RsAllocation rsi_AllocationCreateFromFile(Context *rsc, const char *file, bool genMips)
Jason Samsd19f10d2009-05-22 14:03:28 -0700415{
Jason Samse2ae85f2009-06-03 16:04:54 -0700416 bool use32bpp = false;
417
Jason Samsd19f10d2009-05-22 14:03:28 -0700418 typedef struct _Win3xBitmapHeader
419 {
420 uint16_t type;
421 uint32_t totalSize;
422 uint32_t reserved;
423 uint32_t offset;
424 int32_t hdrSize; /* Size of this header in bytes */
425 int32_t width; /* Image width in pixels */
426 int32_t height; /* Image height in pixels */
427 int16_t planes; /* Number of color planes */
428 int16_t bpp; /* Number of bits per pixel */
429 /* Fields added for Windows 3.x follow this line */
430 int32_t compression; /* Compression methods used */
431 int32_t sizeOfBitmap; /* Size of bitmap in bytes */
432 int32_t horzResolution; /* Horizontal resolution in pixels per meter */
433 int32_t vertResolution; /* Vertical resolution in pixels per meter */
434 int32_t colorsUsed; /* Number of colors in the image */
435 int32_t colorsImportant; /* Minimum number of important colors */
436 } __attribute__((__packed__)) WIN3XBITMAPHEADER;
437
438 _Win3xBitmapHeader hdr;
439
440 FILE *f = fopen(file, "rb");
441 if (f == NULL) {
442 LOGE("rsAllocationCreateFromBitmap failed to open file %s", file);
443 return NULL;
444 }
445 memset(&hdr, 0, sizeof(hdr));
446 fread(&hdr, sizeof(hdr), 1, f);
447
448 if (hdr.bpp != 24) {
449 LOGE("Unsuported BMP type");
450 fclose(f);
451 return NULL;
452 }
453
454 int32_t texWidth = rsHigherPow2(hdr.width);
455 int32_t texHeight = rsHigherPow2(hdr.height);
456
Jason Samse2ae85f2009-06-03 16:04:54 -0700457 if (use32bpp) {
458 rsi_TypeBegin(rsc, rsi_ElementGetPredefined(rsc, RS_ELEMENT_RGBA_8888));
459 } else {
460 rsi_TypeBegin(rsc, rsi_ElementGetPredefined(rsc, RS_ELEMENT_RGB_565));
461 }
Jason Samsd19f10d2009-05-22 14:03:28 -0700462 rsi_TypeAdd(rsc, RS_DIMENSION_X, texWidth);
463 rsi_TypeAdd(rsc, RS_DIMENSION_Y, texHeight);
464 if (genMips) {
465 rsi_TypeAdd(rsc, RS_DIMENSION_LOD, 1);
466 }
467 RsType type = rsi_TypeCreate(rsc);
468
469 RsAllocation vTexAlloc = rsi_AllocationCreateTyped(rsc, type);
470 Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc);
Jason Sams07ae4062009-08-27 20:23:34 -0700471 texAlloc->incUserRef();
Jason Samsd19f10d2009-05-22 14:03:28 -0700472 if (texAlloc == NULL) {
473 LOGE("Memory allocation failure");
474 fclose(f);
475 return NULL;
476 }
477
478 // offset to letterbox if height is not pow2
479 Adapter2D adapt(texAlloc);
480 uint8_t * fileInBuf = new uint8_t[texWidth * 3];
481 uint32_t yOffset = (hdr.width - hdr.height) / 2;
Jason Samsd19f10d2009-05-22 14:03:28 -0700482
Jason Samse2ae85f2009-06-03 16:04:54 -0700483 if (use32bpp) {
484 uint8_t *tmp = static_cast<uint8_t *>(adapt.getElement(0, yOffset));
485 for (int y=0; y < hdr.height; y++) {
486 fseek(f, hdr.offset + (y*hdr.width*3), SEEK_SET);
487 fread(fileInBuf, 1, hdr.width * 3, f);
488 for(int x=0; x < hdr.width; x++) {
489 tmp[0] = fileInBuf[x*3 + 2];
490 tmp[1] = fileInBuf[x*3 + 1];
491 tmp[2] = fileInBuf[x*3];
492 tmp[3] = 0xff;
493 tmp += 4;
494 }
495 }
496 } else {
497 uint16_t *tmp = static_cast<uint16_t *>(adapt.getElement(0, yOffset));
498 for (int y=0; y < hdr.height; y++) {
499 fseek(f, hdr.offset + (y*hdr.width*3), SEEK_SET);
500 fread(fileInBuf, 1, hdr.width * 3, f);
501 for(int x=0; x < hdr.width; x++) {
502 *tmp = rs888to565(fileInBuf[x*3 + 2], fileInBuf[x*3 + 1], fileInBuf[x*3]);
503 tmp++;
504 }
Jason Samsd19f10d2009-05-22 14:03:28 -0700505 }
506 }
507
508 fclose(f);
509 delete [] fileInBuf;
510
511 if (genMips) {
512 Adapter2D adapt2(texAlloc);
513 for(uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) {
514 adapt.setLOD(lod);
515 adapt2.setLOD(lod + 1);
Jason Sams6f5c61c2009-07-28 17:20:11 -0700516 mip(adapt2, adapt);
Jason Samsd19f10d2009-05-22 14:03:28 -0700517 }
518 }
519
520 return texAlloc;
521}
522
Jason Sams07ae4062009-08-27 20:23:34 -0700523void rsi_AllocationData(Context *rsc, RsAllocation va, const void *data, uint32_t sizeBytes)
Jason Samsd19f10d2009-05-22 14:03:28 -0700524{
525 Allocation *a = static_cast<Allocation *>(va);
Jason Sams07ae4062009-08-27 20:23:34 -0700526 a->data(data, sizeBytes);
Jason Sams9bee51c2009-08-05 13:57:03 -0700527 rsc->allocationCheck(a);
Jason Samsd19f10d2009-05-22 14:03:28 -0700528}
529
Jason Sams07ae4062009-08-27 20:23:34 -0700530void rsi_Allocation1DSubData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t count, const void *data, uint32_t sizeBytes)
Jason Samsd19f10d2009-05-22 14:03:28 -0700531{
532 Allocation *a = static_cast<Allocation *>(va);
Jason Sams07ae4062009-08-27 20:23:34 -0700533 a->subData(xoff, count, data, sizeBytes);
Jason Sams9bee51c2009-08-05 13:57:03 -0700534 rsc->allocationCheck(a);
Jason Samsd19f10d2009-05-22 14:03:28 -0700535}
536
Jason Sams07ae4062009-08-27 20:23:34 -0700537void rsi_Allocation2DSubData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, const void *data, uint32_t sizeBytes)
Jason Samsd19f10d2009-05-22 14:03:28 -0700538{
539 Allocation *a = static_cast<Allocation *>(va);
Jason Sams07ae4062009-08-27 20:23:34 -0700540 a->subData(xoff, yoff, w, h, data, sizeBytes);
Jason Sams9bee51c2009-08-05 13:57:03 -0700541 rsc->allocationCheck(a);
Jason Samsd19f10d2009-05-22 14:03:28 -0700542}
543
Jason Sams40a29e82009-08-10 14:55:26 -0700544void rsi_AllocationRead(Context *rsc, RsAllocation va, void *data)
545{
546 Allocation *a = static_cast<Allocation *>(va);
547 a->read(data);
548}
549
Jason Samsd19f10d2009-05-22 14:03:28 -0700550
551}
552}