Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim: set ts=8 sts=4 et sw=4 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef GLCONTEXTEGL_H_
8 #define GLCONTEXTEGL_H_
10 #include "GLContext.h"
11 #include "GLLibraryEGL.h"
13 #ifdef MOZ_WIDGET_GONK
14 #include "HwcComposer2D.h"
15 #endif
17 namespace mozilla {
18 namespace gl {
20 class GLContextEGL : public GLContext
21 {
22 friend class TextureImageEGL;
24 static already_AddRefed<GLContextEGL>
25 CreateGLContext(const SurfaceCaps& caps,
26 GLContextEGL *shareContext,
27 bool isOffscreen,
28 EGLConfig config,
29 EGLSurface surface);
31 public:
32 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextEGL)
33 GLContextEGL(const SurfaceCaps& caps,
34 GLContext* shareContext,
35 bool isOffscreen,
36 EGLConfig config,
37 EGLSurface surface,
38 EGLContext context);
40 ~GLContextEGL();
42 virtual GLContextType GetContextType() const MOZ_OVERRIDE { return GLContextType::EGL; }
44 static GLContextEGL* Cast(GLContext* gl) {
45 MOZ_ASSERT(gl->GetContextType() == GLContextType::EGL);
46 return static_cast<GLContextEGL*>(gl);
47 }
49 bool Init() MOZ_OVERRIDE;
51 virtual bool IsDoubleBuffered() const MOZ_OVERRIDE {
52 return mIsDoubleBuffered;
53 }
55 void SetIsDoubleBuffered(bool aIsDB) {
56 mIsDoubleBuffered = aIsDB;
57 }
59 virtual bool SupportsRobustness() const MOZ_OVERRIDE {
60 return sEGLLibrary.HasRobustness();
61 }
63 virtual bool IsANGLE() const MOZ_OVERRIDE {
64 return sEGLLibrary.IsANGLE();
65 }
67 virtual bool BindTexImage() MOZ_OVERRIDE;
69 virtual bool ReleaseTexImage() MOZ_OVERRIDE;
71 void SetEGLSurfaceOverride(EGLSurface surf);
73 virtual bool MakeCurrentImpl(bool aForce) MOZ_OVERRIDE;
75 virtual bool IsCurrent() MOZ_OVERRIDE;
77 virtual bool RenewSurface() MOZ_OVERRIDE;
79 virtual void ReleaseSurface() MOZ_OVERRIDE;
81 virtual bool SetupLookupFunction() MOZ_OVERRIDE;
83 virtual bool SwapBuffers() MOZ_OVERRIDE;
85 // hold a reference to the given surface
86 // for the lifetime of this context.
87 void HoldSurface(gfxASurface *aSurf);
89 EGLContext GetEGLContext() {
90 return mContext;
91 }
93 bool BindTex2DOffscreen(GLContext *aOffscreen);
94 void UnbindTex2DOffscreen(GLContext *aOffscreen);
95 void BindOffscreenFramebuffer();
97 static already_AddRefed<GLContextEGL>
98 CreateEGLPixmapOffscreenContext(const gfxIntSize& size);
100 static already_AddRefed<GLContextEGL>
101 CreateEGLPBufferOffscreenContext(const gfxIntSize& size);
103 protected:
104 friend class GLContextProviderEGL;
106 EGLConfig mConfig;
107 EGLSurface mSurface;
108 EGLSurface mSurfaceOverride;
109 EGLContext mContext;
110 nsRefPtr<gfxASurface> mThebesSurface;
111 bool mBound;
113 bool mIsPBuffer;
114 bool mIsDoubleBuffered;
115 bool mCanBindToTexture;
116 bool mShareWithEGLImage;
117 #ifdef MOZ_WIDGET_GONK
118 nsRefPtr<HwcComposer2D> mHwc;
119 #endif
120 bool mOwnsContext;
122 static EGLSurface CreatePBufferSurfaceTryingPowerOfTwo(EGLConfig config,
123 EGLenum bindToTextureFormat,
124 gfxIntSize& pbsize);
125 };
127 }
128 }
130 #endif // GLCONTEXTEGL_H_