diff --git a/gfx/thebes/GLContextProviderGLX.cpp b/gfx/thebes/GLContextProviderGLX.cpp index 6a770199656..eba0c96189f 100644 --- a/gfx/thebes/GLContextProviderGLX.cpp +++ b/gfx/thebes/GLContextProviderGLX.cpp @@ -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 + 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 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 + GLContextGLX::CreateBasicTextureImage(GLuint, + const nsIntSize&, + TextureImage::ContentType, + GLContext*); + +protected: + virtual already_AddRefed + CreateUpdateSurface(const gfxIntSize& aSize, ImageFormat aFmt) + { + mUpdateFormat = aFmt; + return gfxPlatform::GetPlatform()->CreateOffscreenSurface(aSize, aFmt); + } + + virtual already_AddRefed + GetImageForUpload(gfxASurface* aUpdateSurface) + { + nsRefPtr image = + new gfxImageSurface(gfxIntSize(mUpdateRect.width, + mUpdateRect.height), + mUpdateFormat); + nsRefPtr 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 +GLContextGLX::CreateBasicTextureImage(GLuint aTexture, + const nsIntSize& aSize, + TextureImage::ContentType aContentType, + GLContext* aContext) +{ + nsRefPtr teximage( + new TextureImageGLX(aTexture, aSize, aContentType, aContext)); + return teximage.forget(); +} + static PRBool AreCompatibleVisuals(XVisualInfo *one, XVisualInfo *two) { if (one->c_class != two->c_class) {