本文整理汇总了C++中SkPath::getSegmentMasks方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPath::getSegmentMasks方法的具体用法?C++ SkPath::getSegmentMasks怎么用?C++ SkPath::getSegmentMasks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPath
的用法示例。
在下文中一共展示了SkPath::getSegmentMasks方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: canDrawPath
bool GrStrokePathRenderer::canDrawPath(const SkPath& path,
const SkStrokeRec& stroke,
const GrDrawTarget* target,
bool antiAlias) const {
// FIXME : put the proper condition once GrDrawTarget::isOpaque is implemented
const bool isOpaque = true; // target->isOpaque();
// FIXME : remove this requirement once we have AA circles and implement the
// circle joins/caps appropriately in the ::onDrawPath() function.
const bool requiresAACircle = (stroke.getCap() == SkPaint::kRound_Cap) ||
(stroke.getJoin() == SkPaint::kRound_Join);
// Indices being stored in uint16, we don't want to overflow the indices capacity
static const int maxVBSize = 1 << 16;
const int maxNbVerts = (path.countPoints() + 1) * 5;
// Check that the path contains no curved lines, only straight lines
static const uint32_t unsupportedMask = SkPath::kQuad_SegmentMask | SkPath::kCubic_SegmentMask;
// Must not be filled nor hairline nor semi-transparent
// Note : May require a check to path.isConvex() if AA is supported
return ((stroke.getStyle() == SkStrokeRec::kStroke_Style) && (maxNbVerts < maxVBSize) &&
!path.isInverseFillType() && isOpaque && !requiresAACircle && !antiAlias &&
((path.getSegmentMasks() & unsupportedMask) == 0));
}
示例2: canDrawPath
bool GrDefaultPathRenderer::canDrawPath(const SkPath& path,
const SkStrokeRec& stroke,
const GrDrawTarget* target,
bool antiAlias) const {
// this class can draw any path with any fill but doesn't do any anti-aliasing.
return !antiAlias && !(SkPath::kConic_SegmentMask & path.getSegmentMasks()) &&
(stroke.isFillStyle() ||
IsStrokeHairlineOrEquivalent(stroke, target->getDrawState().getViewMatrix(), NULL));
}
示例3: canDrawPath
bool GrAAHairLinePathRenderer::canDrawPath(const GrDrawTarget::Caps& targetCaps,
const SkPath& path,
GrPathFill fill,
bool antiAlias) const {
static const uint32_t gReqDerivMask = SkPath::kCubic_SegmentMask |
SkPath::kQuad_SegmentMask;
return (kHairLine_PathFill == fill &&
antiAlias &&
(targetCaps.fShaderDerivativeSupport ||
!(gReqDerivMask & path.getSegmentMasks())));
}
示例4: canDrawPath
bool GrAAHairLinePathRenderer::canDrawPath(const SkPath& path,
const SkStrokeRec& stroke,
const GrDrawTarget* target,
bool antiAlias) const {
if (!stroke.isHairlineStyle() || !antiAlias) {
return false;
}
static const uint32_t gReqDerivMask = SkPath::kCubic_SegmentMask |
SkPath::kQuad_SegmentMask;
if (!target->getCaps().shaderDerivativeSupport() &&
(gReqDerivMask & path.getSegmentMasks())) {
return false;
}
return true;
}
示例5: canDrawPath
bool GrAAHairLinePathRenderer::canDrawPath(const SkPath& path,
GrPathFill fill,
const GrDrawTarget* target,
bool antiAlias) const {
if (fill != kHairLine_GrPathFill || !antiAlias) {
return false;
}
static const uint32_t gReqDerivMask = SkPath::kCubic_SegmentMask |
SkPath::kQuad_SegmentMask;
if (!target->getCaps().fShaderDerivativeSupport &&
(gReqDerivMask & path.getSegmentMasks())) {
return false;
}
return true;
}
示例6: canDrawPath
bool GrAAHairLinePathRenderer::canDrawPath(const GrDrawTarget* target,
const GrPipelineBuilder* pipelineBuilder,
const SkMatrix& viewMatrix,
const SkPath& path,
const GrStrokeInfo& stroke,
bool antiAlias) const {
if (!antiAlias) {
return false;
}
if (!IsStrokeHairlineOrEquivalent(stroke, viewMatrix, NULL)) {
return false;
}
if (SkPath::kLine_SegmentMask == path.getSegmentMasks() ||
target->caps()->shaderCaps()->shaderDerivativeSupport()) {
return true;
}
return false;
}
示例7: canDrawPath
bool GrAAHairLinePathRenderer::canDrawPath(const SkPath& path,
const SkStrokeRec& stroke,
const GrDrawTarget* target,
bool antiAlias) const {
if (!antiAlias) {
return false;
}
if (!IsStrokeHairlineOrEquivalent(stroke,
target->getDrawState().getViewMatrix(),
NULL)) {
return false;
}
if (SkPath::kLine_SegmentMask == path.getSegmentMasks() ||
target->caps()->shaderDerivativeSupport()) {
return true;
}
return false;
}
示例8: InitPathObjectPathData
void GrGLPath::InitPathObjectPathData(GrGLGpu* gpu,
GrGLuint pathID,
const SkPath& skPath) {
SkASSERT(!skPath.isEmpty());
#ifdef SK_SCALAR_IS_FLOAT
// This branch does type punning, converting SkPoint* to GrGLfloat*.
if ((skPath.getSegmentMasks() & SkPath::kConic_SegmentMask) == 0) {
int verbCnt = skPath.countVerbs();
int pointCnt = skPath.countPoints();
int coordCnt = pointCnt * 2;
SkSTArray<16, GrGLubyte, true> pathCommands(verbCnt);
SkSTArray<16, GrGLfloat, true> pathCoords(coordCnt);
static_assert(sizeof(SkPoint) == sizeof(GrGLfloat) * 2, "sk_point_not_two_floats");
pathCommands.resize_back(verbCnt);
pathCoords.resize_back(coordCnt);
skPath.getPoints(reinterpret_cast<SkPoint*>(&pathCoords[0]), pointCnt);
skPath.getVerbs(&pathCommands[0], verbCnt);
SkDEBUGCODE(int verbCoordCnt = 0);
for (int i = 0; i < verbCnt; ++i) {
SkPath::Verb v = static_cast<SkPath::Verb>(pathCommands[i]);
pathCommands[i] = verb_to_gl_path_cmd(v);
SkDEBUGCODE(verbCoordCnt += num_coords(v));
}
SkASSERT(verbCnt == pathCommands.count());
SkASSERT(verbCoordCnt == pathCoords.count());
SkDEBUGCODE(verify_floats(&pathCoords[0], pathCoords.count()));
GR_GL_CALL(gpu->glInterface(), PathCommands(pathID, pathCommands.count(), &pathCommands[0],
pathCoords.count(), GR_GL_FLOAT,
&pathCoords[0]));
return;
}
#endif
SkAssertResult(init_path_object_for_general_path<false>(gpu, pathID, skPath));
}
示例9: InitPathObject
void GrGLPath::InitPathObject(GrGLGpu* gpu,
GrGLuint pathID,
const SkPath& skPath,
const GrStrokeInfo& stroke) {
SkASSERT(!stroke.isDashed());
if (!skPath.isEmpty()) {
int verbCnt = skPath.countVerbs();
int pointCnt = skPath.countPoints();
int minCoordCnt = pointCnt * 2;
SkSTArray<16, GrGLubyte, true> pathCommands(verbCnt);
SkSTArray<16, GrGLfloat, true> pathCoords(minCoordCnt);
SkDEBUGCODE(int numCoords = 0);
if ((skPath.getSegmentMasks() & SkPath::kConic_SegmentMask) == 0) {
// This branch does type punning, converting SkPoint* to GrGLfloat*.
SK_COMPILE_ASSERT(sizeof(SkPoint) == sizeof(GrGLfloat) * 2, sk_point_not_two_floats);
// This branch does not convert with SkScalarToFloat.
#ifndef SK_SCALAR_IS_FLOAT
#error Need SK_SCALAR_IS_FLOAT.
#endif
pathCommands.resize_back(verbCnt);
pathCoords.resize_back(minCoordCnt);
skPath.getPoints(reinterpret_cast<SkPoint*>(&pathCoords[0]), pointCnt);
skPath.getVerbs(&pathCommands[0], verbCnt);
for (int i = 0; i < verbCnt; ++i) {
SkPath::Verb v = static_cast<SkPath::Verb>(pathCommands[i]);
pathCommands[i] = verb_to_gl_path_cmd(v);
SkDEBUGCODE(numCoords += num_coords(v));
}
} else {
SkPoint points[4];
SkPath::RawIter iter(skPath);
SkPath::Verb verb;
while ((verb = iter.next(points)) != SkPath::kDone_Verb) {
pathCommands.push_back(verb_to_gl_path_cmd(verb));
GrGLfloat coords[6];
int coordsForVerb;
switch (verb) {
case SkPath::kMove_Verb:
points_to_coords(points, 0, 1, coords);
coordsForVerb = 2;
break;
case SkPath::kLine_Verb:
points_to_coords(points, 1, 1, coords);
coordsForVerb = 2;
break;
case SkPath::kConic_Verb:
points_to_coords(points, 1, 2, coords);
coords[4] = SkScalarToFloat(iter.conicWeight());
coordsForVerb = 5;
break;
case SkPath::kQuad_Verb:
points_to_coords(points, 1, 2, coords);
coordsForVerb = 4;
break;
case SkPath::kCubic_Verb:
points_to_coords(points, 1, 3, coords);
coordsForVerb = 6;
break;
case SkPath::kClose_Verb:
continue;
default:
SkASSERT(false); // Not reached.
continue;
}
SkDEBUGCODE(numCoords += num_coords(verb));
pathCoords.push_back_n(coordsForVerb, coords);
}
}
SkASSERT(verbCnt == pathCommands.count());
SkASSERT(numCoords == pathCoords.count());
GR_GL_CALL(gpu->glInterface(), PathCommands(pathID, pathCommands.count(), &pathCommands[0],
pathCoords.count(), GR_GL_FLOAT, &pathCoords[0]));
} else {
GR_GL_CALL(gpu->glInterface(), PathCommands(pathID, 0, NULL, 0, GR_GL_FLOAT, NULL));
}
if (stroke.needToApply()) {
SkASSERT(!stroke.isHairlineStyle());
GR_GL_CALL(gpu->glInterface(),
PathParameterf(pathID, GR_GL_PATH_STROKE_WIDTH, SkScalarToFloat(stroke.getWidth())));
GR_GL_CALL(gpu->glInterface(),
PathParameterf(pathID, GR_GL_PATH_MITER_LIMIT, SkScalarToFloat(stroke.getMiter())));
GrGLenum join = join_to_gl_join(stroke.getJoin());
GR_GL_CALL(gpu->glInterface(), PathParameteri(pathID, GR_GL_PATH_JOIN_STYLE, join));
GrGLenum cap = cap_to_gl_cap(stroke.getCap());
GR_GL_CALL(gpu->glInterface(), PathParameteri(pathID, GR_GL_PATH_END_CAPS, cap));
GR_GL_CALL(gpu->glInterface(), PathParameterf(pathID, GR_GL_PATH_STROKE_BOUND, 0.02f));
}
}