From 972f9cd7a063d0544f8c919fd12b9a3adbd12b24 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Fri, 28 Mar 2014 17:58:28 +0000 Subject: [PATCH] SK_SUPPORT_LEGACY_GRTYPES to hide duplicate types from SkTypes.h BUG=skia: R=bsalomon@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/216503004 git-svn-id: http://skia.googlecode.com/svn/trunk@13982 2bbb7eff-a529-9590-31e7-b0007b416f81 --- gm/beziereffects.cpp | 4 +- include/gpu/GrContext.h | 4 +- include/gpu/GrGlyph.h | 8 +-- include/gpu/GrPoint.h | 6 +- include/gpu/GrTexture.h | 4 +- include/gpu/GrTypes.h | 54 +++++++++-------- include/gpu/GrTypesPriv.h | 6 +- src/effects/SkColorFilters.cpp | 2 +- src/gpu/GrAAConvexPathRenderer.cpp | 34 +++++------ src/gpu/GrAAHairLinePathRenderer.cpp | 26 ++++---- src/gpu/GrAARectRenderer.cpp | 62 ++++++++++---------- src/gpu/GrAllocPool.cpp | 6 +- src/gpu/GrAllocator.h | 2 +- src/gpu/GrBitmapTextContext.cpp | 16 ++--- src/gpu/GrBitmapTextContext.h | 2 +- src/gpu/GrBufferAllocPool.cpp | 6 +- src/gpu/GrContext.cpp | 52 ++++++++-------- src/gpu/GrDefaultPathRenderer.cpp | 6 +- src/gpu/GrDistanceFieldTextContext.cpp | 16 ++--- src/gpu/GrDistanceFieldTextContext.h | 2 +- src/gpu/GrDrawState.h | 8 +-- src/gpu/GrDrawTarget.cpp | 8 +-- src/gpu/GrDrawTarget.h | 4 +- src/gpu/GrInOrderDrawBuffer.cpp | 30 +++++----- src/gpu/GrMemoryPool.cpp | 6 +- src/gpu/GrOvalRenderer.cpp | 38 ++++++------ src/gpu/GrPathUtils.cpp | 48 +++++++-------- src/gpu/GrPathUtils.h | 32 +++++----- src/gpu/GrRenderTarget.cpp | 2 +- src/gpu/SkGpuDevice.cpp | 6 +- src/gpu/effects/GrConfigConversionEffect.cpp | 8 +-- src/gpu/effects/GrSimpleTextureEffect.cpp | 2 +- src/gpu/gl/GrGLCaps.cpp | 6 +- src/gpu/gl/GrGLNoOpInterface.cpp | 8 +-- src/gpu/gl/GrGLPath.cpp | 8 +-- src/gpu/gl/GrGLSL.cpp | 2 +- src/gpu/gl/GrGLStencilBuffer.cpp | 2 +- src/gpu/gl/GrGpuGL.cpp | 12 ++-- 38 files changed, 276 insertions(+), 272 deletions(-) diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp index e80853c4de..6a9e65bdec 100644 --- a/gm/beziereffects.cpp +++ b/gm/beziereffects.cpp @@ -26,7 +26,7 @@ namespace { extern const GrVertexAttrib kAttribs[] = { {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, - {kVec4f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding} + {kVec4f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding} }; } @@ -501,7 +501,7 @@ protected: sizeof(Vertex)); GrPathUtils::QuadUVMatrix DevToUV(pts); - DevToUV.apply<4, sizeof(Vertex), sizeof(GrPoint)>(verts); + DevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts); GrTestTarget tt; context->getTestTarget(&tt); diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index d2a3ada9d6..e8ce27f580 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -488,8 +488,8 @@ public: void drawVertices(const GrPaint& paint, GrPrimitiveType primitiveType, int vertexCount, - const GrPoint positions[], - const GrPoint texs[], + const SkPoint positions[], + const SkPoint texs[], const GrColor colors[], const uint16_t indices[], int indexCount); diff --git a/include/gpu/GrGlyph.h b/include/gpu/GrGlyph.h index fe4c835773..6de0c57d98 100644 --- a/include/gpu/GrGlyph.h +++ b/include/gpu/GrGlyph.h @@ -50,22 +50,22 @@ struct GrGlyph { /////////////////////////////////////////////////////////////////////////// - static inline unsigned ExtractSubPixelBitsFromFixed(GrFixed pos) { + static inline unsigned ExtractSubPixelBitsFromFixed(SkFixed pos) { // two most significant fraction bits from fixed-point return (pos >> 14) & 3; } - static inline PackedID Pack(uint16_t glyphID, GrFixed x, GrFixed y) { + static inline PackedID Pack(uint16_t glyphID, SkFixed x, SkFixed y) { x = ExtractSubPixelBitsFromFixed(x); y = ExtractSubPixelBitsFromFixed(y); return (x << 18) | (y << 16) | glyphID; } - static inline GrFixed UnpackFixedX(PackedID packed) { + static inline SkFixed UnpackFixedX(PackedID packed) { return ((packed >> 18) & 3) << 14; } - static inline GrFixed UnpackFixedY(PackedID packed) { + static inline SkFixed UnpackFixedY(PackedID packed) { return ((packed >> 16) & 3) << 14; } diff --git a/include/gpu/GrPoint.h b/include/gpu/GrPoint.h index c987b01134..7be5736f56 100644 --- a/include/gpu/GrPoint.h +++ b/include/gpu/GrPoint.h @@ -15,15 +15,17 @@ #include "SkScalar.h" #include "SkPoint.h" +#if 0 #define GrPoint SkPoint #define GrVec SkVector +#endif struct GrIPoint16 { int16_t fX, fY; void set(intptr_t x, intptr_t y) { - fX = GrToS16(x); - fY = GrToS16(y); + fX = SkToS16(x); + fY = SkToS16(y); } }; diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h index e56f6f401c..1df9dc6e0d 100644 --- a/include/gpu/GrTexture.h +++ b/include/gpu/GrTexture.h @@ -99,11 +99,11 @@ public: * Convert from texels to normalized texture coords for POT textures * only. */ - GrFixed normalizeFixedX(GrFixed x) const { + SkFixed normalizeFixedX(SkFixed x) const { SkASSERT(GrIsPow2(fDesc.fWidth)); return x >> fShiftFixedX; } - GrFixed normalizeFixedY(GrFixed y) const { + SkFixed normalizeFixedY(SkFixed y) const { SkASSERT(GrIsPow2(fDesc.fHeight)); return y >> fShiftFixedY; } diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h index 0bb432d663..c1b3554c6e 100644 --- a/include/gpu/GrTypes.h +++ b/include/gpu/GrTypes.h @@ -15,6 +15,8 @@ #include "GrConfig.h" #include "SkMath.h" +//#define SK_SUPPORT_LEGACY_GRTYPES + //////////////////////////////////////////////////////////////////////////////// /** @@ -50,6 +52,7 @@ friend X operator & (X a, T b); \ //////////////////////////////////////////////////////////////////////////////// +#ifdef SK_SUPPORT_LEGACY_GRTYPES /** * Macro to round n up to the next multiple of 4, or return it unchanged if @@ -66,6 +69,31 @@ template const T& GrMax(const T& a, const T& b) { return (b < a) ? a : b; } +/** + * Count elements in an array + */ +#define GR_ARRAY_COUNT(array) SK_ARRAY_COUNT(array) + +/** + * 16.16 fixed point type + */ +typedef int32_t GrFixed; + +#ifdef SK_DEBUG + +static inline int16_t GrToS16(intptr_t x) { + SkASSERT((int16_t)x == x); + return (int16_t)x; +} + +#else + +#define GrToS16(x) x + +#endif + +#endif + // compile time versions of min/max #define GR_CT_MAX(a, b) (((b) < (a)) ? (a) : (b)) #define GR_CT_MIN(a, b) (((b) < (a)) ? (b) : (a)) @@ -120,11 +148,6 @@ static inline size_t GrSizeAlignDown(size_t x, uint32_t alignment) { return (x / alignment) * alignment; } -/** - * Count elements in an array - */ -#define GR_ARRAY_COUNT(array) SK_ARRAY_COUNT(array) - /////////////////////////////////////////////////////////////////////////////// /** @@ -146,27 +169,6 @@ static inline int GrNextPow2(int n) { return n ? (1 << (32 - SkCLZ(n - 1))) : 1; } -/////////////////////////////////////////////////////////////////////////////// - -/** - * 16.16 fixed point type - */ -typedef int32_t GrFixed; - -#ifdef SK_DEBUG - -static inline int16_t GrToS16(intptr_t x) { - SkASSERT((int16_t)x == x); - return (int16_t)x; -} - -#else - -#define GrToS16(x) x - -#endif - - /////////////////////////////////////////////////////////////////////////////// /** diff --git a/include/gpu/GrTypesPriv.h b/include/gpu/GrTypesPriv.h index 5a220459fd..f09f95d918 100644 --- a/include/gpu/GrTypesPriv.h +++ b/include/gpu/GrTypesPriv.h @@ -45,7 +45,7 @@ static inline int GrSLTypeVectorCount(GrSLType type) { GR_STATIC_ASSERT(5 == kMat33f_GrSLType); GR_STATIC_ASSERT(6 == kMat44f_GrSLType); GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); - GR_STATIC_ASSERT(GR_ARRAY_COUNT(kCounts) == kGrSLTypeCount); + GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrSLTypeCount); } /** Return the type enum for a vector of floats of length n (1..4), @@ -89,7 +89,7 @@ static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) { GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); GR_STATIC_ASSERT(4 == kVec4ub_GrVertexAttribType); - GR_STATIC_ASSERT(GR_ARRAY_COUNT(kCounts) == kGrVertexAttribTypeCount); + GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrVertexAttribTypeCount); } /** @@ -111,7 +111,7 @@ static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) { GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); GR_STATIC_ASSERT(4 == kVec4ub_GrVertexAttribType); - GR_STATIC_ASSERT(GR_ARRAY_COUNT(kSizes) == kGrVertexAttribTypeCount); + GR_STATIC_ASSERT(SK_ARRAY_COUNT(kSizes) == kGrVertexAttribTypeCount); } /** diff --git a/src/effects/SkColorFilters.cpp b/src/effects/SkColorFilters.cpp index a048abca6b..65766c1fc8 100644 --- a/src/effects/SkColorFilters.cpp +++ b/src/effects/SkColorFilters.cpp @@ -305,7 +305,7 @@ namespace { * to which direction the 0.5 goes. */ static inline int color_component_to_int(float value) { - return sk_float_round2int(GrMax(0.f, GrMin(1.f, value)) * 255.f); + return sk_float_round2int(SkTMax(0.f, SkTMin(1.f, value)) * 255.f); } /** MaskedColorExpr is used to evaluate the color and valid color component flags through the diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp index 3e1af80485..2af5bb2e43 100644 --- a/src/gpu/GrAAConvexPathRenderer.cpp +++ b/src/gpu/GrAAConvexPathRenderer.cpp @@ -35,12 +35,12 @@ struct Segment { } fType; // line uses one pt, quad uses 2 pts - GrPoint fPts[2]; + SkPoint fPts[2]; // normal to edge ending at each pt - GrVec fNorms[2]; + SkVector fNorms[2]; // is the corner where the previous segment meets this segment // sharp. If so, fMid is a normalized bisector facing outward. - GrVec fMid; + SkVector fMid; int countPoints() { GR_STATIC_ASSERT(0 == kLine && 1 == kQuad); @@ -118,11 +118,11 @@ static void compute_vectors(SegmentArray* segments, int count = segments->count(); // Make the normals point towards the outside - GrPoint::Side normSide; + SkPoint::Side normSide; if (dir == SkPath::kCCW_Direction) { - normSide = GrPoint::kRight_Side; + normSide = SkPoint::kRight_Side; } else { - normSide = GrPoint::kLeft_Side; + normSide = SkPoint::kLeft_Side; } *vCount = 0; @@ -133,7 +133,7 @@ static void compute_vectors(SegmentArray* segments, int b = (a + 1) % count; Segment& segb = (*segments)[b]; - const GrPoint* prevPt = &sega.endPt(); + const SkPoint* prevPt = &sega.endPt(); int n = segb.countPoints(); for (int p = 0; p < n; ++p) { segb.fNorms[p] = segb.fPts[p] - *prevPt; @@ -173,15 +173,15 @@ struct DegenerateTestData { kLine, kNonDegenerate } fStage; - GrPoint fFirstPoint; - GrVec fLineNormal; + SkPoint fFirstPoint; + SkVector fLineNormal; SkScalar fLineC; }; static const SkScalar kClose = (SK_Scalar1 / 16); static const SkScalar kCloseSqd = SkScalarMul(kClose, kClose); -static void update_degenerate_test(DegenerateTestData* data, const GrPoint& pt) { +static void update_degenerate_test(DegenerateTestData* data, const SkPoint& pt) { switch (data->fStage) { case DegenerateTestData::kInitial: data->fFirstPoint = pt; @@ -288,7 +288,7 @@ static bool get_segments(const SkPath& path, } for (;;) { - GrPoint pts[4]; + SkPoint pts[4]; SkPath::Verb verb = iter.next(pts); switch (verb) { case SkPath::kMove_Verb: @@ -330,8 +330,8 @@ static bool get_segments(const SkPath& path, } struct QuadVertex { - GrPoint fPos; - GrPoint fUV; + SkPoint fPos; + SkPoint fUV; SkScalar fD0; SkScalar fD1; }; @@ -439,9 +439,9 @@ static void create_vertices(const SegmentArray& segments, *v += 5; *i += 9; } else { - GrPoint qpts[] = {sega.endPt(), segb.fPts[0], segb.fPts[1]}; + SkPoint qpts[] = {sega.endPt(), segb.fPts[0], segb.fPts[1]}; - GrVec midVec = segb.fNorms[0] + segb.fNorms[1]; + SkVector midVec = segb.fNorms[0] + segb.fNorms[1]; midVec.normalize(); verts[*v + 0].fPos = fanPt; @@ -468,7 +468,7 @@ static void create_vertices(const SegmentArray& segments, verts[*v + 5].fD1 = -SK_ScalarMax/100; GrPathUtils::QuadUVMatrix toUV(qpts); - toUV.apply<6, sizeof(QuadVertex), sizeof(GrPoint)>(verts + *v); + toUV.apply<6, sizeof(QuadVertex), sizeof(SkPoint)>(verts + *v); idxs[*i + 0] = *v + 3; idxs[*i + 1] = *v + 1; @@ -618,7 +618,7 @@ namespace { // position + edge extern const GrVertexAttrib gPathAttribs[] = { {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, - {kVec4f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding} + {kVec4f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding} }; }; diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp index 60be5be907..864fa6851b 100644 --- a/src/gpu/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/GrAAHairLinePathRenderer.cpp @@ -302,7 +302,7 @@ int num_quad_subdivs(const SkPoint p[3]) { // +1 since we're ignoring the mantissa contribution. int log = get_float_exp(dsqd/(gSubdivTol*gSubdivTol)) + 1; - log = GrMin(GrMax(0, log), kMaxSub); + log = SkTMin(SkTMax(0, log), kMaxSub); return log; } } @@ -333,8 +333,8 @@ int generate_lines_and_quads(const SkPath& path, bool persp = m.hasPerspective(); for (;;) { - GrPoint pathPts[4]; - GrPoint devPts[4]; + SkPoint pathPts[4]; + SkPoint devPts[4]; SkPath::Verb verb = iter.next(pathPts); switch (verb) { case SkPath::kConic_Verb: { @@ -486,26 +486,26 @@ int generate_lines_and_quads(const SkPath& path, } struct LineVertex { - GrPoint fPos; + SkPoint fPos; GrColor fCoverage; }; struct BezierVertex { - GrPoint fPos; + SkPoint fPos; union { struct { SkScalar fK; SkScalar fL; SkScalar fM; } fConic; - GrVec fQuadCoord; + SkVector fQuadCoord; struct { SkScalar fBogus[4]; }; }; }; -GR_STATIC_ASSERT(sizeof(BezierVertex) == 3 * sizeof(GrPoint)); +GR_STATIC_ASSERT(sizeof(BezierVertex) == 3 * sizeof(SkPoint)); void intersect_lines(const SkPoint& ptA, const SkVector& normA, const SkPoint& ptB, const SkVector& normB, @@ -528,7 +528,7 @@ void intersect_lines(const SkPoint& ptA, const SkVector& normA, 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 GrPathUtils::QuadUVMatrix DevToUV(qpts); - DevToUV.apply(verts); + DevToUV.apply(verts); } void bloat_quad(const SkPoint qpts[3], const SkMatrix* toDevice, @@ -708,13 +708,13 @@ namespace { // position + edge extern const GrVertexAttrib gHairlineBezierAttribs[] = { {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, - {kVec4f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding} + {kVec4f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding} }; // position + coverage extern const GrVertexAttrib gHairlineLineAttribs[] = { {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, - {kVec4ub_GrVertexAttribType, sizeof(GrPoint), kCoverage_GrVertexAttribBinding}, + {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kCoverage_GrVertexAttribBinding}, }; }; @@ -949,7 +949,7 @@ bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path, target->setIndexSourceToBuffer(fLinesIndexBuffer); int lines = 0; while (lines < lineCnt) { - int n = GrMin(lineCnt - lines, kNumLineSegsInIdxBuffer); + int n = SkTMin(lineCnt - lines, kNumLineSegsInIdxBuffer); target->drawIndexed(kTriangles_GrPrimitiveType, kVertsPerLineSeg*lines, // startV 0, // startI @@ -1005,7 +1005,7 @@ bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path, drawState->addCoverageEffect(hairQuadEffect, kEdgeAttrIndex)->unref(); int quads = 0; while (quads < quadCnt) { - int n = GrMin(quadCnt - quads, kNumQuadsInIdxBuffer); + int n = SkTMin(quadCnt - quads, kNumQuadsInIdxBuffer); target->drawIndexed(kTriangles_GrPrimitiveType, kVertsPerQuad*quads, // startV 0, // startI @@ -1024,7 +1024,7 @@ bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path, drawState->addCoverageEffect(hairConicEffect, 1, 2)->unref(); int conics = 0; while (conics < conicCnt) { - int n = GrMin(conicCnt - conics, kNumQuadsInIdxBuffer); + int n = SkTMin(conicCnt - conics, kNumQuadsInIdxBuffer); target->drawIndexed(kTriangles_GrPrimitiveType, kVertsPerQuad*(quadCnt + conics), // startV 0, // startI diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp index 2c21f09f00..d23041f236 100644 --- a/src/gpu/GrAARectRenderer.cpp +++ b/src/gpu/GrAARectRenderer.cpp @@ -261,12 +261,12 @@ namespace { extern const GrVertexAttrib gAARectCoverageAttribs[] = { {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, - {kVec4ub_GrVertexAttribType, sizeof(GrPoint), kCoverage_GrVertexAttribBinding}, + {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kCoverage_GrVertexAttribBinding}, }; extern const GrVertexAttrib gAARectColorAttribs[] = { {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, - {kVec4ub_GrVertexAttribType, sizeof(GrPoint), kColor_GrVertexAttribBinding}, + {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVertexAttribBinding}, }; static void set_aa_rect_vertex_attributes(GrDrawState* drawState, bool useCoverage) { @@ -277,7 +277,7 @@ static void set_aa_rect_vertex_attributes(GrDrawState* drawState, bool useCovera } } -static void set_inset_fan(GrPoint* pts, size_t stride, +static void set_inset_fan(SkPoint* pts, size_t stride, const SkRect& r, SkScalar dx, SkScalar dy) { pts->setRectFan(r.fLeft + dx, r.fTop + dy, r.fRight - dx, r.fBottom - dy, stride); @@ -299,7 +299,7 @@ static const uint16_t gFillAARectIdx[] = { 4, 5, 6, 6, 7, 4, }; -static const int kIndicesPerAAFillRect = GR_ARRAY_COUNT(gFillAARectIdx); +static const int kIndicesPerAAFillRect = SK_ARRAY_COUNT(gFillAARectIdx); static const int kVertsPerAAFillRect = 8; static const int kNumAAFillRectsInIndexBuffer = 256; @@ -414,8 +414,8 @@ static const uint16_t gBevelStrokeAARectIdx[] = { }; int GrAARectRenderer::aaStrokeRectIndexCount(bool miterStroke) { - return miterStroke ? GR_ARRAY_COUNT(gMiterStrokeAARectIdx) : - GR_ARRAY_COUNT(gBevelStrokeAARectIdx); + return miterStroke ? SK_ARRAY_COUNT(gMiterStrokeAARectIdx) : + SK_ARRAY_COUNT(gBevelStrokeAARectIdx); } GrIndexBuffer* GrAARectRenderer::aaStrokeRectIndexBuffer(GrGpu* gpu, bool miterStroke) { @@ -474,10 +474,10 @@ void GrAARectRenderer::geometryFillAARect(GrGpu* gpu, intptr_t verts = reinterpret_cast(geo.vertices()); size_t vsize = drawState->getVertexSize(); - SkASSERT(sizeof(GrPoint) + sizeof(GrColor) == vsize); + SkASSERT(sizeof(SkPoint) + sizeof(GrColor) == vsize); - GrPoint* fan0Pos = reinterpret_cast(verts); - GrPoint* fan1Pos = reinterpret_cast(verts + 4 * vsize); + SkPoint* fan0Pos = reinterpret_cast(verts); + SkPoint* fan1Pos = reinterpret_cast(verts + 4 * vsize); SkScalar inset = SkMinScalar(devRect.width(), SK_Scalar1); inset = SK_ScalarHalf * SkMinScalar(inset, devRect.height()); @@ -531,7 +531,7 @@ void GrAARectRenderer::geometryFillAARect(GrGpu* gpu, *((SkPoint*)((intptr_t)fan0Pos + 3 * vsize)) += vec[0] - vec[1]; } - verts += sizeof(GrPoint); + verts += sizeof(SkPoint); for (int i = 0; i < 4; ++i) { *reinterpret_cast(verts + i * vsize) = 0; } @@ -571,30 +571,30 @@ namespace { // Rotated struct RectVertex { - GrPoint fPos; - GrPoint fCenter; - GrPoint fDir; - GrPoint fWidthHeight; + SkPoint fPos; + SkPoint fCenter; + SkPoint fDir; + SkPoint fWidthHeight; }; // Rotated extern const GrVertexAttrib gAARectVertexAttribs[] = { { kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding }, - { kVec4f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding }, - { kVec2f_GrVertexAttribType, 3*sizeof(GrPoint), kEffect_GrVertexAttribBinding } + { kVec4f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding }, + { kVec2f_GrVertexAttribType, 3*sizeof(SkPoint), kEffect_GrVertexAttribBinding } }; // Axis Aligned struct AARectVertex { - GrPoint fPos; - GrPoint fOffset; - GrPoint fWidthHeight; + SkPoint fPos; + SkPoint fOffset; + SkPoint fWidthHeight; }; // Axis Aligned extern const GrVertexAttrib gAAAARectVertexAttribs[] = { { kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding }, - { kVec4f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding }, + { kVec4f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding }, }; }; @@ -695,7 +695,7 @@ void GrAARectRenderer::shaderFillAlignedAARect(GrGpu* gpu, devRect.fBottom + SK_ScalarHalf }; - GrPoint widthHeight = { + SkPoint widthHeight = { SkScalarHalf(devRect.width()) + SK_ScalarHalf, SkScalarHalf(devRect.height()) + SK_ScalarHalf }; @@ -728,7 +728,7 @@ void GrAARectRenderer::strokeAARect(GrGpu* gpu, const SkRect& devRect, const SkStrokeRec* stroke, bool useVertexCoverage) { - GrVec devStrokeSize; + SkVector devStrokeSize; SkScalar width = stroke->getWidth(); if (width > 0) { devStrokeSize.set(width, width); @@ -755,7 +755,7 @@ void GrAARectRenderer::strokeAARect(GrGpu* gpu, { SkScalar w = devRect.width() - dx; SkScalar h = devRect.height() - dy; - spare = GrMin(w, h); + spare = SkTMin(w, h); } SkRect devOutside(devRect); @@ -818,15 +818,15 @@ void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu, intptr_t verts = reinterpret_cast(geo.vertices()); size_t vsize = drawState->getVertexSize(); - SkASSERT(sizeof(GrPoint) + sizeof(GrColor) == vsize); + SkASSERT(sizeof(SkPoint) + sizeof(GrColor) == vsize); // We create vertices for four nested rectangles. There are two ramps from 0 to full // coverage, one on the exterior of the stroke and the other on the interior. // The following pointers refer to the four rects, from outermost to innermost. - GrPoint* fan0Pos = reinterpret_cast(verts); - GrPoint* fan1Pos = reinterpret_cast(verts + outerVertexNum * vsize); - GrPoint* fan2Pos = reinterpret_cast(verts + 2 * outerVertexNum * vsize); - GrPoint* fan3Pos = reinterpret_cast(verts + (2 * outerVertexNum + innerVertexNum) * vsize); + SkPoint* fan0Pos = reinterpret_cast(verts); + SkPoint* fan1Pos = reinterpret_cast(verts + outerVertexNum * vsize); + SkPoint* fan2Pos = reinterpret_cast(verts + 2 * outerVertexNum * vsize); + SkPoint* fan3Pos = reinterpret_cast(verts + (2 * outerVertexNum + innerVertexNum) * vsize); #ifndef SK_IGNORE_THIN_STROKED_RECT_FIX // TODO: this only really works if the X & Y margins are the same all around @@ -853,8 +853,8 @@ void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu, // innermost set_inset_fan(fan3Pos, vsize, devInside, SK_ScalarHalf, SK_ScalarHalf); } else { - GrPoint* fan0AssistPos = reinterpret_cast(verts + 4 * vsize); - GrPoint* fan1AssistPos = reinterpret_cast(verts + (outerVertexNum + 4) * vsize); + SkPoint* fan0AssistPos = reinterpret_cast(verts + 4 * vsize); + SkPoint* fan1AssistPos = reinterpret_cast(verts + (outerVertexNum + 4) * vsize); // outermost set_inset_fan(fan0Pos, vsize, devOutside, -SK_ScalarHalf, -SK_ScalarHalf); set_inset_fan(fan0AssistPos, vsize, devOutsideAssist, -SK_ScalarHalf, -SK_ScalarHalf); @@ -868,7 +868,7 @@ void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu, } // The outermost rect has 0 coverage - verts += sizeof(GrPoint); + verts += sizeof(SkPoint); for (int i = 0; i < outerVertexNum; ++i) { *reinterpret_cast(verts + i * vsize) = 0; } diff --git a/src/gpu/GrAllocPool.cpp b/src/gpu/GrAllocPool.cpp index d7b553176d..c92ebbd121 100644 --- a/src/gpu/GrAllocPool.cpp +++ b/src/gpu/GrAllocPool.cpp @@ -42,7 +42,7 @@ struct GrAllocPool::Block { size_t release(size_t bytes) { SkASSERT(bytes > 0); - size_t free = GrMin(bytes, fBytesTotal - fBytesFree); + size_t free = SkTMin(bytes, fBytesTotal - fBytesFree); fBytesFree += free; fPtr -= free; return bytes - free; @@ -55,7 +55,7 @@ struct GrAllocPool::Block { GrAllocPool::GrAllocPool(size_t blockSize) { fBlock = NULL; - fMinBlockSize = GrMax(blockSize, GrAllocPool_MIN_BLOCK_SIZE); + fMinBlockSize = SkTMax(blockSize, GrAllocPool_MIN_BLOCK_SIZE); SkDEBUGCODE(fBlocksAllocated = 0;) } @@ -80,7 +80,7 @@ void* GrAllocPool::alloc(size_t size) { this->validate(); if (!fBlock || !fBlock->canAlloc(size)) { - size_t blockSize = GrMax(fMinBlockSize, size); + size_t blockSize = SkTMax(fMinBlockSize, size); fBlock = Block::Create(blockSize, fBlock); SkDEBUGCODE(fBlocksAllocated += 1;) } diff --git a/src/gpu/GrAllocator.h b/src/gpu/GrAllocator.h index f2afec8e46..4e47fb1607 100644 --- a/src/gpu/GrAllocator.h +++ b/src/gpu/GrAllocator.h @@ -80,7 +80,7 @@ public: * removes all added items */ void reset() { - int blockCount = GrMax((unsigned)1, + int blockCount = SkTMax((unsigned)1, GrUIDivRoundUp(fCount, fItemsPerBlock)); for (int i = 1; i < blockCount; ++i) { sk_free(fBlocks[i]); diff --git a/src/gpu/GrBitmapTextContext.cpp b/src/gpu/GrBitmapTextContext.cpp index 3683e97201..3b5e27a90c 100755 --- a/src/gpu/GrBitmapTextContext.cpp +++ b/src/gpu/GrBitmapTextContext.cpp @@ -69,7 +69,7 @@ void GrBitmapTextContext::flushGlyphs() { if (fCurrVertex > 0) { // setup our sampler state for our text texture/atlas - SkASSERT(GrIsALIGN4(fCurrVertex)); + SkASSERT(SkIsAlign4(fCurrVertex)); SkASSERT(fCurrTexture); GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNone_FilterMode); @@ -475,13 +475,13 @@ namespace { // position + texture coord extern const GrVertexAttrib gTextVertexAttribs[] = { {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, - {kVec2f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding} + {kVec2f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding} }; }; void GrBitmapTextContext::drawPackedGlyph(GrGlyph::PackedID packed, - GrFixed vx, GrFixed vy, + SkFixed vx, SkFixed vy, GrFontScaler* scaler) { if (NULL == fDrawTarget) { return; @@ -500,8 +500,8 @@ void GrBitmapTextContext::drawPackedGlyph(GrGlyph::PackedID packed, vy += SkIntToFixed(glyph->fBounds.fTop); // keep them as ints until we've done the clip-test - GrFixed width = glyph->fBounds.width(); - GrFixed height = glyph->fBounds.height(); + SkFixed width = glyph->fBounds.width(); + SkFixed height = glyph->fBounds.height(); // check if we clipped out if (true || NULL == glyph->fPlot) { @@ -608,11 +608,11 @@ HAS_ATLAS: GrTCast(&fVertices), NULL); GrAlwaysAssert(success); - SkASSERT(2*sizeof(GrPoint) == fDrawTarget->getDrawState().getVertexSize()); + SkASSERT(2*sizeof(SkPoint) == fDrawTarget->getDrawState().getVertexSize()); } - GrFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX); - GrFixed ty = SkIntToFixed(glyph->fAtlasLocation.fY); + SkFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX); + SkFixed ty = SkIntToFixed(glyph->fAtlasLocation.fY); SkRect r; r.fLeft = SkFixedToFloat(vx); diff --git a/src/gpu/GrBitmapTextContext.h b/src/gpu/GrBitmapTextContext.h index 4122939849..18f5cc0eef 100644 --- a/src/gpu/GrBitmapTextContext.h +++ b/src/gpu/GrBitmapTextContext.h @@ -33,7 +33,7 @@ private: GrTextStrike* fStrike; void init(const GrPaint&, const SkPaint&); - void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, GrFontScaler*); + void drawPackedGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*); void flushGlyphs(); // automatically called by destructor void finish(); diff --git a/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp index b34fe8a8e3..2dbf3eb283 100644 --- a/src/gpu/GrBufferAllocPool.cpp +++ b/src/gpu/GrBufferAllocPool.cpp @@ -28,7 +28,7 @@ GrBufferAllocPool::GrBufferAllocPool(GrGpu* gpu, bool frequentResetHint, size_t blockSize, int preallocBufferCnt) : - fBlocks(GrMax(8, 2*preallocBufferCnt)) { + fBlocks(SkTMax(8, 2*preallocBufferCnt)) { SkASSERT(NULL != gpu); fGpu = gpu; @@ -38,7 +38,7 @@ GrBufferAllocPool::GrBufferAllocPool(GrGpu* gpu, fBufferType = bufferType; fFrequentResetHint = frequentResetHint; fBufferPtr = NULL; - fMinBlockSize = GrMax(GrBufferAllocPool_MIN_BLOCK_SIZE, blockSize); + fMinBlockSize = SkTMax(GrBufferAllocPool_MIN_BLOCK_SIZE, blockSize); fBytesInUse = 0; @@ -258,7 +258,7 @@ void GrBufferAllocPool::putBack(size_t bytes) { bool GrBufferAllocPool::createBlock(size_t requestSize) { - size_t size = GrMax(requestSize, fMinBlockSize); + size_t size = SkTMax(requestSize, fMinBlockSize); SkASSERT(size >= GrBufferAllocPool_MIN_BLOCK_SIZE); VALIDATE(); diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index c26327eecf..c2f62d8d00 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -270,14 +270,14 @@ static void stretchImage(void* dst, int srcW, int srcH, size_t bpp) { - GrFixed dx = (srcW << 16) / dstW; - GrFixed dy = (srcH << 16) / dstH; + SkFixed dx = (srcW << 16) / dstW; + SkFixed dy = (srcH << 16) / dstH; - GrFixed y = dy >> 1; + SkFixed y = dy >> 1; size_t dstXLimit = dstW*bpp; for (int j = 0; j < dstH; ++j) { - GrFixed x = dx >> 1; + SkFixed x = dx >> 1; void* srcRow = (uint8_t*)src + (y>>16)*srcW*bpp; void* dstRow = (uint8_t*)dst + j*dstW*bpp; for (size_t i = 0; i < dstXLimit; i += bpp) { @@ -295,7 +295,7 @@ namespace { // position + local coordinate extern const GrVertexAttrib gVertexAttribs[] = { {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, - {kVec2f_GrVertexAttribType, sizeof(GrPoint), kLocalCoord_GrVertexAttribBinding} + {kVec2f_GrVertexAttribType, sizeof(SkPoint), kLocalCoord_GrVertexAttribBinding} }; }; @@ -342,9 +342,9 @@ GrTexture* GrContext::createResizedTexture(const GrTextureDesc& desc, GrDrawTarget::AutoReleaseGeometry arg(fGpu, 4, 0); if (arg.succeeded()) { - GrPoint* verts = (GrPoint*) arg.vertices(); - verts[0].setIRectFan(0, 0, texture->width(), texture->height(), 2 * sizeof(GrPoint)); - verts[1].setIRectFan(0, 0, 1, 1, 2 * sizeof(GrPoint)); + SkPoint* verts = (SkPoint*) arg.vertices(); + verts[0].setIRectFan(0, 0, texture->width(), texture->height(), 2 * sizeof(SkPoint)); + verts[1].setIRectFan(0, 0, 1, 1, 2 * sizeof(SkPoint)); fGpu->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4); } } else { @@ -439,8 +439,8 @@ GrTexture* GrContext::lockAndRefScratchTexture(const GrTextureDesc& inDesc, Scra if (kApprox_ScratchTexMatch == match) { // bin by pow2 with a reasonable min static const int MIN_SIZE = 16; - desc.fWidth = GrMax(MIN_SIZE, GrNextPow2(desc.fWidth)); - desc.fHeight = GrMax(MIN_SIZE, GrNextPow2(desc.fHeight)); + desc.fWidth = SkTMax(MIN_SIZE, GrNextPow2(desc.fWidth)); + desc.fHeight = SkTMax(MIN_SIZE, GrNextPow2(desc.fHeight)); } GrResource* resource = NULL; @@ -580,7 +580,7 @@ void GrContext::setTextureCacheLimits(int maxTextures, size_t maxTextureBytes) { } int GrContext::getMaxTextureSize() const { - return GrMin(fGpu->caps()->maxTextureSize(), fMaxTextureSizeOverride); + return SkTMin(fGpu->caps()->maxTextureSize(), fMaxTextureSizeOverride); } int GrContext::getMaxRenderTargetSize() const { @@ -680,7 +680,7 @@ void GrContext::dumpFontCache() const { could use an indices array, and then only send 8 verts, but not sure that would be faster. */ -static void setStrokeRectStrip(GrPoint verts[10], SkRect rect, +static void setStrokeRectStrip(SkPoint verts[10], SkRect rect, SkScalar width) { const SkScalar rad = SkScalarHalf(width); rect.sort(); @@ -856,7 +856,7 @@ void GrContext::drawRect(const GrPaint& paint, GrPrimitiveType primType; int vertCount; - GrPoint* vertex = geo.positions(); + SkPoint* vertex = geo.positions(); if (width > 0) { vertCount = 10; @@ -904,17 +904,17 @@ namespace { extern const GrVertexAttrib gPosUVColorAttribs[] = { {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding }, - {kVec2f_GrVertexAttribType, sizeof(GrPoint), kLocalCoord_GrVertexAttribBinding }, - {kVec4ub_GrVertexAttribType, 2*sizeof(GrPoint), kColor_GrVertexAttribBinding} + {kVec2f_GrVertexAttribType, sizeof(SkPoint), kLocalCoord_GrVertexAttribBinding }, + {kVec4ub_GrVertexAttribType, 2*sizeof(SkPoint), kColor_GrVertexAttribBinding} }; extern const GrVertexAttrib gPosColorAttribs[] = { {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, - {kVec4ub_GrVertexAttribType, sizeof(GrPoint), kColor_GrVertexAttribBinding}, + {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVertexAttribBinding}, }; static void set_vertex_attributes(GrDrawState* drawState, - const GrPoint* texCoords, + const SkPoint* texCoords, const GrColor* colors, int* colorOffset, int* texOffset) { @@ -922,14 +922,14 @@ static void set_vertex_attributes(GrDrawState* drawState, *colorOffset = -1; if (NULL != texCoords && NULL != colors) { - *texOffset = sizeof(GrPoint); - *colorOffset = 2*sizeof(GrPoint); + *texOffset = sizeof(SkPoint); + *colorOffset = 2*sizeof(SkPoint); drawState->setVertexAttribs(3); } else if (NULL != texCoords) { - *texOffset = sizeof(GrPoint); + *texOffset = sizeof(SkPoint); drawState->setVertexAttribs(2); } else if (NULL != colors) { - *colorOffset = sizeof(GrPoint); + *colorOffset = sizeof(SkPoint); drawState->setVertexAttribs(2); } else { drawState->setVertexAttribs(1); @@ -941,8 +941,8 @@ static void set_vertex_attributes(GrDrawState* drawState, void GrContext::drawVertices(const GrPaint& paint, GrPrimitiveType primitiveType, int vertexCount, - const GrPoint positions[], - const GrPoint texCoords[], + const SkPoint positions[], + const SkPoint texCoords[], const GrColor colors[], const uint16_t indices[], int indexCount) { @@ -960,7 +960,7 @@ void GrContext::drawVertices(const GrPaint& paint, set_vertex_attributes(drawState, texCoords, colors, &colorOffset, &texOffset); size_t vertexSize = drawState->getVertexSize(); - if (sizeof(GrPoint) != vertexSize) { + if (sizeof(SkPoint) != vertexSize) { if (!geo.set(target, vertexCount, 0)) { GrPrintf("Failed to get space for vertices!\n"); return; @@ -968,10 +968,10 @@ void GrContext::drawVertices(const GrPaint& paint, void* curVertex = geo.vertices(); for (int i = 0; i < vertexCount; ++i) { - *((GrPoint*)curVertex) = positions[i]; + *((SkPoint*)curVertex) = positions[i]; if (texOffset >= 0) { - *(GrPoint*)((intptr_t)curVertex + texOffset) = texCoords[i]; + *(SkPoint*)((intptr_t)curVertex + texOffset) = texCoords[i]; } if (colorOffset >= 0) { *(GrColor*)((intptr_t)curVertex + colorOffset) = colors[i]; diff --git a/src/gpu/GrDefaultPathRenderer.cpp b/src/gpu/GrDefaultPathRenderer.cpp index 8d2b2b7267..01e1a94adc 100644 --- a/src/gpu/GrDefaultPathRenderer.cpp +++ b/src/gpu/GrDefaultPathRenderer.cpp @@ -239,11 +239,11 @@ bool GrDefaultPathRenderer::createGeom(const SkPath& path, uint16_t* idx = idxBase; uint16_t subpathIdxStart = 0; - GrPoint* base = reinterpret_cast(arg->vertices()); + SkPoint* base = reinterpret_cast(arg->vertices()); SkASSERT(NULL != base); - GrPoint* vert = base; + SkPoint* vert = base; - GrPoint pts[4]; + SkPoint pts[4]; bool first = true; int subpath = 0; diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp index 4ce336beb0..638ec59707 100755 --- a/src/gpu/GrDistanceFieldTextContext.cpp +++ b/src/gpu/GrDistanceFieldTextContext.cpp @@ -76,7 +76,7 @@ void GrDistanceFieldTextContext::flushGlyphs() { if (fCurrVertex > 0) { // setup our sampler state for our text texture/atlas - SkASSERT(GrIsALIGN4(fCurrVertex)); + SkASSERT(SkIsAlign4(fCurrVertex)); SkASSERT(fCurrTexture); GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBilerp_FilterMode); @@ -126,13 +126,13 @@ namespace { // position + texture coord extern const GrVertexAttrib gTextVertexAttribs[] = { {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, - {kVec2f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding} + {kVec2f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding} }; }; void GrDistanceFieldTextContext::drawPackedGlyph(GrGlyph::PackedID packed, - GrFixed vx, GrFixed vy, + SkFixed vx, SkFixed vy, GrFontScaler* scaler) { if (NULL == fDrawTarget) { return; @@ -257,7 +257,7 @@ HAS_ATLAS: GrTCast(&fVertices), NULL); GrAlwaysAssert(success); - SkASSERT(2*sizeof(GrPoint) == fDrawTarget->getDrawState().getVertexSize()); + SkASSERT(2*sizeof(SkPoint) == fDrawTarget->getDrawState().getVertexSize()); } SkScalar dx = SkIntToScalar(glyph->fBounds.fLeft); @@ -273,10 +273,10 @@ HAS_ATLAS: width *= scale; height *= scale; - GrFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX); - GrFixed ty = SkIntToFixed(glyph->fAtlasLocation.fY); - GrFixed tw = SkIntToFixed(glyph->fBounds.width()); - GrFixed th = SkIntToFixed(glyph->fBounds.height()); + SkFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX); + SkFixed ty = SkIntToFixed(glyph->fAtlasLocation.fY); + SkFixed tw = SkIntToFixed(glyph->fBounds.width()); + SkFixed th = SkIntToFixed(glyph->fBounds.height()); static const size_t kVertexSize = 2 * sizeof(SkPoint); fVertices[2*fCurrVertex].setRectFan(sx, diff --git a/src/gpu/GrDistanceFieldTextContext.h b/src/gpu/GrDistanceFieldTextContext.h index 63fe8efcb8..26208822d9 100644 --- a/src/gpu/GrDistanceFieldTextContext.h +++ b/src/gpu/GrDistanceFieldTextContext.h @@ -34,7 +34,7 @@ private: SkScalar fTextRatio; void init(const GrPaint&, const SkPaint&); - void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, GrFontScaler*); + void drawPackedGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*); void flushGlyphs(); // automatically called by destructor void finish(); diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h index 3de0b12e85..de28600ddf 100644 --- a/src/gpu/GrDrawState.h +++ b/src/gpu/GrDrawState.h @@ -185,20 +185,20 @@ public: * Defaults to zero (corresponding to vertex position) * @return pointer to the vertex component as a GrPoint */ - static GrPoint* GetVertexPoint(void* vertices, + static SkPoint* GetVertexPoint(void* vertices, int vertexIndex, int vertexSize, int offset = 0) { intptr_t start = GrTCast(vertices); - return GrTCast(start + offset + + return GrTCast(start + offset + vertexIndex * vertexSize); } - static const GrPoint* GetVertexPoint(const void* vertices, + static const SkPoint* GetVertexPoint(const void* vertices, int vertexIndex, int vertexSize, int offset = 0) { intptr_t start = GrTCast(vertices); - return GrTCast(start + offset + + return GrTCast(start + offset + vertexIndex * vertexSize); } diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index 10698442b2..593932e76d 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -651,7 +651,7 @@ void GrDrawTarget::drawIndexedInstances(GrPrimitiveType type, } while (instanceCount) { - info.fInstanceCount = GrMin(instanceCount, maxInstancesPerDraw); + info.fInstanceCount = SkTMin(instanceCount, maxInstancesPerDraw); info.fVertexCount = info.fInstanceCount * verticesPerInstance; info.fIndexCount = info.fInstanceCount * indicesPerInstance; @@ -674,7 +674,7 @@ namespace { // position + (optional) texture coord extern const GrVertexAttrib gBWRectPosUVAttribs[] = { {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, - {kVec2f_GrVertexAttribType, sizeof(GrPoint), kLocalCoord_GrVertexAttribBinding} + {kVec2f_GrVertexAttribType, sizeof(SkPoint), kLocalCoord_GrVertexAttribBinding} }; void set_vertex_attributes(GrDrawState* drawState, bool hasUVs) { @@ -708,8 +708,8 @@ void GrDrawTarget::onDrawRect(const SkRect& rect, size_t vsize = this->drawState()->getVertexSize(); geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vsize); if (NULL != localRect) { - GrPoint* coords = GrTCast(GrTCast(geo.vertices()) + - sizeof(GrPoint)); + SkPoint* coords = GrTCast(GrTCast(geo.vertices()) + + sizeof(SkPoint)); coords->setRectFan(localRect->fLeft, localRect->fTop, localRect->fRight, localRect->fBottom, vsize); diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index 6b3d4637cc..ece2b8822e 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -607,8 +607,8 @@ public: bool succeeded() const { return NULL != fTarget; } void* vertices() const { SkASSERT(this->succeeded()); return fVertices; } void* indices() const { SkASSERT(this->succeeded()); return fIndices; } - GrPoint* positions() const { - return static_cast(this->vertices()); + SkPoint* positions() const { + return static_cast(this->vertices()); } private: diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp index 8d34e6cf76..d0ec73c9eb 100644 --- a/src/gpu/GrInOrderDrawBuffer.cpp +++ b/src/gpu/GrInOrderDrawBuffer.cpp @@ -62,13 +62,13 @@ void get_vertex_bounds(const void* vertices, size_t vertexSize, int vertexCount, SkRect* bounds) { - SkASSERT(vertexSize >= sizeof(GrPoint)); + SkASSERT(vertexSize >= sizeof(SkPoint)); SkASSERT(vertexCount > 0); - const GrPoint* point = static_cast(vertices); + const SkPoint* point = static_cast(vertices); bounds->fLeft = bounds->fRight = point->fX; bounds->fTop = bounds->fBottom = point->fY; for (int i = 1; i < vertexCount; ++i) { - point = reinterpret_cast(reinterpret_cast(point) + vertexSize); + point = reinterpret_cast(reinterpret_cast(point) + vertexSize); bounds->growToInclude(point->fX, point->fY); } } @@ -79,14 +79,14 @@ namespace { extern const GrVertexAttrib kRectPosColorUVAttribs[] = { {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, - {kVec4ub_GrVertexAttribType, sizeof(GrPoint), kColor_GrVertexAttribBinding}, - {kVec2f_GrVertexAttribType, sizeof(GrPoint)+sizeof(GrColor), + {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVertexAttribBinding}, + {kVec2f_GrVertexAttribType, sizeof(SkPoint)+sizeof(GrColor), kLocalCoord_GrVertexAttribBinding}, }; extern const GrVertexAttrib kRectPosUVAttribs[] = { {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, - {kVec2f_GrVertexAttribType, sizeof(GrPoint), kLocalCoord_GrVertexAttribBinding}, + {kVec2f_GrVertexAttribType, sizeof(SkPoint), kLocalCoord_GrVertexAttribBinding}, }; static void set_vertex_attributes(GrDrawState* drawState, @@ -102,14 +102,14 @@ static void set_vertex_attributes(GrDrawState* drawState, // dual-source blending isn't available. This comes into play when there is coverage. If colors // were a stage it could take a hint that every vertex's color will be opaque. if (hasColor && hasUVs) { - *colorOffset = sizeof(GrPoint); - *localOffset = sizeof(GrPoint) + sizeof(GrColor); + *colorOffset = sizeof(SkPoint); + *localOffset = sizeof(SkPoint) + sizeof(GrColor); drawState->setVertexAttribs(3); } else if (hasColor) { - *colorOffset = sizeof(GrPoint); + *colorOffset = sizeof(SkPoint); drawState->setVertexAttribs(2); } else if (hasUVs) { - *localOffset = sizeof(GrPoint); + *localOffset = sizeof(SkPoint); drawState->setVertexAttribs(2); } else { drawState->setVertexAttribs(1); @@ -192,7 +192,7 @@ void GrInOrderDrawBuffer::onDrawRect(const SkRect& rect, get_vertex_bounds(geo.vertices(), vsize, 4, &devBounds); if (localOffset >= 0) { - GrPoint* coords = GrTCast(GrTCast(geo.vertices()) + localOffset); + SkPoint* coords = GrTCast(GrTCast(geo.vertices()) + localOffset); coords->setRectFan(localRect->fLeft, localRect->fTop, localRect->fRight, localRect->fBottom, vsize); @@ -300,12 +300,12 @@ int GrInOrderDrawBuffer::concatInstancedDraw(const DrawInfo& info) { // how many instances can be concat'ed onto draw given the size of the index buffer int instancesToConcat = this->indexCountInCurrentSource() / info.indicesPerInstance(); instancesToConcat -= draw->instanceCount(); - instancesToConcat = GrMin(instancesToConcat, info.instanceCount()); + instancesToConcat = SkTMin(instancesToConcat, info.instanceCount()); // update the amount of reserved vertex data actually referenced in draws size_t vertexBytes = instancesToConcat * info.verticesPerInstance() * drawState.getVertexSize(); - poolState.fUsedPoolVertexBytes = GrMax(poolState.fUsedPoolVertexBytes, vertexBytes); + poolState.fUsedPoolVertexBytes = SkTMax(poolState.fUsedPoolVertexBytes, vertexBytes); draw->adjustInstanceCount(instancesToConcat); @@ -380,7 +380,7 @@ void GrInOrderDrawBuffer::onDraw(const DrawInfo& info) { case kArray_GeometrySrcType: { size_t vertexBytes = (info.vertexCount() + info.startVertex()) * drawState.getVertexSize(); - poolState.fUsedPoolVertexBytes = GrMax(poolState.fUsedPoolVertexBytes, vertexBytes); + poolState.fUsedPoolVertexBytes = SkTMax(poolState.fUsedPoolVertexBytes, vertexBytes); draw->fVertexBuffer = poolState.fPoolVertexBuffer; draw->adjustStartVertex(poolState.fPoolStartVertex); break; @@ -398,7 +398,7 @@ void GrInOrderDrawBuffer::onDraw(const DrawInfo& info) { case kReserved_GeometrySrcType: // fallthrough case kArray_GeometrySrcType: { size_t indexBytes = (info.indexCount() + info.startIndex()) * sizeof(uint16_t); - poolState.fUsedPoolIndexBytes = GrMax(poolState.fUsedPoolIndexBytes, indexBytes); + poolState.fUsedPoolIndexBytes = SkTMax(poolState.fUsedPoolIndexBytes, indexBytes); draw->fIndexBuffer = poolState.fPoolIndexBuffer; draw->adjustStartIndex(poolState.fPoolStartIndex); break; diff --git a/src/gpu/GrMemoryPool.cpp b/src/gpu/GrMemoryPool.cpp index 75a3c9a3b9..8839c66d07 100644 --- a/src/gpu/GrMemoryPool.cpp +++ b/src/gpu/GrMemoryPool.cpp @@ -16,10 +16,10 @@ GrMemoryPool::GrMemoryPool(size_t preallocSize, size_t minAllocSize) { SkDEBUGCODE(fAllocationCnt = 0); - minAllocSize = GrMax(minAllocSize, 1 << 10); + minAllocSize = SkTMax(minAllocSize, 1 << 10); fMinAllocSize = GrSizeAlignUp(minAllocSize + kPerAllocPad, kAlignment), fPreallocSize = GrSizeAlignUp(preallocSize + kPerAllocPad, kAlignment); - fPreallocSize = GrMax(fPreallocSize, fMinAllocSize); + fPreallocSize = SkTMax(fPreallocSize, fMinAllocSize); fHead = CreateBlock(fPreallocSize); fTail = fHead; @@ -42,7 +42,7 @@ void* GrMemoryPool::allocate(size_t size) { size += kPerAllocPad; if (fTail->fFreeSize < size) { size_t blockSize = size; - blockSize = GrMax(blockSize, fMinAllocSize); + blockSize = SkTMax(blockSize, fMinAllocSize); BlockHeader* block = CreateBlock(blockSize); block->fPrev = fTail; diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp index 23ce230bfa..190bf9d257 100644 --- a/src/gpu/GrOvalRenderer.cpp +++ b/src/gpu/GrOvalRenderer.cpp @@ -25,23 +25,23 @@ namespace { struct CircleVertex { - GrPoint fPos; - GrPoint fOffset; + SkPoint fPos; + SkPoint fOffset; SkScalar fOuterRadius; SkScalar fInnerRadius; }; struct EllipseVertex { - GrPoint fPos; - GrPoint fOffset; - GrPoint fOuterRadii; - GrPoint fInnerRadii; + SkPoint fPos; + SkPoint fOffset; + SkPoint fOuterRadii; + SkPoint fInnerRadii; }; struct DIEllipseVertex { - GrPoint fPos; - GrPoint fOuterOffset; - GrPoint fInnerOffset; + SkPoint fPos; + SkPoint fOuterOffset; + SkPoint fInnerOffset; }; inline bool circle_stays_circle(const SkMatrix& m) { @@ -492,7 +492,7 @@ bool GrOvalRenderer::drawOval(GrDrawTarget* target, const GrContext* context, bo // position + edge extern const GrVertexAttrib gCircleVertexAttribs[] = { {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, - {kVec4f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding} + {kVec4f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding} }; void GrOvalRenderer::drawCircle(GrDrawTarget* target, @@ -503,7 +503,7 @@ void GrOvalRenderer::drawCircle(GrDrawTarget* target, GrDrawState* drawState = target->drawState(); const SkMatrix& vm = drawState->getViewMatrix(); - GrPoint center = GrPoint::Make(circle.centerX(), circle.centerY()); + SkPoint center = SkPoint::Make(circle.centerX(), circle.centerY()); vm.mapPoints(¢er, 1); SkScalar radius = vm.mapRadius(SkScalarHalf(circle.width())); SkScalar strokeWidth = vm.mapRadius(stroke.getWidth()); @@ -589,15 +589,15 @@ void GrOvalRenderer::drawCircle(GrDrawTarget* target, // position + offset + 1/radii extern const GrVertexAttrib gEllipseVertexAttribs[] = { {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, - {kVec2f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding}, - {kVec4f_GrVertexAttribType, 2*sizeof(GrPoint), kEffect_GrVertexAttribBinding} + {kVec2f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding}, + {kVec4f_GrVertexAttribType, 2*sizeof(SkPoint), kEffect_GrVertexAttribBinding} }; // position + offsets extern const GrVertexAttrib gDIEllipseVertexAttribs[] = { {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, - {kVec2f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding}, - {kVec2f_GrVertexAttribType, 2*sizeof(GrPoint), kEffect_GrVertexAttribBinding}, + {kVec2f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding}, + {kVec2f_GrVertexAttribType, 2*sizeof(SkPoint), kEffect_GrVertexAttribBinding}, }; bool GrOvalRenderer::drawEllipse(GrDrawTarget* target, @@ -616,7 +616,7 @@ bool GrOvalRenderer::drawEllipse(GrDrawTarget* target, // do any matrix crunching before we reset the draw state for device coords const SkMatrix& vm = drawState->getViewMatrix(); - GrPoint center = GrPoint::Make(ellipse.centerX(), ellipse.centerY()); + SkPoint center = SkPoint::Make(ellipse.centerX(), ellipse.centerY()); vm.mapPoints(¢er, 1); SkScalar ellipseXRadius = SkScalarHalf(ellipse.width()); SkScalar ellipseYRadius = SkScalarHalf(ellipse.height()); @@ -740,7 +740,7 @@ bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target, GrDrawState* drawState = target->drawState(); const SkMatrix& vm = drawState->getViewMatrix(); - GrPoint center = GrPoint::Make(ellipse.centerX(), ellipse.centerY()); + SkPoint center = SkPoint::Make(ellipse.centerX(), ellipse.centerY()); SkScalar xRadius = SkScalarHalf(ellipse.width()); SkScalar yRadius = SkScalarHalf(ellipse.height()); @@ -1031,7 +1031,7 @@ bool GrOvalRenderer::drawSimpleRRect(GrDrawTarget* target, GrContext* context, b } // drop out the middle quad if we're stroked - int indexCnt = isStroked ? GR_ARRAY_COUNT(gRRectIndices)-6 : GR_ARRAY_COUNT(gRRectIndices); + int indexCnt = isStroked ? SK_ARRAY_COUNT(gRRectIndices)-6 : SK_ARRAY_COUNT(gRRectIndices); target->setIndexSourceToBuffer(indexBuffer); target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bounds); @@ -1140,7 +1140,7 @@ bool GrOvalRenderer::drawSimpleRRect(GrDrawTarget* target, GrContext* context, b } // drop out the middle quad if we're stroked - int indexCnt = isStroked ? GR_ARRAY_COUNT(gRRectIndices)-6 : GR_ARRAY_COUNT(gRRectIndices); + int indexCnt = isStroked ? SK_ARRAY_COUNT(gRRectIndices)-6 : SK_ARRAY_COUNT(gRRectIndices); target->setIndexSourceToBuffer(indexBuffer); target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bounds); } diff --git a/src/gpu/GrPathUtils.cpp b/src/gpu/GrPathUtils.cpp index 2f6006947f..5fead5dea2 100644 --- a/src/gpu/GrPathUtils.cpp +++ b/src/gpu/GrPathUtils.cpp @@ -36,7 +36,7 @@ SkScalar GrPathUtils::scaleToleranceToSrc(SkScalar devTol, static const int MAX_POINTS_PER_CURVE = 1 << 10; static const SkScalar gMinCurveTol = 0.0001f; -uint32_t GrPathUtils::quadraticPointCount(const GrPoint points[], +uint32_t GrPathUtils::quadraticPointCount(const SkPoint points[], SkScalar tol) { if (tol < gMinCurveTol) { tol = gMinCurveTol; @@ -59,15 +59,15 @@ uint32_t GrPathUtils::quadraticPointCount(const GrPoint points[], if (pow2 < 1) { pow2 = 1; } - return GrMin(pow2, MAX_POINTS_PER_CURVE); + return SkTMin(pow2, MAX_POINTS_PER_CURVE); } } -uint32_t GrPathUtils::generateQuadraticPoints(const GrPoint& p0, - const GrPoint& p1, - const GrPoint& p2, +uint32_t GrPathUtils::generateQuadraticPoints(const SkPoint& p0, + const SkPoint& p1, + const SkPoint& p2, SkScalar tolSqd, - GrPoint** points, + SkPoint** points, uint32_t pointsLeft) { if (pointsLeft < 2 || (p1.distanceToLineSegmentBetweenSqd(p0, p2)) < tolSqd) { @@ -76,11 +76,11 @@ uint32_t GrPathUtils::generateQuadraticPoints(const GrPoint& p0, return 1; } - GrPoint q[] = { + SkPoint q[] = { { SkScalarAve(p0.fX, p1.fX), SkScalarAve(p0.fY, p1.fY) }, { SkScalarAve(p1.fX, p2.fX), SkScalarAve(p1.fY, p2.fY) }, }; - GrPoint r = { SkScalarAve(q[0].fX, q[1].fX), SkScalarAve(q[0].fY, q[1].fY) }; + SkPoint r = { SkScalarAve(q[0].fX, q[1].fX), SkScalarAve(q[0].fY, q[1].fY) }; pointsLeft >>= 1; uint32_t a = generateQuadraticPoints(p0, q[0], r, tolSqd, points, pointsLeft); @@ -88,14 +88,14 @@ uint32_t GrPathUtils::generateQuadraticPoints(const GrPoint& p0, return a + b; } -uint32_t GrPathUtils::cubicPointCount(const GrPoint points[], +uint32_t GrPathUtils::cubicPointCount(const SkPoint points[], SkScalar tol) { if (tol < gMinCurveTol) { tol = gMinCurveTol; } SkASSERT(tol > 0); - SkScalar d = GrMax( + SkScalar d = SkTMax( points[1].distanceToLineSegmentBetweenSqd(points[0], points[3]), points[2].distanceToLineSegmentBetweenSqd(points[0], points[3])); d = SkScalarSqrt(d); @@ -110,16 +110,16 @@ uint32_t GrPathUtils::cubicPointCount(const GrPoint points[], if (pow2 < 1) { pow2 = 1; } - return GrMin(pow2, MAX_POINTS_PER_CURVE); + return SkTMin(pow2, MAX_POINTS_PER_CURVE); } } -uint32_t GrPathUtils::generateCubicPoints(const GrPoint& p0, - const GrPoint& p1, - const GrPoint& p2, - const GrPoint& p3, +uint32_t GrPathUtils::generateCubicPoints(const SkPoint& p0, + const SkPoint& p1, + const SkPoint& p2, + const SkPoint& p3, SkScalar tolSqd, - GrPoint** points, + SkPoint** points, uint32_t pointsLeft) { if (pointsLeft < 2 || (p1.distanceToLineSegmentBetweenSqd(p0, p3) < tolSqd && @@ -128,16 +128,16 @@ uint32_t GrPathUtils::generateCubicPoints(const GrPoint& p0, *points += 1; return 1; } - GrPoint q[] = { + SkPoint q[] = { { SkScalarAve(p0.fX, p1.fX), SkScalarAve(p0.fY, p1.fY) }, { SkScalarAve(p1.fX, p2.fX), SkScalarAve(p1.fY, p2.fY) }, { SkScalarAve(p2.fX, p3.fX), SkScalarAve(p2.fY, p3.fY) } }; - GrPoint r[] = { + SkPoint r[] = { { SkScalarAve(q[0].fX, q[1].fX), SkScalarAve(q[0].fY, q[1].fY) }, { SkScalarAve(q[1].fX, q[2].fX), SkScalarAve(q[1].fY, q[2].fY) } }; - GrPoint s = { SkScalarAve(r[0].fX, r[1].fX), SkScalarAve(r[0].fY, r[1].fY) }; + SkPoint s = { SkScalarAve(r[0].fX, r[1].fX), SkScalarAve(r[0].fY, r[1].fY) }; pointsLeft >>= 1; uint32_t a = generateCubicPoints(p0, q[0], r[0], s, tolSqd, points, pointsLeft); uint32_t b = generateCubicPoints(s, r[1], q[2], p3, tolSqd, points, pointsLeft); @@ -159,7 +159,7 @@ int GrPathUtils::worstCasePointCount(const SkPath& path, int* subpaths, SkPath::Iter iter(path, false); SkPath::Verb verb; - GrPoint pts[4]; + SkPoint pts[4]; while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { switch (verb) { @@ -186,7 +186,7 @@ int GrPathUtils::worstCasePointCount(const SkPath& path, int* subpaths, return pointCount; } -void GrPathUtils::QuadUVMatrix::set(const GrPoint qPts[3]) { +void GrPathUtils::QuadUVMatrix::set(const SkPoint qPts[3]) { SkMatrix m; // We want M such that M * xy_pt = uv_pt // We know M * control_pts = [0 1/2 1] @@ -226,11 +226,11 @@ void GrPathUtils::QuadUVMatrix::set(const GrPoint qPts[3]) { // We could have a tolerance here, not sure if it would improve anything if (maxD > 0) { // Set the matrix to give (u = 0, v = distance_to_line) - GrVec lineVec = qPts[(maxEdge + 1)%3] - qPts[maxEdge]; + SkVector lineVec = qPts[(maxEdge + 1)%3] - qPts[maxEdge]; // when looking from the point 0 down the line we want positive // distances to be to the left. This matches the non-degenerate // case. - lineVec.setOrthog(lineVec, GrPoint::kLeft_Side); + lineVec.setOrthog(lineVec, SkPoint::kLeft_Side); lineVec.dot(qPts[0]); // first row fM[0] = 0; @@ -519,7 +519,7 @@ void convert_noninflect_cubic_to_quads(const SkPoint p[4], } } -void GrPathUtils::convertCubicToQuads(const GrPoint p[4], +void GrPathUtils::convertCubicToQuads(const SkPoint p[4], SkScalar tolScale, bool constrainWithinTangents, SkPath::Direction dir, diff --git a/src/gpu/GrPathUtils.h b/src/gpu/GrPathUtils.h index 71f6e0b9c1..d6c18ea4a8 100644 --- a/src/gpu/GrPathUtils.h +++ b/src/gpu/GrPathUtils.h @@ -31,25 +31,25 @@ namespace GrPathUtils { /// Since we divide by tol if we're computing exact worst-case bounds, /// very small tolerances will be increased to gMinCurveTol. - uint32_t quadraticPointCount(const GrPoint points[], SkScalar tol); + uint32_t quadraticPointCount(const SkPoint points[], SkScalar tol); - uint32_t generateQuadraticPoints(const GrPoint& p0, - const GrPoint& p1, - const GrPoint& p2, + uint32_t generateQuadraticPoints(const SkPoint& p0, + const SkPoint& p1, + const SkPoint& p2, SkScalar tolSqd, - GrPoint** points, + SkPoint** points, uint32_t pointsLeft); /// Since we divide by tol if we're computing exact worst-case bounds, /// very small tolerances will be increased to gMinCurveTol. - uint32_t cubicPointCount(const GrPoint points[], SkScalar tol); + uint32_t cubicPointCount(const SkPoint points[], SkScalar tol); - uint32_t generateCubicPoints(const GrPoint& p0, - const GrPoint& p1, - const GrPoint& p2, - const GrPoint& p3, + uint32_t generateCubicPoints(const SkPoint& p0, + const SkPoint& p1, + const SkPoint& p2, + const SkPoint& p3, SkScalar tolSqd, - GrPoint** points, + SkPoint** points, uint32_t pointsLeft); // A 2x3 matrix that goes from the 2d space coordinates to UV space where @@ -59,8 +59,8 @@ namespace GrPathUtils { public: QuadUVMatrix() {}; // Initialize the matrix from the control pts - QuadUVMatrix(const GrPoint controlPts[3]) { this->set(controlPts); } - void set(const GrPoint controlPts[3]); + QuadUVMatrix(const SkPoint controlPts[3]) { this->set(controlPts); } + void set(const SkPoint controlPts[3]); /** * Applies the matrix to vertex positions to compute UV coords. This @@ -85,8 +85,8 @@ namespace GrPathUtils { float sy = fM[4]; float ty = fM[5]; for (int i = 0; i < N; ++i) { - const GrPoint* xy = reinterpret_cast(xyPtr); - GrPoint* uv = reinterpret_cast(uvPtr); + const SkPoint* xy = reinterpret_cast(xyPtr); + SkPoint* uv = reinterpret_cast(uvPtr); uv->fX = sx * xy->fX + kx * xy->fY + tx; uv->fY = ky * xy->fX + sy * xy->fY + ty; xyPtr += STRIDE; @@ -119,7 +119,7 @@ namespace GrPathUtils { // Setting constrainWithinTangents to true enforces this property. When this // is true the cubic must be simple and dir must specify the orientation of // the cubic. Otherwise, dir is ignored. - void convertCubicToQuads(const GrPoint p[4], + void convertCubicToQuads(const SkPoint p[4], SkScalar tolScale, bool constrainWithinTangents, SkPath::Direction dir, diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp index 729aa0d469..9348dc16a6 100644 --- a/src/gpu/GrRenderTarget.cpp +++ b/src/gpu/GrRenderTarget.cpp @@ -73,7 +73,7 @@ size_t GrRenderTarget::sizeInBytes() const { uint64_t size = fDesc.fWidth; size *= fDesc.fHeight; size *= colorBits; - size *= GrMax(1, fDesc.fSampleCnt); + size *= SkTMax(1, fDesc.fSampleCnt); return (size_t)(size / 8); } diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index a849c84e4e..1e52d23fba 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -609,7 +609,7 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, fContext->drawVertices(grPaint, gPointMode2PrimtiveType[mode], SkToS32(count), - (GrPoint*)pts, + (SkPoint*)pts, NULL, NULL, NULL, @@ -1797,8 +1797,8 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, fContext->drawVertices(grPaint, gVertexMode2PrimitiveType[vmode], vertexCount, - (GrPoint*) vertices, - (GrPoint*) texs, + vertices, + texs, colors, indices, indexCount); diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index daf51414f2..9b342fb463 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -154,9 +154,9 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context for (int x = 0; x < 256; ++x) { uint8_t* color = reinterpret_cast(&srcData[256*y + x]); color[3] = y; - color[2] = GrMin(x, y); - color[1] = GrMin(x, y); - color[0] = GrMin(x, y); + color[2] = SkTMin(x, y); + color[1] = SkTMin(x, y); + color[0] = SkTMin(x, y); } } @@ -190,7 +190,7 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context bool failed = true; - for (size_t i = 0; i < GR_ARRAY_COUNT(kConversionRules) && failed; ++i) { + for (size_t i = 0; i < SK_ARRAY_COUNT(kConversionRules) && failed; ++i) { *pmToUPMRule = kConversionRules[i][0]; *upmToPMRule = kConversionRules[i][1]; diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp index b27b737f39..841561baa9 100644 --- a/src/gpu/effects/GrSimpleTextureEffect.cpp +++ b/src/gpu/effects/GrSimpleTextureEffect.cpp @@ -73,7 +73,7 @@ GrEffectRef* GrSimpleTextureEffect::TestCreate(SkRandom* random, kLocal_GrCoordSet, kPosition_GrCoordSet }; - GrCoordSet coordSet = kCoordSets[random->nextULessThan(GR_ARRAY_COUNT(kCoordSets))]; + GrCoordSet coordSet = kCoordSets[random->nextULessThan(SK_ARRAY_COUNT(kCoordSets))]; const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); return GrSimpleTextureEffect::Create(textures[texIdx], matrix, coordSet); diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index bf7939ccee..c4b7c2fbed 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -310,7 +310,7 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { GR_GL_GetIntegerv(gli, GR_GL_MAX_RENDERBUFFER_SIZE, &fMaxRenderTargetSize); // Our render targets are always created with textures as the color // attachment, hence this min: - fMaxRenderTargetSize = GrMin(fMaxTextureSize, fMaxRenderTargetSize); + fMaxRenderTargetSize = SkTMin(fMaxTextureSize, fMaxRenderTargetSize); fPathRenderingSupport = ctxInfo.hasExtension("GL_NV_path_rendering"); SkASSERT(!fPathRenderingSupport || fFixedFunctionSupport); @@ -620,7 +620,7 @@ SkString GrGLCaps::dump() const { GR_STATIC_ASSERT(4 == kES_Apple_MSFBOType); GR_STATIC_ASSERT(5 == kES_IMG_MsToTexture_MSFBOType); GR_STATIC_ASSERT(6 == kES_EXT_MsToTexture_MSFBOType); - GR_STATIC_ASSERT(GR_ARRAY_COUNT(kMSFBOExtStr) == kLast_MSFBOType + 1); + GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMSFBOExtStr) == kLast_MSFBOType + 1); static const char* kFBFetchTypeStr[] = { "None", @@ -630,7 +630,7 @@ SkString GrGLCaps::dump() const { GR_STATIC_ASSERT(0 == kNone_FBFetchType); GR_STATIC_ASSERT(1 == kEXT_FBFetchType); GR_STATIC_ASSERT(2 == kNV_FBFetchType); - GR_STATIC_ASSERT(GR_ARRAY_COUNT(kFBFetchTypeStr) == kLast_FBFetchType + 1); + GR_STATIC_ASSERT(SK_ARRAY_COUNT(kFBFetchTypeStr) == kLast_FBFetchType + 1); r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); diff --git a/src/gpu/gl/GrGLNoOpInterface.cpp b/src/gpu/gl/GrGLNoOpInterface.cpp index 65729c962d..de38f6aaa6 100644 --- a/src/gpu/gl/GrGLNoOpInterface.cpp +++ b/src/gpu/gl/GrGLNoOpInterface.cpp @@ -37,11 +37,11 @@ const GrGLubyte* combined_extensions_string() { static SkMutex gMutex; gMutex.acquire(); if (0 == gExtString.size()) { - for (size_t i = 0; i < GR_ARRAY_COUNT(kExtensions) - 1; ++i) { + for (size_t i = 0; i < SK_ARRAY_COUNT(kExtensions) - 1; ++i) { gExtString.append(kExtensions[i]); gExtString.append(" "); } - gExtString.append(kExtensions[GR_ARRAY_COUNT(kExtensions) - 1]); + gExtString.append(kExtensions[SK_ARRAY_COUNT(kExtensions) - 1]); } gMutex.release(); return (const GrGLubyte*) gExtString.c_str(); @@ -509,7 +509,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetIntegerv(GrGLenum pname, GrGLint* params) *params = kDefaultMaxVaryingVectors; break; case GR_GL_NUM_EXTENSIONS: - *params = GR_ARRAY_COUNT(kExtensions); + *params = SK_ARRAY_COUNT(kExtensions); break; default: GrCrash("Unexpected pname to GetIntegerv"); @@ -623,7 +623,7 @@ const GrGLubyte* GR_GL_FUNCTION_TYPE noOpGLGetString(GrGLenum name) { const GrGLubyte* GR_GL_FUNCTION_TYPE noOpGLGetStringi(GrGLenum name, GrGLuint i) { switch (name) { case GR_GL_EXTENSIONS: - if (static_cast(i) <= GR_ARRAY_COUNT(kExtensions)) { + if (static_cast(i) <= SK_ARRAY_COUNT(kExtensions)) { return (const GrGLubyte*) kExtensions[i]; } else { return NULL; diff --git a/src/gpu/gl/GrGLPath.cpp b/src/gpu/gl/GrGLPath.cpp index 514c8c738c..879edd5090 100644 --- a/src/gpu/gl/GrGLPath.cpp +++ b/src/gpu/gl/GrGLPath.cpp @@ -30,7 +30,7 @@ inline GrGLubyte verb_to_gl_path_cmd(SkPath::Verb verb) { GR_STATIC_ASSERT(4 == SkPath::kCubic_Verb); GR_STATIC_ASSERT(5 == SkPath::kClose_Verb); - SkASSERT(verb >= 0 && (size_t)verb < GR_ARRAY_COUNT(gTable)); + SkASSERT(verb >= 0 && (size_t)verb < SK_ARRAY_COUNT(gTable)); return gTable[verb]; } @@ -50,7 +50,7 @@ inline int num_pts(SkPath::Verb verb) { GR_STATIC_ASSERT(4 == SkPath::kCubic_Verb); GR_STATIC_ASSERT(5 == SkPath::kClose_Verb); - SkASSERT(verb >= 0 && (size_t)verb < GR_ARRAY_COUNT(gTable)); + SkASSERT(verb >= 0 && (size_t)verb < SK_ARRAY_COUNT(gTable)); return gTable[verb]; } #endif @@ -65,7 +65,7 @@ inline GrGLenum join_to_gl_join(SkPaint::Join join) { GR_STATIC_ASSERT(0 == SkPaint::kMiter_Join); GR_STATIC_ASSERT(1 == SkPaint::kRound_Join); GR_STATIC_ASSERT(2 == SkPaint::kBevel_Join); - GR_STATIC_ASSERT(GR_ARRAY_COUNT(gSkJoinsToGrGLJoins) == SkPaint::kJoinCount); + GR_STATIC_ASSERT(SK_ARRAY_COUNT(gSkJoinsToGrGLJoins) == SkPaint::kJoinCount); } inline GrGLenum cap_to_gl_cap(SkPaint::Cap cap) { @@ -78,7 +78,7 @@ inline GrGLenum cap_to_gl_cap(SkPaint::Cap cap) { GR_STATIC_ASSERT(0 == SkPaint::kButt_Cap); GR_STATIC_ASSERT(1 == SkPaint::kRound_Cap); GR_STATIC_ASSERT(2 == SkPaint::kSquare_Cap); - GR_STATIC_ASSERT(GR_ARRAY_COUNT(gSkCapsToGrGLCaps) == SkPaint::kCapCount); + GR_STATIC_ASSERT(SK_ARRAY_COUNT(gSkCapsToGrGLCaps) == SkPaint::kCapCount); } } diff --git a/src/gpu/gl/GrGLSL.cpp b/src/gpu/gl/GrGLSL.cpp index a7948cc4bc..1ff0850a1d 100644 --- a/src/gpu/gl/GrGLSL.cpp +++ b/src/gpu/gl/GrGLSL.cpp @@ -67,7 +67,7 @@ namespace { void append_tabs(SkString* outAppend, int tabCnt) { static const char kTabs[] = "\t\t\t\t\t\t\t\t"; while (tabCnt) { - int cnt = GrMin((int)GR_ARRAY_COUNT(kTabs), tabCnt); + int cnt = SkTMin((int)SK_ARRAY_COUNT(kTabs), tabCnt); outAppend->append(kTabs, cnt); tabCnt -= cnt; } diff --git a/src/gpu/gl/GrGLStencilBuffer.cpp b/src/gpu/gl/GrGLStencilBuffer.cpp index d9322c26db..33e346c617 100644 --- a/src/gpu/gl/GrGLStencilBuffer.cpp +++ b/src/gpu/gl/GrGLStencilBuffer.cpp @@ -17,7 +17,7 @@ size_t GrGLStencilBuffer::sizeInBytes() const { uint64_t size = this->width(); size *= this->height(); size *= fFormat.fTotalBits; - size *= GrMax(1,this->numSamples()); + size *= SkTMax(1,this->numSamples()); return static_cast(size / 8); } diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index 78bf8f91cf..a89bb9d64a 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -81,7 +81,7 @@ bool GrGpuGL::BlendCoeffReferencesConstant(GrBlendCoeff coeff) { }; return gCoeffReferencesBlendConst[coeff]; GR_STATIC_ASSERT(kTotalGrBlendCoeffCount == - GR_ARRAY_COUNT(gCoeffReferencesBlendConst)); + SK_ARRAY_COUNT(gCoeffReferencesBlendConst)); GR_STATIC_ASSERT(0 == kZero_GrBlendCoeff); GR_STATIC_ASSERT(1 == kOne_GrBlendCoeff); @@ -105,7 +105,7 @@ bool GrGpuGL::BlendCoeffReferencesConstant(GrBlendCoeff coeff) { // assertion for gXfermodeCoeff2Blend have to be in GrGpu scope GR_STATIC_ASSERT(kTotalGrBlendCoeffCount == - GR_ARRAY_COUNT(gXfermodeCoeff2Blend)); + SK_ARRAY_COUNT(gXfermodeCoeff2Blend)); } /////////////////////////////////////////////////////////////////////////////// @@ -879,7 +879,7 @@ GrTexture* GrGpuGL::onCreateTexture(const GrTextureDesc& desc, return return_null_texture(); } // If the sample count exceeds the max then we clamp it. - glTexDesc.fSampleCnt = GrMin(desc.fSampleCnt, this->caps()->maxSampleCount()); + glTexDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount()); glTexDesc.fFlags = desc.fFlags; glTexDesc.fWidth = desc.fWidth; @@ -1598,7 +1598,7 @@ void GrGpuGL::onGpuDraw(const DrawInfo& info) { size_t indexOffsetInBytes; this->setupGeometry(info, &indexOffsetInBytes); - SkASSERT((size_t)info.primitiveType() < GR_ARRAY_COUNT(gPrimitiveType2GLMode)); + SkASSERT((size_t)info.primitiveType() < SK_ARRAY_COUNT(gPrimitiveType2GLMode)); if (info.isIndexed()) { GrGLvoid* indices = @@ -1859,7 +1859,7 @@ GrGLenum gr_to_gl_stencil_func(GrStencilFunc basicFunc) { GR_GL_EQUAL, // kEqual_StencilFunc, GR_GL_NOTEQUAL, // kNotEqual_StencilFunc, }; - GR_STATIC_ASSERT(GR_ARRAY_COUNT(gTable) == kBasicStencilFuncCount); + GR_STATIC_ASSERT(SK_ARRAY_COUNT(gTable) == kBasicStencilFuncCount); GR_STATIC_ASSERT(0 == kAlways_StencilFunc); GR_STATIC_ASSERT(1 == kNever_StencilFunc); GR_STATIC_ASSERT(2 == kGreater_StencilFunc); @@ -1884,7 +1884,7 @@ GrGLenum gr_to_gl_stencil_op(GrStencilOp op) { GR_GL_ZERO, // kZero_StencilOp GR_GL_INVERT, // kInvert_StencilOp }; - GR_STATIC_ASSERT(GR_ARRAY_COUNT(gTable) == kStencilOpCount); + GR_STATIC_ASSERT(SK_ARRAY_COUNT(gTable) == kStencilOpCount); GR_STATIC_ASSERT(0 == kKeep_StencilOp); GR_STATIC_ASSERT(1 == kReplace_StencilOp); GR_STATIC_ASSERT(2 == kIncWrap_StencilOp); -- 2.34.1