Apply Chromium style fixes.
This addresses several minor code quality issues that are validated
in Chromium, but not yet applied to ANGLE:
* constructors and destructors must be defined out-of-line
* auto is not allowed for simple pointer types
* use override everywhere instead of virtual
* virtual functions must also be defined out-of-line
Slightly reduces binary size for me (~2k on Win, 150k on Linux).
Bug: angleproject:1569
Change-Id: I073ca3365188caf5f29fb28d9eb207903c1843e6
Reviewed-on: https://chromium-review.googlesource.com/779959
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/gl/ClearMultiviewGL.cpp b/src/libANGLE/renderer/gl/ClearMultiviewGL.cpp
index 0c9a3ba..fb32978 100644
--- a/src/libANGLE/renderer/gl/ClearMultiviewGL.cpp
+++ b/src/libANGLE/renderer/gl/ClearMultiviewGL.cpp
@@ -40,7 +40,7 @@
GLfloat depth,
GLint stencil)
{
- const auto &firstAttachment = state.getFirstNonNullAttachment();
+ const gl::FramebufferAttachment *firstAttachment = state.getFirstNonNullAttachment();
switch (firstAttachment->getMultiviewLayout())
{
case GL_FRAMEBUFFER_MULTIVIEW_LAYERED_ANGLE:
@@ -69,7 +69,7 @@
mStateManager->bindFramebuffer(GL_DRAW_FRAMEBUFFER, mFramebuffer);
- const auto &firstAttachment = state.getFirstNonNullAttachment();
+ const gl::FramebufferAttachment *firstAttachment = state.getFirstNonNullAttachment();
ASSERT(firstAttachment->getMultiviewLayout() == GL_FRAMEBUFFER_MULTIVIEW_LAYERED_ANGLE);
const auto &drawBuffers = state.getDrawBufferStates();
@@ -97,7 +97,7 @@
GLfloat depth,
GLint stencil)
{
- const auto &firstAttachment = state.getFirstNonNullAttachment();
+ const gl::FramebufferAttachment *firstAttachment = state.getFirstNonNullAttachment();
ASSERT(firstAttachment->getMultiviewLayout() == GL_FRAMEBUFFER_MULTIVIEW_SIDE_BY_SIDE_ANGLE);
const auto &viewportOffsets = firstAttachment->getMultiviewViewportOffsets();
@@ -147,7 +147,7 @@
{
for (auto drawBufferId : state.getEnabledDrawBuffers())
{
- const auto &attachment = state.getColorAttachment(drawBufferId);
+ const gl::FramebufferAttachment *attachment = state.getColorAttachment(drawBufferId);
if (attachment == nullptr)
{
continue;
@@ -163,9 +163,9 @@
textureGL->getTextureID(), imageIndex.mipIndex, layer);
}
- const auto &depthStencilAttachment = state.getDepthStencilAttachment();
- const auto &depthAttachment = state.getDepthAttachment();
- const auto &stencilAttachment = state.getStencilAttachment();
+ const gl::FramebufferAttachment *depthStencilAttachment = state.getDepthStencilAttachment();
+ const gl::FramebufferAttachment *depthAttachment = state.getDepthAttachment();
+ const gl::FramebufferAttachment *stencilAttachment = state.getStencilAttachment();
if (depthStencilAttachment != nullptr)
{
const auto &imageIndex = depthStencilAttachment->getTextureImageIndex();
@@ -199,7 +199,7 @@
{
for (auto drawBufferId : state.getEnabledDrawBuffers())
{
- const auto &attachment = state.getColorAttachment(drawBufferId);
+ const gl::FramebufferAttachment *attachment = state.getColorAttachment(drawBufferId);
if (attachment == nullptr)
{
continue;
@@ -210,9 +210,9 @@
mFunctions->framebufferTextureLayer(GL_DRAW_FRAMEBUFFER, colorAttachment, 0, 0, 0);
}
- const auto &depthStencilAttachment = state.getDepthStencilAttachment();
- const auto &depthAttachment = state.getDepthAttachment();
- const auto &stencilAttachment = state.getStencilAttachment();
+ const gl::FramebufferAttachment *depthStencilAttachment = state.getDepthStencilAttachment();
+ const gl::FramebufferAttachment *depthAttachment = state.getDepthAttachment();
+ const gl::FramebufferAttachment *stencilAttachment = state.getStencilAttachment();
if (depthStencilAttachment != nullptr)
{
mFunctions->framebufferTextureLayer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, 0, 0,
diff --git a/src/libANGLE/renderer/gl/CompilerGL.cpp b/src/libANGLE/renderer/gl/CompilerGL.cpp
index 71be156..7e643f9 100644
--- a/src/libANGLE/renderer/gl/CompilerGL.cpp
+++ b/src/libANGLE/renderer/gl/CompilerGL.cpp
@@ -88,4 +88,14 @@
{
}
+gl::Error CompilerGL::release()
+{
+ return gl::NoError();
+}
+
+ShShaderOutput CompilerGL::getTranslatorOutputType() const
+{
+ return mTranslatorOutputType;
+}
+
} // namespace rx
diff --git a/src/libANGLE/renderer/gl/CompilerGL.h b/src/libANGLE/renderer/gl/CompilerGL.h
index 4c4104f..22e101b 100644
--- a/src/libANGLE/renderer/gl/CompilerGL.h
+++ b/src/libANGLE/renderer/gl/CompilerGL.h
@@ -21,8 +21,8 @@
CompilerGL(const FunctionsGL *functions);
~CompilerGL() override {}
- gl::Error release() override { return gl::NoError(); }
- ShShaderOutput getTranslatorOutputType() const override { return mTranslatorOutputType; }
+ gl::Error release() override;
+ ShShaderOutput getTranslatorOutputType() const override;
private:
ShShaderOutput mTranslatorOutputType;
diff --git a/src/libANGLE/renderer/gl/FunctionsGL.h b/src/libANGLE/renderer/gl/FunctionsGL.h
index ea4b948..77047c4 100644
--- a/src/libANGLE/renderer/gl/FunctionsGL.h
+++ b/src/libANGLE/renderer/gl/FunctionsGL.h
@@ -33,7 +33,7 @@
{
public:
FunctionsGL();
- virtual ~FunctionsGL();
+ ~FunctionsGL() override;
void initialize(const egl::AttributeMap &displayAttributes);
@@ -53,7 +53,7 @@
bool hasGLESExtension(const std::string &ext) const;
private:
- virtual void *loadProcAddress(const std::string &function) const = 0;
+ void *loadProcAddress(const std::string &function) const override = 0;
void initializeDummyFunctionsForNULLDriver(const std::set<std::string> &extensionSet);
};
diff --git a/src/libANGLE/renderer/gl/PathGL.h b/src/libANGLE/renderer/gl/PathGL.h
index 461d39a..74939d4 100644
--- a/src/libANGLE/renderer/gl/PathGL.h
+++ b/src/libANGLE/renderer/gl/PathGL.h
@@ -21,7 +21,7 @@
{
public:
PathGL(const FunctionsGL *functions, GLuint path);
- ~PathGL();
+ ~PathGL() override;
gl::Error setCommands(GLsizei numCommands,
const GLubyte *commands,
diff --git a/src/libANGLE/renderer/gl/QueryGL.cpp b/src/libANGLE/renderer/gl/QueryGL.cpp
index 9868724..ddbf2f8 100644
--- a/src/libANGLE/renderer/gl/QueryGL.cpp
+++ b/src/libANGLE/renderer/gl/QueryGL.cpp
@@ -245,7 +245,7 @@
mSync = mFunctions->fenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
}
- virtual ~SyncProviderGLSync() { mFunctions->deleteSync(mSync); }
+ ~SyncProviderGLSync() override { mFunctions->deleteSync(mSync); }
gl::Error flush(bool force, bool *finished) override
{
@@ -284,7 +284,7 @@
ANGLE_SWALLOW_ERR(stateManager->resumeQuery(queryType));
}
- virtual ~SyncProviderGLQuery() { mFunctions->deleteQueries(1, &mQuery); }
+ ~SyncProviderGLQuery() override { mFunctions->deleteQueries(1, &mQuery); }
gl::Error flush(bool force, bool *finished) override
{
diff --git a/src/libANGLE/renderer/gl/RenderbufferGL.h b/src/libANGLE/renderer/gl/RenderbufferGL.h
index 2f11b39..7aafec6 100644
--- a/src/libANGLE/renderer/gl/RenderbufferGL.h
+++ b/src/libANGLE/renderer/gl/RenderbufferGL.h
@@ -32,17 +32,16 @@
const gl::TextureCapsMap &textureCaps);
~RenderbufferGL() override;
- virtual gl::Error setStorage(const gl::Context *context,
- GLenum internalformat,
- size_t width,
- size_t height) override;
- virtual gl::Error setStorageMultisample(const gl::Context *context,
- size_t samples,
- GLenum internalformat,
- size_t width,
- size_t height) override;
- virtual gl::Error setStorageEGLImageTarget(const gl::Context *context,
- egl::Image *image) override;
+ gl::Error setStorage(const gl::Context *context,
+ GLenum internalformat,
+ size_t width,
+ size_t height) override;
+ gl::Error setStorageMultisample(const gl::Context *context,
+ size_t samples,
+ GLenum internalformat,
+ size_t width,
+ size_t height) override;
+ gl::Error setStorageEGLImageTarget(const gl::Context *context, egl::Image *image) override;
gl::Error initializeContents(const gl::Context *context,
const gl::ImageIndex &imageIndex) override;
diff --git a/src/libANGLE/renderer/gl/StateManagerGL.cpp b/src/libANGLE/renderer/gl/StateManagerGL.cpp
index 98bf942..f35ef05 100644
--- a/src/libANGLE/renderer/gl/StateManagerGL.cpp
+++ b/src/libANGLE/renderer/gl/StateManagerGL.cpp
@@ -210,6 +210,10 @@
angle::Matrix<GLfloat>::setToIdentity(mPathMatrixMV);
}
+StateManagerGL::~StateManagerGL()
+{
+}
+
void StateManagerGL::deleteProgram(GLuint program)
{
if (program != 0)
diff --git a/src/libANGLE/renderer/gl/StateManagerGL.h b/src/libANGLE/renderer/gl/StateManagerGL.h
index c3a3a5e..9153067 100644
--- a/src/libANGLE/renderer/gl/StateManagerGL.h
+++ b/src/libANGLE/renderer/gl/StateManagerGL.h
@@ -40,6 +40,7 @@
StateManagerGL(const FunctionsGL *functions,
const gl::Caps &rendererCaps,
const gl::Extensions &extensions);
+ ~StateManagerGL();
void deleteProgram(GLuint program);
void deleteVertexArray(GLuint vao);
diff --git a/src/libANGLE/renderer/gl/VertexArrayGL.cpp b/src/libANGLE/renderer/gl/VertexArrayGL.cpp
index 6dc1fe1..512baa5 100644
--- a/src/libANGLE/renderer/gl/VertexArrayGL.cpp
+++ b/src/libANGLE/renderer/gl/VertexArrayGL.cpp
@@ -83,6 +83,10 @@
}
}
+VertexArrayGL::~VertexArrayGL()
+{
+}
+
void VertexArrayGL::destroy(const gl::Context *context)
{
mStateManager->deleteVertexArray(mVertexArrayID);
diff --git a/src/libANGLE/renderer/gl/VertexArrayGL.h b/src/libANGLE/renderer/gl/VertexArrayGL.h
index 6158099..7010d69 100644
--- a/src/libANGLE/renderer/gl/VertexArrayGL.h
+++ b/src/libANGLE/renderer/gl/VertexArrayGL.h
@@ -23,6 +23,8 @@
VertexArrayGL(const gl::VertexArrayState &data,
const FunctionsGL *functions,
StateManagerGL *stateManager);
+ ~VertexArrayGL() override;
+
void destroy(const gl::Context *context) override;
gl::Error syncDrawArraysState(const gl::Context *context,
diff --git a/src/libANGLE/renderer/gl/WorkaroundsGL.h b/src/libANGLE/renderer/gl/WorkaroundsGL.h
index b6cc626..ab50022 100644
--- a/src/libANGLE/renderer/gl/WorkaroundsGL.h
+++ b/src/libANGLE/renderer/gl/WorkaroundsGL.h
@@ -14,6 +14,8 @@
struct WorkaroundsGL
{
+ WorkaroundsGL();
+
// When writing a float to a normalized integer framebuffer, desktop OpenGL is allowed to write
// one of the two closest normalized integer representations (although round to nearest is
// preferred) (see section 2.3.5.2 of the GL 4.5 core specification). OpenGL ES requires that
@@ -142,6 +144,9 @@
// On some Android devices for loops used to initialize variables hit native GLSL compiler bugs.
bool dontUseLoopsToInitializeVariables = false;
};
+
+inline WorkaroundsGL::WorkaroundsGL() = default;
+
} // namespace rx
#endif // LIBANGLE_RENDERER_GL_WORKAROUNDSGL_H_
diff --git a/src/libANGLE/renderer/gl/formatutilsgl.cpp b/src/libANGLE/renderer/gl/formatutilsgl.cpp
index 180e0a7..1829d46 100644
--- a/src/libANGLE/renderer/gl/formatutilsgl.cpp
+++ b/src/libANGLE/renderer/gl/formatutilsgl.cpp
@@ -27,6 +27,12 @@
{
}
+SupportRequirement::SupportRequirement(const SupportRequirement &other) = default;
+
+SupportRequirement::~SupportRequirement()
+{
+}
+
InternalFormat::InternalFormat()
: texture(),
filter(),
@@ -35,6 +41,12 @@
{
}
+InternalFormat::InternalFormat(const InternalFormat &other) = default;
+
+InternalFormat::~InternalFormat()
+{
+}
+
// supported = version || vertexExt
static inline SupportRequirement VersionOrExts(GLuint major, GLuint minor, const std::string &versionExt)
{
diff --git a/src/libANGLE/renderer/gl/formatutilsgl.h b/src/libANGLE/renderer/gl/formatutilsgl.h
index 616f37a..b83e9bb 100644
--- a/src/libANGLE/renderer/gl/formatutilsgl.h
+++ b/src/libANGLE/renderer/gl/formatutilsgl.h
@@ -28,6 +28,8 @@
struct SupportRequirement
{
SupportRequirement();
+ SupportRequirement(const SupportRequirement &other);
+ ~SupportRequirement();
// Version that this format became supported without extensions
gl::Version version;
@@ -42,6 +44,8 @@
struct InternalFormat
{
InternalFormat();
+ InternalFormat(const InternalFormat &other);
+ ~InternalFormat();
SupportRequirement texture;
SupportRequirement filter;
diff --git a/src/libANGLE/renderer/gl/wgl/FunctionsWGL.cpp b/src/libANGLE/renderer/gl/wgl/FunctionsWGL.cpp
index 2cfe6e9..b3a9473 100644
--- a/src/libANGLE/renderer/gl/wgl/FunctionsWGL.cpp
+++ b/src/libANGLE/renderer/gl/wgl/FunctionsWGL.cpp
@@ -97,6 +97,10 @@
{
}
+FunctionsWGL::~FunctionsWGL()
+{
+}
+
void FunctionsWGL::initialize(HMODULE glModule, HDC context)
{
// First grab the wglGetProcAddress function from the gl module
diff --git a/src/libANGLE/renderer/gl/wgl/FunctionsWGL.h b/src/libANGLE/renderer/gl/wgl/FunctionsWGL.h
index 30cf9eb..9f09f62 100644
--- a/src/libANGLE/renderer/gl/wgl/FunctionsWGL.h
+++ b/src/libANGLE/renderer/gl/wgl/FunctionsWGL.h
@@ -19,6 +19,7 @@
{
public:
FunctionsWGL();
+ ~FunctionsWGL();
// Loads all available wgl functions, may be called multiple times
void initialize(HMODULE glModule, HDC context);