Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Unified Diff: src/gpu/GrAARectRenderer.cpp

Issue 15080010: Add special handling of rectori case for gpu (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Added unit test Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/SkDashPathEffect.cpp ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrAARectRenderer.cpp
===================================================================
--- src/gpu/GrAARectRenderer.cpp (revision 9163)
+++ src/gpu/GrAARectRenderer.cpp (working copy)
@@ -635,9 +635,16 @@
const GrRect& rect,
const SkMatrix& combinedMatrix,
const GrRect& devRect,
- const GrVec& devStrokeSize,
+ SkScalar width,
bool useVertexCoverage) {
- GrDrawState* drawState = target->drawState();
+ GrVec devStrokeSize;
+ if (width > 0) {
+ devStrokeSize.set(width, width);
+ combinedMatrix.mapVectors(&devStrokeSize, 1);
+ devStrokeSize.setAbs(devStrokeSize);
+ } else {
+ devStrokeSize.set(SK_Scalar1, SK_Scalar1);
+ }
const SkScalar dx = devStrokeSize.fX;
const SkScalar dy = devStrokeSize.fY;
@@ -659,13 +666,28 @@
spare = GrMin(w, h);
}
+ GrRect devOutside(devRect);
+ devOutside.outset(rx, ry);
+
if (spare <= 0) {
- GrRect r(devRect);
- r.outset(rx, ry);
- this->fillAARect(gpu, target, r, SkMatrix::I(), r, useVertexCoverage);
+ this->fillAARect(gpu, target, devOutside, SkMatrix::I(),
+ devOutside, useVertexCoverage);
return;
}
+ SkRect devInside(devRect);
+ devInside.inset(rx, ry);
+
+ this->geometryStrokeAARect(gpu, target, devOutside, devInside, useVertexCoverage);
+}
+
+void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu,
+ GrDrawTarget* target,
+ const SkRect& devOutside,
+ const SkRect& devInside,
+ bool useVertexCoverage) {
+ GrDrawState* drawState = target->drawState();
+
set_aa_rect_vertex_attributes(drawState, useVertexCoverage);
GrDrawTarget::AutoReleaseGeometry geo(target, 16, 0);
@@ -691,14 +713,12 @@
GrPoint* fan2Pos = reinterpret_cast<GrPoint*>(verts + 8 * vsize);
GrPoint* fan3Pos = reinterpret_cast<GrPoint*>(verts + 12 * vsize);
- set_inset_fan(fan0Pos, vsize, devRect,
- -rx - SK_ScalarHalf, -ry - SK_ScalarHalf);
- set_inset_fan(fan1Pos, vsize, devRect,
- -rx + SK_ScalarHalf, -ry + SK_ScalarHalf);
- set_inset_fan(fan2Pos, vsize, devRect,
- rx - SK_ScalarHalf, ry - SK_ScalarHalf);
- set_inset_fan(fan3Pos, vsize, devRect,
- rx + SK_ScalarHalf, ry + SK_ScalarHalf);
+ // outermost
+ set_inset_fan(fan0Pos, vsize, devOutside, -SK_ScalarHalf, -SK_ScalarHalf);
+ set_inset_fan(fan1Pos, vsize, devOutside, SK_ScalarHalf, SK_ScalarHalf);
+ set_inset_fan(fan2Pos, vsize, devInside, -SK_ScalarHalf, -SK_ScalarHalf);
+ // innermost
+ set_inset_fan(fan3Pos, vsize, devInside, SK_ScalarHalf, SK_ScalarHalf);
// The outermost rect has 0 coverage
verts += sizeof(GrPoint);
@@ -718,7 +738,7 @@
*reinterpret_cast<GrColor*>(verts + i * vsize) = innerColor;
}
- // The innermost rect has full coverage
+ // The innermost rect has 0 coverage
verts += 8 * vsize;
for (int i = 0; i < 4; ++i) {
*reinterpret_cast<GrColor*>(verts + i * vsize) = 0;
@@ -728,3 +748,24 @@
target->drawIndexed(kTriangles_GrPrimitiveType,
0, 0, 16, aaStrokeRectIndexCount());
}
+
+void GrAARectRenderer::fillAANestedRects(GrGpu* gpu,
+ GrDrawTarget* target,
+ const SkRect rects[2],
+ const SkMatrix& combinedMatrix,
+ bool useVertexCoverage) {
+ SkASSERT(combinedMatrix.rectStaysRect());
+ SkASSERT(!rects[1].isEmpty());
+
+ SkRect devOutside, devInside;
+ combinedMatrix.mapRect(&devOutside, rects[0]);
+ // can't call mapRect for devInside since it calls sort
+ combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2);
+
+ if (devInside.isEmpty()) {
+ this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside, useVertexCoverage);
+ return;
+ }
+
+ this->geometryStrokeAARect(gpu, target, devOutside, devInside, useVertexCoverage);
+}
« no previous file with comments | « src/effects/SkDashPathEffect.cpp ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698