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 #include "GrRectOpFactory.h"
9 
10 #include "GrAAStrokeRectOp.h"
11 #include "GrMeshDrawOp.h"
12 #include "SkStrokeRec.h"
13 
14 namespace GrRectOpFactory {
15 
MakeAAFillNestedRects(GrColor color,const SkMatrix & viewMatrix,const SkRect rects[2])16 std::unique_ptr<GrMeshDrawOp> MakeAAFillNestedRects(GrColor color,
17                                                     const SkMatrix& viewMatrix,
18                                                     const SkRect rects[2]) {
19     SkASSERT(viewMatrix.rectStaysRect());
20     SkASSERT(!rects[0].isEmpty() && !rects[1].isEmpty());
21 
22     SkRect devOutside, devInside;
23     viewMatrix.mapRect(&devOutside, rects[0]);
24     viewMatrix.mapRect(&devInside, rects[1]);
25     if (devInside.isEmpty()) {
26         if (devOutside.isEmpty()) {
27             return nullptr;
28         }
29         return GrAAFillRectOp::Make(color, viewMatrix, devOutside, devOutside);
30     }
31 
32     return GrAAStrokeRectOp::MakeFillBetweenRects(color, viewMatrix, devOutside, devInside);
33 }
34 };
35