namespace {
extern const GrVertexAttrib kAttribs[] = {
{kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
- {kVec4f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding}
+ {kVec4f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding}
};
}
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);
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);
///////////////////////////////////////////////////////////////////////////
- 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;
}
#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);
}
};
* 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;
}
#include "GrConfig.h"
#include "SkMath.h"
+//#define SK_SUPPORT_LEGACY_GRTYPES
+
////////////////////////////////////////////////////////////////////////////////
/**
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
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))
return (x / alignment) * alignment;
}
-/**
- * Count elements in an array
- */
-#define GR_ARRAY_COUNT(array) SK_ARRAY_COUNT(array)
-
///////////////////////////////////////////////////////////////////////////////
/**
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
-
-
///////////////////////////////////////////////////////////////////////////////
/**
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),
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);
}
/**
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);
}
/**
* 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
} 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);
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;
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;
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;
}
for (;;) {
- GrPoint pts[4];
+ SkPoint pts[4];
SkPath::Verb verb = iter.next(pts);
switch (verb) {
case SkPath::kMove_Verb:
}
struct QuadVertex {
- GrPoint fPos;
- GrPoint fUV;
+ SkPoint fPos;
+ SkPoint fUV;
SkScalar fD0;
SkScalar fD1;
};
*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;
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;
// position + edge
extern const GrVertexAttrib gPathAttribs[] = {
{kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
- {kVec4f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding}
+ {kVec4f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding}
};
};
// +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;
}
}
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: {
}
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,
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<kVertsPerQuad, sizeof(BezierVertex), sizeof(GrPoint)>(verts);
+ DevToUV.apply<kVertsPerQuad, sizeof(BezierVertex), sizeof(SkPoint)>(verts);
}
void bloat_quad(const SkPoint qpts[3], const SkMatrix* toDevice,
// 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},
};
};
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
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
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
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) {
}
}
-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);
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;
};
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) {
intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices());
size_t vsize = drawState->getVertexSize();
- SkASSERT(sizeof(GrPoint) + sizeof(GrColor) == vsize);
+ SkASSERT(sizeof(SkPoint) + sizeof(GrColor) == vsize);
- GrPoint* fan0Pos = reinterpret_cast<GrPoint*>(verts);
- GrPoint* fan1Pos = reinterpret_cast<GrPoint*>(verts + 4 * vsize);
+ SkPoint* fan0Pos = reinterpret_cast<SkPoint*>(verts);
+ SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + 4 * vsize);
SkScalar inset = SkMinScalar(devRect.width(), SK_Scalar1);
inset = SK_ScalarHalf * SkMinScalar(inset, devRect.height());
*((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<GrColor*>(verts + i * vsize) = 0;
}
// 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 },
};
};
devRect.fBottom + SK_ScalarHalf
};
- GrPoint widthHeight = {
+ SkPoint widthHeight = {
SkScalarHalf(devRect.width()) + SK_ScalarHalf,
SkScalarHalf(devRect.height()) + SK_ScalarHalf
};
const SkRect& devRect,
const SkStrokeRec* stroke,
bool useVertexCoverage) {
- GrVec devStrokeSize;
+ SkVector devStrokeSize;
SkScalar width = stroke->getWidth();
if (width > 0) {
devStrokeSize.set(width, width);
{
SkScalar w = devRect.width() - dx;
SkScalar h = devRect.height() - dy;
- spare = GrMin(w, h);
+ spare = SkTMin(w, h);
}
SkRect devOutside(devRect);
intptr_t verts = reinterpret_cast<intptr_t>(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<GrPoint*>(verts);
- GrPoint* fan1Pos = reinterpret_cast<GrPoint*>(verts + outerVertexNum * vsize);
- GrPoint* fan2Pos = reinterpret_cast<GrPoint*>(verts + 2 * outerVertexNum * vsize);
- GrPoint* fan3Pos = reinterpret_cast<GrPoint*>(verts + (2 * outerVertexNum + innerVertexNum) * vsize);
+ SkPoint* fan0Pos = reinterpret_cast<SkPoint*>(verts);
+ SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + outerVertexNum * vsize);
+ SkPoint* fan2Pos = reinterpret_cast<SkPoint*>(verts + 2 * outerVertexNum * vsize);
+ SkPoint* fan3Pos = reinterpret_cast<SkPoint*>(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
// innermost
set_inset_fan(fan3Pos, vsize, devInside, SK_ScalarHalf, SK_ScalarHalf);
} else {
- GrPoint* fan0AssistPos = reinterpret_cast<GrPoint*>(verts + 4 * vsize);
- GrPoint* fan1AssistPos = reinterpret_cast<GrPoint*>(verts + (outerVertexNum + 4) * vsize);
+ SkPoint* fan0AssistPos = reinterpret_cast<SkPoint*>(verts + 4 * vsize);
+ SkPoint* fan1AssistPos = reinterpret_cast<SkPoint*>(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);
}
// The outermost rect has 0 coverage
- verts += sizeof(GrPoint);
+ verts += sizeof(SkPoint);
for (int i = 0; i < outerVertexNum; ++i) {
*reinterpret_cast<GrColor*>(verts + i * vsize) = 0;
}
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;
GrAllocPool::GrAllocPool(size_t blockSize) {
fBlock = NULL;
- fMinBlockSize = GrMax(blockSize, GrAllocPool_MIN_BLOCK_SIZE);
+ fMinBlockSize = SkTMax(blockSize, GrAllocPool_MIN_BLOCK_SIZE);
SkDEBUGCODE(fBlocksAllocated = 0;)
}
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;)
}
* 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]);
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);
// 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;
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) {
GrTCast<void**>(&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);
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();
bool frequentResetHint,
size_t blockSize,
int preallocBufferCnt) :
- fBlocks(GrMax(8, 2*preallocBufferCnt)) {
+ fBlocks(SkTMax(8, 2*preallocBufferCnt)) {
SkASSERT(NULL != gpu);
fGpu = gpu;
fBufferType = bufferType;
fFrequentResetHint = frequentResetHint;
fBufferPtr = NULL;
- fMinBlockSize = GrMax(GrBufferAllocPool_MIN_BLOCK_SIZE, blockSize);
+ fMinBlockSize = SkTMax(GrBufferAllocPool_MIN_BLOCK_SIZE, blockSize);
fBytesInUse = 0;
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();
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) {
// position + local coordinate
extern const GrVertexAttrib gVertexAttribs[] = {
{kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
- {kVec2f_GrVertexAttribType, sizeof(GrPoint), kLocalCoord_GrVertexAttribBinding}
+ {kVec2f_GrVertexAttribType, sizeof(SkPoint), kLocalCoord_GrVertexAttribBinding}
};
};
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 {
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;
}
int GrContext::getMaxTextureSize() const {
- return GrMin(fGpu->caps()->maxTextureSize(), fMaxTextureSizeOverride);
+ return SkTMin(fGpu->caps()->maxTextureSize(), fMaxTextureSizeOverride);
}
int GrContext::getMaxRenderTargetSize() 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();
GrPrimitiveType primType;
int vertCount;
- GrPoint* vertex = geo.positions();
+ SkPoint* vertex = geo.positions();
if (width > 0) {
vertCount = 10;
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) {
*colorOffset = -1;
if (NULL != texCoords && NULL != colors) {
- *texOffset = sizeof(GrPoint);
- *colorOffset = 2*sizeof(GrPoint);
+ *texOffset = sizeof(SkPoint);
+ *colorOffset = 2*sizeof(SkPoint);
drawState->setVertexAttribs<gPosUVColorAttribs>(3);
} else if (NULL != texCoords) {
- *texOffset = sizeof(GrPoint);
+ *texOffset = sizeof(SkPoint);
drawState->setVertexAttribs<gPosUVColorAttribs>(2);
} else if (NULL != colors) {
- *colorOffset = sizeof(GrPoint);
+ *colorOffset = sizeof(SkPoint);
drawState->setVertexAttribs<gPosColorAttribs>(2);
} else {
drawState->setVertexAttribs<gPosColorAttribs>(1);
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) {
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;
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];
uint16_t* idx = idxBase;
uint16_t subpathIdxStart = 0;
- GrPoint* base = reinterpret_cast<GrPoint*>(arg->vertices());
+ SkPoint* base = reinterpret_cast<SkPoint*>(arg->vertices());
SkASSERT(NULL != base);
- GrPoint* vert = base;
+ SkPoint* vert = base;
- GrPoint pts[4];
+ SkPoint pts[4];
bool first = true;
int subpath = 0;
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);
// 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;
GrTCast<void**>(&fVertices),
NULL);
GrAlwaysAssert(success);
- SkASSERT(2*sizeof(GrPoint) == fDrawTarget->getDrawState().getVertexSize());
+ SkASSERT(2*sizeof(SkPoint) == fDrawTarget->getDrawState().getVertexSize());
}
SkScalar dx = SkIntToScalar(glyph->fBounds.fLeft);
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,
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();
* 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<intptr_t>(vertices);
- return GrTCast<GrPoint*>(start + offset +
+ return GrTCast<SkPoint*>(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<intptr_t>(vertices);
- return GrTCast<const GrPoint*>(start + offset +
+ return GrTCast<const SkPoint*>(start + offset +
vertexIndex * vertexSize);
}
}
while (instanceCount) {
- info.fInstanceCount = GrMin(instanceCount, maxInstancesPerDraw);
+ info.fInstanceCount = SkTMin(instanceCount, maxInstancesPerDraw);
info.fVertexCount = info.fInstanceCount * verticesPerInstance;
info.fIndexCount = info.fInstanceCount * indicesPerInstance;
// 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) {
size_t vsize = this->drawState()->getVertexSize();
geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vsize);
if (NULL != localRect) {
- GrPoint* coords = GrTCast<GrPoint*>(GrTCast<intptr_t>(geo.vertices()) +
- sizeof(GrPoint));
+ SkPoint* coords = GrTCast<SkPoint*>(GrTCast<intptr_t>(geo.vertices()) +
+ sizeof(SkPoint));
coords->setRectFan(localRect->fLeft, localRect->fTop,
localRect->fRight, localRect->fBottom,
vsize);
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<GrPoint*>(this->vertices());
+ SkPoint* positions() const {
+ return static_cast<SkPoint*>(this->vertices());
}
private:
size_t vertexSize,
int vertexCount,
SkRect* bounds) {
- SkASSERT(vertexSize >= sizeof(GrPoint));
+ SkASSERT(vertexSize >= sizeof(SkPoint));
SkASSERT(vertexCount > 0);
- const GrPoint* point = static_cast<const GrPoint*>(vertices);
+ const SkPoint* point = static_cast<const SkPoint*>(vertices);
bounds->fLeft = bounds->fRight = point->fX;
bounds->fTop = bounds->fBottom = point->fY;
for (int i = 1; i < vertexCount; ++i) {
- point = reinterpret_cast<GrPoint*>(reinterpret_cast<intptr_t>(point) + vertexSize);
+ point = reinterpret_cast<SkPoint*>(reinterpret_cast<intptr_t>(point) + vertexSize);
bounds->growToInclude(point->fX, point->fY);
}
}
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,
// 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<kRectPosColorUVAttribs>(3);
} else if (hasColor) {
- *colorOffset = sizeof(GrPoint);
+ *colorOffset = sizeof(SkPoint);
drawState->setVertexAttribs<kRectPosColorUVAttribs>(2);
} else if (hasUVs) {
- *localOffset = sizeof(GrPoint);
+ *localOffset = sizeof(SkPoint);
drawState->setVertexAttribs<kRectPosUVAttribs>(2);
} else {
drawState->setVertexAttribs<kRectPosUVAttribs>(1);
get_vertex_bounds(geo.vertices(), vsize, 4, &devBounds);
if (localOffset >= 0) {
- GrPoint* coords = GrTCast<GrPoint*>(GrTCast<intptr_t>(geo.vertices()) + localOffset);
+ SkPoint* coords = GrTCast<SkPoint*>(GrTCast<intptr_t>(geo.vertices()) + localOffset);
coords->setRectFan(localRect->fLeft, localRect->fTop,
localRect->fRight, localRect->fBottom,
vsize);
// 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);
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;
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;
GrMemoryPool::GrMemoryPool(size_t preallocSize, size_t minAllocSize) {
SkDEBUGCODE(fAllocationCnt = 0);
- minAllocSize = GrMax<size_t>(minAllocSize, 1 << 10);
+ minAllocSize = SkTMax<size_t>(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;
size += kPerAllocPad;
if (fTail->fFreeSize < size) {
size_t blockSize = size;
- blockSize = GrMax<size_t>(blockSize, fMinAllocSize);
+ blockSize = SkTMax<size_t>(blockSize, fMinAllocSize);
BlockHeader* block = CreateBlock(blockSize);
block->fPrev = fTail;
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) {
// 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,
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());
// 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,
// 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());
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());
}
// 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);
}
// 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);
}
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;
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) {
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);
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);
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 &&
*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);
SkPath::Iter iter(path, false);
SkPath::Verb verb;
- GrPoint pts[4];
+ SkPoint pts[4];
while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
switch (verb) {
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]
// 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;
}
}
-void GrPathUtils::convertCubicToQuads(const GrPoint p[4],
+void GrPathUtils::convertCubicToQuads(const SkPoint p[4],
SkScalar tolScale,
bool constrainWithinTangents,
SkPath::Direction dir,
/// 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
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
float sy = fM[4];
float ty = fM[5];
for (int i = 0; i < N; ++i) {
- const GrPoint* xy = reinterpret_cast<const GrPoint*>(xyPtr);
- GrPoint* uv = reinterpret_cast<GrPoint*>(uvPtr);
+ const SkPoint* xy = reinterpret_cast<const SkPoint*>(xyPtr);
+ SkPoint* uv = reinterpret_cast<SkPoint*>(uvPtr);
uv->fX = sx * xy->fX + kx * xy->fY + tx;
uv->fY = ky * xy->fX + sy * xy->fY + ty;
xyPtr += STRIDE;
// 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,
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);
}
fContext->drawVertices(grPaint,
gPointMode2PrimtiveType[mode],
SkToS32(count),
- (GrPoint*)pts,
+ (SkPoint*)pts,
NULL,
NULL,
NULL,
fContext->drawVertices(grPaint,
gVertexMode2PrimitiveType[vmode],
vertexCount,
- (GrPoint*) vertices,
- (GrPoint*) texs,
+ vertices,
+ texs,
colors,
indices,
indexCount);
for (int x = 0; x < 256; ++x) {
uint8_t* color = reinterpret_cast<uint8_t*>(&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);
}
}
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];
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);
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);
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",
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"));
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();
*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");
const GrGLubyte* GR_GL_FUNCTION_TYPE noOpGLGetStringi(GrGLenum name, GrGLuint i) {
switch (name) {
case GR_GL_EXTENSIONS:
- if (static_cast<size_t>(i) <= GR_ARRAY_COUNT(kExtensions)) {
+ if (static_cast<size_t>(i) <= SK_ARRAY_COUNT(kExtensions)) {
return (const GrGLubyte*) kExtensions[i];
} else {
return NULL;
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];
}
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
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) {
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);
}
}
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;
}
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_t>(size / 8);
}
};
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);
// assertion for gXfermodeCoeff2Blend have to be in GrGpu scope
GR_STATIC_ASSERT(kTotalGrBlendCoeffCount ==
- GR_ARRAY_COUNT(gXfermodeCoeff2Blend));
+ SK_ARRAY_COUNT(gXfermodeCoeff2Blend));
}
///////////////////////////////////////////////////////////////////////////////
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;
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 =
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);
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);