Line data Source code
1 : /*
2 : * Copyright 2015 Google Inc.
3 : *
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 :
11 : #include "GrAAFillRectOp.h"
12 : #include "GrAAStrokeRectOp.h"
13 : #include "GrAnalyticRectOp.h"
14 : #include "GrColor.h"
15 : #include "GrMeshDrawOp.h"
16 : #include "GrNonAAFillRectOp.h"
17 : #include "GrNonAAStrokeRectOp.h"
18 : #include "GrPaint.h"
19 : #include "SkMatrix.h"
20 : #include "SkRefCnt.h"
21 :
22 : struct SkRect;
23 : class SkStrokeRec;
24 :
25 : /**
26 : * A factory for returning GrDrawOps which can draw rectangles.
27 : */
28 : namespace GrRectOpFactory {
29 :
30 0 : inline std::unique_ptr<GrLegacyMeshDrawOp> MakeNonAAFill(GrColor color,
31 : const SkMatrix& viewMatrix,
32 : const SkRect& rect,
33 : const SkRect* localRect,
34 : const SkMatrix* localMatrix) {
35 0 : if (viewMatrix.hasPerspective() || (localMatrix && localMatrix->hasPerspective())) {
36 : return GrNonAAFillRectOp::MakeWithPerspective(color, viewMatrix, rect, localRect,
37 0 : localMatrix);
38 : } else {
39 0 : return GrNonAAFillRectOp::Make(color, viewMatrix, rect, localRect, localMatrix);
40 : }
41 : }
42 :
43 0 : inline std::unique_ptr<GrLegacyMeshDrawOp> MakeAAFill(const GrPaint& paint,
44 : const SkMatrix& viewMatrix,
45 : const SkRect& rect,
46 : const SkRect& croppedRect,
47 : const SkRect& devRect) {
48 0 : if (!paint.usesDistanceVectorField()) {
49 0 : return GrAAFillRectOp::Make(paint.getColor(), viewMatrix, croppedRect, devRect);
50 : } else {
51 0 : return GrAnalyticRectOp::Make(paint.getColor(), viewMatrix, rect, croppedRect, devRect);
52 : }
53 : }
54 :
55 : inline std::unique_ptr<GrLegacyMeshDrawOp> MakeAAFill(GrColor color,
56 : const SkMatrix& viewMatrix,
57 : const SkMatrix& localMatrix,
58 : const SkRect& rect,
59 : const SkRect& devRect) {
60 : return GrAAFillRectOp::Make(color, viewMatrix, localMatrix, rect, devRect);
61 : }
62 :
63 0 : inline std::unique_ptr<GrLegacyMeshDrawOp> MakeNonAAStroke(GrColor color,
64 : const SkMatrix& viewMatrix,
65 : const SkRect& rect,
66 : const SkStrokeRec& strokeRec,
67 : bool snapToPixelCenters) {
68 0 : return GrNonAAStrokeRectOp::Make(color, viewMatrix, rect, strokeRec, snapToPixelCenters);
69 : }
70 :
71 0 : inline std::unique_ptr<GrLegacyMeshDrawOp> MakeAAStroke(GrColor color,
72 : const SkMatrix& viewMatrix,
73 : const SkRect& rect,
74 : const SkStrokeRec& stroke) {
75 0 : return GrAAStrokeRectOp::Make(color, viewMatrix, rect, stroke);
76 : }
77 :
78 : // First rect is outer; second rect is inner
79 : std::unique_ptr<GrLegacyMeshDrawOp> MakeAAFillNestedRects(GrColor, const SkMatrix& viewMatrix,
80 : const SkRect rects[2]);
81 : };
82 :
83 : #endif
|