Bug 573889, part 4: Implement TextureImage for GLX. r=vlad

This commit is contained in:
Chris Jones 2010-07-01 11:30:38 -05:00
Родитель 3105100b4f
Коммит 078b326454
1 изменённых файлов: 66 добавлений и 0 удалений

Просмотреть файл

@ -54,6 +54,9 @@
#include "nsIWidget.h"
#include "GLXLibrary.h"
#include "gfxASurface.h"
#include "gfxContext.h"
#include "gfxImageSurface.h"
#include "gfxPlatform.h"
namespace mozilla {
namespace gl {
@ -241,6 +244,12 @@ public:
}
}
virtual already_AddRefed<TextureImage>
CreateBasicTextureImage(GLuint aTexture,
const nsIntSize& aSize,
TextureImage::ContentType aContentType,
GLContext* aContext);
private:
GLContextGLX(Display *aDisplay, GLXDrawable aWindow, GLXContext aContext, PRBool aPBuffer = PR_FALSE, PRBool aDoubleBuffered=PR_FALSE)
: mContext(aContext),
@ -257,6 +266,63 @@ private:
nsTArray<GLuint> textures;
};
// FIXME/bug 575505: this is a (very slow!) placeholder
// implementation. Much better would be to create a Pixmap, wrap that
// in a GLXPixmap, and then glXBindTexImage() to our texture.
class TextureImageGLX : public BasicTextureImage
{
friend already_AddRefed<TextureImage>
GLContextGLX::CreateBasicTextureImage(GLuint,
const nsIntSize&,
TextureImage::ContentType,
GLContext*);
protected:
virtual already_AddRefed<gfxASurface>
CreateUpdateSurface(const gfxIntSize& aSize, ImageFormat aFmt)
{
mUpdateFormat = aFmt;
return gfxPlatform::GetPlatform()->CreateOffscreenSurface(aSize, aFmt);
}
virtual already_AddRefed<gfxImageSurface>
GetImageForUpload(gfxASurface* aUpdateSurface)
{
nsRefPtr<gfxImageSurface> image =
new gfxImageSurface(gfxIntSize(mUpdateRect.width,
mUpdateRect.height),
mUpdateFormat);
nsRefPtr<gfxContext> tmpContext = new gfxContext(image);
tmpContext->SetSource(aUpdateSurface);
tmpContext->SetOperator(gfxContext::OPERATOR_SOURCE);
tmpContext->Paint();
return image.forget();
}
private:
TextureImageGLX(GLuint aTexture,
const nsIntSize& aSize,
ContentType aContentType,
GLContext* aContext)
: BasicTextureImage(aTexture, aSize, aContentType, aContext)
{}
ImageFormat mUpdateFormat;
};
already_AddRefed<TextureImage>
GLContextGLX::CreateBasicTextureImage(GLuint aTexture,
const nsIntSize& aSize,
TextureImage::ContentType aContentType,
GLContext* aContext)
{
nsRefPtr<TextureImageGLX> teximage(
new TextureImageGLX(aTexture, aSize, aContentType, aContext));
return teximage.forget();
}
static PRBool AreCompatibleVisuals(XVisualInfo *one, XVisualInfo *two)
{
if (one->c_class != two->c_class) {