Bug 1482974 - Prefer to initialize members at declaration in gfx/gl. r=jrmuizel

Differential Revision: https://phabricator.services.mozilla.com/D3240

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jeff Gilbert 2018-08-17 22:21:26 +00:00
parent a2e818ca91
commit 2ab455c28d
18 changed files with 77 additions and 157 deletions

View File

@ -377,7 +377,6 @@ DrawBlitProg::DrawBlitProg(const GLBlitHelper* const parent, const GLuint prog)
, mLoc_uTexMatrix0(mParent.mGL->fGetUniformLocation(mProg, "uTexMatrix0"))
, mLoc_uTexMatrix1(mParent.mGL->fGetUniformLocation(mProg, "uTexMatrix1"))
, mLoc_uColorMatrix(mParent.mGL->fGetUniformLocation(mProg, "uColorMatrix"))
, mType_uColorMatrix(0)
{
MOZ_ASSERT(mLoc_uDestMatrix != -1);
MOZ_ASSERT(mLoc_uTexMatrix0 != -1);
@ -513,12 +512,9 @@ DrawBlitProg::Draw(const BaseArgs& args, const YUVArgs* const argsYUV) const
GLBlitHelper::GLBlitHelper(GLContext* const gl)
: mGL(gl)
, mQuadVAO(0)
, mQuadVBO(0)
, mDrawBlitProg_VertShader(mGL->fCreateShader(LOCAL_GL_VERTEX_SHADER))
, mYuvUploads{0}
, mYuvUploads_YSize(0, 0)
, mYuvUploads_UVSize(0, 0)
//, mYuvUploads_YSize(0, 0)
//, mYuvUploads_UVSize(0, 0)
{
mGL->fGenBuffers(1, &mQuadVBO);
{

View File

@ -71,7 +71,7 @@ class DrawBlitProg final
const GLint mLoc_uTexMatrix0;
const GLint mLoc_uTexMatrix1;
const GLint mLoc_uColorMatrix;
GLenum mType_uColorMatrix;
GLenum mType_uColorMatrix = 0;
public:
struct Key final {
@ -126,14 +126,14 @@ class GLBlitHelper final
GLContext* const mGL;
mutable std::map<DrawBlitProg::Key, const DrawBlitProg*> mDrawBlitProgs;
GLuint mQuadVAO;
GLuint mQuadVBO;
GLuint mQuadVAO = 0;
GLuint mQuadVBO = 0;
nsCString mDrawBlitProg_VersionLine;
const GLuint mDrawBlitProg_VertShader;
GLuint mYuvUploads[3];
gfx::IntSize mYuvUploads_YSize;
gfx::IntSize mYuvUploads_UVSize;
GLuint mYuvUploads[3] = {};
gfx::IntSize mYuvUploads_YSize = {0,0};
gfx::IntSize mYuvUploads_UVSize = {0,0};
#ifdef XP_WIN
mutable RefPtr<ID3D11Device> mD3D11;

View File

@ -264,37 +264,12 @@ GLContext::ChooseDebugFlags(const CreateContextFlags createFlags)
GLContext::GLContext(CreateContextFlags flags, const SurfaceCaps& caps,
GLContext* sharedContext, bool isOffscreen, bool useTLSIsCurrent)
: mImplicitMakeCurrent(false),
mUseTLSIsCurrent(ShouldUseTLSIsCurrent(useTLSIsCurrent)),
: mUseTLSIsCurrent(ShouldUseTLSIsCurrent(useTLSIsCurrent)),
mIsOffscreen(isOffscreen),
mContextLost(false),
mVersion(0),
mProfile(ContextProfile::Unknown),
mShadingLanguageVersion(0),
mVendor(GLVendor::Other),
mRenderer(GLRenderer::Other),
mTopError(LOCAL_GL_NO_ERROR),
mDebugFlags(ChooseDebugFlags(flags)),
mSharedContext(sharedContext),
mSymbols{},
mCaps(caps),
mScreen(nullptr),
mLockedSurface(nullptr),
mMaxTextureSize(0),
mMaxCubeMapTextureSize(0),
mMaxTextureImageSize(0),
mMaxRenderbufferSize(0),
mMaxSamples(0),
mNeedsTextureSizeChecks(false),
mNeedsFlushBeforeDeleteFB(false),
mTextureAllocCrashesOnMapFailure(false),
mNeedsCheckAfterAttachTextureToFb(false),
mWorkAroundDriverBugs(true),
mSyncGLCallCount(0),
mHeavyGLCallsSinceLastFlush(false)
mCaps(caps)
{
mMaxViewportDims[0] = 0;
mMaxViewportDims[1] = 0;
mOwningThreadId = PlatformThread::CurrentId();
MOZ_ALWAYS_TRUE( sCurrentContext.init() );
sCurrentContext.set(0);

View File

@ -198,7 +198,7 @@ public:
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(GLContext)
static MOZ_THREAD_LOCAL(uintptr_t) sCurrentContext;
bool mImplicitMakeCurrent;
bool mImplicitMakeCurrent = false;
bool mUseTLSIsCurrent;
class TlsScope final {
@ -338,19 +338,19 @@ public:
protected:
bool mIsOffscreen;
mutable bool mContextLost;
mutable bool mContextLost = false;
/**
* mVersion store the OpenGL's version, multiplied by 100. For example, if
* the context is an OpenGL 2.1 context, mVersion value will be 210.
*/
uint32_t mVersion;
ContextProfile mProfile;
uint32_t mVersion = 0;
ContextProfile mProfile = ContextProfile::Unknown;
uint32_t mShadingLanguageVersion;
uint32_t mShadingLanguageVersion = 0;
GLVendor mVendor;
GLRenderer mRenderer;
GLVendor mVendor = GLVendor::Other;
GLRenderer mRenderer = GLRenderer::Other;
// -----------------------------------------------------------------------------
// Extensions management
@ -571,7 +571,7 @@ public:
}
private:
mutable GLenum mTopError;
mutable GLenum mTopError = 0;
GLenum RawGetError() const {
return mSymbols.fGetError();
@ -3501,7 +3501,7 @@ protected:
// The thread id which this context was created.
PlatformThreadId mOwningThreadId;
GLContextSymbols mSymbols;
GLContextSymbols mSymbols = {};
UniquePtr<GLBlitHelper> mBlitHelper;
UniquePtr<GLReadTexImageHelper> mReadTexImageHelper;
@ -3574,7 +3574,7 @@ protected:
friend class GLScreenBuffer;
UniquePtr<GLScreenBuffer> mScreen;
SharedSurface* mLockedSurface;
SharedSurface* mLockedSurface = nullptr;
public:
void LockSurface(SharedSurface* surf) {
@ -3619,22 +3619,22 @@ private:
protected:
void InitExtensions();
GLint mViewportRect[4];
GLint mScissorRect[4];
GLint mViewportRect[4] = {};
GLint mScissorRect[4] = {};
uint32_t mMaxTexOrRbSize = 0;
GLint mMaxTextureSize;
GLint mMaxCubeMapTextureSize;
GLint mMaxTextureImageSize;
GLint mMaxRenderbufferSize;
GLint mMaxViewportDims[2];
GLsizei mMaxSamples;
bool mNeedsTextureSizeChecks;
bool mNeedsFlushBeforeDeleteFB;
bool mTextureAllocCrashesOnMapFailure;
bool mNeedsCheckAfterAttachTextureToFb;
bool mWorkAroundDriverBugs;
mutable uint64_t mSyncGLCallCount;
GLint mMaxTextureSize = 0;
GLint mMaxCubeMapTextureSize = 0;
GLint mMaxTextureImageSize = 0;
GLint mMaxRenderbufferSize = 0;
GLint mMaxViewportDims[2] = {};
GLsizei mMaxSamples = 0;
bool mNeedsTextureSizeChecks = false;
bool mNeedsFlushBeforeDeleteFB = false;
bool mTextureAllocCrashesOnMapFailure = false;
bool mNeedsCheckAfterAttachTextureToFb = false;
bool mWorkAroundDriverBugs = true;
mutable uint64_t mSyncGLCallCount = 0;
bool IsTextureSizeSafeToPassToDriver(GLenum target, GLsizei width, GLsizei height) const {
if (mNeedsTextureSizeChecks) {
@ -3718,7 +3718,7 @@ public:
protected:
bool mHeavyGLCallsSinceLastFlush;
bool mHeavyGLCallsSinceLastFlush = false;
public:
void FlushIfHeavyGLCallsSinceLastFlush();

View File

@ -65,10 +65,10 @@ public:
}
private:
GLuint mBackbufferRB;
GLuint mBackbufferFB;
GLuint mBackbufferRB = 0;
GLuint mBackbufferFB = 0;
void* mLayer;
void* mLayer = nullptr;
bool RecreateRB();
};

View File

@ -124,15 +124,15 @@ protected:
public:
const EGLContext mContext;
protected:
EGLSurface mSurfaceOverride;
EGLSurface mSurfaceOverride = EGL_NO_SURFACE;
RefPtr<gfxASurface> mThebesSurface;
bool mBound;
bool mBound = false;
bool mIsPBuffer;
bool mIsDoubleBuffered;
bool mCanBindToTexture;
bool mShareWithEGLImage;
bool mOwnsContext;
bool mIsPBuffer = false;
bool mIsDoubleBuffered = false;
bool mCanBindToTexture = false;
bool mShareWithEGLImage = false;
bool mOwnsContext = true;
static EGLSurface CreatePBufferSurfaceTryingPowerOfTwo(EGLConfig config,
EGLenum bindToTextureFormat,

View File

@ -93,7 +93,7 @@ private:
GLXLibrary* mGLX;
RefPtr<gfxXlibSurface> mPixmap;
bool mOwnsContext;
bool mOwnsContext = true;
};
}

View File

@ -31,12 +31,6 @@ using namespace mozilla::widget;
class CGLLibrary
{
public:
CGLLibrary()
: mInitialized(false)
, mUseDoubleBufferedWindows(true)
, mOGLLibrary(nullptr)
{}
bool EnsureInitialized()
{
if (mInitialized) {
@ -65,9 +59,9 @@ public:
}
private:
bool mInitialized;
bool mUseDoubleBufferedWindows;
PRLibrary* mOGLLibrary;
bool mInitialized = false;
bool mUseDoubleBufferedWindows = true;
PRLibrary* mOGLLibrary = nullptr;
};
CGLLibrary sCGLLibrary;

View File

@ -27,9 +27,6 @@ GLContextEAGL::GLContextEAGL(CreateContextFlags flags, const SurfaceCaps& caps,
bool isOffscreen)
: GLContext(flags, caps, sharedContext, isOffscreen)
, mContext(context)
, mBackbufferRB(0)
, mBackbufferFB(0)
, mLayer(nil)
{
}

View File

@ -306,14 +306,6 @@ GLContextEGL::GLContextEGL(CreateContextFlags flags, const SurfaceCaps& caps,
, mSurface(surface)
, mFallbackSurface(CreateFallbackSurface(config))
, mContext(context)
, mSurfaceOverride(EGL_NO_SURFACE)
, mThebesSurface(nullptr)
, mBound(false)
, mIsPBuffer(false)
, mIsDoubleBuffered(false)
, mCanBindToTexture(false)
, mShareWithEGLImage(false)
, mOwnsContext(true)
{
#ifdef DEBUG
printf_stderr("Initializing context %p surface %p on display %p\n", mContext, mSurface, EGL_DISPLAY());

View File

@ -712,8 +712,7 @@ GLContextGLX::GLContextGLX(
mDeleteDrawable(aDeleteDrawable),
mDoubleBuffered(aDoubleBuffered),
mGLX(&sGLXLibrary),
mPixmap(aPixmap),
mOwnsContext(true)
mPixmap(aPixmap)
{
}

View File

@ -280,8 +280,7 @@ GLContextWGL::GLContextWGL(CreateContextFlags flags, const SurfaceCaps& caps,
mContext(aContext),
mWnd(aWindow),
mPBuffer(nullptr),
mPixelFormat(0),
mIsDoubleBuffered(false)
mPixelFormat(0)
{
}
@ -293,8 +292,7 @@ GLContextWGL::GLContextWGL(CreateContextFlags flags, const SurfaceCaps& caps,
mContext(aContext),
mWnd(nullptr),
mPBuffer(aPbuffer),
mPixelFormat(aPixelFormat),
mIsDoubleBuffered(false)
mPixelFormat(aPixelFormat)
{
}

View File

@ -56,7 +56,7 @@ protected:
HANDLE mPBuffer;
int mPixelFormat;
public:
bool mIsDoubleBuffered;
bool mIsDoubleBuffered = false;
};
}

View File

@ -58,20 +58,11 @@ void AfterEGLCall(const char* funcName);
class GLLibraryEGL
{
protected:
~GLLibraryEGL() {}
~GLLibraryEGL() {}
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GLLibraryEGL)
GLLibraryEGL()
: mSymbols{nullptr}
, mInitialized(false)
, mEGLLibrary(nullptr)
, mEGLDisplay(EGL_NO_DISPLAY)
, mIsANGLE(false)
, mIsWARP(false)
{ }
void InitClientExtensions();
void InitDisplayExtensions();
@ -498,7 +489,7 @@ private:
const EGLAttrib* attrib_list);
EGLBoolean (GLAPIENTRY * fReleaseDeviceANGLE) (EGLDeviceEXT device);
} mSymbols;
} mSymbols = {};
private:
bool DoEnsureInitialized(bool forceAccel, nsACString* const out_failureId);
@ -506,13 +497,13 @@ private:
const nsCOMPtr<nsIGfxInfo>& gfxInfo,
nsACString* const out_failureId);
bool mInitialized;
PRLibrary* mEGLLibrary;
EGLDisplay mEGLDisplay;
bool mInitialized = false;
PRLibrary* mEGLLibrary = nullptr;
EGLDisplay mEGLDisplay = EGL_NO_DISPLAY;
RefPtr<GLContext> mReadbackGL;
bool mIsANGLE;
bool mIsWARP;
bool mIsANGLE = false;
bool mIsWARP = false;
static StaticMutex sMutex;
static StaticRefPtr<GLLibraryEGL> sEGLLibrary;
};

View File

@ -31,20 +31,6 @@ namespace gl {
class GLXLibrary
{
public:
GLXLibrary()
: mSymbols{nullptr}
, mInitialized(false)
, mTriedInitializing(false)
, mUseTextureFromPixmap(false)
, mDebug(false)
, mHasRobustness(false)
, mHasCreateContextAttribs(false)
, mHasVideoSync(false)
, mIsATI(false), mIsNVIDIA(false)
, mClientIsMesa(false)
, mOGLLibrary(nullptr)
{}
bool EnsureInitialized();
private:
@ -212,24 +198,24 @@ private:
int (GLAPIENTRY *fGetVideoSyncSGI) (unsigned int*);
int (GLAPIENTRY *fWaitVideoSyncSGI) (int, int, unsigned int*);
void (GLAPIENTRY *fSwapIntervalEXT) (Display*, GLXDrawable, int);
} mSymbols;
} mSymbols = {};
#ifdef DEBUG
void BeforeGLXCall();
void AfterGLXCall();
#endif
bool mInitialized;
bool mTriedInitializing;
bool mUseTextureFromPixmap;
bool mDebug;
bool mHasRobustness;
bool mHasCreateContextAttribs;
bool mHasVideoSync;
bool mIsATI;
bool mIsNVIDIA;
bool mClientIsMesa;
PRLibrary* mOGLLibrary;
bool mInitialized = false;
bool mTriedInitializing = false;
bool mUseTextureFromPixmap = false;
bool mDebug = false;
bool mHasRobustness = false;
bool mHasCreateContextAttribs = false;
bool mHasVideoSync = false;
bool mIsATI = false;
bool mIsNVIDIA = false;
bool mClientIsMesa = false;
PRLibrary* mOGLLibrary = nullptr;
};
// a global GLXLibrary instance

View File

@ -403,10 +403,6 @@ SurfaceFactory::Recycle(layers::SharedSurfaceTextureClient* texClient)
ScopedReadbackFB::ScopedReadbackFB(SharedSurface* src)
: mGL(src->mGL)
, mAutoFB(mGL)
, mTempFB(0)
, mTempTex(0)
, mSurfToUnlock(nullptr)
, mSurfToLock(nullptr)
{
switch (src->mAttachType) {
case AttachmentType::GLRenderbuffer:

View File

@ -318,10 +318,10 @@ class ScopedReadbackFB
{
GLContext* const mGL;
ScopedBindFramebuffer mAutoFB;
GLuint mTempFB;
GLuint mTempTex;
SharedSurface* mSurfToUnlock;
SharedSurface* mSurfToLock;
GLuint mTempFB = 0;
GLuint mTempTex = 0;
SharedSurface* mSurfToUnlock = nullptr;
SharedSurface* mSurfToLock = nullptr;
public:
explicit ScopedReadbackFB(SharedSurface* src);

View File

@ -39,10 +39,6 @@ struct PBufferDC final : public ScopedDC
class WGLLibrary
{
public:
WGLLibrary()
: mSymbols{}
{ }
~WGLLibrary() {
Reset();
}
@ -90,7 +86,7 @@ public:
HANDLE* hObjects);
BOOL (GLAPIENTRY * fDXUnlockObjectsNV) (HANDLE hDevice, GLint count,
HANDLE* hObjects);
} mSymbols;
} mSymbols = {};
bool EnsureInitialized();
//UniquePtr<WindowDC> CreateDummyWindow();