blob: 5a43a342143eb3a7fe223f2ffccebf8e6aa1ca33 [file] [log] [blame]
joshualittecd1a692015-08-10 10:08:26 -07001/*
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 GrRectBatchFactory_DEFINED
9#define GrRectBatchFactory_DEFINED
10
joshualitt37eb1842015-08-12 06:36:57 -070011#include "GrAAFillRectBatch.h"
joshualitt9c80b5f2015-08-13 10:05:51 -070012#include "GrBWFillRectBatch.h"
joshualittecd1a692015-08-10 10:08:26 -070013#include "GrColor.h"
14
15class GrBatch;
16class SkMatrix;
17struct SkRect;
joshualitt14205b12015-08-10 11:40:56 -070018class SkStrokeRec;
joshualittecd1a692015-08-10 10:08:26 -070019
20/*
joshualitt14205b12015-08-10 11:40:56 -070021 * A factory for returning batches which can draw rectangles.
joshualittecd1a692015-08-10 10:08:26 -070022 */
23namespace GrRectBatchFactory {
24
bsalomonabd30f52015-08-13 13:34:48 -070025inline GrDrawBatch* CreateFillBW(GrColor color,
joshualitt0d4bcea2015-08-17 06:59:36 -070026 const SkMatrix& viewMatrix,
27 const SkRect& rect,
28 const SkRect* localRect,
29 const SkMatrix* localMatrix) {
joshualitt9c80b5f2015-08-13 10:05:51 -070030 return GrBWFillRectBatch::Create(color, viewMatrix, rect, localRect, localMatrix);
31}
joshualitt7fc2a262015-08-10 10:30:14 -070032
bsalomonabd30f52015-08-13 13:34:48 -070033inline GrDrawBatch* CreateFillAA(GrColor color,
34 const SkMatrix& viewMatrix,
35 const SkRect& rect,
36 const SkRect& devRect) {
joshualitt37eb1842015-08-12 06:36:57 -070037 return GrAAFillRectBatch::Create(color, viewMatrix, rect, devRect);
38}
joshualitt14205b12015-08-10 11:40:56 -070039
joshualitt0d4bcea2015-08-17 06:59:36 -070040inline GrDrawBatch* CreateFillAA(GrColor color,
41 const SkMatrix& viewMatrix,
42 const SkMatrix& localMatrix,
43 const SkRect& rect,
44 const SkRect& devRect) {
45 return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRect);
46}
47
bsalomonabd30f52015-08-13 13:34:48 -070048GrDrawBatch* CreateStrokeBW(GrColor color,
49 const SkMatrix& viewMatrix,
50 const SkRect& rect,
51 SkScalar strokeWidth,
52 bool snapToPixelCenters);
joshualittecd1a692015-08-10 10:08:26 -070053
bsalomonabd30f52015-08-13 13:34:48 -070054GrDrawBatch* CreateStrokeAA(GrColor,
55 const SkMatrix& viewMatrix,
56 const SkRect& rect,
57 const SkRect& devRect,
58 const SkStrokeRec& stroke);
joshualitt14205b12015-08-10 11:40:56 -070059
60// First rect is outer; second rect is inner
bsalomonabd30f52015-08-13 13:34:48 -070061GrDrawBatch* CreateFillNestedRectsAA(GrColor,
62 const SkMatrix& viewMatrix,
63 const SkRect rects[2]);
joshualitt14205b12015-08-10 11:40:56 -070064
joshualittecd1a692015-08-10 10:08:26 -070065};
66
67#endif