aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'include/gpu')
-rw-r--r--include/gpu/GrRenderTarget.h22
-rw-r--r--include/gpu/GrTypesPriv.h34
2 files changed, 45 insertions, 11 deletions
diff --git a/include/gpu/GrRenderTarget.h b/include/gpu/GrRenderTarget.h
index 05d1239f84..fdf6f9cddc 100644
--- a/include/gpu/GrRenderTarget.h
+++ b/include/gpu/GrRenderTarget.h
@@ -32,16 +32,14 @@ public:
// GrRenderTarget
bool isStencilBufferMultisampled() const { return fDesc.fSampleCnt > 0; }
- /**
- * For our purposes, "Mixed Sampled" means the stencil buffer is multisampled but the color
- * buffer is not.
- */
- bool isMixedSampled() const { return fFlags & Flags::kMixedSampled; }
-
- /**
- * "Unified Sampled" means the stencil and color buffers are both multisampled.
- */
- bool isUnifiedMultisampled() const { return fDesc.fSampleCnt > 0 && !this->isMixedSampled(); }
+ GrFSAAType fsaaType() const {
+ if (!fDesc.fSampleCnt) {
+ SkASSERT(!(fFlags & Flags::kMixedSampled));
+ return GrFSAAType::kNone;
+ }
+ return (fFlags & Flags::kMixedSampled) ? GrFSAAType::kMixedSamples
+ : GrFSAAType::kUnifiedMSAA;
+ }
/**
* Returns the number of samples/pixel in the stencil buffer (Zero if non-MSAA).
@@ -51,7 +49,9 @@ public:
/**
* Returns the number of samples/pixel in the color buffer (Zero if non-MSAA or mixed sampled).
*/
- int numColorSamples() const { return this->isMixedSampled() ? 0 : fDesc.fSampleCnt; }
+ int numColorSamples() const {
+ return GrFSAAType::kMixedSamples == this->fsaaType() ? 0 : fDesc.fSampleCnt;
+ }
/**
* Call to indicate the multisample contents were modified such that the
diff --git a/include/gpu/GrTypesPriv.h b/include/gpu/GrTypesPriv.h
index 8f828e67d6..42da3d4481 100644
--- a/include/gpu/GrTypesPriv.h
+++ b/include/gpu/GrTypesPriv.h
@@ -51,6 +51,40 @@ static inline bool GrAATypeIsHW(GrAAType type) {
return false;
}
+/** The type of full scene antialiasing supported by a render target. */
+enum class GrFSAAType {
+ /** No FSAA */
+ kNone,
+ /** Regular MSAA where each attachment has the same sample count. */
+ kUnifiedMSAA,
+ /** One color sample, N stencil samples. */
+ kMixedSamples,
+};
+
+/**
+ * Not all drawing code paths support using mixed samples when available and instead use
+ * coverage-based aa.
+ */
+enum class GrAllowMixedSamples { kNo, kYes };
+
+static inline GrAAType GrChooseAAType(GrAA aa, GrFSAAType fsaaType,
+ GrAllowMixedSamples allowMixedSamples) {
+ if (GrAA::kNo == aa) {
+ return GrAAType::kNone;
+ }
+ switch (fsaaType) {
+ case GrFSAAType::kNone:
+ return GrAAType::kCoverage;
+ case GrFSAAType::kUnifiedMSAA:
+ return GrAAType::kMSAA;
+ case GrFSAAType::kMixedSamples:
+ return GrAllowMixedSamples::kYes == allowMixedSamples ? GrAAType::kMixedSamples
+ : GrAAType::kCoverage;
+ }
+ SkFAIL("Unexpected fsaa type");
+ return GrAAType::kNone;
+}
+
/**
* Types of shader-language-specific boxed variables we can create. (Currently only GrGLShaderVars,
* but should be applicable to other shader languages.)