321
336
matrix.y0 = 0.0f;
325
341
t->setData (target, matrix, mipmap);
326
342
t->setGeometry (0, 0, width, height);
328
344
glBindTexture (target, t->name ());
347
// internalFormat = GL_BGRA;
348
internalFormat = GL_BGRA;
350
internalFormat = GL_RGBA;
330
354
opt = GLScreen::get (screen)->getOption ("texture_compression");
331
355
if (opt->value ().b () && GL::textureCompression)
332
356
internalFormat = GL_COMPRESSED_RGBA_ARB;
334
internalFormat = GL_RGBA;
336
359
glTexImage2D (target, 0, internalFormat, width, height, 0,
337
360
format, type, image);
416
439
return GLTexture::List ();
443
EglTexture::EglTexture () :
450
EglTexture::~EglTexture ()
452
GLuint temp = name ();
453
glBindTexture (target (), name ());
455
glDeleteTextures (1, &temp);
457
glBindTexture (target (), 0);
459
boundPixmapTex.erase (damage);
460
XDamageDestroy (screen->dpy (), damage);
464
EglTexture::bindPixmapToTexture (Pixmap pixmap,
469
if ((int) width > GL::maxTextureSize || (int) height > GL::maxTextureSize ||
470
!GL::textureFromPixmap)
471
return GLTexture::List ();
473
GLTexture::List rv (1);
474
EglTexture *tex = NULL;
475
EGLImageKHR eglImage = NULL;
476
GLTexture::Matrix matrix = _identity_matrix;
478
const EGLint img_attribs[] = {
479
EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
483
eglImage = GL::createImage (eglGetDisplay (screen->dpy ()),
484
EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR,
485
(EGLClientBuffer)pixmap, img_attribs);
487
if (eglImage == EGL_NO_IMAGE_KHR)
489
compLogMessage ("core", CompLogLevelWarn,
490
"eglCreateImageKHR failed");
492
return GLTexture::List ();
495
matrix.xx = 1.0f / width;
496
matrix.yy = 1.0f / height;
499
tex = new EglTexture ();
500
tex->setData (GL_TEXTURE_2D, matrix, true);
501
tex->setGeometry (0, 0, width, height);
505
glBindTexture (GL_TEXTURE_2D, tex->name ());
507
GL::eglImageTargetTexture (GL_TEXTURE_2D, (GLeglImageOES)eglImage);
508
GL::destroyImage (eglGetDisplay (screen->dpy ()), eglImage);
510
tex->setFilter (GL_NEAREST);
511
tex->setWrap (GL_CLAMP_TO_EDGE);
513
glBindTexture (GL_TEXTURE_2D, 0);
515
tex->damage = XDamageCreate (screen->dpy (), pixmap,
516
XDamageReportRawRectangles);
517
boundPixmapTex[tex->damage] = tex;
523
EglTexture::enable (GLTexture::Filter filter)
525
glBindTexture (target (), name ());
526
GLTexture::enable (filter);
531
if (this->filter () == GL_LINEAR_MIPMAP_LINEAR && updateMipMap)
533
GL::generateMipmap (target ());
534
updateMipMap = false;
419
540
TfpTexture::TfpTexture () :