Add helper for idenitfying hw GrAATypes.
authorBrian Salomon <bsalomon@google.com>
Tue, 13 Dec 2016 15:22:54 +0000 (10:22 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Tue, 13 Dec 2016 18:10:31 +0000 (18:10 +0000)
Change-Id: I7f4e5d87706df24ffb94e41902e0746bd149d733
Reviewed-on: https://skia-review.googlesource.com/5922
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>

include/gpu/GrTypesPriv.h
src/gpu/GrPipelineBuilder.cpp
src/gpu/GrRenderTargetContext.cpp
src/gpu/GrRenderTargetOpList.cpp

index 53e71e7..a0e96a2 100644 (file)
@@ -26,10 +26,25 @@ enum class GrAAType {
     kMixedSamples
 };
 
- /**
-  * Types of shader-language-specific boxed variables we can create. (Currently only GrGLShaderVars,
-  * but should be applicable to other shader languages.)
-  */
+static inline bool GrAATypeIsHW(GrAAType type) {
+    switch (type) {
+        case GrAAType::kNone:
+            return false;
+        case GrAAType::kCoverage:
+            return false;
+        case GrAAType::kMSAA:
+            return true;
+        case GrAAType::kMixedSamples:
+            return true;
+    }
+    SkFAIL("Unknown AA Type");
+    return false;
+}
+
+/**
+ * Types of shader-language-specific boxed variables we can create. (Currently only GrGLShaderVars,
+ * but should be applicable to other shader languages.)
+ */
 enum GrSLType {
     kVoid_GrSLType,
     kBool_GrSLType,
index f2dd1ac..6a0dd19 100644 (file)
@@ -31,8 +31,7 @@ GrPipelineBuilder::GrPipelineBuilder(const GrPaint& paint, GrAAType aaType)
 
     fXPFactory.reset(SkSafeRef(paint.getXPFactory()));
 
-    this->setState(GrPipelineBuilder::kHWAntialias_Flag, GrAAType::kMSAA == aaType ||
-                                                         GrAAType::kMixedSamples == aaType);
+    this->setState(GrPipelineBuilder::kHWAntialias_Flag, GrAATypeIsHW(aaType));
     this->setState(GrPipelineBuilder::kDisableOutputConversionToSRGB_Flag,
                    paint.getDisableOutputConversionToSRGB());
     this->setState(GrPipelineBuilder::kAllowSRGBInputs_Flag,
index 0fcd4ca..af50d87 100644 (file)
@@ -1562,7 +1562,7 @@ void GrRenderTargetContext::internalDrawPath(const GrClip& clip,
             // This time, allow SW renderer
             pr = fDrawingManager->getPathRenderer(canDrawArgs, true, kType);
         }
-        if (!pr && (aaType == GrAAType::kMixedSamples || aaType == GrAAType::kMSAA)) {
+        if (!pr && GrAATypeIsHW(aaType)) {
             // There are exceptional cases where we may wind up falling back to coverage based AA
             // when the target is MSAA (e.g. through disabling path renderers via GrContextOptions).
             aaType = GrAAType::kCoverage;
index 460f484..15d7b75 100644 (file)
@@ -354,7 +354,7 @@ void GrRenderTargetOpList::stencilPath(GrRenderTargetContext* renderTargetContex
                                        GrAAType aaType,
                                        const SkMatrix& viewMatrix,
                                        const GrPath* path) {
-    bool useHWAA = (aaType == GrAAType::kMSAA || aaType == GrAAType::kMixedSamples);
+    bool useHWAA = GrAATypeIsHW(aaType);
     // TODO: extract portions of checkDraw that are relevant to path stenciling.
     SkASSERT(path);
     SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport());