From 7db0b8d74fbcf6bb21518698d21d617445b3436b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 20 Apr 2018 19:50:02 -0400 Subject: gl_rasterizer_cache: Make MatchFlags an enum class Prevents implicit conversions and scope pollution. --- src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/video_core/renderer_opengl/gl_rasterizer_cache.cpp') diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 6c1c6775a..fff1e1a5a 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -672,7 +672,8 @@ void CachedSurface::DownloadGLTexture(const MathUtil::Rectangle& rect, GLui glPixelStorei(GL_PACK_ROW_LENGTH, 0); } -enum MatchFlags { +enum class MatchFlags { + None = 0, Invalid = 1, // Flag that can be applied to other match types, invalid matches require // validation before they can be used Exact = 1 << 1, // Surfaces perfectly match @@ -686,6 +687,10 @@ constexpr MatchFlags operator|(MatchFlags lhs, MatchFlags rhs) { return static_cast(static_cast(lhs) | static_cast(rhs)); } +constexpr MatchFlags operator&(MatchFlags lhs, MatchFlags rhs) { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} + /// Get the best surface match (and its match type) for the given flags template Surface FindMatch(const SurfaceCache& surface_cache, const SurfaceParams& params, @@ -703,15 +708,15 @@ Surface FindMatch(const SurfaceCache& surface_cache, const SurfaceParams& params : (params.res_scale <= surface->res_scale); // validity will be checked in GetCopyableInterval bool is_valid = - find_flags & MatchFlags::Copy + (find_flags & MatchFlags::Copy) != MatchFlags::None ? true : surface->IsRegionValid(validate_interval.value_or(params.GetInterval())); - if (!(find_flags & MatchFlags::Invalid) && !is_valid) + if ((find_flags & MatchFlags::Invalid) == MatchFlags::None && !is_valid) continue; auto IsMatch_Helper = [&](auto check_type, auto match_fn) { - if (!(find_flags & check_type)) + if ((find_flags & check_type) == MatchFlags::None) return; bool matched; -- cgit v1.2.3