gfx/gl/TextureImageEGL.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/gl/TextureImageEGL.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,98 @@
     1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef TEXTUREIMAGEEGL_H_
    1.10 +#define TEXTUREIMAGEEGL_H_
    1.11 +
    1.12 +#include "GLTextureImage.h"
    1.13 +
    1.14 +namespace mozilla {
    1.15 +namespace gl {
    1.16 +
    1.17 +class TextureImageEGL
    1.18 +    : public TextureImage
    1.19 +{
    1.20 +public:
    1.21 +    TextureImageEGL(GLuint aTexture,
    1.22 +                    const nsIntSize& aSize,
    1.23 +                    GLenum aWrapMode,
    1.24 +                    ContentType aContentType,
    1.25 +                    GLContext* aContext,
    1.26 +                    Flags aFlags = TextureImage::NoFlags,
    1.27 +                    TextureState aTextureState = Created,
    1.28 +                    TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
    1.29 +
    1.30 +    virtual ~TextureImageEGL();
    1.31 +
    1.32 +    virtual void GetUpdateRegion(nsIntRegion& aForRegion);
    1.33 +
    1.34 +    virtual gfx::DrawTarget* BeginUpdate(nsIntRegion& aRegion);
    1.35 +
    1.36 +    virtual void EndUpdate();
    1.37 +
    1.38 +    virtual bool DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& aRegion, const gfx::IntPoint& aFrom = gfx::IntPoint(0,0));
    1.39 +
    1.40 +    virtual void BindTexture(GLenum aTextureUnit);
    1.41 +
    1.42 +    virtual GLuint GetTextureID()
    1.43 +    {
    1.44 +        // Ensure the texture is allocated before it is used.
    1.45 +        if (mTextureState == Created) {
    1.46 +            Resize(mSize);
    1.47 +        }
    1.48 +        return mTexture;
    1.49 +    };
    1.50 +
    1.51 +    virtual bool InUpdate() const { return !!mUpdateDrawTarget; }
    1.52 +
    1.53 +    virtual void Resize(const gfx::IntSize& aSize);
    1.54 +
    1.55 +    bool BindTexImage();
    1.56 +
    1.57 +    bool ReleaseTexImage();
    1.58 +
    1.59 +    virtual bool CreateEGLSurface(gfxASurface* aSurface)
    1.60 +    {
    1.61 +        return false;
    1.62 +    }
    1.63 +
    1.64 +    virtual void DestroyEGLSurface(void);
    1.65 +
    1.66 +protected:
    1.67 +    typedef gfxImageFormat ImageFormat;
    1.68 +
    1.69 +    GLContext* mGLContext;
    1.70 +
    1.71 +    nsIntRect mUpdateRect;
    1.72 +    gfx::SurfaceFormat mUpdateFormat;
    1.73 +    RefPtr<gfx::DrawTarget> mUpdateDrawTarget;
    1.74 +    EGLImage mEGLImage;
    1.75 +    GLuint mTexture;
    1.76 +    EGLSurface mSurface;
    1.77 +    EGLConfig mConfig;
    1.78 +    TextureState mTextureState;
    1.79 +
    1.80 +    bool mBound;
    1.81 +};
    1.82 +
    1.83 +already_AddRefed<TextureImage>
    1.84 +CreateTextureImageEGL(GLContext *gl,
    1.85 +                      const gfx::IntSize& aSize,
    1.86 +                      TextureImage::ContentType aContentType,
    1.87 +                      GLenum aWrapMode,
    1.88 +                      TextureImage::Flags aFlags,
    1.89 +                      TextureImage::ImageFormat aImageFormat);
    1.90 +
    1.91 +already_AddRefed<TextureImage>
    1.92 +TileGenFuncEGL(GLContext *gl,
    1.93 +               const nsIntSize& aSize,
    1.94 +               TextureImage::ContentType aContentType,
    1.95 +               TextureImage::Flags aFlags,
    1.96 +               TextureImage::ImageFormat aImageFormat);
    1.97 +
    1.98 +}
    1.99 +}
   1.100 +
   1.101 +#endif // TEXTUREIMAGEEGL_H_

mercurial