From 2cf444f7040614b43af67e368f3aa636ebeaa45a Mon Sep 17 00:00:00 2001 From: "skia.committer@gmail.com" Date: Fri, 26 Apr 2013 07:00:58 +0000 Subject: [PATCH] Sanitizing source files in Skia_Periodic_House_Keeping git-svn-id: http://skia.googlecode.com/svn/trunk@8873 2bbb7eff-a529-9590-31e7-b0007b416f81 --- include/gpu/GrEffectStage.h | 8 +++---- include/gpu/GrOvalRenderer.h | 4 ++-- src/core/SkRRect.cpp | 2 +- src/core/SkXfermode.cpp | 2 +- src/gpu/GrOvalRenderer.cpp | 57 ++++++++++++++++++++++---------------------- tests/RoundRectTest.cpp | 16 ++++++------- 6 files changed, 44 insertions(+), 45 deletions(-) diff --git a/include/gpu/GrEffectStage.h b/include/gpu/GrEffectStage.h index 7548258..07294e1 100644 --- a/include/gpu/GrEffectStage.h +++ b/include/gpu/GrEffectStage.h @@ -70,9 +70,9 @@ public: * @param matrix The transformation from the old coord system in which geometry is specified * to the new one from which it will actually be drawn. */ - void localCoordChange(const SkMatrix& matrix) { + void localCoordChange(const SkMatrix& matrix) { if (fCoordChangeMatrixSet) { - fCoordChangeMatrix.preConcat(matrix); + fCoordChangeMatrix.preConcat(matrix); } else { fCoordChangeMatrixSet = true; fCoordChangeMatrix = matrix; @@ -205,11 +205,11 @@ public: * Gets the matrix representing all changes of coordinate system since the GrEffect was * installed in the stage. */ - const SkMatrix& getCoordChangeMatrix() const { + const SkMatrix& getCoordChangeMatrix() const { if (fCoordChangeMatrixSet) { return fCoordChangeMatrix; } else { - return SkMatrix::I(); + return SkMatrix::I(); } } diff --git a/include/gpu/GrOvalRenderer.h b/include/gpu/GrOvalRenderer.h index 68e6070..0f6809d 100644 --- a/include/gpu/GrOvalRenderer.h +++ b/include/gpu/GrOvalRenderer.h @@ -43,9 +43,9 @@ private: const SkStrokeRec& stroke); GrIndexBuffer* rRectIndexBuffer(GrGpu* gpu); - + GrIndexBuffer* fRRectIndexBuffer; - + typedef GrRefCnt INHERITED; }; diff --git a/src/core/SkRRect.cpp b/src/core/SkRRect.cpp index c8d0329..75af106 100644 --- a/src/core/SkRRect.cpp +++ b/src/core/SkRRect.cpp @@ -137,7 +137,7 @@ bool SkRRect::contains(SkScalar x, SkScalar y) const { return checkCornerContainment(x, y); } -// This method determines if a point known to be inside the RRect's bounds is +// This method determines if a point known to be inside the RRect's bounds is // inside all the corners. bool SkRRect::checkCornerContainment(SkScalar x, SkScalar y) const { SkPoint canonicalPt; // (x,y) translated to one of the quadrants diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp index 4318e71..ac8546c 100644 --- a/src/core/SkXfermode.cpp +++ b/src/core/SkXfermode.cpp @@ -1372,7 +1372,7 @@ GrEffectRef* XferEffect::TestCreate(SkMWCRandom* rand, do { mode = rand->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLastSeparableMode); } while (mode == SkXfermode::kHardLight_Mode); - + static AutoEffectUnref gEffect(SkNEW_ARGS(XferEffect, (static_cast(mode)))); return CreateEffectRef(gEffect); } diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp index 5ab7a64..8309bf6 100644 --- a/src/gpu/GrOvalRenderer.cpp +++ b/src/gpu/GrOvalRenderer.cpp @@ -291,9 +291,9 @@ GrEffectRef* EllipseEdgeEffect::TestCreate(SkMWCRandom* random, * x and y directions. * * This uses a slightly different algorithm than the EllipseEdgeEffect, above. Rather than - * scaling an ellipse to be a circle, it attempts to find the distance from the offset point to the - * ellipse by determining where the line through the origin and offset point would cross the - * ellipse, and computing the distance to that. This is slower but works better for roundrects + * scaling an ellipse to be a circle, it attempts to find the distance from the offset point to the + * ellipse by determining where the line through the origin and offset point would cross the + * ellipse, and computing the distance to that. This is slower but works better for roundrects * because the straight edges will be more accurate. */ @@ -303,7 +303,7 @@ public: // we go through this so we only have one copy of each effect (stroked/filled) GR_CREATE_STATIC_EFFECT(gAltEllipseStrokeEdge, AltEllipseEdgeEffect, (true)); GR_CREATE_STATIC_EFFECT(gAltEllipseFillEdge, AltEllipseEdgeEffect, (false)); - + if (stroke) { gAltEllipseStrokeEdge->ref(); return gAltEllipseStrokeEdge; @@ -358,9 +358,9 @@ public: // get length of offset builder->fsCodeAppendf("\tfloat len = length(%s.xy);\n", fsOffsetName); builder->fsCodeAppend("\tvec2 offset;\n"); - + // for outer curve - builder->fsCodeAppendf("\toffset.xy = %s.xy*%s.yx;\n", + builder->fsCodeAppendf("\toffset.xy = %s.xy*%s.yx;\n", fsOffsetName, fsRadiiName); builder->fsCodeAppendf("\tfloat tOuter = " "%s.x*%s.y*inversesqrt(dot(offset.xy, offset.xy));\n", @@ -369,7 +369,7 @@ public: // for inner curve if (rrectEffect.isStroked()) { - builder->fsCodeAppendf("\toffset.xy = %s.xy*%s.wz;\n", + builder->fsCodeAppendf("\toffset.xy = %s.xy*%s.wz;\n", fsOffsetName, fsRadiiName); builder->fsCodeAppendf("\tfloat tInner = " "%s.z*%s.w*inversesqrt(dot(offset.xy, offset.xy));\n", @@ -713,13 +713,13 @@ static const uint16_t gRRectIndices[] = { 2, 3, 7, 2, 7, 6, 8, 9, 13, 8, 13, 12, 10, 11, 15, 10, 15, 14, - + // edges 1, 2, 6, 1, 6, 5, 4, 5, 9, 4, 9, 8, 6, 7, 11, 6, 11, 10, 9, 10, 14, 9, 14, 13, - + // center // we place this at the end so that we can ignore these indices when rendering stroke-only 5, 6, 10, 5, 10, 9 @@ -760,9 +760,9 @@ bool GrOvalRenderer::drawSimpleRRect(GrDrawTarget* target, GrContext* context, vm.mapRect(&bounds, rrectBounds); SkVector radii = rrect.getSimpleRadii(); - SkScalar xRadius = SkScalarAbs(vm[SkMatrix::kMScaleX]*radii.fX + + SkScalar xRadius = SkScalarAbs(vm[SkMatrix::kMScaleX]*radii.fX + vm[SkMatrix::kMSkewY]*radii.fY); - SkScalar yRadius = SkScalarAbs(vm[SkMatrix::kMSkewX]*radii.fX + + SkScalar yRadius = SkScalarAbs(vm[SkMatrix::kMSkewX]*radii.fX + vm[SkMatrix::kMScaleY]*radii.fY); // tall or wide quarter-ellipse corners aren't handled if (SkScalarDiv(xRadius, yRadius) > 2 || SkScalarDiv(yRadius, xRadius) > 2) { @@ -806,24 +806,24 @@ bool GrOvalRenderer::drawSimpleRRect(GrDrawTarget* target, GrContext* context, if (NULL == indexBuffer) { GrPrintf("Failed to create index buffer!\n"); return false; - } - + } + // if the corners are circles, use the circle renderer if ((!isStroked || scaledStroke.fX == scaledStroke.fY) && xRadius == yRadius) { drawState->setVertexAttribs(SK_ARRAY_COUNT(gCircleVertexAttribs)); GrAssert(sizeof(CircleVertex) == drawState->getVertexSize()); - + GrDrawTarget::AutoReleaseGeometry geo(target, 16, 0); if (!geo.succeeded()) { GrPrintf("Failed to get space for vertices!\n"); return false; } CircleVertex* verts = reinterpret_cast(geo.vertices()); - + GrEffectRef* effect = CircleEdgeEffect::Create(isStroked); static const int kCircleEdgeAttrIndex = 1; drawState->setEffect(kEdgeEffectStage, effect, kCircleEdgeAttrIndex)->unref(); - + SkScalar innerRadius = 0.0f; SkScalar outerRadius = xRadius; SkScalar halfWidth = 0; @@ -833,24 +833,24 @@ bool GrOvalRenderer::drawSimpleRRect(GrDrawTarget* target, GrContext* context, } else { halfWidth = SkScalarHalf(scaledStroke.fX); } - + if (isStroked) { innerRadius = SkMaxScalar(0, xRadius - halfWidth); } outerRadius += halfWidth; bounds.outset(halfWidth, halfWidth); } - + // The radii are outset for two reasons. First, it allows the shader to simply perform // clamp(distance-to-center - radius, 0, 1). Second, the outer radius is used to compute the // verts of the bounding box that is rendered and the outset ensures the box will cover all // pixels partially covered by the circle. outerRadius += SK_ScalarHalf; innerRadius -= SK_ScalarHalf; - + // Expand the rect so all the pixels will be captured. bounds.outset(SK_ScalarHalf, SK_ScalarHalf); - + SkScalar yCoords[4] = { bounds.fTop, bounds.fTop + outerRadius, @@ -869,34 +869,34 @@ bool GrOvalRenderer::drawSimpleRRect(GrDrawTarget* target, GrContext* context, verts->fOuterRadius = outerRadius; verts->fInnerRadius = innerRadius; verts++; - + verts->fPos = SkPoint::Make(bounds.fLeft + outerRadius, yCoords[i]); verts->fOffset = SkPoint::Make(0, yOuterRadii[i]); verts->fOuterRadius = outerRadius; verts->fInnerRadius = innerRadius; verts++; - + verts->fPos = SkPoint::Make(bounds.fRight - outerRadius, yCoords[i]); verts->fOffset = SkPoint::Make(0, yOuterRadii[i]); verts->fOuterRadius = outerRadius; verts->fInnerRadius = innerRadius; verts++; - + verts->fPos = SkPoint::Make(bounds.fRight, yCoords[i]); verts->fOffset = SkPoint::Make(outerRadius, yOuterRadii[i]); verts->fOuterRadius = outerRadius; verts->fInnerRadius = innerRadius; verts++; } - + // drop out the middle quad if we're stroked int indexCnt = isStroked ? GR_ARRAY_COUNT(gRRectIndices)-6 : GR_ARRAY_COUNT(gRRectIndices); target->setIndexSourceToBuffer(indexBuffer); target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bounds); - + // otherwise we use the special ellipse renderer } else { - + drawState->setVertexAttribs(SK_ARRAY_COUNT(gEllipseVertexAttribs)); GrAssert(sizeof(RRectVertex) == drawState->getVertexSize()); @@ -980,13 +980,12 @@ bool GrOvalRenderer::drawSimpleRRect(GrDrawTarget* target, GrContext* context, verts->fInnerRadii = SkPoint::Make(xInnerRadius, yInnerRadius); verts++; } - + // drop out the middle quad if we're stroked int indexCnt = isStroked ? GR_ARRAY_COUNT(gRRectIndices)-6 : GR_ARRAY_COUNT(gRRectIndices); target->setIndexSourceToBuffer(indexBuffer); target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bounds); } - + return true; } - diff --git a/tests/RoundRectTest.cpp b/tests/RoundRectTest.cpp index 486037c..93f5e7d 100644 --- a/tests/RoundRectTest.cpp +++ b/tests/RoundRectTest.cpp @@ -320,12 +320,12 @@ static void test_round_rect_iffy_parameters(skiatest::Reporter* reporter) { // Move a small box from the start position by (stepX, stepY) 'numSteps' times // testing for containment in 'rr' at each step. static void test_direction(skiatest::Reporter* reporter, const SkRRect &rr, - SkScalar initX, int stepX, SkScalar initY, int stepY, + SkScalar initX, int stepX, SkScalar initY, int stepY, int numSteps, const bool* contains) { SkScalar x = initX, y = initY; for (int i = 0; i < numSteps; ++i) { - SkRect test = SkRect::MakeXYWH(x, y, - stepX ? SkIntToScalar(stepX) : SK_Scalar1, + SkRect test = SkRect::MakeXYWH(x, y, + stepX ? SkIntToScalar(stepX) : SK_Scalar1, stepY ? SkIntToScalar(stepY) : SK_Scalar1); test.sort(); @@ -364,15 +364,15 @@ static void test_round_rect_contains_rect(skiatest::Reporter* reporter) { { -5, 35, 5, 45 }, // SW { -5, 15, 5, 20 } // W }; - + for (int i = 0; i < kNumRRects; ++i) { for (size_t j = 0; j < SK_ARRAY_COUNT(easyOuts); ++j) { REPORTER_ASSERT(reporter, !rrects[i].contains(easyOuts[j])); } } - // Now test non-trivial containment. For each compass - // point walk a 1x1 rect in from the edge of the bounding + // Now test non-trivial containment. For each compass + // point walk a 1x1 rect in from the edge of the bounding // rect static const int kNumSteps = 15; bool answers[kNumRRects][8][kNumSteps] = { @@ -389,8 +389,8 @@ static void test_round_rect_contains_rect(skiatest::Reporter* reporter) { { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }, // for the circle we expect 6 blocks to be out on the - // corners (then the rest in) and only the first block - // out on the vertical and horizontal axes (then + // corners (then the rest in) and only the first block + // out on the vertical and horizontal axes (then // the rest in) { // circle -- 2.7.4