Ejemplo n.º 1
0
/**
 * Free SdkEnv resource
 */
int freeSdkEnv(SdkEnv *env)
{
    if (NULL == env) {
        return -1;
    }

    if (env->egl.display != EGL_NO_DISPLAY) {
        eglMakeCurrent(env->egl.display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
        if (env->egl.context != EGL_NO_CONTEXT) {
            eglDestroyContext(env->egl.display, env->egl.context);
        }
        if (env->egl.surface != EGL_NO_SURFACE) {
            eglDestroySurface(env->egl.display, env->egl.surface);
        }
        eglTerminate(env->egl.display);
        eglReleaseThread();
    }

    env->egl.display = EGL_NO_DISPLAY;
    env->egl.context = EGL_NO_CONTEXT;
    env->egl.surface = EGL_NO_SURFACE;
    if (ACTIVE_PATH == env->userData.active 
            && NULL != env->userData.inputPath) {
        free (env->userData.inputPath);
        env->userData.inputPath = NULL;
    }

    if (ACTIVE_PARAM == env->userData.active 
            && NULL != env->userData.param) {
        Bitmap_t *img = (Bitmap_t *) env->userData.param;
        freeBitmap (img);
        env->userData.param = NULL;
    }

    if (NULL != env->userCmd) {
        freeChrbuf (env->userCmd);
        env->userCmd = NULL;
    }

    if (NULL != env->userData.inputPath) {
        free (env->userData.inputPath);
        env->userData.inputPath = NULL;
    }

    if (NULL != env->userData.outputPath) {
        free (env->userData.outputPath);
        env->userData.outputPath = NULL;
    }

    releaseShader(env);

    if (OFF_SCREEN_RENDER == env->type) {
        glDeleteFramebuffers (1, &env->handle.fboIdx);
        glDeleteTextures (1, &env->handle.texture2Idx);
    }

    freeEffectCmd(&env->effectCmd);

    free (env);
}
Ejemplo n.º 2
0
ObjectNode *op_LoadBmp
    (ExecuteHandler execute, Context *context, Node *node){
    void *res = NULL;
    ObjectNode *objpath = execute(context, &node->childs[0]);

    char *path = listToString(objpath);
    BITMAP bmp;
    if(readBitmap(&bmp, path))
      return newObjectNode(NTYPE_NONE, NULL);
    res = (void *) mkList(&bmp);
    freeBitmap(&bmp);
    return res;
}
Ejemplo n.º 3
0
void window_deleter(void* item) {

	window* win = (window*)item;

	//Free the context
	freeBitmap((void*)win->context);

#ifndef HARNESS_TEST    
	//Free the title (if we ever decide to error on unsuccessful frees, this could be an issue for static or undefined titles)
	if (win->title)
		free((void*)win->title);
#endif //HARNESS_TEST

	//And finally free ourself 
	free((void*)win);
}
Ejemplo n.º 4
0
void resizeWindow(Window* win, int width, int height) {

	bitmap* new_context = newBitmap(width, height);

	if (!new_context)
		return;

	int copy_w = width < win->w ? width : win->w;
	int copy_h = height < win->h ? height : win->h;

	win->w = width;
	win->h = height;

	int x, y;
	for (y = 0; y < copy_h; y++)
	for (x = 0; x < copy_w; x++)
		new_context->data[y*new_context->width + x] = win->context->data[y*win->context->width + x];

	freeBitmap(win->context);
	win->context = new_context;

	drawWindow(win, 0);
}
Ejemplo n.º 5
0
Window* newWindow(unsigned int width, unsigned int height, unsigned char flags, unsigned int pid) {

	static int next_handle = 1;
	Window *new_window, *temp_window;
	unsigned int i, bufsz;

	if (!(new_window = (Window*)malloc(sizeof(window)))) {

		printf("Coudln't allocate a new window structure");
		return 0;
	}

	new_window->active = 1;
	new_window->pid = pid;
	new_window->flags = flags;
	new_window->x = 0;
	new_window->y = 0;
	new_window->w = width;
	new_window->h = height;
	new_window->title = (unsigned char*)0;
	new_window->frame_needs_redraw = 1;

	//Create a drawing context for the new window
	if (!(new_window->context = newBitmap(new_window->w, new_window->h))) {

		free((void*)new_window);
		printf("Couldn't allocate bitmap area for new window");
		return (window*)0;
	}

	bufsz = new_window->w * new_window->h;

	//Clear new window to white
	for (i = 0; i < bufsz; i++)
		new_window->context->data[i] = RGB(255, 255, 255);

	new_window->handle = next_handle++;

	if (mouse_window)
		List_pop(window_list, (void*)mouse_window);

	//De-activate the old active window
	if (temp_window = (window*)List_get_at(window_list, window_list->count - (mouse_window ? 2 : 1))) {

		temp_window->active = 0;
	}

	if (!List_add(window_list, (void*)new_window)){

		freeBitmap(new_window->context);
		free((void*)new_window);

		//re-activate the old active window
		if (temp_window)
			temp_window->active = 1;

		return (window*)0;
	}

	//Give the new window its initial decoration
	if (!(new_window->flags & WIN_UNDECORATED))
		drawFrame(new_window);

	drawWindow(new_window, 0);

	//Update the titlebar on the old active window 
	if (temp_window)
		drawTitlebar(temp_window, 1);

	if (mouse_window) {

		List_add(window_list, mouse_window);
		drawWindow(mouse_window, 0);
	}

	return new_window;
}
Ejemplo n.º 6
0
// =======================================================
CBlocksUseBitmap::~CBlocksUseBitmap()
{
  freeBitmap();
}
Ejemplo n.º 7
0
ABitmapPlanes::~ABitmapPlanes()
{
  DEBUG_OUT<<"ABitmapPlanes::~ABitmapPlanes()\n";
  freeBitmap();
}