void test_all() { std::cout << "----------test vector----------" << std::endl; tc_constructor(); tc_assignment(); tc_size(); tc_empty(); tc_resize(); tc_reserve(); tc_shrink_to_fit(); tc_elementAccess(); tc_at(); tc_front_back(); tc_data(); tc_assign(); tc_push_back(); tc_pop_back(); tc_insert(); tc_erase(); tc_swap(); tc_clear(); //tc_emplace(); //tc_emplace_back(); //tc_get_allocator(); tc_relationalOperators(); std::cout << "----------test vector success----------\n" << std::endl; }
void tc_hori_pad (GLsizei dst_width, GLsizei src_width, GLsizei height, GLubyte *data, GLenum format, GLenum clamp) { GLint row, col; const GLsizei MUW = ((format == GL_COMPRESSED_RGB_FXT1_3DFX) || (format == GL_COMPRESSED_RGBA_FXT1_3DFX)) ? 8 : 4; const GLboolean can_decode = (h != NULL); TC_FETCHER fetch = NULL; TC_ENCODER encoder = NULL; switch (format) { case GL_COMPRESSED_RGB_FXT1_3DFX: fetch = fxt1_decode_1; encoder = fxt1_encode; break; case GL_COMPRESSED_RGBA_FXT1_3DFX: fetch = fxt1_decode_1; encoder = fxt1_encode; break; case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: fetch = dxt1_rgb_decode_1; encoder = dxt1_rgb_encode; break; case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: fetch = dxt1_rgba_decode_1; encoder = dxt1_rgba_encode; break; case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: fetch = dxt3_rgba_decode_1; encoder = dxt3_rgba_encode; break; case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: fetch = dxt5_rgba_decode_1; encoder = dxt5_rgba_encode; break; default: return; } /* XXX implement mirroring */ if (!can_decode || (clamp == TC_WRAP) || (clamp == TC_MIRROR)) { /* replicate texture */ GLubyte *tex0 = data; GLsizei width = (src_width + (MUW-1)) / MUW; GLuint instride = tc_stride(format, src_width); GLuint outstride = tc_stride(format, dst_width); for (row = 0; row < ((height + (MUH-1)) & ~(MUH-1)); row += MUH) { GLubyte *texture = tex0; for (col = width; col < ((dst_width + (MUW-1)) / MUW); col += width) { texture += instride; memcpy(texture, tex0, instride); } tex0 += outstride; } } else { /* pad the right area with edge values */ GLubyte *texture = data; GLuint width = src_width; GLuint instride = tc_stride(format, width); GLint outstride = tc_stride(format, dst_width); GLuint tstride = tc_stride(format, MUW); GLubyte *tex0 = malloc(tc_size(format, MUW, MUH)); GLubyte *tex1 = malloc(MUW * MUH * 4); GLuint i = 0; for (row = 0; row < ((height + (MUH-1)) & ~(MUH-1)); row += MUH) { GLuint j; for (j = 0; j < MUH; j++, i++) { fetch(data, dst_width, width - 1, i, &tex1[j * MUW * 4]); for (col = 1; col < MUW; col++) { ((GLuint *)tex1)[j * MUW + col] = ((GLuint *)tex1)[j * MUW]; } } encoder(MUW, MUH, 4, tex1, MUW * 4, tex0, tstride); texture += instride; for (col = instride; col < outstride; col += tstride) { memcpy(texture, tex0, tstride); texture += tstride; } } free(tex1); free(tex0); } }
void tc_vert_pad (GLsizei width, GLsizei dst_height, GLsizei src_height, GLubyte *data, GLenum format, GLenum clamp) { GLint row; const GLboolean can_decode = (h != NULL); TC_FETCHER fetch = NULL; TC_ENCODER encoder = NULL; switch (format) { case GL_COMPRESSED_RGB_FXT1_3DFX: fetch = fxt1_decode_1; encoder = fxt1_encode; break; case GL_COMPRESSED_RGBA_FXT1_3DFX: fetch = fxt1_decode_1; encoder = fxt1_encode; break; case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: fetch = dxt1_rgb_decode_1; encoder = dxt1_rgb_encode; break; case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: fetch = dxt1_rgba_decode_1; encoder = dxt1_rgba_encode; break; case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: fetch = dxt3_rgba_decode_1; encoder = dxt3_rgba_encode; break; case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: fetch = dxt5_rgba_decode_1; encoder = dxt5_rgba_encode; break; default: return; } /* XXX implement mirroring */ if (!can_decode || (clamp == TC_WRAP) || (clamp == TC_MIRROR)) { /* replicate texture */ GLubyte *tex0 = data; GLubyte *texture = data; GLubyte height = (src_height + (MUH-1)) / MUH; GLuint block = tc_size(format, width, src_height); for (row = height; row < ((dst_height + (MUH-1)) / MUH); row += height) { texture += block; memcpy(texture, tex0, block); } } else { GLint col; /* pad the bottom area with edge values */ GLubyte *texture = data; GLuint cstride = tc_stride(format, width); GLuint ustride = width * 4; GLubyte *tex0 = malloc(tc_size(format, width, MUH)); GLubyte *tex1 = malloc(ustride * MUH); for (col = 0; col < width; col++) { fetch(data, width, col, src_height - 1, &tex1[col * 4]); } for (row = 1; row < MUH; row++) { memcpy(&tex1[ustride * row], tex1, ustride); } encoder(width, MUH, 4, tex1, ustride, tex0, cstride); free(tex1); texture += tc_size(format, width, src_height); for (row = (src_height + (MUH-1)) & ~(MUH-1); row < ((dst_height + (MUH-1)) & ~(MUH-1)); row += MUH) { memcpy(texture, tex0, cstride); texture += cstride; } free(tex0); } }
void * tc_encode (const PACKING *unpack, int dst_width, int dst_height, void *dst, GLenum dst_format, int src_width, int src_height, const GLvoid *src, GLenum src_format, GLenum src_type) { TC_ENCODER encoder = NULL; int srcStrideInBytes; int srcTexelBytes; int destRowStride; int size; if (h == NULL) { return NULL; } if ((src_format != GL_RGB && src_format != GL_RGBA) || (src_type != GL_UNSIGNED_BYTE)) { return NULL; } srcTexelBytes = (src_format == GL_RGB) ? 3 : 4; switch (dst_format) { case GL_COMPRESSED_RGB_FXT1_3DFX: case GL_COMPRESSED_RGBA_FXT1_3DFX: encoder = fxt1_encode; break; case GL_RGB_S3TC: case GL_RGB4_S3TC: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: encoder = dxt1_rgb_encode; break; case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: encoder = dxt1_rgba_encode; break; case GL_RGBA_S3TC: case GL_RGBA4_S3TC: case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: encoder = dxt3_rgba_encode; break; case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: encoder = dxt5_rgba_encode; break; default: return NULL; } srcStrideInBytes = image_stride(unpack, src_width, srcTexelBytes); destRowStride = tc_stride(dst_format, dst_width); size = tc_size(dst_format, dst_width, dst_height); if (dst == NULL) { dst = malloc(size); } if (dst == NULL) { return NULL; } encoder(src_width, src_height, srcTexelBytes, src, srcStrideInBytes, dst, destRowStride); return dst; }