blob: 0cf7faac05ea0b2bfa0eb3a32d45cb9eb1481f48 [file] [log] [blame]
robertphillips@google.comf6747b02012-06-12 00:32:28 +00001/*
2 * Copyright 2012 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
9#ifndef GrAARectRenderer_DEFINED
10#define GrAARectRenderer_DEFINED
11
12#include "GrRect.h"
13#include "GrRefCnt.h"
14
15class GrGpu;
16class GrDrawTarget;
17class GrIndexBuffer;
18
19/*
20 * This class wraps helper functions that draw AA rects (filled & stroked)
21 */
22class GrAARectRenderer : public GrRefCnt {
23public:
robertphillips@google.com4d73ac22012-06-13 18:54:08 +000024 SK_DECLARE_INST_COUNT(GrAARectRenderer)
robertphillips@google.comf6747b02012-06-12 00:32:28 +000025
rmistry@google.comfbfcd562012-08-23 18:09:54 +000026 GrAARectRenderer()
robertphillips@google.comf6747b02012-06-12 00:32:28 +000027 : fAAFillRectIndexBuffer(NULL)
28 , fAAStrokeRectIndexBuffer(NULL) {
29 }
30
31 void reset();
32
33 ~GrAARectRenderer() {
34 this->reset();
35 }
36
37 // TODO: potentialy fuse the fill & stroke methods and differentiate
38 // btween them by passing in strokeWidth (<0 means fill).
39
40 // TODO: Remove the useVertexCoverage boolean. Just use it all the time
41 // since we now have a coverage vertex attribute
42 void fillAARect(GrGpu* gpu,
43 GrDrawTarget* target,
44 const GrRect& devRect,
45 bool useVertexCoverage);
46
47 void strokeAARect(GrGpu* gpu,
48 GrDrawTarget* target,
49 const GrRect& devRect,
50 const GrVec& devStrokeSize,
51 bool useVertexCoverage);
52
53private:
54 GrIndexBuffer* fAAFillRectIndexBuffer;
55 GrIndexBuffer* fAAStrokeRectIndexBuffer;
56
robertphillips@google.comf6747b02012-06-12 00:32:28 +000057 GrIndexBuffer* aaFillRectIndexBuffer(GrGpu* gpu);
58
59 static int aaStrokeRectIndexCount();
60 GrIndexBuffer* aaStrokeRectIndexBuffer(GrGpu* gpu);
robertphillips@google.com4d73ac22012-06-13 18:54:08 +000061
62 typedef GrRefCnt INHERITED;
robertphillips@google.comf6747b02012-06-12 00:32:28 +000063};
64
65#endif // GrAARectRenderer_DEFINED