mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-11-27 03:09:59 +03:00
pixlib: pxDestroyPlanar()
git-svn-id: svn://kolibrios.org@6142 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
48b0ebd898
commit
98b9eb4616
@ -21,12 +21,6 @@ bitmap_t *pxCreateBitmap(uint32_t width, uint32_t height);
|
||||
|
||||
int pxDestroyBitmap(bitmap_t *bitmap);
|
||||
|
||||
planar_t* pxCreatePlanar(int name, int format,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t offset0, uint32_t pitch0,
|
||||
uint32_t offset1, uint32_t pitch1,
|
||||
uint32_t offset2, uint32_t pitch2);
|
||||
|
||||
void *pxLockBitmap(bitmap_t *bitmap, uint32_t *pitch);
|
||||
|
||||
int pxResizeBitmap(bitmap_t *bitmap, uint32_t width, uint32_t height);
|
||||
@ -34,6 +28,14 @@ int pxResizeBitmap(bitmap_t *bitmap, uint32_t width, uint32_t height);
|
||||
int pxBlitBitmap(bitmap_t *bitmap, int dst_x, int dst_y,
|
||||
uint32_t w, uint32_t h, int src_x, int src_y);
|
||||
|
||||
planar_t* pxCreatePlanar(int name, int format,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t offset0, uint32_t pitch0,
|
||||
uint32_t offset1, uint32_t pitch1,
|
||||
uint32_t offset2, uint32_t pitch2);
|
||||
|
||||
int pxDestroyPlanar(planar_t *planar);
|
||||
|
||||
int pxBlitPlanar(planar_t *planar, int dst_x, int dst_y,
|
||||
uint32_t w, uint32_t h, int src_x, int src_y);
|
||||
|
||||
|
@ -18,6 +18,7 @@ struct pix_driver
|
||||
uint32_t offset0, uint32_t pitch0,
|
||||
uint32_t offset1, uint32_t pitch1,
|
||||
uint32_t offset2, uint32_t pitch2);
|
||||
int (*destroy_planar)(planar_t *planar);
|
||||
int (*blit_planar)(planar_t *planar, int dst_x, int dst_y,
|
||||
uint32_t w, uint32_t h, int src_x, int src_y);
|
||||
};
|
||||
|
@ -156,6 +156,35 @@ int pxBlitBitmap(bitmap_t *bitmap, int dst_x, int dst_y,
|
||||
w, h, src_x, src_y);
|
||||
};
|
||||
|
||||
planar_t* pxCreatePlanar(int name, int format,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t offset0, uint32_t pitch0,
|
||||
uint32_t offset1, uint32_t pitch1,
|
||||
uint32_t offset2, uint32_t pitch2)
|
||||
{
|
||||
if(driver->create_planar)
|
||||
return driver->create_planar(name, format, width, height,
|
||||
offset0, pitch0, offset1, pitch1,
|
||||
offset2, pitch2);
|
||||
else
|
||||
return NULL;
|
||||
};
|
||||
|
||||
int pxDestroyPlanar(planar_t *planar)
|
||||
{
|
||||
return driver->destroy_planar(planar);
|
||||
};
|
||||
|
||||
int pxBlitPlanar(planar_t *planar, int dst_x, int dst_y,
|
||||
uint32_t w, uint32_t h, int src_x, int src_y)
|
||||
{
|
||||
if(driver->blit_planar)
|
||||
return driver->blit_planar(planar, dst_x, dst_y,
|
||||
w, h, src_x, src_y);
|
||||
else
|
||||
return 0;
|
||||
};
|
||||
|
||||
int pxCreateClient(int x, int y, uint32_t width, uint32_t height)
|
||||
{
|
||||
return driver->create_client(x, y, width, height);
|
||||
@ -166,6 +195,7 @@ int pxResizeClient(int x, int y, uint32_t width, uint32_t height)
|
||||
return driver->resize_client(x, y, width, height);
|
||||
}
|
||||
|
||||
|
||||
static struct pix_driver sw_driver =
|
||||
{
|
||||
0,
|
||||
@ -176,9 +206,10 @@ static struct pix_driver sw_driver =
|
||||
sw_blit,
|
||||
sw_create_client,
|
||||
sw_resize_client,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
NULL, /* fini() */
|
||||
NULL, /* create_planar() */
|
||||
NULL, /* destroy_planar() */
|
||||
NULL /* blit_planar() */
|
||||
};
|
||||
|
||||
|
||||
@ -256,32 +287,3 @@ void pxFini()
|
||||
driver->fini();
|
||||
};
|
||||
|
||||
|
||||
planar_t* pxCreatePlanar(int name, int format,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t offset0, uint32_t pitch0,
|
||||
uint32_t offset1, uint32_t pitch1,
|
||||
uint32_t offset2, uint32_t pitch2)
|
||||
{
|
||||
if(driver->create_planar)
|
||||
return driver->create_planar(name, format, width, height,
|
||||
offset0, pitch0, offset1, pitch1,
|
||||
offset2, pitch2);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int pxBlitPlanar(planar_t *planar, int dst_x, int dst_y,
|
||||
uint32_t w, uint32_t h, int src_x, int src_y)
|
||||
{
|
||||
if(driver->blit_planar)
|
||||
return driver->blit_planar(planar, dst_x, dst_y,
|
||||
w, h, src_x, src_y);
|
||||
else
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -615,6 +615,22 @@ err_0:
|
||||
return NULL;
|
||||
};
|
||||
|
||||
static int hw_destroy_planar(planar_t *planar)
|
||||
{
|
||||
glDeleteTextures(planar->num_planes, &planar->tex[0]);
|
||||
|
||||
if(planar->image[2] != NULL)
|
||||
eglDestroyImageKHR(px->dpy, planar->image[2]);
|
||||
if(planar->image[1] != NULL)
|
||||
eglDestroyImageKHR(px->dpy, planar->image[1]);
|
||||
if(planar->image[0] != NULL)
|
||||
eglDestroyImageKHR(px->dpy, planar->image[0]);
|
||||
if(planar->planar_image != NULL)
|
||||
eglDestroyImageKHR(px->dpy, planar->planar_image);
|
||||
free(planar);
|
||||
return 0;
|
||||
};
|
||||
|
||||
static planar_t* hw_create_planar(EGLint name, EGLint format, uint32_t width, uint32_t height,
|
||||
uint32_t offset0, uint32_t pitch0,
|
||||
uint32_t offset1, uint32_t pitch1,
|
||||
@ -670,6 +686,7 @@ static planar_t* hw_create_planar(EGLint name, EGLint format, uint32_t width, ui
|
||||
planar->width = width;
|
||||
planar->height = height;
|
||||
planar->name = name;
|
||||
planar->num_planes = num_planes;
|
||||
planar->planar_image = img;
|
||||
|
||||
planar->offset[0] = offset0;
|
||||
@ -681,6 +698,8 @@ static planar_t* hw_create_planar(EGLint name, EGLint format, uint32_t width, ui
|
||||
planar->pitch[2] = pitch2;
|
||||
|
||||
glGenTextures(num_planes, &planar->tex[0]);
|
||||
if(glGetError() != GL_NO_ERROR)
|
||||
goto err_0;
|
||||
|
||||
for(i = 0; i < num_planes; i++)
|
||||
{
|
||||
@ -692,19 +711,20 @@ static planar_t* hw_create_planar(EGLint name, EGLint format, uint32_t width, ui
|
||||
|
||||
image = eglCreateImageKHR(px->dpy, px->context,
|
||||
EGL_WAYLAND_BUFFER_WL,(EGLClientBuffer)img, attr);
|
||||
if(image == NULL)
|
||||
goto err_1;
|
||||
|
||||
planar->image[i] = image;
|
||||
glBindTexture(GL_TEXTURE_2D, planar->tex[i]);
|
||||
|
||||
if(glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
goto fail;
|
||||
goto err_1;
|
||||
};
|
||||
|
||||
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
|
||||
if(glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
goto fail;
|
||||
goto err_1;
|
||||
}
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
|
||||
@ -713,14 +733,16 @@ static planar_t* hw_create_planar(EGLint name, EGLint format, uint32_t width, ui
|
||||
|
||||
return planar;
|
||||
|
||||
err_1:
|
||||
hw_destroy_planar(planar);
|
||||
return NULL;
|
||||
|
||||
err_0:
|
||||
free(planar);
|
||||
fail:
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static int hw_destroy_bitmap(bitmap_t * bitmap)
|
||||
{
|
||||
struct drm_gem_close close;
|
||||
@ -731,6 +753,7 @@ static int hw_destroy_bitmap(bitmap_t * bitmap)
|
||||
close.handle = bitmap->handle;
|
||||
drm_ioctl(px->fd, DRM_IOCTL_GEM_CLOSE, &close);
|
||||
free(bitmap);
|
||||
return 0;
|
||||
};
|
||||
|
||||
static void *hw_lock_bitmap(bitmap_t *bitmap, uint32_t *pitch)
|
||||
@ -1015,6 +1038,7 @@ static struct pix_driver gl_driver =
|
||||
hw_resize_client,
|
||||
hw_fini,
|
||||
hw_create_planar,
|
||||
hw_destroy_planar,
|
||||
hw_blit_planar
|
||||
};
|
||||
|
||||
|
@ -87,6 +87,7 @@ struct planar
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
GLuint name;
|
||||
int num_planes;
|
||||
EGLImageKHR planar_image;
|
||||
EGLImageKHR image[3];
|
||||
GLuint offset[3];
|
||||
|
Loading…
Reference in New Issue
Block a user