Revert of Oval and stroke AA rect now batch (patchset #7 id:110001 of https://codereview.chromium.org/664193002/)

Reason for revert:
whoops, accidental commit

Original issue's description:
> Oval and stroke AA rect now batch
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/bc54fab1a4e5b51628a8c1557c62bc74e078870d
>
> Committed: https://skia.googlesource.com/skia/+/18055afb838a278b5a8436cd51dbfbb688e1e0a0

TBR=robertphillips@google.com,bsalomon@google.com,joshualitt@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review URL: https://codereview.chromium.org/675623002
This commit is contained in:
joshualitt 2014-10-22 15:51:52 -07:00 committed by Commit bot
parent 18055afb83
commit 67f7f74fb2
8 changed files with 279 additions and 251 deletions

View File

@ -85,22 +85,3 @@ spritebitmap
testimagefilters testimagefilters
tileimagefilter tileimagefilter
xfermodeimagefilter xfermodeimagefilter
# joshualitt batching oval renderer and AA rect
testimagefilters
strokes_round
rrect
ovals
mixed_xfermodes
hairmodes
circles
blurs
aarectmodes
peekpixels
shadows
stroke-fill
srcmode_gpu
rrect_draw_aa
twopointconical
image-surface

View File

@ -21,9 +21,12 @@
#include "effects/GrBezierEffect.h" #include "effects/GrBezierEffect.h"
namespace {
// quadratics are rendered as 5-sided polys in order to bound the // quadratics are rendered as 5-sided polys in order to bound the
// AA stroke around the center-curve. See comments in push_quad_index_buffer and // AA stroke around the center-curve. See comments in push_quad_index_buffer and
// bloat_quad. Quadratics and conics share an index buffer // bloat_quad. Quadratics and conics share an index buffer
static const int kVertsPerQuad = 5;
static const int kIdxsPerQuad = 9;
// lines are rendered as: // lines are rendered as:
// *______________* // *______________*
@ -33,66 +36,127 @@
// | / ______/ \ | // | / ______/ \ |
// */_-__________\* // */_-__________\*
// For: 6 vertices and 18 indices (for 6 triangles) // For: 6 vertices and 18 indices (for 6 triangles)
static const int kVertsPerLineSeg = 6;
static const int kIdxsPerLineSeg = 18;
// Each quadratic is rendered as a five sided polygon. This poly bounds static const int kNumQuadsInIdxBuffer = 256;
// the quadratic's bounding triangle but has been expanded so that the static const size_t kQuadIdxSBufize = kIdxsPerQuad *
// 1-pixel wide area around the curve is inside the poly. sizeof(uint16_t) *
// If a,b,c are the original control points then the poly a0,b0,c0,c1,a1 kNumQuadsInIdxBuffer;
// that is rendered would look like this:
// b0
// b
//
// a0 c0
// a c
// a1 c1
// Each is drawn as three triangles specified by these 9 indices:
static const uint16_t kQuadIdxBufPattern[] = {
0, 1, 2,
2, 4, 3,
1, 4, 2
};
static const int kIdxsPerQuad = SK_ARRAY_COUNT(kQuadIdxBufPattern); static const int kNumLineSegsInIdxBuffer = 256;
static const int kQuadNumVertices = 5; static const size_t kLineSegIdxSBufize = kIdxsPerLineSeg *
static const int kQuadsNumInIdxBuffer = 256; sizeof(uint16_t) *
kNumLineSegsInIdxBuffer;
static bool push_quad_index_data(GrIndexBuffer* qIdxBuffer) {
uint16_t* data = (uint16_t*) qIdxBuffer->map();
bool tempData = NULL == data;
if (tempData) {
data = SkNEW_ARRAY(uint16_t, kNumQuadsInIdxBuffer * kIdxsPerQuad);
}
for (int i = 0; i < kNumQuadsInIdxBuffer; ++i) {
// Each line segment is rendered as two quads and two triangles. // Each quadratic is rendered as a five sided polygon. This poly bounds
// p0 and p1 have alpha = 1 while all other points have alpha = 0. // the quadratic's bounding triangle but has been expanded so that the
// The four external points are offset 1 pixel perpendicular to the // 1-pixel wide area around the curve is inside the poly.
// line and half a pixel parallel to the line. // If a,b,c are the original control points then the poly a0,b0,c0,c1,a1
// // that is rendered would look like this:
// p4 p5 // b0
// p0 p1 // b
// p2 p3 //
// // a0 c0
// Each is drawn as six triangles specified by these 18 indices: // a c
// a1 c1
// Each is drawn as three triangles specified by these 9 indices:
int baseIdx = i * kIdxsPerQuad;
uint16_t baseVert = (uint16_t)(i * kVertsPerQuad);
data[0 + baseIdx] = baseVert + 0; // a0
data[1 + baseIdx] = baseVert + 1; // a1
data[2 + baseIdx] = baseVert + 2; // b0
data[3 + baseIdx] = baseVert + 2; // b0
data[4 + baseIdx] = baseVert + 4; // c1
data[5 + baseIdx] = baseVert + 3; // c0
data[6 + baseIdx] = baseVert + 1; // a1
data[7 + baseIdx] = baseVert + 4; // c1
data[8 + baseIdx] = baseVert + 2; // b0
}
if (tempData) {
bool ret = qIdxBuffer->updateData(data, kQuadIdxSBufize);
delete[] data;
return ret;
} else {
qIdxBuffer->unmap();
return true;
}
}
static const uint16_t kLineSegIdxBufPattern[] = { static bool push_line_index_data(GrIndexBuffer* lIdxBuffer) {
0, 1, 3, uint16_t* data = (uint16_t*) lIdxBuffer->map();
0, 3, 2, bool tempData = NULL == data;
0, 4, 5, if (tempData) {
0, 5, 1, data = SkNEW_ARRAY(uint16_t, kNumLineSegsInIdxBuffer * kIdxsPerLineSeg);
0, 2, 4, }
1, 5, 3 for (int i = 0; i < kNumLineSegsInIdxBuffer; ++i) {
}; // Each line segment is rendered as two quads and two triangles.
// p0 and p1 have alpha = 1 while all other points have alpha = 0.
// The four external points are offset 1 pixel perpendicular to the
// line and half a pixel parallel to the line.
//
// p4 p5
// p0 p1
// p2 p3
//
// Each is drawn as six triangles specified by these 18 indices:
int baseIdx = i * kIdxsPerLineSeg;
uint16_t baseVert = (uint16_t)(i * kVertsPerLineSeg);
data[0 + baseIdx] = baseVert + 0;
data[1 + baseIdx] = baseVert + 1;
data[2 + baseIdx] = baseVert + 3;
static const int kIdxsPerLineSeg = SK_ARRAY_COUNT(kLineSegIdxBufPattern); data[3 + baseIdx] = baseVert + 0;
static const int kLineSegNumVertices = 6; data[4 + baseIdx] = baseVert + 3;
static const int kLineSegsNumInIdxBuffer = 256; data[5 + baseIdx] = baseVert + 2;
data[6 + baseIdx] = baseVert + 0;
data[7 + baseIdx] = baseVert + 4;
data[8 + baseIdx] = baseVert + 5;
data[9 + baseIdx] = baseVert + 0;
data[10+ baseIdx] = baseVert + 5;
data[11+ baseIdx] = baseVert + 1;
data[12 + baseIdx] = baseVert + 0;
data[13 + baseIdx] = baseVert + 2;
data[14 + baseIdx] = baseVert + 4;
data[15 + baseIdx] = baseVert + 1;
data[16 + baseIdx] = baseVert + 5;
data[17 + baseIdx] = baseVert + 3;
}
if (tempData) {
bool ret = lIdxBuffer->updateData(data, kLineSegIdxSBufize);
delete[] data;
return ret;
} else {
lIdxBuffer->unmap();
return true;
}
}
}
GrPathRenderer* GrAAHairLinePathRenderer::Create(GrContext* context) { GrPathRenderer* GrAAHairLinePathRenderer::Create(GrContext* context) {
GrGpu* gpu = context->getGpu(); GrGpu* gpu = context->getGpu();
GrIndexBuffer* qIdxBuf = gpu->createInstancedIndexBuffer(kQuadIdxBufPattern, GrIndexBuffer* qIdxBuf = gpu->createIndexBuffer(kQuadIdxSBufize, false);
kIdxsPerQuad,
kQuadsNumInIdxBuffer,
kQuadNumVertices);
SkAutoTUnref<GrIndexBuffer> qIdxBuffer(qIdxBuf); SkAutoTUnref<GrIndexBuffer> qIdxBuffer(qIdxBuf);
GrIndexBuffer* lIdxBuf = gpu->createInstancedIndexBuffer(kLineSegIdxBufPattern, if (NULL == qIdxBuf || !push_quad_index_data(qIdxBuf)) {
kIdxsPerLineSeg, return NULL;
kLineSegsNumInIdxBuffer, }
kLineSegNumVertices); GrIndexBuffer* lIdxBuf = gpu->createIndexBuffer(kLineSegIdxSBufize, false);
SkAutoTUnref<GrIndexBuffer> lIdxBuffer(lIdxBuf); SkAutoTUnref<GrIndexBuffer> lIdxBuffer(lIdxBuf);
if (NULL == lIdxBuf || !push_line_index_data(lIdxBuf)) {
return NULL;
}
return SkNEW_ARGS(GrAAHairLinePathRenderer, return SkNEW_ARGS(GrAAHairLinePathRenderer,
(context, lIdxBuf, qIdxBuf)); (context, lIdxBuf, qIdxBuf));
} }
@ -461,14 +525,14 @@ void intersect_lines(const SkPoint& ptA, const SkVector& normA,
result->fY = SkScalarMul(result->fY, wInv); result->fY = SkScalarMul(result->fY, wInv);
} }
void set_uv_quad(const SkPoint qpts[3], BezierVertex verts[kQuadNumVertices]) { void set_uv_quad(const SkPoint qpts[3], BezierVertex verts[kVertsPerQuad]) {
// this should be in the src space, not dev coords, when we have perspective // this should be in the src space, not dev coords, when we have perspective
GrPathUtils::QuadUVMatrix DevToUV(qpts); GrPathUtils::QuadUVMatrix DevToUV(qpts);
DevToUV.apply<kQuadNumVertices, sizeof(BezierVertex), sizeof(SkPoint)>(verts); DevToUV.apply<kVertsPerQuad, sizeof(BezierVertex), sizeof(SkPoint)>(verts);
} }
void bloat_quad(const SkPoint qpts[3], const SkMatrix* toDevice, void bloat_quad(const SkPoint qpts[3], const SkMatrix* toDevice,
const SkMatrix* toSrc, BezierVertex verts[kQuadNumVertices], const SkMatrix* toSrc, BezierVertex verts[kVertsPerQuad],
SkRect* devBounds) { SkRect* devBounds) {
SkASSERT(!toDevice == !toSrc); SkASSERT(!toDevice == !toSrc);
// original quad is specified by tri a,b,c // original quad is specified by tri a,b,c
@ -534,10 +598,10 @@ void bloat_quad(const SkPoint qpts[3], const SkMatrix* toDevice,
c1.fPos -= cbN; c1.fPos -= cbN;
intersect_lines(a0.fPos, abN, c0.fPos, cbN, &b0.fPos); intersect_lines(a0.fPos, abN, c0.fPos, cbN, &b0.fPos);
devBounds->growToInclude(&verts[0].fPos, sizeof(BezierVertex), kQuadNumVertices); devBounds->growToInclude(&verts[0].fPos, sizeof(BezierVertex), kVertsPerQuad);
if (toSrc) { if (toSrc) {
toSrc->mapPointsWithStride(&verts[0].fPos, sizeof(BezierVertex), kQuadNumVertices); toSrc->mapPointsWithStride(&verts[0].fPos, sizeof(BezierVertex), kVertsPerQuad);
} }
} }
@ -548,13 +612,13 @@ void bloat_quad(const SkPoint qpts[3], const SkMatrix* toDevice,
// f(x, y, w) = f(P) = K^2 - LM // f(x, y, w) = f(P) = K^2 - LM
// K = dot(k, P), L = dot(l, P), M = dot(m, P) // K = dot(k, P), L = dot(l, P), M = dot(m, P)
// k, l, m are calculated in function GrPathUtils::getConicKLM // k, l, m are calculated in function GrPathUtils::getConicKLM
void set_conic_coeffs(const SkPoint p[3], BezierVertex verts[kQuadNumVertices], void set_conic_coeffs(const SkPoint p[3], BezierVertex verts[kVertsPerQuad],
const SkScalar weight) { const SkScalar weight) {
SkScalar klm[9]; SkScalar klm[9];
GrPathUtils::getConicKLM(p, weight, klm); GrPathUtils::getConicKLM(p, weight, klm);
for (int i = 0; i < kQuadNumVertices; ++i) { for (int i = 0; i < kVertsPerQuad; ++i) {
const SkPoint pnt = verts[i].fPos; const SkPoint pnt = verts[i].fPos;
verts[i].fConic.fK = pnt.fX * klm[0] + pnt.fY * klm[1] + klm[2]; verts[i].fConic.fK = pnt.fX * klm[0] + pnt.fY * klm[1] + klm[2];
verts[i].fConic.fL = pnt.fX * klm[3] + pnt.fY * klm[4] + klm[5]; verts[i].fConic.fL = pnt.fX * klm[3] + pnt.fY * klm[4] + klm[5];
@ -570,7 +634,7 @@ void add_conics(const SkPoint p[3],
SkRect* devBounds) { SkRect* devBounds) {
bloat_quad(p, toDevice, toSrc, *vert, devBounds); bloat_quad(p, toDevice, toSrc, *vert, devBounds);
set_conic_coeffs(p, *vert, weight); set_conic_coeffs(p, *vert, weight);
*vert += kQuadNumVertices; *vert += kVertsPerQuad;
} }
void add_quads(const SkPoint p[3], void add_quads(const SkPoint p[3],
@ -588,7 +652,7 @@ void add_quads(const SkPoint p[3],
} else { } else {
bloat_quad(p, toDevice, toSrc, *vert, devBounds); bloat_quad(p, toDevice, toSrc, *vert, devBounds);
set_uv_quad(p, *vert); set_uv_quad(p, *vert);
*vert += kQuadNumVertices; *vert += kVertsPerQuad;
} }
} }
@ -623,16 +687,16 @@ void add_line(const SkPoint p[2],
if (toSrc) { if (toSrc) {
toSrc->mapPointsWithStride(&(*vert)->fPos, toSrc->mapPointsWithStride(&(*vert)->fPos,
sizeof(LineVertex), sizeof(LineVertex),
kLineSegNumVertices); kVertsPerLineSeg);
} }
} else { } else {
// just make it degenerate and likely offscreen // just make it degenerate and likely offscreen
for (int i = 0; i < kLineSegNumVertices; ++i) { for (int i = 0; i < kVertsPerLineSeg; ++i) {
(*vert)[i].fPos.set(SK_ScalarMax, SK_ScalarMax); (*vert)[i].fPos.set(SK_ScalarMax, SK_ScalarMax);
} }
} }
*vert += kLineSegNumVertices; *vert += kVertsPerLineSeg;
} }
} }
@ -665,7 +729,7 @@ bool GrAAHairLinePathRenderer::createLineGeom(const SkPath& path,
const SkMatrix& viewM = drawState->getViewMatrix(); const SkMatrix& viewM = drawState->getViewMatrix();
int vertCnt = kLineSegNumVertices * lineCnt; int vertCnt = kVertsPerLineSeg * lineCnt;
drawState->setVertexAttribs<gHairlineLineAttribs>(SK_ARRAY_COUNT(gHairlineLineAttribs), drawState->setVertexAttribs<gHairlineLineAttribs>(SK_ARRAY_COUNT(gHairlineLineAttribs),
sizeof(LineVertex)); sizeof(LineVertex));
@ -712,7 +776,7 @@ bool GrAAHairLinePathRenderer::createBezierGeom(
const SkMatrix& viewM = drawState->getViewMatrix(); const SkMatrix& viewM = drawState->getViewMatrix();
int vertCnt = kQuadNumVertices * quadCnt + kQuadNumVertices * conicCnt; int vertCnt = kVertsPerQuad * quadCnt + kVertsPerQuad * conicCnt;
int vAttribCnt = SK_ARRAY_COUNT(gHairlineBezierAttribs); int vAttribCnt = SK_ARRAY_COUNT(gHairlineBezierAttribs);
target->drawState()->setVertexAttribs<gHairlineBezierAttribs>(vAttribCnt, sizeof(BezierVertex)); target->drawState()->setVertexAttribs<gHairlineBezierAttribs>(vAttribCnt, sizeof(BezierVertex));
@ -878,19 +942,19 @@ bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path,
// Check devBounds // Check devBounds
SkASSERT(check_bounds<LineVertex>(drawState, devBounds, arg.vertices(), SkASSERT(check_bounds<LineVertex>(drawState, devBounds, arg.vertices(),
kLineSegNumVertices * lineCnt)); kVertsPerLineSeg * lineCnt));
{ {
GrDrawState::AutoRestoreEffects are(drawState); GrDrawState::AutoRestoreEffects are(drawState);
target->setIndexSourceToBuffer(fLinesIndexBuffer); target->setIndexSourceToBuffer(fLinesIndexBuffer);
int lines = 0; int lines = 0;
while (lines < lineCnt) { while (lines < lineCnt) {
int n = SkTMin(lineCnt - lines, kLineSegsNumInIdxBuffer); int n = SkTMin(lineCnt - lines, kNumLineSegsInIdxBuffer);
target->drawIndexed(kTriangles_GrPrimitiveType, target->drawIndexed(kTriangles_GrPrimitiveType,
kLineSegNumVertices*lines, // startV kVertsPerLineSeg*lines, // startV
0, // startI 0, // startI
kLineSegNumVertices*n, // vCount kVertsPerLineSeg*n, // vCount
kIdxsPerLineSeg*n, // iCount kIdxsPerLineSeg*n, // iCount
&devBounds); &devBounds);
lines += n; lines += n;
} }
@ -928,7 +992,7 @@ bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path,
// Check devBounds // Check devBounds
SkASSERT(check_bounds<BezierVertex>(drawState, devBounds, arg.vertices(), SkASSERT(check_bounds<BezierVertex>(drawState, devBounds, arg.vertices(),
kQuadNumVertices * quadCnt + kQuadNumVertices * conicCnt)); kVertsPerQuad * quadCnt + kVertsPerQuad * conicCnt));
if (quadCnt > 0) { if (quadCnt > 0) {
GrGeometryProcessor* hairQuadProcessor = GrGeometryProcessor* hairQuadProcessor =
@ -939,12 +1003,12 @@ bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path,
drawState->setGeometryProcessor(hairQuadProcessor)->unref(); drawState->setGeometryProcessor(hairQuadProcessor)->unref();
int quads = 0; int quads = 0;
while (quads < quadCnt) { while (quads < quadCnt) {
int n = SkTMin(quadCnt - quads, kQuadsNumInIdxBuffer); int n = SkTMin(quadCnt - quads, kNumQuadsInIdxBuffer);
target->drawIndexed(kTriangles_GrPrimitiveType, target->drawIndexed(kTriangles_GrPrimitiveType,
kQuadNumVertices*quads, // startV kVertsPerQuad*quads, // startV
0, // startI 0, // startI
kQuadNumVertices*n, // vCount kVertsPerQuad*n, // vCount
kIdxsPerQuad*n, // iCount kIdxsPerQuad*n, // iCount
&devBounds); &devBounds);
quads += n; quads += n;
} }
@ -958,12 +1022,12 @@ bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path,
drawState->setGeometryProcessor(hairConicProcessor)->unref(); drawState->setGeometryProcessor(hairConicProcessor)->unref();
int conics = 0; int conics = 0;
while (conics < conicCnt) { while (conics < conicCnt) {
int n = SkTMin(conicCnt - conics, kQuadsNumInIdxBuffer); int n = SkTMin(conicCnt - conics, kNumQuadsInIdxBuffer);
target->drawIndexed(kTriangles_GrPrimitiveType, target->drawIndexed(kTriangles_GrPrimitiveType,
kQuadNumVertices*(quadCnt + conics), // startV kVertsPerQuad*(quadCnt + conics), // startV
0, // startI 0, // startI
kQuadNumVertices*n, // vCount kVertsPerQuad*n, // vCount
kIdxsPerQuad*n, // iCount kIdxsPerQuad*n, // iCount
&devBounds); &devBounds);
conics += n; conics += n;
} }

View File

@ -311,6 +311,42 @@ static const int kIndicesPerAAFillRect = SK_ARRAY_COUNT(gFillAARectIdx);
static const int kVertsPerAAFillRect = 8; static const int kVertsPerAAFillRect = 8;
static const int kNumAAFillRectsInIndexBuffer = 256; static const int kNumAAFillRectsInIndexBuffer = 256;
GrIndexBuffer* GrAARectRenderer::aaFillRectIndexBuffer(GrGpu* gpu) {
static const size_t kAAFillRectIndexBufferSize = kIndicesPerAAFillRect *
sizeof(uint16_t) *
kNumAAFillRectsInIndexBuffer;
if (NULL == fAAFillRectIndexBuffer) {
fAAFillRectIndexBuffer = gpu->createIndexBuffer(kAAFillRectIndexBufferSize, false);
if (fAAFillRectIndexBuffer) {
uint16_t* data = (uint16_t*) fAAFillRectIndexBuffer->map();
bool useTempData = (NULL == data);
if (useTempData) {
data = SkNEW_ARRAY(uint16_t, kNumAAFillRectsInIndexBuffer * kIndicesPerAAFillRect);
}
for (int i = 0; i < kNumAAFillRectsInIndexBuffer; ++i) {
// Each AA filled rect is drawn with 8 vertices and 10 triangles (8 around
// the inner rect (for AA) and 2 for the inner rect.
int baseIdx = i * kIndicesPerAAFillRect;
uint16_t baseVert = (uint16_t)(i * kVertsPerAAFillRect);
for (int j = 0; j < kIndicesPerAAFillRect; ++j) {
data[baseIdx+j] = baseVert + gFillAARectIdx[j];
}
}
if (useTempData) {
if (!fAAFillRectIndexBuffer->updateData(data, kAAFillRectIndexBufferSize)) {
SkFAIL("Can't get AA Fill Rect indices into buffer!");
}
SkDELETE_ARRAY(data);
} else {
fAAFillRectIndexBuffer->unmap();
}
}
}
return fAAFillRectIndexBuffer;
}
static const uint16_t gMiterStrokeAARectIdx[] = { static const uint16_t gMiterStrokeAARectIdx[] = {
0 + 0, 1 + 0, 5 + 0, 5 + 0, 4 + 0, 0 + 0, 0 + 0, 1 + 0, 5 + 0, 5 + 0, 4 + 0, 0 + 0,
1 + 0, 2 + 0, 6 + 0, 6 + 0, 5 + 0, 1 + 0, 1 + 0, 2 + 0, 6 + 0, 6 + 0, 5 + 0, 1 + 0,
@ -328,10 +364,6 @@ static const uint16_t gMiterStrokeAARectIdx[] = {
3 + 8, 0 + 8, 4 + 8, 4 + 8, 7 + 8, 3 + 8, 3 + 8, 0 + 8, 4 + 8, 4 + 8, 7 + 8, 3 + 8,
}; };
static const int kIndicesPerMiterStrokeRect = SK_ARRAY_COUNT(gMiterStrokeAARectIdx);
static const int kVertsPerMiterStrokeRect = 16;
static const int kNumMiterStrokeRectsInIndexBuffer = 256;
/** /**
* As in miter-stroke, index = a + b, and a is the current index, b is the shift * As in miter-stroke, index = a + b, and a is the current index, b is the shift
* from the first index. The index layout: * from the first index. The index layout:
@ -389,10 +421,6 @@ static const uint16_t gBevelStrokeAARectIdx[] = {
3 + 16, 0 + 16, 4 + 16, 4 + 16, 7 + 16, 3 + 16, 3 + 16, 0 + 16, 4 + 16, 4 + 16, 7 + 16, 3 + 16,
}; };
static const int kIndicesPerBevelStrokeRect = SK_ARRAY_COUNT(gBevelStrokeAARectIdx);
static const int kVertsPerBevelStrokeRect = 24;
static const int kNumBevelStrokeRectsInIndexBuffer = 256;
int GrAARectRenderer::aaStrokeRectIndexCount(bool miterStroke) { int GrAARectRenderer::aaStrokeRectIndexCount(bool miterStroke) {
return miterStroke ? SK_ARRAY_COUNT(gMiterStrokeAARectIdx) : return miterStroke ? SK_ARRAY_COUNT(gMiterStrokeAARectIdx) :
SK_ARRAY_COUNT(gBevelStrokeAARectIdx); SK_ARRAY_COUNT(gBevelStrokeAARectIdx);
@ -402,19 +430,29 @@ GrIndexBuffer* GrAARectRenderer::aaStrokeRectIndexBuffer(GrGpu* gpu, bool miterS
if (miterStroke) { if (miterStroke) {
if (NULL == fAAMiterStrokeRectIndexBuffer) { if (NULL == fAAMiterStrokeRectIndexBuffer) {
fAAMiterStrokeRectIndexBuffer = fAAMiterStrokeRectIndexBuffer =
gpu->createInstancedIndexBuffer(gMiterStrokeAARectIdx, gpu->createIndexBuffer(sizeof(gMiterStrokeAARectIdx), false);
kIndicesPerMiterStrokeRect, if (fAAMiterStrokeRectIndexBuffer) {
kNumMiterStrokeRectsInIndexBuffer, #ifdef SK_DEBUG
kVertsPerMiterStrokeRect); bool updated =
#endif
fAAMiterStrokeRectIndexBuffer->updateData(gMiterStrokeAARectIdx,
sizeof(gMiterStrokeAARectIdx));
GR_DEBUGASSERT(updated);
}
} }
return fAAMiterStrokeRectIndexBuffer; return fAAMiterStrokeRectIndexBuffer;
} else { } else {
if (NULL == fAABevelStrokeRectIndexBuffer) { if (NULL == fAABevelStrokeRectIndexBuffer) {
fAABevelStrokeRectIndexBuffer = fAABevelStrokeRectIndexBuffer =
gpu->createInstancedIndexBuffer(gBevelStrokeAARectIdx, gpu->createIndexBuffer(sizeof(gBevelStrokeAARectIdx), false);
kIndicesPerBevelStrokeRect, if (fAABevelStrokeRectIndexBuffer) {
kNumBevelStrokeRectsInIndexBuffer, #ifdef SK_DEBUG
kVertsPerBevelStrokeRect); bool updated =
#endif
fAABevelStrokeRectIndexBuffer->updateData(gBevelStrokeAARectIdx,
sizeof(gBevelStrokeAARectIdx));
GR_DEBUGASSERT(updated);
}
} }
return fAABevelStrokeRectIndexBuffer; return fAABevelStrokeRectIndexBuffer;
} }
@ -440,13 +478,7 @@ void GrAARectRenderer::geometryFillAARect(GrGpu* gpu,
return; return;
} }
if (NULL == fAAFillRectIndexBuffer) { GrIndexBuffer* indexBuffer = this->aaFillRectIndexBuffer(gpu);
fAAFillRectIndexBuffer = gpu->createInstancedIndexBuffer(gFillAARectIdx,
kIndicesPerAAFillRect,
kNumAAFillRectsInIndexBuffer,
kVertsPerAAFillRect);
}
GrIndexBuffer* indexBuffer = fAAFillRectIndexBuffer;
if (NULL == indexBuffer) { if (NULL == indexBuffer) {
GrPrintf("Failed to create index buffer!\n"); GrPrintf("Failed to create index buffer!\n");
return; return;
@ -901,9 +933,8 @@ void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu,
} }
target->setIndexSourceToBuffer(indexBuffer); target->setIndexSourceToBuffer(indexBuffer);
target->drawIndexedInstances(kTriangles_GrPrimitiveType, 1, target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0,
totalVertexNum, aaStrokeRectIndexCount(miterStroke)); totalVertexNum, aaStrokeRectIndexCount(miterStroke));
target->resetIndexSource();
} }
void GrAARectRenderer::fillAANestedRects(GrGpu* gpu, void GrAARectRenderer::fillAANestedRects(GrGpu* gpu,

View File

@ -75,6 +75,8 @@ private:
GrIndexBuffer* fAAMiterStrokeRectIndexBuffer; GrIndexBuffer* fAAMiterStrokeRectIndexBuffer;
GrIndexBuffer* fAABevelStrokeRectIndexBuffer; GrIndexBuffer* fAABevelStrokeRectIndexBuffer;
GrIndexBuffer* aaFillRectIndexBuffer(GrGpu* gpu);
static int aaStrokeRectIndexCount(bool miterStroke); static int aaStrokeRectIndexCount(bool miterStroke);
GrIndexBuffer* aaStrokeRectIndexBuffer(GrGpu* gpu, bool miterStroke); GrIndexBuffer* aaStrokeRectIndexBuffer(GrGpu* gpu, bool miterStroke);

View File

@ -164,39 +164,6 @@ GrIndexBuffer* GrGpu::createIndexBuffer(size_t size, bool dynamic) {
return this->onCreateIndexBuffer(size, dynamic); return this->onCreateIndexBuffer(size, dynamic);
} }
GrIndexBuffer* GrGpu::createInstancedIndexBuffer(const uint16_t* pattern,
int patternSize,
int reps,
int vertCount,
bool isDynamic) {
size_t bufferSize = patternSize * reps * sizeof(uint16_t);
GrGpu* me = const_cast<GrGpu*>(this);
GrIndexBuffer* buffer = me->createIndexBuffer(bufferSize, isDynamic);
if (buffer) {
uint16_t* data = (uint16_t*) buffer->map();
bool useTempData = (NULL == data);
if (useTempData) {
data = SkNEW_ARRAY(uint16_t, reps * patternSize);
}
for (int i = 0; i < reps; ++i) {
int baseIdx = i * patternSize;
uint16_t baseVert = (uint16_t)(i * vertCount);
for (int j = 0; j < patternSize; ++j) {
data[baseIdx+j] = baseVert + pattern[j];
}
}
if (useTempData) {
if (!buffer->updateData(data, bufferSize)) {
SkFAIL("Can't get indices into buffer!");
}
SkDELETE_ARRAY(data);
} else {
buffer->unmap();
}
}
return buffer;
}
void GrGpu::clear(const SkIRect* rect, void GrGpu::clear(const SkIRect* rect,
GrColor color, GrColor color,
bool canIgnoreRect, bool canIgnoreRect,
@ -279,18 +246,39 @@ static const int MAX_QUADS = 1 << 12; // max possible: (1 << 14) - 1;
GR_STATIC_ASSERT(4 * MAX_QUADS <= 65535); GR_STATIC_ASSERT(4 * MAX_QUADS <= 65535);
static const uint16_t gQuadIndexPattern[] = { static inline void fill_indices(uint16_t* indices, int quadCount) {
0, 1, 2, 0, 2, 3 for (int i = 0; i < quadCount; ++i) {
}; indices[6 * i + 0] = 4 * i + 0;
indices[6 * i + 1] = 4 * i + 1;
indices[6 * i + 2] = 4 * i + 2;
indices[6 * i + 3] = 4 * i + 0;
indices[6 * i + 4] = 4 * i + 2;
indices[6 * i + 5] = 4 * i + 3;
}
}
const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const { const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const {
if (NULL == fQuadIndexBuffer || fQuadIndexBuffer->wasDestroyed()) { if (NULL == fQuadIndexBuffer || fQuadIndexBuffer->wasDestroyed()) {
SkSafeUnref(fQuadIndexBuffer); SkSafeUnref(fQuadIndexBuffer);
static const int SIZE = sizeof(uint16_t) * 6 * MAX_QUADS;
GrGpu* me = const_cast<GrGpu*>(this); GrGpu* me = const_cast<GrGpu*>(this);
fQuadIndexBuffer = me->createInstancedIndexBuffer(gQuadIndexPattern, fQuadIndexBuffer = me->createIndexBuffer(SIZE, false);
6, if (fQuadIndexBuffer) {
MAX_QUADS, uint16_t* indices = (uint16_t*)fQuadIndexBuffer->map();
4); if (indices) {
fill_indices(indices, MAX_QUADS);
fQuadIndexBuffer->unmap();
} else {
indices = (uint16_t*)sk_malloc_throw(SIZE);
fill_indices(indices, MAX_QUADS);
if (!fQuadIndexBuffer->updateData(indices, SIZE)) {
fQuadIndexBuffer->unref();
fQuadIndexBuffer = NULL;
SkFAIL("Can't get indices into buffer!");
}
sk_free(indices);
}
}
} }
return fQuadIndexBuffer; return fQuadIndexBuffer;

View File

@ -142,25 +142,6 @@ public:
*/ */
GrIndexBuffer* createIndexBuffer(size_t size, bool dynamic); GrIndexBuffer* createIndexBuffer(size_t size, bool dynamic);
/**
* Creates an index buffer for instance drawing with a specific pattern.
*
* @param pattern the pattern to repeat
* @param patternSize size in bytes of the pattern
* @param reps number of times to repeat the pattern
* @param vertCount number of vertices the pattern references
* @param dynamic hints whether the data will be frequently changed
* by either GrIndexBuffer::map() or
* GrIndexBuffer::updateData().
*
* @return The index buffer if successful, otherwise NULL.
*/
GrIndexBuffer* createInstancedIndexBuffer(const uint16_t* pattern,
int patternSize,
int reps,
int vertCount,
bool isDynamic = false);
/** /**
* Returns an index buffer that can be used to render quads. * Returns an index buffer that can be used to render quads.
* Six indices per quad: 0, 1, 2, 0, 2, 3, etc. * Six indices per quad: 0, 1, 2, 0, 2, 3, etc.

View File

@ -26,7 +26,7 @@
#include "effects/GrRRectEffect.h" #include "effects/GrRRectEffect.h"
namespace { namespace {
// TODO(joshualitt) add per vertex colors
struct CircleVertex { struct CircleVertex {
SkPoint fPos; SkPoint fPos;
SkPoint fOffset; SkPoint fOffset;
@ -478,13 +478,13 @@ bool GrOvalRenderer::drawOval(GrDrawTarget* target, const GrContext* context, bo
// we can draw circles // we can draw circles
if (SkScalarNearlyEqual(oval.width(), oval.height()) if (SkScalarNearlyEqual(oval.width(), oval.height())
&& circle_stays_circle(vm)) { && circle_stays_circle(vm)) {
this->drawCircle(target, context, useCoverageAA, oval, stroke); this->drawCircle(target, useCoverageAA, oval, stroke);
// if we have shader derivative support, render as device-independent // if we have shader derivative support, render as device-independent
} else if (target->caps()->shaderDerivativeSupport()) { } else if (target->caps()->shaderDerivativeSupport()) {
return this->drawDIEllipse(target, context, useCoverageAA, oval, stroke); return this->drawDIEllipse(target, useCoverageAA, oval, stroke);
// otherwise axis-aligned ellipses only // otherwise axis-aligned ellipses only
} else if (vm.rectStaysRect()) { } else if (vm.rectStaysRect()) {
return this->drawEllipse(target, context, useCoverageAA, oval, stroke); return this->drawEllipse(target, useCoverageAA, oval, stroke);
} else { } else {
return false; return false;
} }
@ -501,7 +501,6 @@ extern const GrVertexAttrib gCircleVertexAttribs[] = {
}; };
void GrOvalRenderer::drawCircle(GrDrawTarget* target, void GrOvalRenderer::drawCircle(GrDrawTarget* target,
const GrContext* context,
bool useCoverageAA, bool useCoverageAA,
const SkRect& circle, const SkRect& circle,
const SkStrokeRec& stroke) const SkStrokeRec& stroke)
@ -573,24 +572,22 @@ void GrOvalRenderer::drawCircle(GrDrawTarget* target,
verts[0].fOuterRadius = outerRadius; verts[0].fOuterRadius = outerRadius;
verts[0].fInnerRadius = innerRadius; verts[0].fInnerRadius = innerRadius;
verts[1].fPos = SkPoint::Make(bounds.fLeft, bounds.fBottom); verts[1].fPos = SkPoint::Make(bounds.fRight, bounds.fTop);
verts[1].fOffset = SkPoint::Make(-outerRadius, outerRadius); verts[1].fOffset = SkPoint::Make(outerRadius, -outerRadius);
verts[1].fOuterRadius = outerRadius; verts[1].fOuterRadius = outerRadius;
verts[1].fInnerRadius = innerRadius; verts[1].fInnerRadius = innerRadius;
verts[2].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom); verts[2].fPos = SkPoint::Make(bounds.fLeft, bounds.fBottom);
verts[2].fOffset = SkPoint::Make(outerRadius, outerRadius); verts[2].fOffset = SkPoint::Make(-outerRadius, outerRadius);
verts[2].fOuterRadius = outerRadius; verts[2].fOuterRadius = outerRadius;
verts[2].fInnerRadius = innerRadius; verts[2].fInnerRadius = innerRadius;
verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom);
verts[3].fOffset = SkPoint::Make(outerRadius, -outerRadius); verts[3].fOffset = SkPoint::Make(outerRadius, outerRadius);
verts[3].fOuterRadius = outerRadius; verts[3].fOuterRadius = outerRadius;
verts[3].fInnerRadius = innerRadius; verts[3].fInnerRadius = innerRadius;
target->setIndexSourceToBuffer(context->getGpu()->getQuadIndexBuffer()); target->drawNonIndexed(kTriangleStrip_GrPrimitiveType, 0, 4, &bounds);
target->drawIndexedInstances(kTriangles_GrPrimitiveType, 1, 4, 6, &bounds);
target->resetIndexSource();
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -610,7 +607,6 @@ extern const GrVertexAttrib gDIEllipseVertexAttribs[] = {
}; };
bool GrOvalRenderer::drawEllipse(GrDrawTarget* target, bool GrOvalRenderer::drawEllipse(GrDrawTarget* target,
const GrContext* context,
bool useCoverageAA, bool useCoverageAA,
const SkRect& ellipse, const SkRect& ellipse,
const SkStrokeRec& stroke) const SkStrokeRec& stroke)
@ -722,30 +718,27 @@ bool GrOvalRenderer::drawEllipse(GrDrawTarget* target,
verts[0].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); verts[0].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
verts[0].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip); verts[0].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip);
verts[1].fPos = SkPoint::Make(bounds.fLeft, bounds.fBottom); verts[1].fPos = SkPoint::Make(bounds.fRight, bounds.fTop);
verts[1].fOffset = SkPoint::Make(-xRadius, yRadius); verts[1].fOffset = SkPoint::Make(xRadius, -yRadius);
verts[1].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); verts[1].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
verts[1].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip); verts[1].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip);
verts[2].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom); verts[2].fPos = SkPoint::Make(bounds.fLeft, bounds.fBottom);
verts[2].fOffset = SkPoint::Make(xRadius, yRadius); verts[2].fOffset = SkPoint::Make(-xRadius, yRadius);
verts[2].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); verts[2].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
verts[2].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip); verts[2].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip);
verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom);
verts[3].fOffset = SkPoint::Make(xRadius, -yRadius); verts[3].fOffset = SkPoint::Make(xRadius, yRadius);
verts[3].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip); verts[3].fOuterRadii = SkPoint::Make(xRadRecip, yRadRecip);
verts[3].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip); verts[3].fInnerRadii = SkPoint::Make(xInnerRadRecip, yInnerRadRecip);
target->setIndexSourceToBuffer(context->getGpu()->getQuadIndexBuffer()); target->drawNonIndexed(kTriangleStrip_GrPrimitiveType, 0, 4, &bounds);
target->drawIndexedInstances(kTriangles_GrPrimitiveType, 1, 4, 6, &bounds);
target->resetIndexSource();
return true; return true;
} }
bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target, bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target,
const GrContext* context,
bool useCoverageAA, bool useCoverageAA,
const SkRect& ellipse, const SkRect& ellipse,
const SkStrokeRec& stroke) const SkStrokeRec& stroke)
@ -839,21 +832,19 @@ bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target,
verts[0].fOuterOffset = SkPoint::Make(-1.0f - offsetDx, -1.0f - offsetDy); verts[0].fOuterOffset = SkPoint::Make(-1.0f - offsetDx, -1.0f - offsetDy);
verts[0].fInnerOffset = SkPoint::Make(-innerRatioX - offsetDx, -innerRatioY - offsetDy); verts[0].fInnerOffset = SkPoint::Make(-innerRatioX - offsetDx, -innerRatioY - offsetDy);
verts[1].fPos = SkPoint::Make(bounds.fLeft, bounds.fBottom); verts[1].fPos = SkPoint::Make(bounds.fRight, bounds.fTop);
verts[1].fOuterOffset = SkPoint::Make(-1.0f - offsetDx, 1.0f + offsetDy); verts[1].fOuterOffset = SkPoint::Make(1.0f + offsetDx, -1.0f - offsetDy);
verts[1].fInnerOffset = SkPoint::Make(-innerRatioX - offsetDx, innerRatioY + offsetDy); verts[1].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, -innerRatioY - offsetDy);
verts[2].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom); verts[2].fPos = SkPoint::Make(bounds.fLeft, bounds.fBottom);
verts[2].fOuterOffset = SkPoint::Make(1.0f + offsetDx, 1.0f + offsetDy); verts[2].fOuterOffset = SkPoint::Make(-1.0f - offsetDx, 1.0f + offsetDy);
verts[2].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, innerRatioY + offsetDy); verts[2].fInnerOffset = SkPoint::Make(-innerRatioX - offsetDx, innerRatioY + offsetDy);
verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fTop); verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom);
verts[3].fOuterOffset = SkPoint::Make(1.0f + offsetDx, -1.0f - offsetDy); verts[3].fOuterOffset = SkPoint::Make(1.0f + offsetDx, 1.0f + offsetDy);
verts[3].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, -innerRatioY - offsetDy); verts[3].fInnerOffset = SkPoint::Make(innerRatioX + offsetDx, innerRatioY + offsetDy);
target->setIndexSourceToBuffer(context->getGpu()->getQuadIndexBuffer()); target->drawNonIndexed(kTriangleStrip_GrPrimitiveType, 0, 4, &bounds);
target->drawIndexedInstances(kTriangles_GrPrimitiveType, 1, 4, 6, &bounds);
target->resetIndexSource();
return true; return true;
} }
@ -878,29 +869,21 @@ static const uint16_t gRRectIndices[] = {
5, 6, 10, 5, 10, 9 5, 6, 10, 5, 10, 9
}; };
static const int kIndicesPerStrokeRRect = SK_ARRAY_COUNT(gRRectIndices) - 6;
static const int kIndicesPerRRect = SK_ARRAY_COUNT(gRRectIndices);
static const int kVertsPerRRect = 16;
static const int kNumRRectsInIndexBuffer = 256;
GrIndexBuffer* GrOvalRenderer::rRectIndexBuffer(bool isStrokeOnly, GrGpu* gpu) { GrIndexBuffer* GrOvalRenderer::rRectIndexBuffer(GrGpu* gpu) {
if (isStrokeOnly) { if (NULL == fRRectIndexBuffer) {
if (NULL == fStrokeRRectIndexBuffer) { fRRectIndexBuffer =
fStrokeRRectIndexBuffer = gpu->createInstancedIndexBuffer(gRRectIndices, gpu->createIndexBuffer(sizeof(gRRectIndices), false);
kIndicesPerStrokeRRect, if (fRRectIndexBuffer) {
kNumRRectsInIndexBuffer, #ifdef SK_DEBUG
kVertsPerRRect); bool updated =
#endif
fRRectIndexBuffer->updateData(gRRectIndices,
sizeof(gRRectIndices));
GR_DEBUGASSERT(updated);
} }
return fStrokeRRectIndexBuffer;
} else {
if (NULL == fRRectIndexBuffer) {
fRRectIndexBuffer = gpu->createInstancedIndexBuffer(gRRectIndices,
kIndicesPerRRect,
kNumRRectsInIndexBuffer,
kVertsPerRRect);
}
return fRRectIndexBuffer;
} }
return fRRectIndexBuffer;
} }
bool GrOvalRenderer::drawDRRect(GrDrawTarget* target, GrContext* context, bool useAA, bool GrOvalRenderer::drawDRRect(GrDrawTarget* target, GrContext* context, bool useAA,
@ -1035,7 +1018,7 @@ bool GrOvalRenderer::drawRRect(GrDrawTarget* target, GrContext* context, bool us
return false; return false;
} }
GrIndexBuffer* indexBuffer = this->rRectIndexBuffer(isStrokeOnly, context->getGpu()); GrIndexBuffer* indexBuffer = this->rRectIndexBuffer(context->getGpu());
if (NULL == indexBuffer) { if (NULL == indexBuffer) {
GrPrintf("Failed to create index buffer!\n"); GrPrintf("Failed to create index buffer!\n");
return false; return false;
@ -1127,7 +1110,7 @@ bool GrOvalRenderer::drawRRect(GrDrawTarget* target, GrContext* context, bool us
int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 :
SK_ARRAY_COUNT(gRRectIndices); SK_ARRAY_COUNT(gRRectIndices);
target->setIndexSourceToBuffer(indexBuffer); target->setIndexSourceToBuffer(indexBuffer);
target->drawIndexedInstances(kTriangles_GrPrimitiveType, 1, 16, indexCnt, &bounds); target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bounds);
// otherwise we use the ellipse renderer // otherwise we use the ellipse renderer
} else { } else {
@ -1234,9 +1217,8 @@ bool GrOvalRenderer::drawRRect(GrDrawTarget* target, GrContext* context, bool us
int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 : int indexCnt = isStrokeOnly ? SK_ARRAY_COUNT(gRRectIndices) - 6 :
SK_ARRAY_COUNT(gRRectIndices); SK_ARRAY_COUNT(gRRectIndices);
target->setIndexSourceToBuffer(indexBuffer); target->setIndexSourceToBuffer(indexBuffer);
target->drawIndexedInstances(kTriangles_GrPrimitiveType, 1, 16, indexCnt, &bounds); target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bounds);
} }
target->resetIndexSource();
return true; return true;
} }

View File

@ -24,7 +24,7 @@ class GrOvalRenderer : public SkRefCnt {
public: public:
SK_DECLARE_INST_COUNT(GrOvalRenderer) SK_DECLARE_INST_COUNT(GrOvalRenderer)
GrOvalRenderer() : fRRectIndexBuffer(NULL), fStrokeRRectIndexBuffer(NULL) {} GrOvalRenderer() : fRRectIndexBuffer(NULL) {}
~GrOvalRenderer() { ~GrOvalRenderer() {
this->reset(); this->reset();
} }
@ -39,20 +39,19 @@ public:
const SkRRect& outer, const SkRRect& inner); const SkRRect& outer, const SkRRect& inner);
private: private:
bool drawEllipse(GrDrawTarget* target, const GrContext* context, bool useCoverageAA, bool drawEllipse(GrDrawTarget* target, bool useCoverageAA,
const SkRect& ellipse, const SkRect& ellipse,
const SkStrokeRec& stroke); const SkStrokeRec& stroke);
bool drawDIEllipse(GrDrawTarget* target, const GrContext* context, bool useCoverageAA, bool drawDIEllipse(GrDrawTarget* target, bool useCoverageAA,
const SkRect& ellipse, const SkRect& ellipse,
const SkStrokeRec& stroke); const SkStrokeRec& stroke);
void drawCircle(GrDrawTarget* target, const GrContext* context, bool useCoverageAA, void drawCircle(GrDrawTarget* target, bool useCoverageAA,
const SkRect& circle, const SkRect& circle,
const SkStrokeRec& stroke); const SkStrokeRec& stroke);
GrIndexBuffer* rRectIndexBuffer(bool isStrokeOnly, GrGpu* gpu); GrIndexBuffer* rRectIndexBuffer(GrGpu* gpu);
GrIndexBuffer* fRRectIndexBuffer; GrIndexBuffer* fRRectIndexBuffer;
GrIndexBuffer* fStrokeRRectIndexBuffer;
typedef SkRefCnt INHERITED; typedef SkRefCnt INHERITED;
}; };