本文整理汇总了C++中GrCrash函数的典型用法代码示例。如果您正苦于以下问题:C++ GrCrash函数的具体用法?C++ GrCrash怎么用?C++ GrCrash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GrCrash函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void GrDrawTarget::drawNonIndexed(GrPrimitiveType type,
int startVertex,
int vertexCount) {
#if GR_DEBUG
GeometrySrcState& geoSrc = fGeoSrcStateStack.back();
int maxVertex = startVertex + vertexCount;
int maxValidVertex;
switch (geoSrc.fVertexSrc) {
case kNone_GeometrySrcType:
GrCrash("Attempting to draw non-indexed geom without vertex src.");
case kReserved_GeometrySrcType: // fallthrough
case kArray_GeometrySrcType:
maxValidVertex = geoSrc.fVertexCount;
break;
case kBuffer_GeometrySrcType:
maxValidVertex = geoSrc.fVertexBuffer->sizeInBytes() /
VertexSize(geoSrc.fVertexLayout);
break;
}
if (maxVertex > maxValidVertex) {
GrCrash("Non-indexed drawing outside valid vertex range.");
}
#endif
if (vertexCount > 0) {
this->onDrawNonIndexed(type, startVertex, vertexCount);
}
}
示例2: update_degenerate_test
static void update_degenerate_test(DegenerateTestData* data, const GrPoint& pt) {
switch (data->fStage) {
case DegenerateTestData::kInitial:
data->fFirstPoint = pt;
data->fStage = DegenerateTestData::kPoint;
break;
case DegenerateTestData::kPoint:
if (pt.distanceToSqd(data->fFirstPoint) > kCloseSqd) {
data->fLineNormal = pt - data->fFirstPoint;
data->fLineNormal.normalize();
data->fLineNormal.setOrthog(data->fLineNormal);
data->fLineC = -data->fLineNormal.dot(data->fFirstPoint);
data->fStage = DegenerateTestData::kLine;
}
break;
case DegenerateTestData::kLine:
if (SkScalarAbs(data->fLineNormal.dot(pt) + data->fLineC) > kClose) {
data->fStage = DegenerateTestData::kNonDegenerate;
}
case DegenerateTestData::kNonDegenerate:
break;
default:
GrCrash("Unexpected degenerate test stage.");
}
}
示例3: INHERITED
GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path) : INHERITED(gpu, kIsWrapped) {
#ifndef SK_SCALAR_IS_FLOAT
GrCrash("Assumes scalar is float.");
#endif
SkASSERT(!path.isEmpty());
GL_CALL_RET(fPathID, GenPaths(1));
SkSTArray<16, GrGLubyte, true> pathCommands;
SkSTArray<16, SkPoint, true> pathPoints;
int verbCnt = path.countVerbs();
int pointCnt = path.countPoints();
pathCommands.resize_back(verbCnt);
pathPoints.resize_back(pointCnt);
// TODO: Direct access to path points since we could pass them on directly.
path.getPoints(&pathPoints[0], pointCnt);
path.getVerbs(&pathCommands[0], verbCnt);
GR_DEBUGCODE(int numPts = 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);
GR_DEBUGCODE(numPts += num_pts(v));
}
GrAssert(pathPoints.count() == numPts);
GL_CALL(PathCommands(fPathID,
verbCnt, &pathCommands[0],
2 * pointCnt, GR_GL_FLOAT, &pathPoints[0]));
fBounds = path.getBounds();
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_skia_src,代码行数:33,代码来源:GrGLPath.cpp
示例4: GrAssert
void GrClip::setFromIterator(GrClipIterator* iter, GrScalar tx, GrScalar ty,
const GrRect* conservativeBounds) {
fList.reset();
int rectCount = 0;
// compute bounds for common case of series of intersecting rects.
bool isectRectValid = true;
if (iter) {
for (iter->rewind(); !iter->isDone(); iter->next()) {
Element& e = fList.push_back();
e.fType = iter->getType();
e.fOp = iter->getOp();
// iterators should not emit replace
GrAssert(kReplace_SetOp != e.fOp);
switch (e.fType) {
case kRect_ClipType:
iter->getRect(&e.fRect);
if (tx || ty) {
e.fRect.offset(tx, ty);
}
++rectCount;
if (isectRectValid) {
if (kIntersect_SetOp == e.fOp) {
GrAssert(fList.count() <= 2);
if (fList.count() > 1) {
GrAssert(2 == rectCount);
rectCount = 1;
fList.pop_back();
GrAssert(kRect_ClipType == fList.back().fType);
intersectWith(&fList.back().fRect, e.fRect);
}
} else {
isectRectValid = false;
}
}
break;
case kPath_ClipType:
e.fPath = *iter->getPath();
if (tx || ty) {
e.fPath.offset(tx, ty);
}
e.fPathFill = iter->getPathFill();
isectRectValid = false;
break;
default:
GrCrash("Unknown clip element type.");
}
}
}
fConservativeBoundsValid = false;
if (isectRectValid && rectCount) {
fConservativeBounds = fList[0].fRect;
fConservativeBoundsValid = true;
} else if (NULL != conservativeBounds) {
fConservativeBounds = *conservativeBounds;
fConservativeBoundsValid = true;
}
}
示例5: GrGetGLSLVersionDecl
const char* GrGetGLSLVersionDecl(GrGLBinding binding, GrGLSLGeneration gen) {
switch (gen) {
case k110_GrGLSLGeneration:
if (kES2_GrGLBinding == binding) {
// ES2s shader language is based on version 1.20 but is version
// 1.00 of the ES language.
return "#version 100\n";
} else {
GrAssert(kDesktop_GrGLBinding == binding);
return "#version 110\n";
}
case k130_GrGLSLGeneration:
GrAssert(kDesktop_GrGLBinding == binding);
return "#version 130\n";
case k140_GrGLSLGeneration:
GrAssert(kDesktop_GrGLBinding == binding);
return "#version 140\n";
case k150_GrGLSLGeneration:
GrAssert(kDesktop_GrGLBinding == binding);
return "#version 150\n";
default:
GrCrash("Unknown GL version.");
return ""; // suppress warning
}
}
示例6: switch
bool GrGLShaderBuilder::enablePrivateFeature(GLSLPrivateFeature feature) {
switch (feature) {
case kFragCoordConventions_GLSLPrivateFeature:
if (!fGpu->glCaps().fragCoordConventionsSupport()) {
return false;
}
if (fGpu->glslGeneration() < k150_GrGLSLGeneration) {
this->addFSFeature(1 << kFragCoordConventions_GLSLPrivateFeature,
"GL_ARB_fragment_coord_conventions");
}
return true;
case kEXTShaderFramebufferFetch_GLSLPrivateFeature:
if (GrGLCaps::kEXT_FBFetchType != fGpu->glCaps().fbFetchType()) {
return false;
}
this->addFSFeature(1 << kEXTShaderFramebufferFetch_GLSLPrivateFeature,
"GL_EXT_shader_framebuffer_fetch");
return true;
case kNVShaderFramebufferFetch_GLSLPrivateFeature:
if (GrGLCaps::kNV_FBFetchType != fGpu->glCaps().fbFetchType()) {
return false;
}
this->addFSFeature(1 << kNVShaderFramebufferFetch_GLSLPrivateFeature,
"GL_NV_shader_framebuffer_fetch");
return true;
default:
GrCrash("Unexpected GLSLPrivateFeature requested.");
return false;
}
}
示例7: GL_CALL
void GrGpuGLShaders::flushConvolution(int s) {
const GrSamplerState& sampler = this->getDrawState().getSampler(s);
int kernelUni = fProgramData->fUniLocations.fStages[s].fKernelUni;
if (GrGLProgram::kUnusedUniform != kernelUni) {
GL_CALL(Uniform1fv(kernelUni, sampler.getKernelWidth(),
sampler.getKernel()));
}
int imageIncrementUni = fProgramData->fUniLocations.fStages[s].fImageIncrementUni;
if (GrGLProgram::kUnusedUniform != imageIncrementUni) {
const GrGLTexture* texture =
static_cast<const GrGLTexture*>(this->getDrawState().getTexture(s));
float imageIncrement[2] = { 0 };
switch (sampler.getFilterDirection()) {
case GrSamplerState::kX_FilterDirection:
imageIncrement[0] = 1.0f / texture->width();
break;
case GrSamplerState::kY_FilterDirection:
imageIncrement[1] = 1.0f / texture->height();
break;
default:
GrCrash("Unknown filter direction.");
}
GL_CALL(Uniform2fv(imageIncrementUni, 1, imageIncrement));
}
}
示例8: sizeof
const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const {
if (NULL == fQuadIndexBuffer) {
static const int SIZE = sizeof(uint16_t) * 6 * MAX_QUADS;
GrGpu* me = const_cast<GrGpu*>(this);
fQuadIndexBuffer = me->createIndexBuffer(SIZE, false);
if (NULL != fQuadIndexBuffer) {
uint16_t* indices = (uint16_t*)fQuadIndexBuffer->lock();
if (NULL != indices) {
fill_indices(indices, MAX_QUADS);
fQuadIndexBuffer->unlock();
} else {
indices = (uint16_t*)GrMalloc(SIZE);
fill_indices(indices, MAX_QUADS);
if (!fQuadIndexBuffer->updateData(indices, SIZE)) {
fQuadIndexBuffer->unref();
fQuadIndexBuffer = NULL;
GrCrash("Can't get indices into buffer!");
}
GrFree(indices);
}
}
}
return fQuadIndexBuffer;
}
示例9: sizeof
GrIndexBuffer* GrAARectRenderer::aaFillRectIndexBuffer(GrGpu* gpu) {
static const size_t kAAFillRectIndexBufferSize = kIndicesPerAAFillRect *
sizeof(uint16_t) *
kNumAAFillRectsInIndexBuffer;
if (NULL == fAAFillRectIndexBuffer) {
fAAFillRectIndexBuffer = gpu->createIndexBuffer(kAAFillRectIndexBufferSize, false);
if (NULL != fAAFillRectIndexBuffer) {
uint16_t* data = (uint16_t*) fAAFillRectIndexBuffer->lock();
bool useTempData = (NULL == data);
if (useTempData) {
data = SkNEW_ARRAY(uint16_t, kNumAAFillRectsInIndexBuffer * kIndicesPerAAFillRect);
}
for (int i = 0; i < kNumAAFillRectsInIndexBuffer; ++i) {
// Each AA filled rect is drawn with 8 vertices and 10 triangles (8 around
// the inner rect (for AA) and 2 for the inner rect.
int baseIdx = i * kIndicesPerAAFillRect;
uint16_t baseVert = (uint16_t)(i * kVertsPerAAFillRect);
for (int j = 0; j < kIndicesPerAAFillRect; ++j) {
data[baseIdx+j] = baseVert + gFillAARectIdx[j];
}
}
if (useTempData) {
if (!fAAFillRectIndexBuffer->updateData(data, kAAFillRectIndexBufferSize)) {
GrCrash("Can't get AA Fill Rect indices into buffer!");
}
SkDELETE_ARRAY(data);
} else {
fAAFillRectIndexBuffer->unlock();
}
}
}
return fAAFillRectIndexBuffer;
}
示例10: switch
void GrGLShaderBuilder::setupTextureAccess(const char* varyingFSName, GrSLType varyingType) {
// FIXME: We don't know how the custom stage will manipulate the coords. So we give up on using
// projective texturing and always give the stage 2D coords. This will be fixed when custom
// stages are repsonsible for setting up their own tex coords / tex matrices.
switch (varyingType) {
case kVec2f_GrSLType:
fDefaultTexCoordsName = varyingFSName;
fTexCoordVaryingType = kVec2f_GrSLType;
break;
case kVec3f_GrSLType: {
fDefaultTexCoordsName = "inCoord";
GrAssert(kNonStageIdx != fCurrentStage);
fDefaultTexCoordsName.appendS32(fCurrentStage);
fTexCoordVaryingType = kVec3f_GrSLType;
fFSCode.appendf("\t%s %s = %s.xy / %s.z;\n",
GrGLShaderVar::TypeString(kVec2f_GrSLType),
fDefaultTexCoordsName.c_str(),
varyingFSName,
varyingFSName);
break;
}
default:
GrCrash("Tex coords must either be Vec2f or Vec3f");
}
}
示例11: GrPoint
const GrVertexBuffer* GrGpu::getUnitSquareVertexBuffer() const {
if (NULL == fUnitSquareVertexBuffer) {
static const GrPoint DATA[] = {
{ 0, 0 },
{ GR_Scalar1, 0 },
{ GR_Scalar1, GR_Scalar1 },
{ 0, GR_Scalar1 }
#if 0
GrPoint(0, 0),
GrPoint(GR_Scalar1,0),
GrPoint(GR_Scalar1,GR_Scalar1),
GrPoint(0, GR_Scalar1)
#endif
};
static const size_t SIZE = sizeof(DATA);
GrGpu* me = const_cast<GrGpu*>(this);
fUnitSquareVertexBuffer = me->createVertexBuffer(SIZE, false);
if (NULL != fUnitSquareVertexBuffer) {
if (!fUnitSquareVertexBuffer->updateData(DATA, SIZE)) {
fUnitSquareVertexBuffer->unref();
fUnitSquareVertexBuffer = NULL;
GrCrash("Can't get vertices into buffer!");
}
}
}
return fUnitSquareVertexBuffer;
}
示例12: switch
void GrGpu::ConvertStencilFuncAndMask(GrStencilFunc func,
bool clipInStencil,
unsigned int clipBit,
unsigned int userBits,
unsigned int* ref,
unsigned int* mask) {
if (func < kBasicStencilFuncCount) {
*mask &= userBits;
*ref &= userBits;
} else {
if (clipInStencil) {
switch (func) {
case kAlwaysIfInClip_StencilFunc:
*mask = clipBit;
*ref = clipBit;
break;
case kEqualIfInClip_StencilFunc:
case kLessIfInClip_StencilFunc:
case kLEqualIfInClip_StencilFunc:
*mask = (*mask & userBits) | clipBit;
*ref = (*ref & userBits) | clipBit;
break;
case kNonZeroIfInClip_StencilFunc:
*mask = (*mask & userBits) | clipBit;
*ref = clipBit;
break;
default:
GrCrash("Unknown stencil func");
}
} else {
*mask &= userBits;
*ref &= userBits;
}
}
}
示例13: switch
void GrGLProgram::genInputColor(GrGLShaderBuilder* builder, SkString* inColor) {
switch (fDesc.fColorInput) {
case GrGLProgram::Desc::kAttribute_ColorInput: {
builder->fVSAttrs.push_back().set(kVec4f_GrSLType,
GrGLShaderVar::kAttribute_TypeModifier,
COL_ATTR_NAME);
const char *vsName, *fsName;
builder->addVarying(kVec4f_GrSLType, "Color", &vsName, &fsName);
builder->fVSCode.appendf("\t%s = " COL_ATTR_NAME ";\n", vsName);
*inColor = fsName;
} break;
case GrGLProgram::Desc::kUniform_ColorInput: {
const char* name;
fUniforms.fColorUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
kVec4f_GrSLType, "Color", &name);
*inColor = name;
break;
}
case GrGLProgram::Desc::kTransBlack_ColorInput:
GrAssert(!"needComputedColor should be false.");
break;
case GrGLProgram::Desc::kSolidWhite_ColorInput:
break;
default:
GrCrash("Unknown color type.");
break;
}
}
示例14: nullGLGetBufferParameteriv
GrGLvoid GR_GL_FUNCTION_TYPE nullGLGetBufferParameteriv(GrGLenum target, GrGLenum pname, GrGLint* params) {
switch (pname) {
case GR_GL_BUFFER_MAPPED: {
*params = GR_GL_FALSE;
GrGLuint buf = 0;
switch (target) {
case GR_GL_ARRAY_BUFFER:
buf = gCurrArrayBuffer;
break;
case GR_GL_ELEMENT_ARRAY_BUFFER:
buf = gCurrElementArrayBuffer;
break;
}
if (buf) {
for (int i = 0; i < gMappedBuffers.count(); ++i) {
if (gMappedBuffers[i] == buf) {
*params = GR_GL_TRUE;
break;
}
}
}
break; }
default:
GrCrash("Unexpected pname to GetBufferParamateriv");
break;
}
};
示例15: GrGetGLSLVersionDecl
const char* GrGetGLSLVersionDecl(const GrGLContextInfo& info) {
switch (info.glslGeneration()) {
case k110_GrGLSLGeneration:
if (kES_GrGLBinding == info.binding()) {
// ES2s shader language is based on version 1.20 but is version
// 1.00 of the ES language.
return "#version 100\n";
} else {
SkASSERT(kDesktop_GrGLBinding == info.binding());
return "#version 110\n";
}
case k130_GrGLSLGeneration:
SkASSERT(kDesktop_GrGLBinding == info.binding());
return "#version 130\n";
case k140_GrGLSLGeneration:
SkASSERT(kDesktop_GrGLBinding == info.binding());
return "#version 140\n";
case k150_GrGLSLGeneration:
SkASSERT(kDesktop_GrGLBinding == info.binding());
if (info.caps()->isCoreProfile()) {
return "#version 150\n";
} else {
return "#version 150 compatibility\n";
}
default:
GrCrash("Unknown GL version.");
return ""; // suppress warning
}
}