blob: 85a93549599c1abacc62033d0a1a3c9f256d1ffa [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
joshualitt5ead6da2014-10-22 16:00:29 -070027 GrOvalRenderer() : fRRectIndexBuffer(NULL), fStrokeRRectIndexBuffer(NULL) {}
commit-bot@chromium.orgef284a82013-07-11 22:29:29 +000028 ~GrOvalRenderer() {
29 this->reset();
30 }
31
32 void reset();
commit-bot@chromium.org81312832013-03-22 18:34:09 +000033
joshualitt9853cce2014-11-17 14:22:48 -080034 bool drawOval(GrDrawTarget*,
35 GrDrawState*,
joshualitt2e3b3e32014-12-09 13:31:14 -080036 GrColor,
joshualitt9853cce2014-11-17 14:22:48 -080037 const GrContext*,
38 bool useAA,
39 const SkRect& oval,
40 const SkStrokeRec& stroke);
41 bool drawRRect(GrDrawTarget*,
42 GrDrawState*,
joshualitt2e3b3e32014-12-09 13:31:14 -080043 GrColor,
joshualitt9853cce2014-11-17 14:22:48 -080044 GrContext*,
45 bool useAA,
46 const SkRRect& rrect,
47 const SkStrokeRec& stroke);
48 bool drawDRRect(GrDrawTarget* target,
49 GrDrawState*,
joshualitt2e3b3e32014-12-09 13:31:14 -080050 GrColor,
joshualitt9853cce2014-11-17 14:22:48 -080051 GrContext* context,
52 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 const GrContext* context,
61 bool useCoverageAA,
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000062 const SkRect& ellipse,
commit-bot@chromium.org81312832013-03-22 18:34:09 +000063 const SkStrokeRec& stroke);
joshualitt9853cce2014-11-17 14:22:48 -080064 bool drawDIEllipse(GrDrawTarget* target,
65 GrDrawState*,
joshualitt2e3b3e32014-12-09 13:31:14 -080066 GrColor,
joshualitt9853cce2014-11-17 14:22:48 -080067 const GrContext* context,
68 bool useCoverageAA,
commit-bot@chromium.org5242ed72013-09-05 19:26:51 +000069 const SkRect& ellipse,
70 const SkStrokeRec& stroke);
joshualitt9853cce2014-11-17 14:22:48 -080071 void drawCircle(GrDrawTarget* target,
72 GrDrawState*,
joshualitt2e3b3e32014-12-09 13:31:14 -080073 GrColor,
joshualitt9853cce2014-11-17 14:22:48 -080074 const GrContext* context,
75 bool useCoverageAA,
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000076 const SkRect& circle,
commit-bot@chromium.org81312832013-03-22 18:34:09 +000077 const SkStrokeRec& stroke);
78
joshualitt5ead6da2014-10-22 16:00:29 -070079 GrIndexBuffer* rRectIndexBuffer(bool isStrokeOnly, GrGpu* gpu);
skia.committer@gmail.com2cf444f2013-04-26 07:00:58 +000080
commit-bot@chromium.orgf2bfd542013-04-25 15:27:00 +000081 GrIndexBuffer* fRRectIndexBuffer;
joshualitt5ead6da2014-10-22 16:00:29 -070082 GrIndexBuffer* fStrokeRRectIndexBuffer;
skia.committer@gmail.com2cf444f2013-04-26 07:00:58 +000083
commit-bot@chromium.orga4de8c22013-09-09 13:38:37 +000084 typedef SkRefCnt INHERITED;
commit-bot@chromium.org81312832013-03-22 18:34:09 +000085};
86
87#endif // GrOvalRenderer_DEFINED