Move skgpu::graphite::Mask to SkEnumBitMask

This will let us use this utility everywhere.

Bug: skia:12701
Change-Id: I9342d0b40a81789ed93e3ec4009e5602033d6691
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/534662
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2022-04-27 16:04:04 -04:00 committed by SkCQ
parent 4a62131537
commit 0326a9f27a
23 changed files with 158 additions and 160 deletions

View File

@ -207,6 +207,7 @@ skia_core_sources = [
"$_src/core/SkEdgeClipper.cpp",
"$_src/core/SkEdgeClipper.h",
"$_src/core/SkEndian.h",
"$_src/core/SkEnumBitMask.h",
"$_src/core/SkEnumerate.h",
"$_src/core/SkExecutor.cpp",
"$_src/core/SkFDot6.h",

View File

@ -50,7 +50,6 @@ skia_graphite_sources = [
"$_src/DrawTypes.h",
"$_src/DrawWriter.cpp",
"$_src/DrawWriter.h",
"$_src/EnumBitMask.h",
"$_src/GlobalCache.cpp",
"$_src/GlobalCache.h",
"$_src/Gpu.cpp",

View File

@ -234,6 +234,7 @@ tests_sources = [
"$_tests/SkColorSpaceXformStepsTest.cpp",
"$_tests/SkDOMTest.cpp",
"$_tests/SkDSLRuntimeEffectTest.cpp",
"$_tests/SkEnumBitMaskTest.cpp",
"$_tests/SkGaussFilterTest.cpp",
"$_tests/SkGlyphBufferTest.cpp",
"$_tests/SkGlyphTest.cpp",
@ -337,7 +338,6 @@ graphite_tests_sources = [
"$_tests/graphite/CommandBufferTest.cpp",
"$_tests/graphite/IntersectionTreeTest.cpp",
"$_tests/graphite/KeyTest.cpp",
"$_tests/graphite/MaskTest.cpp",
"$_tests/graphite/PipelineDataCacheTest.cpp",
"$_tests/graphite/RecorderTest.cpp",
"$_tests/graphite/RectTest.cpp",

View File

@ -5704,13 +5704,13 @@ generated_cc_atom(
visibility = ["//:__subpackages__"],
deps = [
":SkArenaAlloc_hdr",
":SkEnumBitMask_hdr",
":SkPaintParamsKey_hdr",
":SkPipelineData_hdr",
":SkUniform_hdr",
"//include/core:SkSpan_hdr",
"//include/private:SkSpinlock_hdr",
"//include/private:SkUniquePaintParamsID_hdr",
"//src/gpu/graphite:EnumBitMask_hdr",
],
)
@ -5719,6 +5719,7 @@ generated_cc_atom(
hdrs = ["SkPipelineData.h"],
visibility = ["//:__subpackages__"],
deps = [
":SkEnumBitMask_hdr",
"//include/core:SkPoint_hdr",
"//include/core:SkRefCnt_hdr",
"//include/core:SkSamplingOptions_hdr",
@ -5726,7 +5727,6 @@ generated_cc_atom(
"//include/core:SkTileMode_hdr",
"//include/private:SkColorData_hdr",
"//src/gpu:Blend_hdr",
"//src/gpu/graphite:EnumBitMask_hdr",
"//src/gpu/graphite:TextureProxy_hdr",
"//src/gpu/graphite:UniformManager_hdr",
"//src/gpu/graphite/geom:VectorTypes_hdr",
@ -5765,3 +5765,10 @@ generated_cc_atom(
"//src/gpu/graphite:ResourceProvider_hdr",
],
)
generated_cc_atom(
name = "SkEnumBitMask_hdr",
hdrs = ["SkEnumBitMask.h"],
visibility = ["//:__subpackages__"],
deps = ["//include/core:SkTypes_hdr"],
)

87
src/core/SkEnumBitMask.h Normal file
View File

@ -0,0 +1,87 @@
/*
* Copyright 2021 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkEnumBitMask_DEFINED
#define SkEnumBitMask_DEFINED
#include "include/core/SkTypes.h"
/**
* Wraps an enum that is used for flags, and enables masking with type safety. Example:
*
* enum class MyFlags {
* kNone = 0,
* kA = 1,
* kB = 2,
* kC = 4,
* };
*
* MAKE_MASK_OPS(MyFlags)
*
* ...
*
* Mask<MyFlags> flags = MyFlags::kA | MyFlags::kB;
*
* if (flags & MyFlags::kB) {}
*
* ...
*/
template<typename E>
class SkEnumBitMask {
public:
SK_ALWAYS_INLINE constexpr SkEnumBitMask(E e) : SkEnumBitMask((int)e) {}
SK_ALWAYS_INLINE constexpr operator bool() const { return fValue; }
SK_ALWAYS_INLINE bool operator==(SkEnumBitMask m) const { return fValue == m.fValue; }
SK_ALWAYS_INLINE bool operator!=(SkEnumBitMask m) const { return fValue != m.fValue; }
SK_ALWAYS_INLINE constexpr SkEnumBitMask operator|(SkEnumBitMask m) const {
return SkEnumBitMask(fValue | m.fValue);
}
SK_ALWAYS_INLINE constexpr SkEnumBitMask operator&(SkEnumBitMask m) const {
return SkEnumBitMask(fValue & m.fValue);
}
SK_ALWAYS_INLINE constexpr SkEnumBitMask operator^(SkEnumBitMask m) const {
return SkEnumBitMask(fValue ^ m.fValue);
}
SK_ALWAYS_INLINE constexpr SkEnumBitMask operator~() const { return SkEnumBitMask(~fValue); }
SK_ALWAYS_INLINE SkEnumBitMask& operator|=(SkEnumBitMask m) { return *this = *this | m; }
SK_ALWAYS_INLINE SkEnumBitMask& operator&=(SkEnumBitMask m) { return *this = *this & m; }
SK_ALWAYS_INLINE SkEnumBitMask& operator^=(SkEnumBitMask m) { return *this = *this ^ m; }
private:
SK_ALWAYS_INLINE constexpr explicit SkEnumBitMask(int value) : fValue(value) {}
int fValue;
};
/**
* Defines functions that make it possible to use bitwise operators on an enum.
*/
#define SK_MAKE_BITMASK_OPS(E) \
SK_MAYBE_UNUSED constexpr SkEnumBitMask<E> operator|(E a, E b) { \
return SkEnumBitMask<E>(a) | b; \
} \
SK_MAYBE_UNUSED constexpr SkEnumBitMask<E> operator&(E a, E b) { \
return SkEnumBitMask<E>(a) & b; \
} \
SK_MAYBE_UNUSED constexpr SkEnumBitMask<E> operator^(E a, E b) { \
return SkEnumBitMask<E>(a) ^ b; \
} \
SK_MAYBE_UNUSED constexpr SkEnumBitMask<E> operator~(E e) { \
return ~SkEnumBitMask<E>(e); \
} \
#define SK_DECL_BITMASK_OPS_FRIENDS(E) \
friend constexpr SkEnumBitMask<E> operator|(E, E); \
friend constexpr SkEnumBitMask<E> operator&(E, E); \
friend constexpr SkEnumBitMask<E> operator^(E, E); \
friend constexpr SkEnumBitMask<E> operator~(E); \
#endif // SkEnumBitMask_DEFINED

View File

@ -21,8 +21,8 @@ void SkPipelineDataGatherer::reset() {
fTextureDataBlock.reset();
fBlendInfo = BlendInfo();
fUniformManager.reset();
fSnippetRequirementFlags = SnippetRequirementFlags::kNone;
#endif
fSnippetRequirementFlags = SnippetRequirementFlags::kNone;
}
#ifdef SK_DEBUG
@ -31,12 +31,11 @@ void SkPipelineDataGatherer::checkReset() {
SkASSERT(fTextureDataBlock.empty());
SkASSERT(fBlendInfo == BlendInfo());
SkDEBUGCODE(fUniformManager.checkReset());
SkASSERT(fSnippetRequirementFlags == SnippetRequirementFlags::kNone);
#endif
SkASSERT(fSnippetRequirementFlags == SnippetRequirementFlags::kNone);
}
#endif // SK_DEBUG
#ifdef SK_GRAPHITE_ENABLED
void SkPipelineDataGatherer::addFlags(SnippetRequirementFlags flags) {
fSnippetRequirementFlags |= flags;
}
@ -44,7 +43,6 @@ void SkPipelineDataGatherer::addFlags(SnippetRequirementFlags flags) {
bool SkPipelineDataGatherer::needsDev2Local() const {
return fSnippetRequirementFlags & SnippetRequirementFlags::kDev2LocalMat;
}
#endif // SK_GRAPHITE_ENABLED
////////////////////////////////////////////////////////////////////////////////////////////////////
SkUniformDataBlock* SkUniformDataBlock::Make(const SkUniformDataBlock& other,

View File

@ -15,10 +15,10 @@
#include "include/core/SkSpan.h"
#include "include/core/SkTileMode.h"
#include "include/private/SkColorData.h"
#include "src/core/SkEnumBitMask.h"
#ifdef SK_GRAPHITE_ENABLED
#include "src/gpu/Blend.h"
#include "src/gpu/graphite/EnumBitMask.h"
#include "src/gpu/graphite/TextureProxy.h"
#include "src/gpu/graphite/UniformManager.h"
#include "src/gpu/graphite/geom/VectorTypes.h"
@ -156,10 +156,12 @@ public:
fTextureDataBlock.add(sampling, tileModes, std::move(proxy));
}
bool hasTextures() const { return !fTextureDataBlock.empty(); }
#endif // SK_GRAPHITE_ENABLED
void addFlags(SnippetRequirementFlags flags);
bool needsDev2Local() const;
#ifdef SK_GRAPHITE_ENABLED
const SkTextureDataBlock& textureDataBlock() { return fTextureDataBlock; }
void write(const SkM44& mat) { fUniformManager.write(mat); }
@ -186,11 +188,11 @@ private:
void doneWithExpectedUniforms() { fUniformManager.doneWithExpectedUniforms(); }
#endif // SK_DEBUG
SkTextureDataBlock fTextureDataBlock;
BlendInfo fBlendInfo;
skgpu::graphite::UniformManager fUniformManager;
skgpu::graphite::Mask<SnippetRequirementFlags> fSnippetRequirementFlags;
SkTextureDataBlock fTextureDataBlock;
BlendInfo fBlendInfo;
skgpu::graphite::UniformManager fUniformManager;
#endif // SK_GRAPHITE_ENABLED
SkEnumBitMask<SnippetRequirementFlags> fSnippetRequirementFlags;
};
#if defined(SK_DEBUG) && defined(SK_GRAPHITE_ENABLED)

View File

@ -15,14 +15,11 @@
#include "include/private/SkSpinlock.h"
#include "include/private/SkUniquePaintParamsID.h"
#include "src/core/SkArenaAlloc.h"
#include "src/core/SkEnumBitMask.h"
#include "src/core/SkPaintParamsKey.h"
#include "src/core/SkPipelineData.h"
#include "src/core/SkUniform.h"
#ifdef SK_GRAPHITE_ENABLED
#include "src/gpu/graphite/EnumBitMask.h"
#endif
// TODO: How to represent the type (e.g., 2D) of texture being sampled?
class SkTextureAndSampler {
public:
@ -38,9 +35,7 @@ enum class SnippetRequirementFlags : uint32_t {
kNone = 0x0,
kDev2LocalMat = 0x1,
};
#ifdef SK_GRAPHITE_ENABLED
SKGPU_MAKE_MASK_OPS(SnippetRequirementFlags);
#endif
SK_MAKE_BITMASK_OPS(SnippetRequirementFlags);
struct SkShaderSnippet {
using GenerateGlueCodeForEntry = std::string (*)(const std::string& resultName,
@ -86,7 +81,6 @@ public:
void add(const SkPaintParamsKey::BlockReader& reader) {
fBlockReaders.push_back(reader);
}
#ifdef SK_GRAPHITE_ENABLED
void addFlags(SnippetRequirementFlags flags) {
fSnippetRequirementFlags |= flags;
}
@ -94,6 +88,7 @@ public:
return fSnippetRequirementFlags & SnippetRequirementFlags::kDev2LocalMat;
}
#ifdef SK_GRAPHITE_ENABLED
void setBlendInfo(const SkPipelineDataGatherer::BlendInfo& blendInfo) {
fBlendInfo = blendInfo;
}
@ -112,9 +107,9 @@ private:
std::vector<SkPaintParamsKey::BlockReader> fBlockReaders;
SkEnumBitMask<SnippetRequirementFlags> fSnippetRequirementFlags =SnippetRequirementFlags::kNone;
#ifdef SK_GRAPHITE_ENABLED
skgpu::graphite::Mask<SnippetRequirementFlags> fSnippetRequirementFlags =
SnippetRequirementFlags::kNone;
// The blendInfo doesn't actually contribute to the program's creation but, it contains the
// matching fixed-function settings that the program's caller needs to set up.
SkPipelineDataGatherer::BlendInfo fBlendInfo;

View File

@ -44,6 +44,7 @@ generated_cc_atom(
":ResourceTypes_hdr",
"//include/core:SkImageInfo_hdr",
"//include/core:SkRefCnt_hdr",
"//src/core:SkEnumBitMask_hdr",
"//src/gpu:ResourceKey_hdr",
"//src/gpu:Swizzle_hdr",
],
@ -190,8 +191,8 @@ generated_cc_atom(
deps = [
":ClipStack_graphite_hdr",
":DrawOrder_hdr",
":EnumBitMask_hdr",
"//src/core:SkDevice_hdr",
"//src/core:SkEnumBitMask_hdr",
"//src/gpu/graphite/geom:Rect_hdr",
"//src/gpu/graphite/geom:Transform_graphite_hdr",
],
@ -344,6 +345,7 @@ generated_cc_atom(
"//include/core:SkColor_hdr",
"//include/core:SkRect_hdr",
"//include/core:SkRefCnt_hdr",
"//src/core:SkEnumBitMask_hdr",
"//src/core:SkTBlockList_hdr",
],
)
@ -411,13 +413,6 @@ generated_cc_atom(
],
)
generated_cc_atom(
name = "EnumBitMask_hdr",
hdrs = ["EnumBitMask.h"],
visibility = ["//:__subpackages__"],
deps = ["//include/gpu/graphite:GraphiteTypes_hdr"],
)
generated_cc_atom(
name = "GpuWorkSubmission_hdr",
hdrs = ["GpuWorkSubmission.h"],
@ -587,11 +582,11 @@ generated_cc_atom(
deps = [
":Attribute_hdr",
":DrawTypes_hdr",
":EnumBitMask_hdr",
":ResourceTypes_hdr",
"//include/core:SkSpan_hdr",
"//include/core:SkString_hdr",
"//include/core:SkTypes_hdr",
"//src/core:SkEnumBitMask_hdr",
"//src/core:SkUniform_hdr",
],
)
@ -635,8 +630,8 @@ generated_cc_atom(
hdrs = ["ResourceTypes.h"],
visibility = ["//:__subpackages__"],
deps = [
":EnumBitMask_hdr",
"//include/gpu/graphite:GraphiteTypes_hdr",
"//src/core:SkEnumBitMask_hdr",
],
)

View File

@ -10,6 +10,7 @@
#include "include/core/SkImageInfo.h"
#include "include/core/SkRefCnt.h"
#include "src/core/SkEnumBitMask.h"
#include "src/gpu/ResourceKey.h"
#include "src/gpu/Swizzle.h"
#include "src/gpu/graphite/ResourceTypes.h"
@ -38,7 +39,7 @@ public:
virtual TextureInfo getDefaultMSAATextureInfo(const TextureInfo& singleSampledInfo) const = 0;
virtual TextureInfo getDefaultDepthStencilTextureInfo(Mask<DepthStencilFlags>,
virtual TextureInfo getDefaultDepthStencilTextureInfo(SkEnumBitMask<DepthStencilFlags>,
uint32_t sampleCount,
Protected) const = 0;

View File

@ -518,7 +518,7 @@ void Device::drawImageRect(const SkImage* image, const SkRect* src, const SkRect
void Device::drawShape(const Shape& shape,
const SkPaint& paint,
const SkStrokeRec& style,
Mask<DrawFlags> flags) {
SkEnumBitMask<DrawFlags> flags) {
const Transform& localToDevice = this->localToDeviceTransform();
if (!localToDevice.valid()) {
// If the transform is not invertible or not finite then drawing isn't well defined.

View File

@ -9,10 +9,10 @@
#define skgpu_Device_DEFINED
#include "src/core/SkDevice.h"
#include "src/core/SkEnumBitMask.h"
#include "src/gpu/graphite/ClipStack_graphite.h"
#include "src/gpu/graphite/DrawOrder.h"
#include "src/gpu/graphite/EnumBitMask.h"
#include "src/gpu/graphite/geom/Rect.h"
#include "src/gpu/graphite/geom/Transform_graphite.h"
@ -154,7 +154,7 @@ private:
// - drawShape after it's applied the path effect.
kIgnorePathEffect = 0b10,
};
SKGPU_DECL_MASK_OPS_FRIENDS(DrawFlags);
SK_DECL_BITMASK_OPS_FRIENDS(DrawFlags);
Device(Recorder*, sk_sp<DrawContext>);
@ -163,7 +163,7 @@ private:
void drawShape(const Shape&,
const SkPaint&,
const SkStrokeRec&,
Mask<DrawFlags> = DrawFlags::kNone);
SkEnumBitMask<DrawFlags> = DrawFlags::kNone);
// Lowest level draw recording where everything but Renderer has been decided.
void recordDraw(const Transform& localToDevice,
const Shape& shape,
@ -196,7 +196,7 @@ private:
friend class ClipStack; // for recordDraw
};
SKGPU_MAKE_MASK_OPS(Device::DrawFlags)
SK_MAKE_BITMASK_OPS(Device::DrawFlags)
} // namespace skgpu

View File

@ -11,6 +11,7 @@
#include "include/core/SkColor.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "src/core/SkEnumBitMask.h"
#include "src/core/SkTBlockList.h"
#include "src/gpu/graphite/DrawTypes.h"
#include "src/gpu/graphite/GraphicsPipelineDesc.h"
@ -65,7 +66,7 @@ public:
bool requiresDstTexture() const { return false; }
bool requiresMSAA() const { return fRequiresMSAA; }
Mask<DepthStencilFlags> depthStencilFlags() const { return fDepthStencilFlags; }
SkEnumBitMask<DepthStencilFlags> depthStencilFlags() const { return fDepthStencilFlags; }
size_t vertexBufferSize() const { return 0; }
size_t uniformBufferSize() const { return 0; }
@ -207,7 +208,7 @@ private:
std::pair<LoadOp, StoreOp> fOps;
std::array<float, 4> fClearColor;
Mask<DepthStencilFlags> fDepthStencilFlags = DepthStencilFlags::kNone;
SkEnumBitMask<DepthStencilFlags> fDepthStencilFlags = DepthStencilFlags::kNone;
bool fRequiresMSAA = false;
};

View File

@ -1,87 +0,0 @@
/*
* Copyright 2021 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef skgpu_graphite_EnumBitMask_DEFINED
#define skgpu_graphite_EnumBitMask_DEFINED
#include "include/gpu/graphite/GraphiteTypes.h"
namespace skgpu::graphite {
/**
* Wraps an enum that is used for flags, and enables masking with type safety. Example:
*
* enum class MyFlags {
* kNone = 0,
* kA = 1,
* kB = 2,
* kC = 4,
* };
*
* SKGPU_MAKE_MASK_OPS(MyFlags)
*
* ...
*
* Mask<MyFlags> flags = MyFlags::kA | MyFlags::kB;
*
* if (flags & MyFlags::kB) {}
*
* ...
*/
template<typename E>
class Mask {
public:
SK_ALWAYS_INLINE constexpr Mask(E e) : Mask((int)e) {}
SK_ALWAYS_INLINE constexpr operator bool() const { return fValue; }
SK_ALWAYS_INLINE bool operator==(Mask m) const { return fValue == m.fValue; }
SK_ALWAYS_INLINE bool operator!=(Mask m) const { return fValue != m.fValue; }
SK_ALWAYS_INLINE constexpr Mask operator|(Mask m) const { return Mask(fValue | m.fValue); }
SK_ALWAYS_INLINE constexpr Mask operator&(Mask m) const { return Mask(fValue & m.fValue); }
SK_ALWAYS_INLINE constexpr Mask operator^(Mask m) const { return Mask(fValue ^ m.fValue); }
SK_ALWAYS_INLINE constexpr Mask operator~() const { return Mask(~fValue); }
SK_ALWAYS_INLINE Mask& operator|=(Mask m) { return *this = *this | m; }
SK_ALWAYS_INLINE Mask& operator&=(Mask m) { return *this = *this & m; }
SK_ALWAYS_INLINE Mask& operator^=(Mask m) { return *this = *this ^ m; }
private:
SK_ALWAYS_INLINE constexpr explicit Mask(int value) : fValue(value) {}
int fValue;
};
/**
* Defines functions that make it possible to use bitwise operators on an enum.
*/
#define SKGPU_MAKE_MASK_OPS(E) \
SK_MAYBE_UNUSED constexpr skgpu::graphite::Mask<E> operator|(E a, E b) { \
return skgpu::graphite::Mask<E>(a) | b; \
} \
SK_MAYBE_UNUSED constexpr skgpu::graphite::Mask<E> operator&(E a, E b) { \
return skgpu::graphite::Mask<E>(a) & b; \
} \
SK_MAYBE_UNUSED constexpr skgpu::graphite::Mask<E> operator^(E a, E b) { \
return skgpu::graphite::Mask<E>(a) ^ b; \
} \
SK_MAYBE_UNUSED constexpr skgpu::graphite::Mask<E> operator~(E e) { \
return ~skgpu::graphite::Mask<E>(e); \
} \
#define SKGPU_DECL_MASK_OPS_FRIENDS(E) \
friend constexpr skgpu::graphite::Mask<E> operator|(E, E); \
friend constexpr skgpu::graphite::Mask<E> operator&(E, E); \
friend constexpr skgpu::graphite::Mask<E> operator^(E, E); \
friend constexpr skgpu::graphite::Mask<E> operator~(E); \
}; // namespace skgpu::graphite
#endif // skgpu_graphite_EnumBitMask_DEFINED

View File

@ -8,9 +8,9 @@
#ifndef skgpu_graphite_Renderer_DEFINED
#define skgpu_graphite_Renderer_DEFINED
#include "src/core/SkEnumBitMask.h"
#include "src/gpu/graphite/Attribute.h"
#include "src/gpu/graphite/DrawTypes.h"
#include "src/gpu/graphite/EnumBitMask.h"
#include "src/gpu/graphite/ResourceTypes.h"
#include "include/core/SkSpan.h"
@ -82,7 +82,7 @@ public:
const DepthStencilSettings& depthStencilSettings() const { return fDepthStencilSettings; }
Mask<DepthStencilFlags> depthStencilFlags() const {
SkEnumBitMask<DepthStencilFlags> depthStencilFlags() const {
return (fDepthStencilSettings.fStencilTestEnabled
? DepthStencilFlags::kStencil : DepthStencilFlags::kNone) |
(fDepthStencilSettings.fDepthTestEnabled || fDepthStencilSettings.fDepthWriteEnabled
@ -114,14 +114,14 @@ protected:
kRequiresMSAA = 0b001,
kPerformsShading = 0b010,
};
SKGPU_DECL_MASK_OPS_FRIENDS(Flags);
SK_DECL_BITMASK_OPS_FRIENDS(Flags);
// While RenderStep does not define the full program that's run for a draw, it defines the
// entire vertex layout of the pipeline. This is not allowed to change, so can be provided to
// the RenderStep constructor by subclasses.
RenderStep(std::string_view className,
std::string_view variantName,
Mask<Flags> flags,
SkEnumBitMask<Flags> flags,
std::initializer_list<SkUniform> uniforms,
PrimitiveType primitiveType,
DepthStencilSettings depthStencilSettings,
@ -154,8 +154,8 @@ private:
RenderStep(const RenderStep&) = delete;
RenderStep(RenderStep&&) = delete;
Mask<Flags> fFlags;
PrimitiveType fPrimitiveType;
SkEnumBitMask<Flags> fFlags;
PrimitiveType fPrimitiveType;
DepthStencilSettings fDepthStencilSettings;
@ -174,7 +174,7 @@ private:
std::string fName;
};
SKGPU_MAKE_MASK_OPS(RenderStep::Flags);
SK_MAKE_BITMASK_OPS(RenderStep::Flags);
/**
* The actual technique for rasterizing a high-level draw recorded in a DrawList is handled by a
@ -218,7 +218,7 @@ public:
int numRenderSteps() const { return fStepCount; }
bool requiresMSAA() const { return fRequiresMSAA; }
Mask<DepthStencilFlags> depthStencilFlags() const { return fDepthStencilFlags; }
SkEnumBitMask<DepthStencilFlags> depthStencilFlags() const { return fDepthStencilFlags; }
private:
// max render steps is 4, so just spell the options out for now...
@ -260,7 +260,7 @@ private:
int fStepCount;
bool fRequiresMSAA = false;
Mask<DepthStencilFlags> fDepthStencilFlags = DepthStencilFlags::kNone;
SkEnumBitMask<DepthStencilFlags> fDepthStencilFlags = DepthStencilFlags::kNone;
};
} // skgpu namespace::graphite

View File

@ -9,7 +9,7 @@
#define skgpu_graphite_ResourceTypes_DEFINED
#include "include/gpu/graphite/GraphiteTypes.h"
#include "src/gpu/graphite/EnumBitMask.h"
#include "src/core/SkEnumBitMask.h"
namespace skgpu::graphite {
@ -27,7 +27,7 @@ enum class DepthStencilFlags : int {
kStencil = 0b010,
kDepthStencil = kDepth | kStencil,
};
SKGPU_MAKE_MASK_OPS(DepthStencilFlags);
SK_MAKE_BITMASK_OPS(DepthStencilFlags);
/**
* What a GPU buffer will be used for

View File

@ -28,7 +28,7 @@ public:
TextureInfo getDefaultMSAATextureInfo(const TextureInfo& singleSampledInfo) const override;
TextureInfo getDefaultDepthStencilTextureInfo(Mask<DepthStencilFlags>,
TextureInfo getDefaultDepthStencilTextureInfo(SkEnumBitMask<DepthStencilFlags>,
uint32_t sampleCount,
Protected) const override;

View File

@ -501,7 +501,9 @@ TextureInfo MtlCaps::getDefaultMSAATextureInfo(const TextureInfo& singleSampledI
}
TextureInfo MtlCaps::getDefaultDepthStencilTextureInfo(
Mask<DepthStencilFlags> depthStencilType, uint32_t sampleCount, Protected) const {
SkEnumBitMask<DepthStencilFlags> depthStencilType,
uint32_t sampleCount,
Protected) const {
MtlTextureInfo info;
info.fSampleCount = sampleCount;
info.fLevelCount = 1;

View File

@ -26,7 +26,7 @@ bool MtlFormatIsDepthOrStencil(MTLPixelFormat);
bool MtlFormatIsDepth(MTLPixelFormat);
bool MtlFormatIsStencil(MTLPixelFormat);
MTLPixelFormat MtlDepthStencilFlagsToFormat(Mask<DepthStencilFlags>);
MTLPixelFormat MtlDepthStencilFlagsToFormat(SkEnumBitMask<DepthStencilFlags>);
/**
* Produces MSL code generated by SkSLC

View File

@ -51,7 +51,7 @@ bool MtlFormatIsStencil(MTLPixelFormat format) {
}
}
MTLPixelFormat MtlDepthStencilFlagsToFormat(Mask<DepthStencilFlags> mask) {
MTLPixelFormat MtlDepthStencilFlagsToFormat(SkEnumBitMask<DepthStencilFlags> mask) {
// TODO: Decide if we want to change this to always return a combined depth and stencil format
// to allow more sharing of depth stencil allocations.
if (mask == DepthStencilFlags::kDepth) {

View File

@ -7220,3 +7220,13 @@ generated_cc_atom(
visibility = ["//:__subpackages__"],
deps = [":TestHarness_hdr"],
)
generated_cc_atom(
name = "SkEnumBitMaskTest_src",
srcs = ["SkEnumBitMaskTest.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":Test_hdr",
"//src/core:SkEnumBitMask_hdr",
],
)

View File

@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
#include "src/gpu/graphite/EnumBitMask.h"
#include "src/core/SkEnumBitMask.h"
#include "tests/Test.h"
enum class Flags {
@ -14,13 +14,10 @@ enum class Flags {
kB = 2,
kC = 4
};
SK_MAKE_BITMASK_OPS(Flags);
SKGPU_MAKE_MASK_OPS(Flags);
using namespace skgpu::graphite;
DEF_GRAPHITE_TEST(skgpu_Mask, r) {
Mask<Flags> flags = Flags::kNone;
DEF_TEST(skgpu_Mask, r) {
SkEnumBitMask<Flags> flags = Flags::kNone;
REPORTER_ASSERT(r, !flags);
flags |= Flags::kA;
REPORTER_ASSERT(r, flags);

View File

@ -66,16 +66,6 @@ generated_cc_atom(
],
)
generated_cc_atom(
name = "MaskTest_src",
srcs = ["MaskTest.cpp"],
visibility = ["//:__subpackages__"],
deps = [
"//src/gpu/graphite:EnumBitMask_hdr",
"//tests:Test_hdr",
],
)
generated_cc_atom(
name = "RecorderTest_src",
srcs = ["RecorderTest.cpp"],