blob: 84dd52fe94743616ad891e60deb93de639c4bb9c [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;
robertphillips@google.comdf3695e2013-04-09 14:01:44 +000018class SkMatrix;
robertphillips@google.comf6747b02012-06-12 00:32:28 +000019
20/*
21 * This class wraps helper functions that draw AA rects (filled & stroked)
22 */
23class GrAARectRenderer : public GrRefCnt {
24public:
robertphillips@google.com4d73ac22012-06-13 18:54:08 +000025 SK_DECLARE_INST_COUNT(GrAARectRenderer)
robertphillips@google.comf6747b02012-06-12 00:32:28 +000026
rmistry@google.comfbfcd562012-08-23 18:09:54 +000027 GrAARectRenderer()
robertphillips@google.comf6747b02012-06-12 00:32:28 +000028 : fAAFillRectIndexBuffer(NULL)
29 , fAAStrokeRectIndexBuffer(NULL) {
30 }
31
32 void reset();
33
34 ~GrAARectRenderer() {
35 this->reset();
36 }
37
38 // TODO: potentialy fuse the fill & stroke methods and differentiate
robertphillips@google.comdf3695e2013-04-09 14:01:44 +000039 // between them by passing in strokeWidth (<0 means fill).
robertphillips@google.comf6747b02012-06-12 00:32:28 +000040
41 // TODO: Remove the useVertexCoverage boolean. Just use it all the time
42 // since we now have a coverage vertex attribute
43 void fillAARect(GrGpu* gpu,
44 GrDrawTarget* target,
45 const GrRect& devRect,
46 bool useVertexCoverage);
47
robertphillips@google.comdf3695e2013-04-09 14:01:44 +000048 void shaderFillAARect(GrGpu* gpu,
49 GrDrawTarget* target,
50 const GrRect& rect,
51 const SkMatrix& combinedMatrix,
52 const GrRect& devRect,
53 bool useVertexCoverage);
54
robertphillips@google.comf6747b02012-06-12 00:32:28 +000055 void strokeAARect(GrGpu* gpu,
56 GrDrawTarget* target,
57 const GrRect& devRect,
58 const GrVec& devStrokeSize,
59 bool useVertexCoverage);
60
61private:
62 GrIndexBuffer* fAAFillRectIndexBuffer;
63 GrIndexBuffer* fAAStrokeRectIndexBuffer;
64
robertphillips@google.comf6747b02012-06-12 00:32:28 +000065 GrIndexBuffer* aaFillRectIndexBuffer(GrGpu* gpu);
66
67 static int aaStrokeRectIndexCount();
68 GrIndexBuffer* aaStrokeRectIndexBuffer(GrGpu* gpu);
robertphillips@google.com4d73ac22012-06-13 18:54:08 +000069
70 typedef GrRefCnt INHERITED;
robertphillips@google.comf6747b02012-06-12 00:32:28 +000071};
72
73#endif // GrAARectRenderer_DEFINED