Fix compiler warning using mixed enum types

Started getting:

   error: bitwise operation between different enumeration types ('GrStencilSettings::(anonymous enum at ../../src/gpu/GrStencilSettings.h:134:5)' and 'GrStencilFlags') [-Werror,-Wanon-enum-enum-conversion]
       if ((kInvalid_PrivateFlag | kDisabled_StencilFlag) & (fFlags | that.fFlags)) {

after updating clang, which this CL fixes.

Change-Id: Ib2668e98298248ce5712d4ee9f125c78bf3445b2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269140
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
Michael Ludwig 2020-02-06 12:19:57 -05:00 committed by Skia Commit-Bot
parent aba642c6ac
commit 6c48aad1a3
2 changed files with 6 additions and 2 deletions

View File

@ -131,7 +131,11 @@ public:
private:
// Internal flag for backends to optionally mark their tracked stencil state as invalid.
enum { kInvalid_PrivateFlag = (kLast_StencilFlag << 1) };
// NOTE: This value is outside the declared range of GrStencilFlags, but since that type is
// explicitly backed by 'int', it can still represent this constant. clang 11 complains about
// mixing enum types in bit operations, so this works around that.
static constexpr GrStencilFlags kInvalid_PrivateFlag =
static_cast<GrStencilFlags>(kLast_StencilFlag << 1);
uint32_t fFlags;
Face fCWFace;

View File

@ -32,7 +32,7 @@
* clip).
*/
enum GrStencilFlags {
enum GrStencilFlags : int {
kDisabled_StencilFlag = (1 << 0),
kTestAlwaysPasses_StencilFlag = (1 << 1),
kNoModifyStencil_StencilFlag = (1 << 2),