aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gm/windowrectangles.cpp2
-rw-r--r--include/gpu/GrRenderTarget.h22
-rw-r--r--include/gpu/GrTypesPriv.h34
-rw-r--r--include/private/GrInstancedPipelineInfo.h6
-rw-r--r--include/private/GrRenderTargetProxy.h26
-rw-r--r--src/gpu/GrClipStackClip.cpp18
-rw-r--r--src/gpu/GrDrawingManager.cpp2
-rw-r--r--src/gpu/GrPathRenderer.h4
-rw-r--r--src/gpu/GrReducedClip.cpp2
-rw-r--r--src/gpu/GrRenderTargetContext.cpp40
-rw-r--r--src/gpu/GrRenderTargetContext.h25
-rw-r--r--src/gpu/SkGpuDevice.cpp20
-rw-r--r--src/gpu/SkGpuDevice_drawTexture.cpp10
-rw-r--r--src/gpu/effects/GrCoverageSetOpXP.cpp3
-rw-r--r--src/gpu/gl/GrGLGpu.cpp8
-rw-r--r--src/gpu/gl/GrGLRenderTarget.h5
-rw-r--r--src/gpu/ops/GrAAConvexPathRenderer.cpp2
-rw-r--r--src/gpu/ops/GrAAHairLinePathRenderer.cpp2
-rw-r--r--src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp2
-rw-r--r--src/gpu/text/GrStencilAndCoverTextContext.cpp10
-rw-r--r--tests/ProxyTest.cpp5
21 files changed, 124 insertions, 124 deletions
diff --git a/gm/windowrectangles.cpp b/gm/windowrectangles.cpp
index 7083487997..5f569ddfbc 100644
--- a/gm/windowrectangles.cpp
+++ b/gm/windowrectangles.cpp
@@ -188,7 +188,7 @@ void WindowRectanglesMaskGM::onCoverClipStack(const SkClipStack& stack, SkCanvas
const GrReducedClip reducedClip(stack, SkRect::Make(kCoverRect), kNumWindows);
GrPaint paint;
- if (!rtc->isStencilBufferMultisampled()) {
+ if (GrFSAAType::kNone == rtc->fsaaType()) {
paint.setColor4f(GrColor4f(0, 0.25f, 1, 1));
this->visualizeAlphaMask(ctx, rtc, reducedClip, std::move(paint));
} else {
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.)
diff --git a/include/private/GrInstancedPipelineInfo.h b/include/private/GrInstancedPipelineInfo.h
index 196c35b96f..c07425909a 100644
--- a/include/private/GrInstancedPipelineInfo.h
+++ b/include/private/GrInstancedPipelineInfo.h
@@ -16,9 +16,9 @@
*/
struct GrInstancedPipelineInfo {
GrInstancedPipelineInfo(const GrRenderTargetProxy* rtp)
- : fIsMultisampled(rtp->isStencilBufferMultisampled())
- , fIsMixedSampled(rtp->isMixedSampled())
- , fIsRenderingToFloat(GrPixelConfigIsFloatingPoint(rtp->desc().fConfig)) {}
+ : fIsMultisampled(GrFSAAType::kNone != rtp->fsaaType())
+ , fIsMixedSampled(GrFSAAType::kMixedSamples == rtp->fsaaType())
+ , fIsRenderingToFloat(GrPixelConfigIsFloatingPoint(rtp->desc().fConfig)) {}
bool canUseCoverageAA() const { return !fIsMultisampled || fIsMixedSampled; }
diff --git a/include/private/GrRenderTargetProxy.h b/include/private/GrRenderTargetProxy.h
index adc7553941..dd28b0f86d 100644
--- a/include/private/GrRenderTargetProxy.h
+++ b/include/private/GrRenderTargetProxy.h
@@ -26,28 +26,26 @@ public:
// Actually instantiate the backing rendertarget, if necessary.
GrRenderTarget* instantiate(GrResourceProvider* resourceProvider);
- 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 fRenderTargetFlags & GrRenderTarget::Flags::kMixedSampled; }
-
- /**
- * "Unified Sampled" means the stencil and color buffers are both multisampled.
- */
- bool isUnifiedMultisampled() const { return fDesc.fSampleCnt > 0 && !this->isMixedSampled(); }
-
/**
* Returns the number of samples/pixel in the stencil buffer (Zero if non-MSAA).
*/
int numStencilSamples() const { return fDesc.fSampleCnt; }
+ GrFSAAType fsaaType() const {
+ if (!fDesc.fSampleCnt) {
+ SkASSERT(!(fRenderTargetFlags & GrRenderTarget::Flags::kMixedSampled));
+ return GrFSAAType::kNone;
+ }
+ return (fRenderTargetFlags & GrRenderTarget::Flags::kMixedSampled)
+ ? GrFSAAType::kMixedSamples
+ : GrFSAAType::kUnifiedMSAA;
+ }
/**
* 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;
+ }
int maxWindowRectangles(const GrCaps& caps) const;
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index e24e63565b..15f976716b 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -118,15 +118,9 @@ bool GrClipStackClip::PathNeedsSWRenderer(GrContext* context,
canDrawArgs.fCaps = context->caps();
canDrawArgs.fViewMatrix = &viewMatrix;
canDrawArgs.fShape = &shape;
- if (!element->isAA()) {
- canDrawArgs.fAAType = GrAAType::kNone;
- } else if (renderTargetContext->isUnifiedMultisampled()) {
- canDrawArgs.fAAType = GrAAType::kMSAA;
- } else if (renderTargetContext->isStencilBufferMultisampled()){
- canDrawArgs.fAAType = GrAAType::kMixedSamples;
- } else {
- canDrawArgs.fAAType = GrAAType::kCoverage;
- }
+ canDrawArgs.fAAType = GrChooseAAType(GrBoolToAA(element->isAA()),
+ renderTargetContext->fsaaType(),
+ GrAllowMixedSamples::kYes);
canDrawArgs.fHasUserStencilSettings = hasUserStencilSettings;
// the 'false' parameter disallows use of the SW path renderer
@@ -300,8 +294,8 @@ bool GrClipStackClip::apply(GrContext* context, GrRenderTargetContext* renderTar
if (reducedClip.elements().count() <= kMaxAnalyticElements) {
// When there are multiple samples we want to do per-sample clipping, not compute a
// fractional pixel coverage.
- bool disallowAnalyticAA = renderTargetContext->isStencilBufferMultisampled() &&
- !avoidStencilBuffers;
+ bool disallowAnalyticAA =
+ GrFSAAType::kNone != renderTargetContext->fsaaType() && !avoidStencilBuffers;
if (disallowAnalyticAA && !renderTargetContext->numColorSamples()) {
// With a single color sample, any coverage info is lost from color once it hits the
// color buffer anyway, so we may as well use coverage AA if nothing else in the pipe
@@ -318,7 +312,7 @@ bool GrClipStackClip::apply(GrContext* context, GrRenderTargetContext* renderTar
}
// If the stencil buffer is multisampled we can use it to do everything.
- if ((!renderTargetContext->isStencilBufferMultisampled() && reducedClip.requiresAA()) ||
+ if ((GrFSAAType::kNone == renderTargetContext->fsaaType() && reducedClip.requiresAA()) ||
avoidStencilBuffers) {
sk_sp<GrTextureProxy> result;
if (UseSWOnlyPath(context, hasUserStencilSettings, renderTargetContext, reducedClip)) {
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 38cfb8c71a..0dc78ecb1e 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -302,7 +302,7 @@ sk_sp<GrRenderTargetContext> GrDrawingManager::makeRenderTargetContext(
}
if (useDIF && fContext->caps()->shaderCaps()->pathRenderingSupport() &&
- rtp->isStencilBufferMultisampled()) {
+ GrFSAAType::kNone != rtp->fsaaType()) {
// TODO: defer stencil buffer attachment for PathRenderingDrawContext
sk_sp<GrRenderTarget> rt(sk_ref_sp(rtp->instantiate(fContext->resourceProvider())));
if (!rt) {
diff --git a/src/gpu/GrPathRenderer.h b/src/gpu/GrPathRenderer.h
index 0845bc0c01..2f08f4392a 100644
--- a/src/gpu/GrPathRenderer.h
+++ b/src/gpu/GrPathRenderer.h
@@ -160,9 +160,9 @@ public:
canArgs.fHasUserStencilSettings = !args.fUserStencilSettings->isUnused();
SkASSERT(!(canArgs.fAAType == GrAAType::kMSAA &&
- !args.fRenderTargetContext->isUnifiedMultisampled()));
+ GrFSAAType::kUnifiedMSAA != args.fRenderTargetContext->fsaaType()));
SkASSERT(!(canArgs.fAAType == GrAAType::kMixedSamples &&
- !args.fRenderTargetContext->isStencilBufferMultisampled()));
+ GrFSAAType::kMixedSamples != args.fRenderTargetContext->fsaaType()));
SkASSERT(this->canDrawPath(canArgs));
if (!args.fUserStencilSettings->isUnused()) {
SkPath path;
diff --git a/src/gpu/GrReducedClip.cpp b/src/gpu/GrReducedClip.cpp
index 28ba47c688..b7ffa7b26f 100644
--- a/src/gpu/GrReducedClip.cpp
+++ b/src/gpu/GrReducedClip.cpp
@@ -704,7 +704,7 @@ bool GrReducedClip::drawStencilClipMask(GrContext* context,
for (ElementList::Iter iter(fElements); iter.get(); iter.next()) {
const Element* element = iter.get();
GrAAType aaType = GrAAType::kNone;
- if (element->isAA() && renderTargetContext->isStencilBufferMultisampled()) {
+ if (element->isAA() && GrFSAAType::kNone != renderTargetContext->fsaaType()) {
aaType = GrAAType::kMSAA;
}
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index f18e7b2a47..f622053049 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -447,7 +447,7 @@ bool GrRenderTargetContext::drawFilledRect(const GrClip& clip,
return true;
}
}
- GrAAType aaType = this->decideAAType(aa);
+ GrAAType aaType = this->chooseAAType(aa, GrAllowMixedSamples::kNo);
if (GrAAType::kCoverage == aaType) {
// The fill path can handle rotation but not skew.
if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
@@ -564,7 +564,7 @@ void GrRenderTargetContext::drawRect(const GrClip& clip,
std::unique_ptr<GrLegacyMeshDrawOp> op;
GrColor color = paint.getColor();
- GrAAType aaType = this->decideAAType(aa);
+ GrAAType aaType = this->chooseAAType(aa, GrAllowMixedSamples::kNo);
if (GrAAType::kCoverage == aaType) {
// The stroke path needs the rect to remain axis aligned (no rotation or skew).
if (viewMatrix.rectStaysRect()) {
@@ -575,7 +575,7 @@ void GrRenderTargetContext::drawRect(const GrClip& clip,
// hairline rects. We jam all the vertices to pixel centers to avoid this, but not
// when MSAA is enabled because it can cause ugly artifacts.
snapToPixelCenters = stroke.getStyle() == SkStrokeRec::kHairline_Style &&
- !fRenderTargetProxy->isUnifiedMultisampled();
+ GrFSAAType::kUnifiedMSAA != fRenderTargetProxy->fsaaType();
op = GrRectOpFactory::MakeNonAAStroke(color, viewMatrix, rect, stroke,
snapToPixelCenters);
}
@@ -751,7 +751,7 @@ void GrRenderTargetContext::fillRectToRect(const GrClip& clip,
}
}
- GrAAType aaType = this->decideAAType(aa);
+ GrAAType aaType = this->chooseAAType(aa, GrAllowMixedSamples::kNo);
if (GrAAType::kCoverage != aaType) {
this->drawNonAAFilledRect(clip, std::move(paint), viewMatrix, croppedRect,
&croppedLocalRect, nullptr, nullptr, aaType);
@@ -807,7 +807,7 @@ void GrRenderTargetContext::fillRectWithLocalMatrix(const GrClip& clip,
}
}
- GrAAType aaType = this->decideAAType(aa);
+ GrAAType aaType = this->chooseAAType(aa, GrAllowMixedSamples::kNo);
if (GrAAType::kCoverage != aaType) {
this->drawNonAAFilledRect(clip, std::move(paint), viewMatrix, croppedRect, nullptr,
&localMatrix, nullptr, aaType);
@@ -959,7 +959,7 @@ void GrRenderTargetContext::drawRRect(const GrClip& origClip,
}
}
- GrAAType aaType = this->decideAAType(aa);
+ GrAAType aaType = this->chooseAAType(aa, GrAllowMixedSamples::kNo);
if (GrAAType::kCoverage == aaType) {
const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
std::unique_ptr<GrLegacyMeshDrawOp> op =
@@ -1033,7 +1033,7 @@ bool GrRenderTargetContext::drawFilledDRRect(const GrClip& clip,
}
}
- GrAAType aaType = this->decideAAType(aa);
+ GrAAType aaType = this->chooseAAType(aa, GrAllowMixedSamples::kNo);
GrPrimitiveEdgeType innerEdgeType, outerEdgeType;
if (GrAAType::kCoverage == aaType) {
@@ -1182,7 +1182,7 @@ void GrRenderTargetContext::drawOval(const GrClip& clip,
}
}
- GrAAType aaType = this->decideAAType(aa);
+ GrAAType aaType = this->chooseAAType(aa, GrAllowMixedSamples::kNo);
if (GrAAType::kCoverage == aaType) {
const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
std::unique_ptr<GrLegacyMeshDrawOp> op =
@@ -1216,7 +1216,7 @@ void GrRenderTargetContext::drawArc(const GrClip& clip,
AutoCheckFlush acf(this->drawingManager());
- GrAAType aaType = this->decideAAType(aa);
+ GrAAType aaType = this->chooseAAType(aa, GrAllowMixedSamples::kNo);
if (GrAAType::kCoverage == aaType) {
const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
std::unique_ptr<GrLegacyMeshDrawOp> op = GrOvalOpFactory::MakeArcOp(paint.getColor(),
@@ -1278,7 +1278,7 @@ void GrRenderTargetContext::drawNonAAFilledRect(const GrClip& clip,
const GrUserStencilSettings* ss,
GrAAType hwOrNoneAAType) {
SkASSERT(GrAAType::kCoverage != hwOrNoneAAType);
- SkASSERT(GrAAType::kNone == hwOrNoneAAType || this->isStencilBufferMultisampled());
+ SkASSERT(GrAAType::kNone == hwOrNoneAAType || GrFSAAType::kNone != this->fsaaType());
std::unique_ptr<GrDrawOp> op = GrNonAAFillRectOp::Make(
std::move(paint), viewMatrix, rect, localRect, localMatrix, hwOrNoneAAType, ss);
this->addDrawOp(clip, std::move(op));
@@ -1350,7 +1350,7 @@ void GrRenderTargetContext::drawPath(const GrClip& clip,
AutoCheckFlush acf(this->drawingManager());
- GrAAType aaType = this->decideAAType(aa);
+ GrAAType aaType = this->chooseAAType(aa, GrAllowMixedSamples::kNo);
if (GrAAType::kCoverage == aaType && !style.pathEffect()) {
if (style.isSimpleFill() && !path.isConvex()) {
// Concave AA paths are expensive - try to avoid them for special cases
@@ -1415,7 +1415,7 @@ bool GrRenderTargetContextPriv::drawAndStencilPath(const GrClip& clip,
// the src color (either the input alpha or in the frag shader) to implement
// aa. If we have some future driver-mojo path AA that can do the right
// thing WRT to the blend then we'll need some query on the PR.
- GrAAType aaType = fRenderTargetContext->decideAAType(aa);
+ GrAAType aaType = fRenderTargetContext->chooseAAType(aa, GrAllowMixedSamples::kNo);
bool hasUserStencilSettings = !ss->isUnused();
GrShape shape(path, GrStyle::SimpleFill());
@@ -1472,14 +1472,12 @@ void GrRenderTargetContext::internalDrawPath(const GrClip& clip,
RETURN_IF_ABANDONED
SkASSERT(!path.isEmpty());
GrShape shape;
-
- GrAAType aaType = this->decideAAType(aa, /*allowMixedSamples*/ true);
- if (style.isSimpleHairline() && aaType == GrAAType::kMixedSamples) {
- // NVPR cannot handle hairlines, so this will would get picked up by a different stencil and
- // cover path renderer (i.e. default path renderer). The hairline renderer produces much
- // smoother hairlines than MSAA.
- aaType = GrAAType::kCoverage;
- }
+ // NVPR cannot handle hairlines, so this would get picked up by a different stencil and
+ // cover path renderer (i.e. default path renderer). The hairline renderer produces much
+ // smoother hairlines than MSAA.
+ GrAllowMixedSamples allowMixedSamples =
+ style.isSimpleHairline() ? GrAllowMixedSamples::kNo : GrAllowMixedSamples::kYes;
+ GrAAType aaType = this->chooseAAType(aa, allowMixedSamples);
GrPathRenderer::CanDrawPathArgs canDrawArgs;
canDrawArgs.fCaps = this->drawingManager()->getContext()->caps();
canDrawArgs.fViewMatrix = &viewMatrix;
@@ -1651,7 +1649,7 @@ uint32_t GrRenderTargetContext::addLegacyMeshDrawOp(GrPipelineBuilder&& pipeline
}
}
- bool isMixedSamples = fRenderTargetProxy->isMixedSampled() &&
+ bool isMixedSamples = GrFSAAType::kMixedSamples == this->fsaaType() &&
(pipelineBuilder.isHWAntialias() || usesStencil);
GrColor overrideColor;
diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h
index 5aef96a65b..40d8732bef 100644
--- a/src/gpu/GrRenderTargetContext.h
+++ b/src/gpu/GrRenderTargetContext.h
@@ -8,15 +8,16 @@
#ifndef GrRenderTargetContext_DEFINED
#define GrRenderTargetContext_DEFINED
+#include "../private/GrInstancedPipelineInfo.h"
+#include "../private/GrRenderTargetProxy.h"
#include "GrColor.h"
#include "GrContext.h"
#include "GrPaint.h"
#include "GrSurfaceContext.h"
+#include "GrTypesPriv.h"
#include "GrXferProcessor.h"
#include "SkRefCnt.h"
#include "SkSurfaceProps.h"
-#include "../private/GrInstancedPipelineInfo.h"
-#include "../private/GrRenderTargetProxy.h"
class GrClip;
class GrDrawingManager;
@@ -344,12 +345,7 @@ public:
*/
void prepareForExternalIO();
- bool isStencilBufferMultisampled() const {
- return fRenderTargetProxy->isStencilBufferMultisampled();
- }
- bool isUnifiedMultisampled() const { return fRenderTargetProxy->isUnifiedMultisampled(); }
- bool hasMixedSamples() const { return fRenderTargetProxy->isMixedSampled(); }
-
+ GrFSAAType fsaaType() const { return fRenderTargetProxy->fsaaType(); }
const GrCaps* caps() const { return fContext->caps(); }
const GrSurfaceDesc& desc() const { return fRenderTargetProxy->desc(); }
int width() const { return fRenderTargetProxy->width(); }
@@ -394,17 +390,8 @@ protected:
SkDEBUGCODE(void validate() const;)
private:
- inline GrAAType decideAAType(GrAA aa, bool allowMixedSamples = false) {
- if (GrAA::kNo == aa) {
- return GrAAType::kNone;
- }
- if (this->isUnifiedMultisampled()) {
- return GrAAType::kMSAA;
- }
- if (allowMixedSamples && this->isStencilBufferMultisampled()) {
- return GrAAType::kMixedSamples;
- }
- return GrAAType::kCoverage;
+ inline GrAAType chooseAAType(GrAA aa, GrAllowMixedSamples allowMixedSamples) {
+ return GrChooseAAType(aa, this->fsaaType(), allowMixedSamples);
}
friend class GrAtlasTextBlob; // for access to add[Mesh]DrawOp
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 19d9185119..5640ef60a3 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -862,9 +862,8 @@ void SkGpuDevice::drawBitmap(const SkBitmap& bitmap,
// The tile code path doesn't currently support AA, so if the paint asked for aa and we could
// draw untiled, then we bypass checking for tiling purely for optimization reasons.
- bool drawAA = !fRenderTargetContext->isUnifiedMultisampled() &&
- paint.isAntiAlias() &&
- bitmap.width() <= maxTileSize &&
+ bool drawAA = GrFSAAType::kUnifiedMSAA != fRenderTargetContext->fsaaType() &&
+ paint.isAntiAlias() && bitmap.width() <= maxTileSize &&
bitmap.height() <= maxTileSize;
bool skipTileCheck = drawAA || paint.getMaskFilter();
@@ -959,7 +958,7 @@ void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap,
const SkPaint* paint = &origPaint;
SkPaint tempPaint;
- if (origPaint.isAntiAlias() && !fRenderTargetContext->isUnifiedMultisampled()) {
+ if (origPaint.isAntiAlias() && GrFSAAType::kUnifiedMSAA != fRenderTargetContext->fsaaType()) {
// Drop antialiasing to avoid seams at tile boundaries.
tempPaint = origPaint;
tempPaint.setAntiAlias(false);
@@ -1106,7 +1105,7 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap,
// Coverage-based AA would cause seams between tiles.
GrAA aa = GrBoolToAA(paint.isAntiAlias() &&
- fRenderTargetContext->isStencilBufferMultisampled());
+ GrFSAAType::kNone != fRenderTargetContext->fsaaType());
fRenderTargetContext->drawRect(this->clip(), std::move(grPaint), aa, viewMatrix, dstRect);
}
@@ -1231,12 +1230,11 @@ void SkGpuDevice::drawBitmapRect(const SkBitmap& bitmap,
// The tile code path doesn't currently support AA, so if the paint asked for aa and we could
// draw untiled, then we bypass checking for tiling purely for optimization reasons.
- bool drawAA = !fRenderTargetContext->isUnifiedMultisampled() &&
- paint.isAntiAlias() &&
- bitmap.width() <= maxTileSize &&
- bitmap.height() <= maxTileSize;
+ bool useCoverageAA = GrFSAAType::kUnifiedMSAA != fRenderTargetContext->fsaaType() &&
+ paint.isAntiAlias() && bitmap.width() <= maxTileSize &&
+ bitmap.height() <= maxTileSize;
- bool skipTileCheck = drawAA || paint.getMaskFilter();
+ bool skipTileCheck = useCoverageAA || paint.getMaskFilter();
if (!skipTileCheck) {
int tileSize;
@@ -1434,7 +1432,7 @@ void SkGpuDevice::drawProducerNine(GrTextureProducer* producer,
CHECK_SHOULD_DRAW();
bool useFallback = paint.getMaskFilter() || paint.isAntiAlias() ||
- fRenderTargetContext->isUnifiedMultisampled();
+ GrFSAAType::kUnifiedMSAA == fRenderTargetContext->fsaaType();
bool doBicubic;
GrSamplerParams::FilterMode textureFilterMode =
GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), this->ctm(), SkMatrix::I(),
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index f0dbeb92ff..48015a3906 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -42,12 +42,12 @@ static bool has_aligned_samples(const SkRect& srcRect, const SkRect& transformed
static bool may_color_bleed(const SkRect& srcRect,
const SkRect& transformedRect,
const SkMatrix& m,
- bool isMSAA) {
+ GrFSAAType fsaaType) {
// Only gets called if has_aligned_samples returned false.
// So we can assume that sampling is axis aligned but not texel aligned.
SkASSERT(!has_aligned_samples(srcRect, transformedRect));
SkRect innerSrcRect(srcRect), innerTransformedRect, outerTransformedRect(transformedRect);
- if (isMSAA) {
+ if (GrFSAAType::kUnifiedMSAA == fsaaType) {
innerSrcRect.inset(SK_Scalar1, SK_Scalar1);
} else {
innerSrcRect.inset(SK_ScalarHalf, SK_ScalarHalf);
@@ -71,14 +71,14 @@ static bool may_color_bleed(const SkRect& srcRect,
static bool can_ignore_bilerp_constraint(const GrTextureProducer& producer,
const SkRect& srcRect,
const SkMatrix& srcRectToDeviceSpace,
- bool isMSAA) {
+ GrFSAAType fsaaType) {
if (srcRectToDeviceSpace.rectStaysRect()) {
// sampling is axis-aligned
SkRect transformedRect;
srcRectToDeviceSpace.mapRect(&transformedRect, srcRect);
if (has_aligned_samples(srcRect, transformedRect) ||
- !may_color_bleed(srcRect, transformedRect, srcRectToDeviceSpace, isMSAA)) {
+ !may_color_bleed(srcRect, transformedRect, srcRectToDeviceSpace, fsaaType)) {
return true;
}
}
@@ -186,7 +186,7 @@ void SkGpuDevice::drawTextureProducerImpl(GrTextureProducer* producer,
SkMatrix combinedMatrix;
combinedMatrix.setConcat(viewMatrix, srcToDstMatrix);
if (can_ignore_bilerp_constraint(*producer, clippedSrcRect, combinedMatrix,
- fRenderTargetContext->isUnifiedMultisampled())) {
+ fRenderTargetContext->fsaaType())) {
constraintMode = GrTextureAdjuster::kNo_FilterConstraint;
}
}
diff --git a/src/gpu/effects/GrCoverageSetOpXP.cpp b/src/gpu/effects/GrCoverageSetOpXP.cpp
index e75a588cff..344762dd19 100644
--- a/src/gpu/effects/GrCoverageSetOpXP.cpp
+++ b/src/gpu/effects/GrCoverageSetOpXP.cpp
@@ -228,7 +228,8 @@ GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory);
#if GR_TEST_UTILS
const GrXPFactory* GrCoverageSetOpXPFactory::TestGet(GrProcessorTestData* d) {
SkRegion::Op regionOp = SkRegion::Op(d->fRandom->nextULessThan(SkRegion::kLastOp + 1));
- bool invertCoverage = !d->fRenderTargetContext->hasMixedSamples() && d->fRandom->nextBool();
+ bool isMixedSamples = GrFSAAType::kMixedSamples == d->fRenderTargetContext->fsaaType();
+ bool invertCoverage = !isMixedSamples && d->fRandom->nextBool();
return GrCoverageSetOpXPFactory::Get(regionOp, invertCoverage);
}
#endif
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index c3e0a0c75c..0343373880 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2861,7 +2861,7 @@ void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabl
}
if (0 != this->caps()->maxRasterSamples()) {
- if (useHWAA && rt->isMixedSampled() && !stencilEnabled) {
+ if (useHWAA && GrFSAAType::kMixedSamples == rt->fsaaType() && !stencilEnabled) {
// Since stencil is disabled and we want more samples than are in the color buffer, we
// need to tell the rasterizer explicitly how many to run.
if (kYes_TriState != fHWRasterMultisampleEnabled) {
@@ -2880,7 +2880,7 @@ void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabl
}
}
} else {
- SkASSERT(!useHWAA || !rt->isMixedSampled() || stencilEnabled);
+ SkASSERT(!useHWAA || GrFSAAType::kMixedSamples != rt->fsaaType() || stencilEnabled);
}
}
@@ -4273,8 +4273,8 @@ bool GrGLGpu::generateMipmap(GrGLTexture* texture, bool gammaCorrect) {
void GrGLGpu::onQueryMultisampleSpecs(GrRenderTarget* rt, const GrStencilSettings& stencil,
int* effectiveSampleCnt, SamplePattern* samplePattern) {
- SkASSERT(!rt->isMixedSampled() || rt->renderTargetPriv().getStencilAttachment() ||
- stencil.isDisabled());
+ SkASSERT(GrFSAAType::kMixedSamples != rt->fsaaType() ||
+ rt->renderTargetPriv().getStencilAttachment() || stencil.isDisabled());
this->flushStencil(stencil);
this->flushHWAAState(rt, true, !stencil.isDisabled());
diff --git a/src/gpu/gl/GrGLRenderTarget.h b/src/gpu/gl/GrGLRenderTarget.h
index e4efc94a92..795b41e75d 100644
--- a/src/gpu/gl/GrGLRenderTarget.h
+++ b/src/gpu/gl/GrGLRenderTarget.h
@@ -48,9 +48,8 @@ public:
// override of GrRenderTarget
ResolveType getResolveType() const override {
- if (!this->isUnifiedMultisampled() ||
- fRTFBOID == fTexFBOID) {
- // catches FBO 0 and non MSAA case
+ if (GrFSAAType::kUnifiedMSAA != this->fsaaType() || fRTFBOID == fTexFBOID) {
+ // catches FBO 0 and non unified-MSAA case
return kAutoResolves_ResolveType;
} else if (kUnresolvableFBOID == fTexFBOID) {
return kCantResolve_ResolveType;
diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp
index 9144d16511..47132595e9 100644
--- a/src/gpu/ops/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp
@@ -969,7 +969,7 @@ private:
bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
"GrAAConvexPathRenderer::onDrawPath");
- SkASSERT(!args.fRenderTargetContext->isUnifiedMultisampled());
+ SkASSERT(GrFSAAType::kUnifiedMSAA != args.fRenderTargetContext->fsaaType());
SkASSERT(!args.fShape->isEmpty());
SkPath path;
diff --git a/src/gpu/ops/GrAAHairLinePathRenderer.cpp b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
index a40f0597aa..91e8c368a6 100644
--- a/src/gpu/ops/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
@@ -953,7 +953,7 @@ void AAHairlineOp::onPrepareDraws(Target* target) const {
bool GrAAHairLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
"GrAAHairlinePathRenderer::onDrawPath");
- SkASSERT(!args.fRenderTargetContext->isUnifiedMultisampled());
+ SkASSERT(GrFSAAType::kUnifiedMSAA != args.fRenderTargetContext->fsaaType());
SkIRect devClipBounds;
args.fClip->getConservativeBounds(args.fRenderTargetContext->width(),
diff --git a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp
index 6c94793a35..ad18518656 100644
--- a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp
@@ -327,7 +327,7 @@ private:
bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
"GrAALinearizingConvexPathRenderer::onDrawPath");
- SkASSERT(!args.fRenderTargetContext->isUnifiedMultisampled());
+ SkASSERT(GrFSAAType::kUnifiedMSAA != args.fRenderTargetContext->fsaaType());
SkASSERT(!args.fShape->isEmpty());
SkASSERT(!args.fShape->style().pathEffect());
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp
index 65889b2c56..d2872d246f 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp
@@ -604,14 +604,8 @@ void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx,
renderTargetContext->height());
// The run's "font" overrides the anti-aliasing of the passed in SkPaint!
- GrAAType aaType;
- if (this->aa() == GrAA::kYes) {
- SkASSERT(renderTargetContext->isStencilBufferMultisampled());
- aaType = renderTargetContext->isUnifiedMultisampled() ? GrAAType::kMSAA
- : GrAAType::kMixedSamples;
- } else {
- aaType = GrAAType::kNone;
- }
+ GrAAType aaType = GrChooseAAType(this->aa(), renderTargetContext->fsaaType(),
+ GrAllowMixedSamples::kYes);
std::unique_ptr<GrDrawOp> op = GrDrawPathRangeOp::Make(
viewMatrix, fTextRatio, fTextInverseRatio * x, fTextInverseRatio * y,
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index 6553b4e94f..7b3600f800 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -71,12 +71,9 @@ static void check_rendertarget(skiatest::Reporter* reporter,
}
REPORTER_ASSERT(reporter, rt->config() == rtProxy->config());
- REPORTER_ASSERT(reporter, rt->isUnifiedMultisampled() == rtProxy->isUnifiedMultisampled());
- REPORTER_ASSERT(reporter, rt->isStencilBufferMultisampled() ==
- rtProxy->isStencilBufferMultisampled());
+ REPORTER_ASSERT(reporter, rt->fsaaType() == rtProxy->fsaaType());
REPORTER_ASSERT(reporter, rt->numColorSamples() == rtProxy->numColorSamples());
REPORTER_ASSERT(reporter, rt->numStencilSamples() == rtProxy->numStencilSamples());
- REPORTER_ASSERT(reporter, rt->isMixedSampled() == rtProxy->isMixedSampled());
REPORTER_ASSERT(reporter, rt->renderTargetPriv().flags() == rtProxy->testingOnly_getFlags());
}