blob: abad623589e1f734b6c002a4044825cc7e678b1d [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*,
36 const GrContext*,
37 bool useAA,
38 const SkRect& oval,
39 const SkStrokeRec& stroke);
40 bool drawRRect(GrDrawTarget*,
41 GrDrawState*,
42 GrContext*,
43 bool useAA,
44 const SkRRect& rrect,
45 const SkStrokeRec& stroke);
46 bool drawDRRect(GrDrawTarget* target,
47 GrDrawState*,
48 GrContext* context,
49 bool useAA,
50 const SkRRect& outer,
51 const SkRRect& inner);
commit-bot@chromium.orgf2bfd542013-04-25 15:27:00 +000052
commit-bot@chromium.org81312832013-03-22 18:34:09 +000053private:
joshualitt9853cce2014-11-17 14:22:48 -080054 bool drawEllipse(GrDrawTarget* target,
55 GrDrawState*,
56 const GrContext* context,
57 bool useCoverageAA,
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000058 const SkRect& ellipse,
commit-bot@chromium.org81312832013-03-22 18:34:09 +000059 const SkStrokeRec& stroke);
joshualitt9853cce2014-11-17 14:22:48 -080060 bool drawDIEllipse(GrDrawTarget* target,
61 GrDrawState*,
62 const GrContext* context,
63 bool useCoverageAA,
commit-bot@chromium.org5242ed72013-09-05 19:26:51 +000064 const SkRect& ellipse,
65 const SkStrokeRec& stroke);
joshualitt9853cce2014-11-17 14:22:48 -080066 void drawCircle(GrDrawTarget* target,
67 GrDrawState*,
68 const GrContext* context,
69 bool useCoverageAA,
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000070 const SkRect& circle,
commit-bot@chromium.org81312832013-03-22 18:34:09 +000071 const SkStrokeRec& stroke);
72
joshualitt5ead6da2014-10-22 16:00:29 -070073 GrIndexBuffer* rRectIndexBuffer(bool isStrokeOnly, GrGpu* gpu);
skia.committer@gmail.com2cf444f2013-04-26 07:00:58 +000074
commit-bot@chromium.orgf2bfd542013-04-25 15:27:00 +000075 GrIndexBuffer* fRRectIndexBuffer;
joshualitt5ead6da2014-10-22 16:00:29 -070076 GrIndexBuffer* fStrokeRRectIndexBuffer;
skia.committer@gmail.com2cf444f2013-04-26 07:00:58 +000077
commit-bot@chromium.orga4de8c22013-09-09 13:38:37 +000078 typedef SkRefCnt INHERITED;
commit-bot@chromium.org81312832013-03-22 18:34:09 +000079};
80
81#endif // GrOvalRenderer_DEFINED