blob: e662ab108a605a6cc2341a7ed5a944207bcd4ed9 [file] [log] [blame]
Brian Salomon6a639042016-12-14 11:08:17 -05001/*
Brian Salomonbaaf4392017-06-15 09:59:23 -04002 * Copyright 2017 Google Inc.
Brian Salomon6a639042016-12-14 11:08:17 -05003 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrRectOpFactory_DEFINED
9#define GrRectOpFactory_DEFINED
10
Brian Salomonbaaf4392017-06-15 09:59:23 -040011#include <memory>
12#include "GrTypes.h"
Brian Salomon6a639042016-12-14 11:08:17 -050013
Brian Salomonbaaf4392017-06-15 09:59:23 -040014enum class GrAAType : unsigned;
15class GrDrawOp;
16class GrPaint;
17struct GrUserStencilSettings;
18class SkMatrix;
Brian Salomon6a639042016-12-14 11:08:17 -050019struct SkRect;
20class SkStrokeRec;
21
22/**
Brian Salomonbaaf4392017-06-15 09:59:23 -040023 * A set of factory functions for drawing rectangles including fills, strokes, coverage-antialiased,
24 * and non-antialiased. The non-antialiased ops can be used with MSAA. As with other GrDrawOp
25 * factories, the GrPaint is only consumed by these methods if a valid op is returned. If null is
26 * returned then the paint is unmodified and may still be used.
Brian Salomon6a639042016-12-14 11:08:17 -050027 */
28namespace GrRectOpFactory {
Brian Salomonbaaf4392017-06-15 09:59:23 -040029/** AA Fill */
Brian Salomon6a639042016-12-14 11:08:17 -050030
Brian Salomonbaaf4392017-06-15 09:59:23 -040031std::unique_ptr<GrDrawOp> MakeAAFill(GrPaint&&, const SkMatrix&, const SkRect&,
32 const GrUserStencilSettings* = nullptr);
Brian Salomon6a639042016-12-14 11:08:17 -050033
Brian Salomonbaaf4392017-06-15 09:59:23 -040034std::unique_ptr<GrDrawOp> MakeAAFillWithLocalMatrix(GrPaint&&, const SkMatrix& viewMatrix,
35 const SkMatrix& localMatrix, const SkRect&);
Brian Salomon6a639042016-12-14 11:08:17 -050036
Brian Salomonbaaf4392017-06-15 09:59:23 -040037std::unique_ptr<GrDrawOp> MakeAAFillWithLocalRect(GrPaint&&, const SkMatrix&, const SkRect& rect,
38 const SkRect& localRect);
Brian Salomon6a639042016-12-14 11:08:17 -050039
Brian Salomonbaaf4392017-06-15 09:59:23 -040040/** Non-AA Fill - GrAAType must be either kNone or kMSAA. */
41
42std::unique_ptr<GrDrawOp> MakeNonAAFill(GrPaint&&, const SkMatrix& viewMatrix, const SkRect& rect,
43 GrAAType, const GrUserStencilSettings* = nullptr);
44
45std::unique_ptr<GrDrawOp> MakeNonAAFillWithLocalMatrix(GrPaint&&, const SkMatrix& viewMatrix,
46 const SkMatrix& localMatrix, const SkRect&,
47 GrAAType,
48 const GrUserStencilSettings* = nullptr);
49
50std::unique_ptr<GrDrawOp> MakeNonAAFillWithLocalRect(GrPaint&&, const SkMatrix&, const SkRect& rect,
51 const SkRect& localRect, GrAAType);
52
53/** AA Stroke */
54
55std::unique_ptr<GrDrawOp> MakeAAStroke(GrPaint&&, const SkMatrix&, const SkRect&,
56 const SkStrokeRec&);
57
58// rects[0] == outer rectangle, rects[1] == inner rectangle. Null return means there is nothing to
59// draw rather than failure.
60std::unique_ptr<GrDrawOp> MakeAAFillNestedRects(GrPaint&&, const SkMatrix&, const SkRect rects[2]);
61
62/** Non-AA Stroke - GrAAType must be either kNone or kMSAA. */
63
64std::unique_ptr<GrDrawOp> MakeNonAAStroke(GrPaint&&, const SkMatrix&, const SkRect&,
65 const SkStrokeRec&, GrAAType);
66
67} // namespace GrRectOpFactory
Brian Salomon6a639042016-12-14 11:08:17 -050068
69#endif