blob: c67815c451b9df103c500ce27f6e49edbedc02c5 [file] [log] [blame]
commit-bot@chromium.org81312832013-03-22 18:34:09 +00001/*
2 * Copyright 2013 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
commit-bot@chromium.org81312832013-03-22 18:34:09 +00008#ifndef GrOvalRenderer_DEFINED
9#define GrOvalRenderer_DEFINED
10
11#include "GrContext.h"
12#include "GrPaint.h"
commit-bot@chromium.org81312832013-03-22 18:34:09 +000013
14class GrContext;
15class GrDrawTarget;
16class GrPaint;
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000017struct SkRect;
commit-bot@chromium.org81312832013-03-22 18:34:09 +000018class SkStrokeRec;
19
20/*
commit-bot@chromium.orgf2bfd542013-04-25 15:27:00 +000021 * This class wraps helper functions that draw ovals and roundrects (filled & stroked)
commit-bot@chromium.org81312832013-03-22 18:34:09 +000022 */
commit-bot@chromium.orga4de8c22013-09-09 13:38:37 +000023class GrOvalRenderer : public SkRefCnt {
commit-bot@chromium.org81312832013-03-22 18:34:09 +000024public:
25 SK_DECLARE_INST_COUNT(GrOvalRenderer)
26
joshualitt5531d512014-12-17 15:50:11 -080027 GrOvalRenderer(GrGpu* gpu)
28 : fGpu(gpu)
29 , fRRectIndexBuffer(NULL)
30 , fStrokeRRectIndexBuffer(NULL) {}
commit-bot@chromium.orgef284a82013-07-11 22:29:29 +000031 ~GrOvalRenderer() {
32 this->reset();
33 }
34
35 void reset();
commit-bot@chromium.org81312832013-03-22 18:34:09 +000036
joshualitt9853cce2014-11-17 14:22:48 -080037 bool drawOval(GrDrawTarget*,
38 GrDrawState*,
joshualitt2e3b3e32014-12-09 13:31:14 -080039 GrColor,
joshualitt9853cce2014-11-17 14:22:48 -080040 bool useAA,
41 const SkRect& oval,
42 const SkStrokeRec& stroke);
43 bool drawRRect(GrDrawTarget*,
44 GrDrawState*,
joshualitt2e3b3e32014-12-09 13:31:14 -080045 GrColor,
joshualitt9853cce2014-11-17 14:22:48 -080046 bool useAA,
47 const SkRRect& rrect,
48 const SkStrokeRec& stroke);
49 bool drawDRRect(GrDrawTarget* target,
50 GrDrawState*,
joshualitt2e3b3e32014-12-09 13:31:14 -080051 GrColor,
joshualitt9853cce2014-11-17 14:22:48 -080052 bool useAA,
53 const SkRRect& outer,
54 const SkRRect& inner);
commit-bot@chromium.orgf2bfd542013-04-25 15:27:00 +000055
commit-bot@chromium.org81312832013-03-22 18:34:09 +000056private:
joshualitt9853cce2014-11-17 14:22:48 -080057 bool drawEllipse(GrDrawTarget* target,
58 GrDrawState*,
joshualitt2e3b3e32014-12-09 13:31:14 -080059 GrColor,
joshualitt9853cce2014-11-17 14:22:48 -080060 bool useCoverageAA,
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000061 const SkRect& ellipse,
commit-bot@chromium.org81312832013-03-22 18:34:09 +000062 const SkStrokeRec& stroke);
joshualitt9853cce2014-11-17 14:22:48 -080063 bool drawDIEllipse(GrDrawTarget* target,
64 GrDrawState*,
joshualitt2e3b3e32014-12-09 13:31:14 -080065 GrColor,
joshualitt9853cce2014-11-17 14:22:48 -080066 bool useCoverageAA,
commit-bot@chromium.org5242ed72013-09-05 19:26:51 +000067 const SkRect& ellipse,
68 const SkStrokeRec& stroke);
joshualitt9853cce2014-11-17 14:22:48 -080069 void drawCircle(GrDrawTarget* target,
70 GrDrawState*,
joshualitt2e3b3e32014-12-09 13:31:14 -080071 GrColor,
joshualitt9853cce2014-11-17 14:22:48 -080072 bool useCoverageAA,
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000073 const SkRect& circle,
commit-bot@chromium.org81312832013-03-22 18:34:09 +000074 const SkStrokeRec& stroke);
75
joshualitt5531d512014-12-17 15:50:11 -080076 GrIndexBuffer* rRectIndexBuffer(bool isStrokeOnly);
skia.committer@gmail.com2cf444f2013-04-26 07:00:58 +000077
joshualitt5531d512014-12-17 15:50:11 -080078 GrGpu* fGpu;
commit-bot@chromium.orgf2bfd542013-04-25 15:27:00 +000079 GrIndexBuffer* fRRectIndexBuffer;
joshualitt5ead6da2014-10-22 16:00:29 -070080 GrIndexBuffer* fStrokeRRectIndexBuffer;
skia.committer@gmail.com2cf444f2013-04-26 07:00:58 +000081
commit-bot@chromium.orga4de8c22013-09-09 13:38:37 +000082 typedef SkRefCnt INHERITED;
commit-bot@chromium.org81312832013-03-22 18:34:09 +000083};
84
85#endif // GrOvalRenderer_DEFINED