diff options
Diffstat (limited to 'src/gpu/ops/GrRectOpFactory.h')
-rw-r--r-- | src/gpu/ops/GrRectOpFactory.h | 100 |
1 files changed, 54 insertions, 46 deletions
diff --git a/src/gpu/ops/GrRectOpFactory.h b/src/gpu/ops/GrRectOpFactory.h index 58927ef91b..cf3da2f8bd 100644 --- a/src/gpu/ops/GrRectOpFactory.h +++ b/src/gpu/ops/GrRectOpFactory.h @@ -1,5 +1,5 @@ /* - * Copyright 2015 Google Inc. + * Copyright 2017 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. @@ -8,58 +8,66 @@ #ifndef GrRectOpFactory_DEFINED #define GrRectOpFactory_DEFINED -#include "GrAAFillRectOp.h" -#include "GrAAStrokeRectOp.h" -#include "GrAnalyticRectOp.h" -#include "GrColor.h" -#include "GrMeshDrawOp.h" -#include "GrNonAAStrokeRectOp.h" -#include "GrPaint.h" -#include "SkMatrix.h" -#include "SkRefCnt.h" +#include <memory> +#include "GrTypes.h" +enum class GrAAType : unsigned; +class GrDrawOp; +class GrPaint; +struct GrUserStencilSettings; +class SkMatrix; struct SkRect; class SkStrokeRec; /** - * A factory for returning GrDrawOps which can draw rectangles. + * A set of factory functions for drawing rectangles including fills, strokes, coverage-antialiased, + * and non-antialiased. The non-antialiased ops can be used with MSAA. As with other GrDrawOp + * factories, the GrPaint is only consumed by these methods if a valid op is returned. If null is + * returned then the paint is unmodified and may still be used. */ namespace GrRectOpFactory { +/** AA Fill */ -inline std::unique_ptr<GrLegacyMeshDrawOp> MakeAAFill(const GrPaint& paint, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkRect& croppedRect, - const SkRect& devRect) { - return GrAAFillRectOp::Make(paint.getColor(), viewMatrix, croppedRect, devRect); -} - -inline std::unique_ptr<GrLegacyMeshDrawOp> MakeAAFill(GrColor color, - const SkMatrix& viewMatrix, - const SkMatrix& localMatrix, - const SkRect& rect, - const SkRect& devRect) { - return GrAAFillRectOp::Make(color, viewMatrix, localMatrix, rect, devRect); -} - -inline std::unique_ptr<GrLegacyMeshDrawOp> MakeNonAAStroke(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkStrokeRec& strokeRec, - bool snapToPixelCenters) { - return GrNonAAStrokeRectOp::Make(color, viewMatrix, rect, strokeRec, snapToPixelCenters); -} - -inline std::unique_ptr<GrLegacyMeshDrawOp> MakeAAStroke(GrColor color, - const SkMatrix& viewMatrix, - const SkRect& rect, - const SkStrokeRec& stroke) { - return GrAAStrokeRectOp::Make(color, viewMatrix, rect, stroke); -} - -// First rect is outer; second rect is inner -std::unique_ptr<GrLegacyMeshDrawOp> MakeAAFillNestedRects(GrColor, const SkMatrix& viewMatrix, - const SkRect rects[2]); -}; +std::unique_ptr<GrDrawOp> MakeAAFill(GrPaint&&, const SkMatrix&, const SkRect&, + const GrUserStencilSettings* = nullptr); + +// Using this method to supply a device rect simply saves recalculation if the device rect is known. +std::unique_ptr<GrDrawOp> MakeAAFillWithDevRect(GrPaint&&, const SkMatrix& viewMatrix, + const SkRect& rect, const SkRect& devRect); + +std::unique_ptr<GrDrawOp> MakeAAFillWithLocalMatrix(GrPaint&&, const SkMatrix& viewMatrix, + const SkMatrix& localMatrix, const SkRect&); + +std::unique_ptr<GrDrawOp> MakeAAFillWithLocalRect(GrPaint&&, const SkMatrix&, const SkRect& rect, + const SkRect& localRect); + +/** Non-AA Fill - GrAAType must be either kNone or kMSAA. */ + +std::unique_ptr<GrDrawOp> MakeNonAAFill(GrPaint&&, const SkMatrix& viewMatrix, const SkRect& rect, + GrAAType, const GrUserStencilSettings* = nullptr); + +std::unique_ptr<GrDrawOp> MakeNonAAFillWithLocalMatrix(GrPaint&&, const SkMatrix& viewMatrix, + const SkMatrix& localMatrix, const SkRect&, + GrAAType, + const GrUserStencilSettings* = nullptr); + +std::unique_ptr<GrDrawOp> MakeNonAAFillWithLocalRect(GrPaint&&, const SkMatrix&, const SkRect& rect, + const SkRect& localRect, GrAAType); + +/** AA Stroke */ + +std::unique_ptr<GrDrawOp> MakeAAStroke(GrPaint&&, const SkMatrix&, const SkRect&, + const SkStrokeRec&); + +// rects[0] == outer rectangle, rects[1] == inner rectangle. Null return means there is nothing to +// draw rather than failure. +std::unique_ptr<GrDrawOp> MakeAAFillNestedRects(GrPaint&&, const SkMatrix&, const SkRect rects[2]); + +/** Non-AA Stroke - GrAAType must be either kNone or kMSAA. */ + +std::unique_ptr<GrDrawOp> MakeNonAAStroke(GrPaint&&, const SkMatrix&, const SkRect&, + const SkStrokeRec&, GrAAType); + +} // namespace GrRectOpFactory #endif |