aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2016-12-09 20:02:08 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-09 20:02:22 +0000
commit073285c0595d46205d1482cc19af2d7d891bfeae (patch)
treef127dd2c03ef707cd47396be0bf1cbf911403849 /include
parent3944484020d98ff8f386378296106c321279482b (diff)
Revert "Reland "Remove antialiasing control from GrPaint.""
This reverts commit 3944484020d98ff8f386378296106c321279482b. Reason for revert: Merges badly with a recent change. Will rebase and reland. Original change's description: > Reland "Remove antialiasing control from GrPaint." > > This contains fixes for GLPrograms test and mixed samples rendering. > > This reverts commit 419d81eed4a010e6080db199795117cbedf9e6e4. > > BUG=skia: > > Change-Id: If8f002fbfaaaab6d1607403f2b15ccc7f1e17e87 > Reviewed-on: https://skia-review.googlesource.com/5763 > Commit-Queue: Brian Salomon <bsalomon@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> > TBR=bsalomon@google.com,robertphillips@google.com,reviews@skia.org BUG=skia: NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: Iff9657041e28604a845bc5a9acec7c9b248c53bd Reviewed-on: https://skia-review.googlesource.com/5772 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/gpu/GrClip.h5
-rw-r--r--include/gpu/GrPaint.h15
-rw-r--r--include/gpu/GrRenderTargetContext.h139
-rw-r--r--include/gpu/GrTypes.h12
-rw-r--r--include/gpu/GrTypesPriv.h15
5 files changed, 69 insertions, 117 deletions
diff --git a/include/gpu/GrClip.h b/include/gpu/GrClip.h
index 9bf2da205e..2d4c1f2628 100644
--- a/include/gpu/GrClip.h
+++ b/include/gpu/GrClip.h
@@ -8,7 +8,6 @@
#ifndef GrClip_DEFINED
#define GrClip_DEFINED
-#include "GrTypes.h"
#include "SkRect.h"
#include "SkRRect.h"
@@ -46,7 +45,7 @@ public:
* @return true if the clip is equivalent to a single rrect, false otherwise.
*
*/
- virtual bool isRRect(const SkRect& rtBounds, SkRRect* rrect, GrAA* aa) const = 0;
+ virtual bool isRRect(const SkRect& rtBounds, SkRRect* rrect, bool* aa) const = 0;
/**
* This is the maximum distance that a draw may extend beyond a clip's boundary and still count
@@ -141,7 +140,7 @@ private:
bool apply(GrContext*, GrRenderTargetContext*, bool, bool, GrAppliedClip*) const final {
return true;
}
- bool isRRect(const SkRect&, SkRRect*, GrAA*) const override { return false; }
+ bool isRRect(const SkRect&, SkRRect*, bool*) const override { return false; }
};
#endif
diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h
index 6cdc2de09c..9390d021a3 100644
--- a/include/gpu/GrPaint.h
+++ b/include/gpu/GrPaint.h
@@ -30,9 +30,10 @@
* The primitive color computation starts with the color specified by setColor(). This color is the
* input to the first color stage. Each color stage feeds its output to the next color stage.
*
- * Fractional pixel coverage follows a similar flow. The GrGeometryProcessor (specified elsewhere)
- * provides the initial coverage which is passed to the first coverage fragment processor, which
- * feeds its output to next coverage fragment processor.
+ * Fractional pixel coverage follows a similar flow. The coverage is initially the value specified
+ * by setCoverage(). This is input to the first coverage stage. Coverage stages are chained
+ * together in the same manner as color stages. The output of the last stage is modulated by any
+ * fractional coverage produced by anti-aliasing. This last step produces the final coverage, C.
*
* setXPFactory is used to control blending between the output color and dest. It also implements
* the application of fractional coverage from the coverage pipeline.
@@ -57,6 +58,12 @@ public:
GrColor getColor() const { return fColor.toGrColor(); }
/**
+ * Should primitives be anti-aliased or not. Defaults to false.
+ */
+ void setAntiAlias(bool aa) { fAntiAlias = aa; }
+ bool isAntiAlias() const { return fAntiAlias; }
+
+ /**
* Should shader output conversion from linear to sRGB be disabled.
* Only relevant if the destination is sRGB. Defaults to false.
*/
@@ -139,6 +146,7 @@ public:
}
GrPaint& operator=(const GrPaint& paint) {
+ fAntiAlias = paint.fAntiAlias;
fDisableOutputConversionToSRGB = paint.fDisableOutputConversionToSRGB;
fAllowSRGBInputs = paint.fAllowSRGBInputs;
fUsesDistanceVectorField = paint.fUsesDistanceVectorField;
@@ -177,6 +185,7 @@ private:
SkSTArray<4, sk_sp<GrFragmentProcessor>> fColorFragmentProcessors;
SkSTArray<2, sk_sp<GrFragmentProcessor>> fCoverageFragmentProcessors;
+ bool fAntiAlias;
bool fDisableOutputConversionToSRGB;
bool fAllowSRGBInputs;
bool fUsesDistanceVectorField;
diff --git a/include/gpu/GrRenderTargetContext.h b/include/gpu/GrRenderTargetContext.h
index d958ba2761..7ef572abce 100644
--- a/include/gpu/GrRenderTargetContext.h
+++ b/include/gpu/GrRenderTargetContext.h
@@ -88,17 +88,15 @@ public:
void drawPaint(const GrClip&, const GrPaint&, const SkMatrix& viewMatrix);
/**
- * Draw the rect using a paint.
- * @param paint describes how to color pixels.
- * @param GrAA Controls whether rect is antialiased
- * @param viewMatrix transformation matrix
- * @param style The style to apply. Null means fill. Currently path effects are not
- * allowed.
- * The rects coords are used to access the paint (through texture matrix)
+ * Draw the rect using a paint.
+ * @param paint describes how to color pixels.
+ * @param viewMatrix transformation matrix
+ * @param style The style to apply. Null means fill. Currently path effects are not
+ * allowed.
+ * The rects coords are used to access the paint (through texture matrix)
*/
void drawRect(const GrClip&,
const GrPaint& paint,
- GrAA,
const SkMatrix& viewMatrix,
const SkRect&,
const GrStyle* style = nullptr);
@@ -106,15 +104,13 @@ public:
/**
* Maps a rectangle of shader coordinates to a rectangle and fills that rectangle.
*
- * @param paint describes how to color pixels.
- * @param GrAA Controls whether rect is antialiased
- * @param viewMatrix transformation matrix which applies to rectToDraw
- * @param rectToDraw the rectangle to draw
- * @param localRect the rectangle of shader coordinates applied to rectToDraw
+ * @param paint describes how to color pixels.
+ * @param viewMatrix transformation matrix which applies to rectToDraw
+ * @param rectToDraw the rectangle to draw
+ * @param localRect the rectangle of shader coordinates applied to rectToDraw
*/
void fillRectToRect(const GrClip&,
const GrPaint& paint,
- GrAA,
const SkMatrix& viewMatrix,
const SkRect& rectToDraw,
const SkRect& localRect);
@@ -124,36 +120,33 @@ public:
*/
void fillRectWithLocalMatrix(const GrClip& clip,
const GrPaint& paint,
- GrAA,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkMatrix& localMatrix);
/**
- * Draw a roundrect using a paint.
+ * Draw a roundrect using a paint.
*
- * @param paint describes how to color pixels.
- * @param GrAA Controls whether rrect is antialiased.
- * @param viewMatrix transformation matrix
- * @param rrect the roundrect to draw
- * @param style style to apply to the rrect. Currently path effects are not allowed.
+ * @param paint describes how to color pixels.
+ * @param viewMatrix transformation matrix
+ * @param rrect the roundrect to draw
+ * @param style style to apply to the rrect. Currently path effects are not allowed.
*/
void drawRRect(const GrClip&,
const GrPaint&,
- GrAA,
const SkMatrix& viewMatrix,
const SkRRect& rrect,
const GrStyle& style);
/**
- * Draw a roundrect using a paint and a shadow shader. This is separate from drawRRect
- * because it uses different underlying geometry and GeometryProcessor
+ * Draw a roundrect using a paint and a shadow shader. This is separate from drawRRect
+ * because it uses different underlying geometry and GeometryProcessor
*
- * @param paint describes how to color pixels.
- * @param viewMatrix transformation matrix
- * @param rrect the roundrect to draw
- * @param blurRadius amount of shadow blur to apply (in device space)
- * @param style style to apply to the rrect. Currently path effects are not allowed.
+ * @param paint describes how to color pixels.
+ * @param viewMatrix transformation matrix
+ * @param rrect the roundrect to draw
+ * @param blurRadius amount of shadow blur to apply (in device space)
+ * @param style style to apply to the rrect. Currently path effects are not allowed.
*/
void drawShadowRRect(const GrClip&,
const GrPaint&,
@@ -163,18 +156,17 @@ public:
const GrStyle& style);
/**
- * Shortcut for filling a SkPath consisting of nested rrects using a paint. The result is
- * undefined if outer does not contain inner.
+ * Shortcut for drawing an SkPath consisting of nested rrects using a paint.
+ * Does not support stroking. The result is undefined if outer does not contain
+ * inner.
*
- * @param paint describes how to color pixels.
- * @param GrAA Controls whether rrects edges are antialiased
- * @param viewMatrix transformation matrix
- * @param outer the outer roundrect
- * @param inner the inner roundrect
+ * @param paint describes how to color pixels.
+ * @param viewMatrix transformation matrix
+ * @param outer the outer roundrect
+ * @param inner the inner roundrect
*/
void drawDRRect(const GrClip&,
const GrPaint&,
- GrAA,
const SkMatrix& viewMatrix,
const SkRRect& outer,
const SkRRect& inner);
@@ -183,14 +175,12 @@ public:
* Draws a path.
*
* @param paint describes how to color pixels.
- * @param GrAA Controls whether the path is antialiased.
* @param viewMatrix transformation matrix
* @param path the path to draw
* @param style style to apply to the path.
*/
void drawPath(const GrClip&,
const GrPaint&,
- GrAA,
const SkMatrix& viewMatrix,
const SkPath&,
const GrStyle& style);
@@ -224,8 +214,7 @@ public:
int indexCount);
/**
- * Draws textured sprites from an atlas with a paint. This currently does not support AA for the
- * sprite rectangle edges.
+ * Draws textured sprites from an atlas with a paint.
*
* @param paint describes how to color pixels.
* @param viewMatrix transformation matrix
@@ -248,13 +237,11 @@ public:
*
* @param paint describes how to color pixels
* @param viewMatrix transformation matrix
- * @param aa should the rects of the region be antialiased.
* @param region the region to be drawn
* @param style style to apply to the region
*/
void drawRegion(const GrClip&,
const GrPaint& paint,
- GrAA aa,
const SkMatrix& viewMatrix,
const SkRegion& region,
const GrStyle& style);
@@ -263,35 +250,31 @@ public:
* Draws an oval.
*
* @param paint describes how to color pixels.
- * @param GrAA Controls whether the oval is antialiased.
* @param viewMatrix transformation matrix
* @param oval the bounding rect of the oval.
* @param style style to apply to the oval. Currently path effects are not allowed.
*/
void drawOval(const GrClip&,
const GrPaint& paint,
- GrAA,
const SkMatrix& viewMatrix,
const SkRect& oval,
const GrStyle& style);
- /**
- * Draws a partial arc of an oval.
- *
- * @param paint describes how to color pixels.
- * @param GrGrAA Controls whether the arc is antialiased.
- * @param viewMatrix transformation matrix.
- * @param oval the bounding rect of the oval.
- * @param startAngle starting angle in degrees.
- * @param sweepAngle angle to sweep in degrees. Must be in (-360, 360)
- * @param useCenter true means that the implied path begins at the oval center, connects as
- * a line to the point indicated by the start contains the arc indicated by
- * the sweep angle. If false the line beginning at the center point is
- * omitted.
- * @param style style to apply to the oval.
- */
+ /**
+ * Draws a partial arc of an oval.
+ *
+ * @param paint describes how to color pixels.
+ * @param viewMatrix transformation matrix.
+ * @param oval the bounding rect of the oval.
+ * @param startAngle starting angle in degrees.
+ * @param sweepAngle angle to sweep in degrees. Must be in (-360, 360)
+ * @param useCenter true means that the implied path begins at the oval center, connects as a
+ * line to the point indicated by the start contains the arc indicated by
+ * the sweep angle. If false the line beginning at the center point is
+ * omitted.
+ * @param style style to apply to the oval.
+ */
void drawArc(const GrClip&,
const GrPaint& paint,
- GrAA,
const SkMatrix& viewMatrix,
const SkRect& oval,
SkScalar startAngle,
@@ -350,6 +333,10 @@ public:
bool isUnifiedMultisampled() const { return fRenderTargetProxy->isUnifiedMultisampled(); }
bool hasMixedSamples() const { return fRenderTargetProxy->isMixedSampled(); }
+ bool mustUseHWAA(const GrPaint& paint) const {
+ return paint.isAntiAlias() && fRenderTargetProxy->isUnifiedMultisampled();
+ }
+
const GrCaps* caps() const { return fContext->caps(); }
const GrSurfaceDesc& desc() const { return fRenderTargetProxy->desc(); }
int width() const { return fRenderTargetProxy->width(); }
@@ -405,19 +392,6 @@ 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;
- }
-
friend class GrAtlasTextBlob; // for access to addDrawOp
friend class GrStencilAndCoverTextContext; // for access to addDrawOp
@@ -443,14 +417,12 @@ private:
bool drawFilledDRRect(const GrClip& clip,
const GrPaint& paint,
- GrAA,
const SkMatrix& viewMatrix,
const SkRRect& origOuter,
const SkRRect& origInner);
bool drawFilledRect(const GrClip& clip,
const GrPaint& paint,
- GrAA,
const SkMatrix& viewMatrix,
const SkRect& rect,
const GrUserStencilSettings* ss);
@@ -462,14 +434,13 @@ private:
const SkRect* localRect,
const SkMatrix* localMatrix,
const GrUserStencilSettings* ss,
- GrAAType hwOrNoneAAType);
-
- void internalDrawPath(const GrClip&,
- const GrPaint&,
- GrAA,
- const SkMatrix&,
- const SkPath&,
- const GrStyle&);
+ bool useHWAA);
+
+ void internalDrawPath(const GrClip& clip,
+ const GrPaint& paint,
+ const SkMatrix& viewMatrix,
+ const SkPath& path,
+ const GrStyle& style);
// This entry point allows the GrTextContext-derived classes to add their ops to the GrOpList.
void addDrawOp(const GrPipelineBuilder&, const GrClip&, GrDrawOp*);
diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h
index 86e83f93e8..846537a546 100644
--- a/include/gpu/GrTypes.h
+++ b/include/gpu/GrTypes.h
@@ -149,18 +149,6 @@ typedef intptr_t GrBackendContext;
///////////////////////////////////////////////////////////////////////////////
/**
- * Used to control antialiasing in draw calls.
- */
-enum class GrAA {
- kYes,
- kNo
-};
-
-static inline GrAA GrBoolToAA(bool aa) { return aa ? GrAA::kYes : GrAA::kNo; }
-
-///////////////////////////////////////////////////////////////////////////////
-
-/**
* Geometric primitives used for drawing.
*/
enum GrPrimitiveType {
diff --git a/include/gpu/GrTypesPriv.h b/include/gpu/GrTypesPriv.h
index 53e71e74ab..51dccc5f7d 100644
--- a/include/gpu/GrTypesPriv.h
+++ b/include/gpu/GrTypesPriv.h
@@ -11,21 +11,6 @@
#include "GrTypes.h"
#include "SkRefCnt.h"
-/** This enum indicates the type of antialiasing to be performed. */
-enum class GrAAType {
- /** No antialiasing */
- kNone,
- /** Use fragment shader code to compute a fractional pixel coverage. */
- kCoverage,
- /** Use normal MSAA. */
- kMSAA,
- /**
- * Use "mixed samples" MSAA such that the stencil buffer is multisampled but the color buffer is
- * not.
- */
- kMixedSamples
-};
-
/**
* Types of shader-language-specific boxed variables we can create. (Currently only GrGLShaderVars,
* but should be applicable to other shader languages.)