gfx/gl/GLContextEGL.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/gl/GLContextEGL.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,130 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* vim: set ts=8 sts=4 et sw=4 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef GLCONTEXTEGL_H_
    1.11 +#define GLCONTEXTEGL_H_
    1.12 +
    1.13 +#include "GLContext.h"
    1.14 +#include "GLLibraryEGL.h"
    1.15 +
    1.16 +#ifdef MOZ_WIDGET_GONK
    1.17 +#include "HwcComposer2D.h"
    1.18 +#endif
    1.19 +
    1.20 +namespace mozilla {
    1.21 +namespace gl {
    1.22 +
    1.23 +class GLContextEGL : public GLContext
    1.24 +{
    1.25 +    friend class TextureImageEGL;
    1.26 +
    1.27 +    static already_AddRefed<GLContextEGL>
    1.28 +    CreateGLContext(const SurfaceCaps& caps,
    1.29 +                    GLContextEGL *shareContext,
    1.30 +                    bool isOffscreen,
    1.31 +                    EGLConfig config,
    1.32 +                    EGLSurface surface);
    1.33 +
    1.34 +public:
    1.35 +    MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextEGL)
    1.36 +    GLContextEGL(const SurfaceCaps& caps,
    1.37 +                 GLContext* shareContext,
    1.38 +                 bool isOffscreen,
    1.39 +                 EGLConfig config,
    1.40 +                 EGLSurface surface,
    1.41 +                 EGLContext context);
    1.42 +
    1.43 +    ~GLContextEGL();
    1.44 +
    1.45 +    virtual GLContextType GetContextType() const MOZ_OVERRIDE { return GLContextType::EGL; }
    1.46 +
    1.47 +    static GLContextEGL* Cast(GLContext* gl) {
    1.48 +        MOZ_ASSERT(gl->GetContextType() == GLContextType::EGL);
    1.49 +        return static_cast<GLContextEGL*>(gl);
    1.50 +    }
    1.51 +
    1.52 +    bool Init() MOZ_OVERRIDE;
    1.53 +
    1.54 +    virtual bool IsDoubleBuffered() const MOZ_OVERRIDE {
    1.55 +        return mIsDoubleBuffered;
    1.56 +    }
    1.57 +
    1.58 +    void SetIsDoubleBuffered(bool aIsDB) {
    1.59 +        mIsDoubleBuffered = aIsDB;
    1.60 +    }
    1.61 +
    1.62 +    virtual bool SupportsRobustness() const MOZ_OVERRIDE {
    1.63 +        return sEGLLibrary.HasRobustness();
    1.64 +    }
    1.65 +
    1.66 +    virtual bool IsANGLE() const MOZ_OVERRIDE {
    1.67 +        return sEGLLibrary.IsANGLE();
    1.68 +    }
    1.69 +
    1.70 +    virtual bool BindTexImage() MOZ_OVERRIDE;
    1.71 +
    1.72 +    virtual bool ReleaseTexImage() MOZ_OVERRIDE;
    1.73 +
    1.74 +    void SetEGLSurfaceOverride(EGLSurface surf);
    1.75 +
    1.76 +    virtual bool MakeCurrentImpl(bool aForce) MOZ_OVERRIDE;
    1.77 +
    1.78 +    virtual bool IsCurrent() MOZ_OVERRIDE;
    1.79 +
    1.80 +    virtual bool RenewSurface() MOZ_OVERRIDE;
    1.81 +
    1.82 +    virtual void ReleaseSurface() MOZ_OVERRIDE;
    1.83 +
    1.84 +    virtual bool SetupLookupFunction() MOZ_OVERRIDE;
    1.85 +
    1.86 +    virtual bool SwapBuffers() MOZ_OVERRIDE;
    1.87 +
    1.88 +    // hold a reference to the given surface
    1.89 +    // for the lifetime of this context.
    1.90 +    void HoldSurface(gfxASurface *aSurf);
    1.91 +
    1.92 +    EGLContext GetEGLContext() {
    1.93 +        return mContext;
    1.94 +    }
    1.95 +
    1.96 +    bool BindTex2DOffscreen(GLContext *aOffscreen);
    1.97 +    void UnbindTex2DOffscreen(GLContext *aOffscreen);
    1.98 +    void BindOffscreenFramebuffer();
    1.99 +
   1.100 +    static already_AddRefed<GLContextEGL>
   1.101 +    CreateEGLPixmapOffscreenContext(const gfxIntSize& size);
   1.102 +
   1.103 +    static already_AddRefed<GLContextEGL>
   1.104 +    CreateEGLPBufferOffscreenContext(const gfxIntSize& size);
   1.105 +
   1.106 +protected:
   1.107 +    friend class GLContextProviderEGL;
   1.108 +
   1.109 +    EGLConfig  mConfig;
   1.110 +    EGLSurface mSurface;
   1.111 +    EGLSurface mSurfaceOverride;
   1.112 +    EGLContext mContext;
   1.113 +    nsRefPtr<gfxASurface> mThebesSurface;
   1.114 +    bool mBound;
   1.115 +
   1.116 +    bool mIsPBuffer;
   1.117 +    bool mIsDoubleBuffered;
   1.118 +    bool mCanBindToTexture;
   1.119 +    bool mShareWithEGLImage;
   1.120 +#ifdef MOZ_WIDGET_GONK
   1.121 +    nsRefPtr<HwcComposer2D> mHwc;
   1.122 +#endif
   1.123 +    bool mOwnsContext;
   1.124 +
   1.125 +    static EGLSurface CreatePBufferSurfaceTryingPowerOfTwo(EGLConfig config,
   1.126 +                                                           EGLenum bindToTextureFormat,
   1.127 +                                                           gfxIntSize& pbsize);
   1.128 +};
   1.129 +
   1.130 +}
   1.131 +}
   1.132 +
   1.133 +#endif // GLCONTEXTEGL_H_

mercurial