XMThreadStorage* xmCreateTS ( const KDvoid* id ) { XMThreadStorage* ts = 0; if ( ( ts = (XMThreadStorage *) kdMalloc ( sizeof ( XMThreadStorage ) ) ) ) { if ( pthread_key_create ( &ts->pkey, 0 ) == 0 ) { if ( !xmQueuePushRear ( l_tss, ts ) ) { ts->id = id; ts->key = (KDThreadStorageKeyKHR) ts->pkey; } else { pthread_key_delete ( ts->pkey ); kdFree ( ts ); ts = 0; } } else { kdSetError ( KD_ENOMEM ); kdFree ( ts ); ts = 0; } } return ts; }
KDint xmBadaClosedir ( XMDir* dirp ) { kdFree ( (KDvoid *) dirp->dir_info.d_name ); kdFree ( dirp ); return 0; }
/* kdFreeImageATX: Free image object. */ KD_API void KD_APIENTRY kdFreeImageATX(KDImageATX image) { _KDImageATX *_image = image; if(_image->buffer) { kdFree(_image->buffer); } kdFree(_image); }
KDvoid CCTextureAtlas::moveQuadsFromIndex ( KDuint uOldIndex, KDuint uAmount, KDuint uNewIndex ) { CCAssert ( uNewIndex + uAmount <= m_uTotalQuads, "insertQuadFromIndex:atIndex: Invalid index" ); CCAssert ( uOldIndex < m_uTotalQuads, "insertQuadFromIndex:atIndex: Invalid index" ); if ( uOldIndex == uNewIndex ) { return; } //create buffer KDsize nQuadSize = sizeof ( ccV3F_C4B_T2F_Quad ); ccV3F_C4B_T2F_Quad* pTempQuads = (ccV3F_C4B_T2F_Quad*) kdMalloc ( nQuadSize * uAmount ); kdMemcpy ( pTempQuads, &m_pQuads [ uOldIndex ], nQuadSize * uAmount ); if ( uNewIndex < uOldIndex ) { // move quads from newIndex to newIndex + amount to make room for buffer kdMemmove ( &m_pQuads [ uNewIndex ], &m_pQuads [ uNewIndex + uAmount ], ( uOldIndex - uNewIndex ) * nQuadSize ); } else { // move quads above back kdMemmove ( &m_pQuads [ uOldIndex ], &m_pQuads [ uOldIndex + uAmount ], ( uNewIndex - uOldIndex ) * nQuadSize ); } kdMemcpy ( &m_pQuads [ uNewIndex ], pTempQuads, uAmount * nQuadSize ); kdFree ( pTempQuads ); m_bDirty = KD_TRUE; }
JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_kd_WindowDriver_CreateWindow (JNIEnv *env, jobject obj, jlong display, jlong jeglConfig) { EGLDisplay dpy = (EGLDisplay)(intptr_t)display; EGLConfig eglConfig = (EGLConfig)(intptr_t)jeglConfig; KDWindow *window = 0; if(dpy==NULL) { fprintf(stderr, "[CreateWindow] invalid display connection..\n"); return 0; } JOGLKDUserdata * userData = kdMalloc(sizeof(JOGLKDUserdata)); userData->magic = JOGL_KD_USERDATA_MAGIC; window = kdCreateWindow(dpy, eglConfig, (void *)userData); if(NULL==window) { kdFree(userData); fprintf(stderr, "[CreateWindow] failed: 0x%X\n", kdGetError()); } else { userData->javaWindow = (*env)->NewGlobalRef(env, obj); userData->kdWindow = window; (*env)->CallVoidMethod(env, obj, windowCreatedID, (jlong) (intptr_t) userData); DBG_PRINT( "[CreateWindow] ok: %p, userdata %p\n", window, userData); } return (jlong) (intptr_t) window; }
void ActionManager::deleteHashElement(tHashElement *element) { ccArrayFree(element->actions); HASH_DEL(m_pTargets, element); element->target->release(); kdFree(element); }
// kdThreadSemFree : Free a semaphore. KD_API KDint KD_APIENTRY kdThreadSemFree ( KDThreadSem* sem ) { KDint ret = sem_destroy ( &sem->psem ); kdFree ( sem ); return ret; }
// kdThreadCondFree: Free a condition variable. KD_API KDint KD_APIENTRY kdThreadCondFree ( KDThreadCond* cond ) { KDint ret = pthread_cond_destroy ( &cond->pcond ); kdFree ( cond ); return ret; }
// kdThreadMutexFree : Free a mutex. KD_API KDint KD_APIENTRY kdThreadMutexFree ( KDThreadMutex* mutex ) { KDint ret = pthread_mutex_destroy ( &mutex->pmutex ); kdFree ( mutex ); return ret; }
FTGlyph* MakeGlyph(FT_GlyphSlot slot) { FTGLglyph *g = makeglyphCallback(slot, data); FTGlyph *glyph = g->ptr; // XXX: we no longer need g, and no one will free it for us. Not // very elegant, and we need to make sure no one else will try to // use it. kdFree(g); return glyph; }
static KDvoid _xmFreeTS ( KDvoid* f ) { XMThreadStorage* ts = (XMThreadStorage *) f; KDvoid* value = 0; if ( ts ) { value = (KDvoid *) pthread_getspecific ( ts->pkey ); if ( value ) { kdFree ( value ); pthread_setspecific ( ts->pkey, 0 ); } pthread_key_delete ( ts->pkey ); kdFree ( ts ); } }
bool SAXParser::parse(const char *pszFile) { bool ret = false; KDint32 size = 0; char* pBuffer = (char*)FileUtils::getInstance()->getFileData(pszFile, "rt", &size); if (pBuffer != NULL && size > 0) { ret = parse(pBuffer, size); } kdFree(pBuffer); return ret; }
JNIEXPORT jint JNICALL Java_jogamp_newt_driver_kd_WindowDriver_CloseWindow (JNIEnv *env, jobject obj, jlong window, jlong juserData) { KDWindow *w = (KDWindow*) (intptr_t) window; JOGLKDUserdata * userData = (JOGLKDUserdata*) (intptr_t) juserData; int res = kdDestroyWindow(w); (*env)->DeleteGlobalRef(env, userData->javaWindow); kdFree(userData); DBG_PRINT( "[CloseWindow] res: %d\n", res); return res; }
bool Image::initWithImageFileThreadSafe(const char *fullpath) { bool ret = false; KDint32 dataLen = 0; unsigned char *buffer = FileUtils::getInstance()->getFileData(fullpath, "rb", &dataLen); if (buffer != NULL && dataLen > 0) { ret = initWithImageData(buffer, dataLen); } kdFree(buffer); return ret; }
void XMGPolygon::SetTexture ( const XMGVector2* src_arr_coord, const XMGTexture* texture, XMGTexUnit unit, GLuint src_idx_shape, GLuint src_idx_facet ) { XMGRenderImpl* impl_parent = (XMGRenderImpl *) XMGRender::m_impl; XMGTexture* tex = (XMGTexture *) texture; XMGShape* shape; XMGFacet* facet; GLuint idx_shape; GLuint idx_facet; GLuint idx_vertex; GLuint num_shape; GLuint num_facet; GLuint num_vertex; GLuint off_src; XMGVector2X* arr_coord; XMGVector2F size; tex->GetSize ( size ); off_src = 0; for ( impl_parent->RangeArray ( src_idx_shape, impl_parent->m_vec_shape.size ( ), idx_shape, num_shape ); idx_shape < num_shape; idx_shape++ ) { shape = impl_parent->m_vec_shape[ idx_shape ]; for ( impl_parent->RangeArray ( src_idx_facet, shape->m_vec_facet.size ( ), idx_facet, num_facet ); idx_facet < num_facet; idx_facet++ ) { facet = shape->m_vec_facet[ idx_facet ]; XMGAssert ( arr_coord = (XMGVector2X *) kdMalloc ( sizeof ( XMGVector2X ) * facet->m_num_vertex ) ); for ( idx_vertex = 0, num_vertex = facet->m_num_vertex; idx_vertex < num_vertex; idx_vertex++ ) { arr_coord[ idx_vertex ].m_x = XMG_F2X ( src_arr_coord[ off_src + idx_vertex ].m_x / size.m_x ); arr_coord[ idx_vertex ].m_y = XMG_F2X ( src_arr_coord[ off_src + idx_vertex ].m_y / size.m_y ); } SetCoordArray ( arr_coord, unit, idx_shape, idx_facet ); kdFree ( arr_coord ); off_src += facet->m_num_vertex; } } XMGRender::SetTexture ( texture, unit, src_idx_shape, src_idx_facet ); XMGRender::SetDispMode ( XMG_DISP_TEXTURE, src_idx_shape ); }
/* Initializes the OpenGL ES context into a KDWindow */ void initEGL(KDWindow *wnd) { GLbyte *buf = KD_NULL; GLbyte *walk; KDint i, k; const KDint sizes[9] = { 256, 128, 64, 32, 16, 8, 4, 2, 1 }; const GLubyte rs[9] = { 255, 0, 255, 0, 255, 0, 255, 0, 255 }; const GLubyte gs[9] = { 0, 0, 255, 0, 0, 255, 0, 0, 255}; const GLubyte bs[9] = { 0, 255, 0, 255, 0, 255, 0, 255, 0 }; /* Set the attributes for the window surface */ static const EGLint s_surfaceAttribs[] = { EGL_COLORSPACE, EGL_COLORSPACE_LINEAR, EGL_ALPHA_FORMAT, EGL_ALPHA_FORMAT_NONPRE, EGL_NONE }; EGLNativeWindowType nativeType; if(kdRealizeWindow(wnd, &nativeType) != 0) kdExit(20); /* Create a window surface for OpenGL ES */ GLOBALS->eglWindowSurface = eglCreateWindowSurface(GLOBALS->eglDisplay, GLOBALS->eglConfig, nativeType, s_surfaceAttribs); /* Create a context for OpenGL ES */ #ifndef TEST_LOCKSURFACE eglBindAPI (EGL_OPENGL_ES_API); GLOBALS->eglContextOpenGLES = eglCreateContext(GLOBALS->eglDisplay, GLOBALS->eglConfig, KD_NULL, KD_NULL); eglMakeCurrent (GLOBALS->eglDisplay, GLOBALS->eglWindowSurface, GLOBALS->eglWindowSurface, GLOBALS->eglContextOpenGLES); #endif /* Generate a texture */ glGenTextures(1, &GLOBALS->tex); glBindTexture(GL_TEXTURE_2D, GLOBALS->tex); buf = kdMalloc(sizes[0] * sizes[0] * 3); for(k = 0; k < 9; k++) { walk = buf; for(i = 0; i < sizes[k] * sizes[k]; i++) { *(walk++) = (i % 3 == 0) ? rs[k] : 0; *(walk++) = (i % 3 == 0) ? gs[k] : 0; *(walk++) = (i % 3 == 0) ? bs[k] : 0; } glTexImage2D(GL_TEXTURE_2D, k, GL_RGB, sizes[k], sizes[k], 0, GL_RGB, GL_UNSIGNED_BYTE, buf); } kdFree(buf); }
KDint xmFreeImageETC ( XMImage* image ) { ETCDecode* decode = (ETCDecode*) image->decode; if ( decode ) { if ( decode->pixels ) { kdFree ( decode->pixels ); decode->pixels = 0; } } return 0; }
KDvoid xmEventDestroy ( KDvoid ) { KD_GET_TLS ( KDTLS, tls ); kdFree ( tls->xmg_vertex ); delete tls->xmg_quad; delete tls->xmg_morph; delete tls->xmg_text; delete tls->xmg_ani; delete tls->xmg_tex[0]; delete tls->xmg_tex[1]; delete tls->xmg_font; delete tls->xmg_canvas; }
KDint xmFreeImageTIFF ( XMImage* image ) { TIFFInfo* info = (TIFFInfo*) image->info; TIFFDecode* decode = (TIFFDecode*) image->decode; if ( decode && decode->pixels ) { kdFree ( decode->pixels ); } if ( info && info->tiff ) { TIFFClose ( info->tiff ); } return 0; }
XMGPolygonImpl::~XMGPolygonImpl ( void ) { GLuint idx_tess; GLuint idx_shape; for ( idx_tess = 0; idx_tess < 2; idx_tess++ ) { if ( m_tess[ idx_tess ] ) { for ( idx_shape = 0; idx_shape < m_num_shape; idx_shape++ ) { delete m_data[ idx_tess ][ idx_shape ]; } kdFree ( m_data[ idx_tess ] ); gluDeleteTess ( m_tess[ idx_tess ] ); } } }
// kdThreadSemCreate: Create a semaphore. KD_API KDThreadSem *KD_APIENTRY kdThreadSemCreate ( KDuint value ) { KDThreadSem* sem = 0; if ( ( sem = (KDThreadSem *) kdMalloc ( sizeof ( KDThreadSem ) ) ) ) { if ( ( sem_init ( &sem->psem, 0, value ) ) ) { kdSetError ( xmGetErrno ( ) == EINVAL ? KD_EINVAL : KD_ENOSPC ); kdFree ( sem ); sem = 0; } } else { kdSetError ( KD_ENOMEM ); } return sem; }
// kdThreadAttrCreate : Create a thread attribute object. KD_API KDThreadAttr* KD_APIENTRY kdThreadAttrCreate ( KDvoid ) { KDThreadAttr* attr = 0; if ( ( attr = (KDThreadAttr *) kdMalloc ( sizeof ( KDThreadAttr ) ) ) ) { if ( ( pthread_attr_init ( &attr->pattr ) ) ) { kdSetError ( KD_ENOMEM ); kdFree ( attr ); attr = 0; } } else { kdSetError ( KD_ENOMEM ); } return attr; }
JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_kd_KDWindow_CreateWindow (JNIEnv *env, jobject obj, jlong display, jintArray jAttrs) { jint * attrs = NULL; jsize attrsLen; EGLDisplay dpy = (EGLDisplay)(intptr_t)display; KDWindow *window = 0; if(dpy==NULL) { fprintf(stderr, "[CreateWindow] invalid display connection..\n"); return 0; } attrsLen = (*env)->GetArrayLength(env, jAttrs); if(0==attrsLen) { fprintf(stderr, "[CreateWindow] attribute array size 0..\n"); return 0; } attrs = (*env)->GetIntArrayElements(env, jAttrs, 0); if(NULL==attrs) { fprintf(stderr, "[CreateWindow] attribute array NULL..\n"); return 0; } JOGLKDUserdata * userData = kdMalloc(sizeof(JOGLKDUserdata)); userData->magic = JOGL_KD_USERDATA_MAGIC; window = kdCreateWindow(dpy, attrs, (void *)userData); (*env)->ReleaseIntArrayElements(env, jAttrs, attrs, 0); if(NULL==window) { kdFree(userData); fprintf(stderr, "[CreateWindow] failed: 0x%X\n", kdGetError()); } else { userData->javaWindow = (*env)->NewGlobalRef(env, obj); userData->kdWindow = window; (*env)->CallVoidMethod(env, obj, windowCreatedID, (jlong) (intptr_t) userData); DBG_PRINT( "[CreateWindow] ok: %p, userdata %p\n", window, userData); } return (jlong) (intptr_t) window; }
XMDir* xmBadaOpendir ( const KDchar* dirname ) { Directory dir; XMDir* ret; result r; r = dir.Construct ( dirname ); if ( IsFailed ( r ) ) { ret = 0; goto failed; } ret = (XMDir *) kdMalloc ( sizeof ( XMDir ) ); if ( ret ) { ret->dir_enum = dir.ReadN ( ); ret->dir_info.d_name = (const KDchar *) kdMalloc ( 256 ); } else { goto failed; } return ret; failed : if ( ret ) { kdFree( ret ); ret = 0; } xmBadaSetError ( r ); return ret; }
bool Image::initWithImageFile(const char * strPath) { bool bRet = false; std::string fullPath = FileUtils::getInstance()->fullPathForFilename(strPath); #ifdef EMSCRIPTEN // Emscripten includes a re-implementation of SDL that uses HTML5 canvas // operations underneath. Consequently, loading images via IMG_Load (an SDL // API) will be a lot faster than running libpng et al as compiled with // Emscripten. SDL_Surface *iSurf = IMG_Load(fullPath.c_str()); int size = 4 * (iSurf->w * iSurf->h); bRet = initWithRawData((const unsigned char*)iSurf->pixels, size, iSurf->w, iSurf->h, 8, true); unsigned int *tmp = (unsigned int *)m_pData; int nrPixels = iSurf->w * iSurf->h; for (int i = 0; i < nrPixels; i++) { unsigned char *p = m_pData + i * 4; tmp[i] = CC_RGB_PREMULTIPLY_ALPHA(p[0], p[1], p[2], p[3]); } SDL_FreeSurface(iSurf); #else KDint32 bufferLen = 0; unsigned char* buffer = FileUtils::getInstance()->getFileData(fullPath.c_str(), "rb", &bufferLen); if (buffer != nullptr && bufferLen > 0) { bRet = initWithImageData(buffer, bufferLen); } kdFree(buffer); #endif // EMSCRIPTEN return bRet; }
bool GridBase::initWithSize(const Size& gridSize) { Director *pDirector = Director::getInstance(); Size s = pDirector->getWinSizeInPixels(); unsigned long POTWide = ccNextPOT((unsigned int)s.width); unsigned long POTHigh = ccNextPOT((unsigned int)s.height); // we only use rgba8888 Texture2D::PixelFormat format = Texture2D::PixelFormat::RGBA8888; long dataLen = POTWide * POTHigh * 4; void *data = kdCalloc(dataLen, 1); if (! data) { CCLOG("cocos2d: Grid: not enough memory."); this->release(); return false; } Texture2D *texture = new Texture2D(); texture->initWithData(data, dataLen, format, POTWide, POTHigh, s); kdFree(data); if (! texture) { CCLOG("cocos2d: Grid: error creating texture"); return false; } initWithSize(gridSize, texture, false); texture->release(); return true; }
// kdThreadMutexCreate : Create a mutex. KD_API KDThreadMutex* KD_APIENTRY kdThreadMutexCreate ( const KDvoid* mutexattr ) { pthread_mutex_t pmutex = PTHREAD_MUTEX_INITIALIZER; KDThreadMutex* mutex = 0; KDint ret = 0; if ( ( mutex = (KDThreadMutex *) kdMalloc ( sizeof ( KDThreadMutex ) ) ) ) { kdMemcpy ( &mutex->pmutex, &pmutex, sizeof ( pthread_mutex_t ) ); if ( ( ret = pthread_mutex_init ( &mutex->pmutex, (const pthread_mutexattr_t *) mutexattr ) ) ) { kdSetError ( ret == ENOMEM ? KD_ENOMEM : KD_EAGAIN ); kdFree ( mutex ); mutex = 0; } } else { kdSetError ( KD_ENOMEM ); } return mutex; }
// kdThreadCondCreate : Create a condition variable. KD_API KDThreadCond* KD_APIENTRY kdThreadCondCreate ( const KDvoid* attr ) { pthread_cond_t pcond = PTHREAD_COND_INITIALIZER; KDThreadCond* cond = 0; KDint ret = 0; if ( ( cond = (KDThreadCond *) kdMalloc ( sizeof ( KDThreadCond ) ) ) ) { kdMemcpy ( &cond->pcond, &pcond, sizeof ( pthread_cond_t ) ); if ( ( ret = pthread_cond_init ( &cond->pcond, (const pthread_condattr_t *) attr) ) ) { kdSetError ( ret == ENOMEM ? KD_ENOMEM : KD_EAGAIN ); kdFree ( cond ); cond = 0; } } else { kdSetError ( KD_ENOMEM ); } return cond; }
KDvoid Controller::setExample ( KDint nIndex ) { KDubyte* pPixels = (KDubyte*) kdCalloc ( 1024 * 512 * 3, 1 ); ccGLBindTexture2D ( m_uTexture ); glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGB, 1024, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, pPixels ); kdFree ( pPixels ); if ( m_pExitFunc ) { m_pExitFunc ( ); } m_nIndex = nIndex; m_pDrawFunc = KD_NULL; m_pExitFunc = KD_NULL; m_pTitle->setString ( l_aExamples [ nIndex ].title ); m_pSubTitle->setString ( l_aExamples [ nIndex ].subtitle ); m_pMessage->setString ( "" ); l_aExamples [ nIndex ].func ( l_aExamples [ nIndex ].index ); }
KDvoid AWTextureFilter::blurInput ( KDvoid* pInput, KDvoid* pOutput, CCTexture2DPixelFormat eFormat, const CCSize& tContentSize, KDint nRadius, const CCRect tRect ) { KDint i, xl, yl, yi, ym, ri, riw; KDint cx = (KDint) tContentSize.cx; KDint cy = (KDint) tContentSize.cy; KDint w = (KDint) ( tRect.size.cx ); KDint h = (KDint) ( tRect.size.cy ); // const KDint wh = (KDint) ( tContentSize.cx * tContentSize.cy ); KDint nRead; w = ( w == 0 ) ? cx : w; h = ( h == 0 ) ? cy : h; // Check data KDint px = KD_MAX ( 0, (KDint) tRect.origin.x ); KDint py = KD_MAX ( 0, (KDint) tRect.origin.y ); w = px + w - KD_MAX ( 0, ( px + w ) - cx ); h = py + h - KD_MAX ( 0, ( py + h ) - cy ); yi = py * cx; // Generate Gaussian kernel nRadius = KD_MIN ( KD_MAX ( 1, nRadius ), 248 ); KDint nKernelSize = 1 + nRadius * 2; KDint* pKernel = new KDint [ nKernelSize ]; KDint g = 0, nSum = 0; // Gaussian filter for ( i = 0; i < nRadius; i++ ) { g = i * i * i + 1; pKernel [ i ] = pKernel [ nKernelSize - i - 1 ] = g; nSum += g * 2; } g = nRadius * nRadius; pKernel [ nRadius ] = g; nSum += g; if ( eFormat == kCCTexture2DPixelFormat_RGBA8888 ) { KDint cr, cg, cb, ca; const ccColor4B* pOriginalData = (ccColor4B*) pInput; ccColor4B* pData = (ccColor4B*) pOutput; ccColor4B* pTemp = (ccColor4B*) kdMalloc ( cx * cy * 4 ); ccColor4B* pPixel; // Horizontal blur for ( yl = py; yl < h; yl++ ) { for ( xl = px; xl < w; xl++ ) { cb = cg = cr = ca = 0; ri = xl - nRadius; for ( i = 0; i < nKernelSize; i++ ) { nRead = ri + i; if ( nRead >= px && nRead < w ) { nRead += yi; pPixel = (ccColor4B*) &pOriginalData [ nRead ]; cr += pPixel->r * pKernel [ i ]; cg += pPixel->g * pKernel [ i ]; cb += pPixel->b * pKernel [ i ]; ca += pPixel->a * pKernel [ i ]; } } ri = yi + xl; pPixel = &pTemp [ ri ]; pPixel->r = cr / nSum; pPixel->g = cg / nSum; pPixel->b = cb / nSum; pPixel->a = ca / nSum; } yi += cx; } yi = py * cx; // Vertical blur for ( yl = py; yl < h; yl++ ) { ym = yl - nRadius; riw = ym * cx; for ( xl = px; xl < w; xl++ ) { cb = cg = cr = ca = 0; ri = ym; nRead = xl + riw; for ( i = 0; i < nKernelSize; i++ ) { if ( ri < h && ri >= py ) { pPixel = &pTemp [ nRead ]; cr += pPixel->r * pKernel [ i ]; cg += pPixel->g * pKernel [ i ]; cb += pPixel->b * pKernel [ i ]; ca += pPixel->a * pKernel [ i ]; } ri++; nRead += cx; } pPixel = &pData [ xl + yi ]; pPixel->r = cr / nSum; pPixel->g = cg / nSum; pPixel->b = cb / nSum; pPixel->a = ca / nSum; } yi += cx; } // Free temp data kdFree ( pTemp ); } else if ( eFormat == kCCTexture2DPixelFormat_A8 ) { KDint ca; const KDubyte* pOriginalData = (const KDubyte*) pInput; KDubyte* pData = (KDubyte*) pOutput; KDubyte* pTemp = (KDubyte*) kdMalloc ( cx * cy ); // Horizontal blur for ( yl = py; yl < h; yl++ ) { for ( xl = px; xl < w; xl++ ) { ca = 0; ri = xl - nRadius; for ( i = 0; i < nKernelSize; i++ ) { nRead = ri + i; if ( nRead >= px && nRead < w ) { nRead += yi; ca += pOriginalData [ nRead ] * pKernel [ i ]; } } ri = yi + xl; pTemp [ ri ] = ca / nSum; } yi += cx; } yi = py * cx; // Vertical blur for ( yl = py; yl < h; yl++ ) { ym = yl - nRadius; riw = ym * cx; for ( xl = px; xl < w; xl++ ) { ca = 0; ri = ym; nRead = xl + riw; for ( i = 0; i < nKernelSize; i++ ) { if ( ri < h && ri >= py ) { ca += pTemp [ nRead ] * pKernel [ i ]; } ri++; nRead += cx; } pData [ xl + yi ] = ca / nSum; } yi += cx; } // Free temp data kdFree ( pTemp ); } else { CCAssert ( KD_FALSE, "AWTextureFilter : Pixel format don't supported. It should be RGBA8888 or A8" ); } delete [] pKernel; }