summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-05-13 10:16:17 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-05-13 10:46:06 +0900
commit94b447e99b0a1bb71e00a9c923f3485e2e0f5b72 (patch)
treea3db86c47f09b9b82a88142b983c2509efb2c820
parent8f4d840876dc2c658f7ec5253ca13c0de60175a8 (diff)
Evas filters: Fix glReadPixels usage for EGLdevs/spacegrapher/evasgl-1.14
EGL might very well not support RGBA read mode, so we need to check for it first. Also remove some error logs (see previous commit), and useless initialization of the Evas GL engine. @fix
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c
index 0167703a83..0e3b14e5b1 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -621,7 +621,6 @@ _rotate_image_data(void *data, void *img)
621 evas_common_draw_context_free(dc); 621 evas_common_draw_context_free(dc);
622 622
623 glsym_glBindFramebuffer(GL_FRAMEBUFFER, im2->tex->pt->fb); 623 glsym_glBindFramebuffer(GL_FRAMEBUFFER, im2->tex->pt->fb);
624 GLERRV("glsym_glBindFramebuffer");
625 624
626 // Rely on Evas_GL_Image infrastructure to allocate pixels 625 // Rely on Evas_GL_Image infrastructure to allocate pixels
627 im2->im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get()); 626 im2->im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
@@ -652,7 +651,6 @@ _rotate_image_data(void *data, void *img)
652 } 651 }
653 652
654 glsym_glBindFramebuffer(GL_FRAMEBUFFER, 0); 653 glsym_glBindFramebuffer(GL_FRAMEBUFFER, 0);
655 GLERRV("glsym_glBindFramebuffer");
656 654
657 return im2; 655 return im2;
658} 656}
@@ -725,7 +723,6 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, i
725 if (!im->tex->pt->dyn.data) 723 if (!im->tex->pt->dyn.data)
726 { 724 {
727 if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; 725 if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
728 GLERRV("secsym_eglMapImageSEC");
729 return im; 726 return im;
730 } 727 }
731 im->tex->pt->dyn.checked_out++; 728 im->tex->pt->dyn.checked_out++;
@@ -1600,12 +1597,10 @@ eng_gl_get_pixels_post(void *data EINA_UNUSED)
1600} 1597}
1601 1598
1602static Eina_Bool 1599static Eina_Bool
1603eng_gl_surface_lock(void *data, void *surface) 1600eng_gl_surface_lock(void *data EINA_UNUSED, void *surface)
1604{ 1601{
1605 Render_Engine_GL_Generic *re = data;
1606 Evas_GL_Image *im = surface; 1602 Evas_GL_Image *im = surface;
1607 1603
1608 EVGLINIT(re, EINA_FALSE);
1609 if (!im->tex || !im->tex->pt) 1604 if (!im->tex || !im->tex->pt)
1610 { 1605 {
1611 ERR("Can not lock image that is not a surface!"); 1606 ERR("Can not lock image that is not a surface!");
@@ -1618,27 +1613,25 @@ eng_gl_surface_lock(void *data, void *surface)
1618} 1613}
1619 1614
1620static Eina_Bool 1615static Eina_Bool
1621eng_gl_surface_unlock(void *data, void *surface) 1616eng_gl_surface_unlock(void *data EINA_UNUSED, void *surface)
1622{ 1617{
1623 Render_Engine_GL_Generic *re = data;
1624 Evas_GL_Image *im = surface; 1618 Evas_GL_Image *im = surface;
1625 1619
1626 EVGLINIT(re, EINA_FALSE);
1627 im->locked = EINA_FALSE; 1620 im->locked = EINA_FALSE;
1628 return EINA_TRUE; 1621 return EINA_TRUE;
1629} 1622}
1630 1623
1631static Eina_Bool 1624static Eina_Bool
1632eng_gl_surface_read_pixels(void *data, void *surface, 1625eng_gl_surface_read_pixels(void *data EINA_UNUSED, void *surface,
1633 int x, int y, int w, int h, 1626 int x, int y, int w, int h,
1634 Evas_Colorspace cspace, void *pixels) 1627 Evas_Colorspace cspace, void *pixels)
1635{ 1628{
1636 Render_Engine_GL_Generic *re = data;
1637 Evas_GL_Image *im = surface; 1629 Evas_GL_Image *im = surface;
1630 GLint fmt = GL_BGRA;
1631 int done = 0;
1638 1632
1639 EINA_SAFETY_ON_NULL_RETURN_VAL(pixels, EINA_FALSE); 1633 EINA_SAFETY_ON_NULL_RETURN_VAL(pixels, EINA_FALSE);
1640 1634
1641 EVGLINIT(re, EINA_FALSE);
1642 if (!im->locked) 1635 if (!im->locked)
1643 { 1636 {
1644 // For now, this is useless, but let's force clients to lock :) 1637 // For now, this is useless, but let's force clients to lock :)
@@ -1657,10 +1650,20 @@ eng_gl_surface_read_pixels(void *data, void *surface,
1657 */ 1650 */
1658 1651
1659 glsym_glBindFramebuffer(GL_FRAMEBUFFER, im->tex->pt->fb); 1652 glsym_glBindFramebuffer(GL_FRAMEBUFFER, im->tex->pt->fb);
1660 GLERRV("glsym_glBindFramebuffer"); 1653 glPixelStorei(GL_PACK_ALIGNMENT, 4);
1661 if (im->tex->pt->format == GL_BGRA) 1654
1662 glReadPixels(x, y, w, h, GL_BGRA, GL_UNSIGNED_BYTE, pixels); 1655 // With GLX we will try to read BGRA even if the driver reports RGBA
1663 else 1656#if defined(GL_GLES) && defined(GL_IMPLEMENTATION_COLOR_READ_FORMAT)
1657 glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &fmt);
1658#endif
1659
1660 if ((im->tex->pt->format == GL_BGRA) && (fmt == GL_BGRA))
1661 {
1662 glReadPixels(x, y, w, h, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
1663 done = (glGetError() == GL_NO_ERROR);
1664 }
1665
1666 if (!done)
1664 { 1667 {
1665 DATA32 *ptr = pixels; 1668 DATA32 *ptr = pixels;
1666 int k; 1669 int k;
@@ -1674,8 +1677,8 @@ eng_gl_surface_read_pixels(void *data, void *surface,
1674 | ((v & 0x000000FF) << 16); 1677 | ((v & 0x000000FF) << 16);
1675 } 1678 }
1676 } 1679 }
1680
1677 glsym_glBindFramebuffer(GL_FRAMEBUFFER, 0); 1681 glsym_glBindFramebuffer(GL_FRAMEBUFFER, 0);
1678 GLERRV("glsym_glBindFramebuffer");
1679 1682
1680 return EINA_TRUE; 1683 return EINA_TRUE;
1681} 1684}