本文整理汇总了C++中GrPrimitiveProcessor类的典型用法代码示例。如果您正苦于以下问题:C++ GrPrimitiveProcessor类的具体用法?C++ GrPrimitiveProcessor怎么用?C++ GrPrimitiveProcessor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GrPrimitiveProcessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: emitAndInstallProc
void GrGLProgramBuilder::emitAndInstallProc(const GrPrimitiveProcessor& gp,
const char* outColor,
const char* outCoverage) {
SkASSERT(!fGeometryProcessor);
fGeometryProcessor = new GrGLInstalledGeoProc;
fGeometryProcessor->fGLProc.reset(gp.createGLSLInstance(*fGpu->glCaps().glslCaps()));
SkSTArray<4, GrGLSLTextureSampler> samplers(gp.numTextures());
this->emitSamplers(gp, &samplers, fGeometryProcessor);
GrGLSLGeometryProcessor::EmitArgs args(this,
&fVS,
&fFS,
&fVaryingHandler,
this->glslCaps(),
gp,
outColor,
outCoverage,
samplers,
fCoordTransforms,
&fOutCoords);
fGeometryProcessor->fGLProc->emitCode(args);
// We have to check that effects and the code they emit are consistent, ie if an effect
// asks for dst color, then the emit code needs to follow suit
verify(gp);
}
示例2: onSetRenderTargetState
void GrGLPathProgram::onSetRenderTargetState(const GrPrimitiveProcessor& primProc,
const GrPipeline& pipeline) {
SkASSERT(!primProc.willUseGeoShader() && primProc.numAttribs() == 0);
const GrRenderTarget* rt = pipeline.getRenderTarget();
SkISize size;
size.set(rt->width(), rt->height());
const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>();
fGpu->glPathRendering()->setProjectionMatrix(pathProc.viewMatrix(),
size, rt->origin());
}
示例3: setData
virtual void setData(const GrGLProgramDataManager& pdman,
const GrPrimitiveProcessor& processor,
const GrBatchTracker& bt) override {
SkASSERT(fDistanceAdjustUni.isValid());
const GrDistanceFieldLCDTextureEffect& dfTexEffect =
processor.cast<GrDistanceFieldLCDTextureEffect>();
GrDistanceFieldLCDTextureEffect::DistanceAdjust wa = dfTexEffect.getDistanceAdjust();
if (wa != fDistanceAdjust) {
pdman.set3f(fDistanceAdjustUni,
wa.fR,
wa.fG,
wa.fB);
fDistanceAdjust = wa;
}
this->setUniformViewMatrix(pdman, processor.viewMatrix());
const DistanceFieldLCDBatchTracker& local = bt.cast<DistanceFieldLCDBatchTracker>();
if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
GrGLfloat c[4];
GrColorToRGBAFloat(local.fColor, c);
pdman.set4fv(fColorUniform, 1, c);
fColor = local.fColor;
}
}
示例4: setTransformData
void GrGLNormalPathProcessor::setTransformData(
const GrPrimitiveProcessor& primProc,
int index,
const SkTArray<const GrCoordTransform*, true>& coordTransforms,
GrGLPathRendering* glpr,
GrGLuint programID) {
SkSTArray<2, Transform, true>& transforms = fInstalledTransforms[index];
int numTransforms = transforms.count();
for (int t = 0; t < numTransforms; ++t) {
SkASSERT(transforms[t].fHandle.isValid());
const SkMatrix& transform = GetTransformMatrix(primProc.localMatrix(),
*coordTransforms[t]);
if (transforms[t].fCurrentValue.cheapEqualTo(transform)) {
continue;
}
transforms[t].fCurrentValue = transform;
const SeparableVaryingInfo& fragmentInput =
fSeparableVaryingInfos[transforms[t].fHandle.handle()];
SkASSERT(transforms[t].fType == kVec2f_GrSLType ||
transforms[t].fType == kVec3f_GrSLType);
unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3;
glpr->setProgramPathFragmentInputTransform(programID,
fragmentInput.fLocation,
GR_GL_OBJECT_LINEAR,
components,
transform);
}
}
示例5: canMakeEqual
bool GrPathProcessor::canMakeEqual(const GrBatchTracker& m,
const GrPrimitiveProcessor& that,
const GrBatchTracker& t) const {
if (this->classID() != that.classID() || !this->hasSameTextureAccesses(that)) {
return false;
}
const GrPathProcessor& other = that.cast<GrPathProcessor>();
if (!this->viewMatrix().cheapEqualTo(other.viewMatrix())) {
return false;
}
const PathBatchTracker& mine = m.cast<PathBatchTracker>();
const PathBatchTracker& theirs = t.cast<PathBatchTracker>();
if (mine.fColor != theirs.fColor) {
return false;
}
if (mine.fUsesLocalCoords != theirs.fUsesLocalCoords) {
return false;
}
if (mine.fUsesLocalCoords && !this->localMatrix().cheapEqualTo(other.localMatrix())) {
return false;
}
return true;
}
示例6: setRenderTargetState
void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc,
const GrPipeline& pipeline) {
// Load the RT height uniform if it is needed to y-flip gl_FragCoord.
if (fBuiltinUniformHandles.fRTHeightUni.isValid() &&
fRenderTargetState.fRenderTargetSize.fHeight != pipeline.getRenderTarget()->height()) {
fProgramDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni,
SkIntToScalar(pipeline.getRenderTarget()->height()));
}
// set RT adjustment
const GrRenderTarget* rt = pipeline.getRenderTarget();
SkISize size;
size.set(rt->width(), rt->height());
if (!primProc.isPathRendering()) {
if (fRenderTargetState.fRenderTargetOrigin != rt->origin() ||
fRenderTargetState.fRenderTargetSize != size) {
fRenderTargetState.fRenderTargetSize = size;
fRenderTargetState.fRenderTargetOrigin = rt->origin();
float rtAdjustmentVec[4];
fRenderTargetState.getRTAdjustmentVec(rtAdjustmentVec);
fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, rtAdjustmentVec);
}
} else {
SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport());
const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>();
fGpu->glPathRendering()->setProjectionMatrix(pathProc.viewMatrix(),
size, rt->origin());
}
}
示例7: setData
virtual void setData(const GrGLProgramDataManager& pdman,
const GrPrimitiveProcessor& proc,
const GrBatchTracker& bt) override {
SkASSERT(fTextureSizeUni.isValid());
GrTexture* texture = proc.texture(0);
if (texture->width() != fTextureSize.width() ||
texture->height() != fTextureSize.height()) {
fTextureSize = SkISize::Make(texture->width(), texture->height());
pdman.set2f(fTextureSizeUni,
SkIntToScalar(fTextureSize.width()),
SkIntToScalar(fTextureSize.height()));
}
const GrDistanceFieldPathGeoProc& dfpgp = proc.cast<GrDistanceFieldPathGeoProc>();
if (!dfpgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dfpgp.viewMatrix())) {
fViewMatrix = dfpgp.viewMatrix();
GrGLfloat viewMatrix[3 * 3];
GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
if (dfpgp.color() != fColor) {
GrGLfloat c[4];
GrColorToRGBAFloat(dfpgp.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = dfpgp.color();
}
}
示例8: emitAndInstallProc
void GrGLProgramBuilder::emitAndInstallProc(const GrPrimitiveProcessor& proc,
GrGLSLExpr4* outputColor,
GrGLSLExpr4* outputCoverage) {
// Program builders have a bit of state we need to clear with each effect
AutoStageAdvance adv(this);
this->nameExpression(outputColor, "outputColor");
this->nameExpression(outputCoverage, "outputCoverage");
// Enclose custom code in a block to avoid namespace conflicts
SkString openBrace;
openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name());
fFS.codeAppend(openBrace.c_str());
fVS.codeAppendf("// Primitive Processor %s\n", proc.name());
this->emitAndInstallProc(proc, outputColor->c_str(), outputCoverage->c_str());
fFS.codeAppend("}");
}
示例9: canMakeEqual
bool GrPathProcessor::canMakeEqual(const GrBatchTracker& m,
const GrPrimitiveProcessor& that,
const GrBatchTracker& t) const {
if (this->classID() != that.classID() || !this->hasSameTextureAccesses(that)) {
return false;
}
if (!this->viewMatrix().cheapEqualTo(that.viewMatrix())) {
return false;
}
const PathBatchTracker& mine = m.cast<PathBatchTracker>();
const PathBatchTracker& theirs = t.cast<PathBatchTracker>();
return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords,
that, theirs.fUsesLocalCoords) &&
CanCombineOutput(mine.fInputColorType, mine.fColor,
theirs.fInputColorType, theirs.fColor) &&
CanCombineOutput(mine.fInputCoverageType, 0xff,
theirs.fInputCoverageType, 0xff);
}
示例10: draw
bool GrGpuCommandBuffer::draw(const GrPipeline& pipeline,
const GrPrimitiveProcessor& primProc,
const GrMesh* mesh,
int meshCount) {
if (primProc.numAttribs() > this->gpu()->caps()->maxVertexAttributes()) {
this->gpu()->stats()->incNumFailedDraws();
return false;
}
this->onDraw(pipeline, primProc, mesh, meshCount);
return true;
}
示例11: setup_vertex_input_state
static void setup_vertex_input_state(const GrPrimitiveProcessor& primProc,
VkPipelineVertexInputStateCreateInfo* vertexInputInfo,
VkVertexInputBindingDescription* bindingDesc,
int maxBindingDescCount,
VkVertexInputAttributeDescription* attributeDesc,
int maxAttributeDescCount) {
// for now we have only one vertex buffer and one binding
memset(bindingDesc, 0, sizeof(VkVertexInputBindingDescription));
bindingDesc->binding = 0;
bindingDesc->stride = (uint32_t)primProc.getVertexStride();
bindingDesc->inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
// setup attribute descriptions
int vaCount = primProc.numAttribs();
SkASSERT(vaCount < maxAttributeDescCount);
if (vaCount > 0) {
size_t offset = 0;
for (int attribIndex = 0; attribIndex < vaCount; attribIndex++) {
const GrGeometryProcessor::Attribute& attrib = primProc.getAttrib(attribIndex);
GrVertexAttribType attribType = attrib.fType;
VkVertexInputAttributeDescription& vkAttrib = attributeDesc[attribIndex];
vkAttrib.location = attribIndex; // for now assume location = attribIndex
vkAttrib.binding = 0; // for now only one vertex buffer & binding
vkAttrib.format = attrib_type_to_vkformat(attribType);
vkAttrib.offset = static_cast<uint32_t>(offset);
offset += attrib.fOffset;
}
}
memset(vertexInputInfo, 0, sizeof(VkPipelineVertexInputStateCreateInfo));
vertexInputInfo->sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
vertexInputInfo->pNext = nullptr;
vertexInputInfo->flags = 0;
vertexInputInfo->vertexBindingDescriptionCount = 1;
vertexInputInfo->pVertexBindingDescriptions = bindingDesc;
vertexInputInfo->vertexAttributeDescriptionCount = vaCount;
vertexInputInfo->pVertexAttributeDescriptions = attributeDesc;
}
示例12: setData
virtual void setData(const GrGLProgramDataManager& pdman,
const GrPrimitiveProcessor& gp,
const GrBatchTracker& bt) override {
this->setUniformViewMatrix(pdman, gp.viewMatrix());
const BitmapTextBatchTracker& local = bt.cast<BitmapTextBatchTracker>();
if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColor) {
GrGLfloat c[4];
GrColorToRGBAFloat(local.fColor, c);
pdman.set4fv(fColorUniform, 1, c);
fColor = local.fColor;
}
}
示例13: emitAndInstallPrimProc
void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& proc,
GrGLSLExpr4* outputColor,
GrGLSLExpr4* outputCoverage) {
// Program builders have a bit of state we need to clear with each effect
AutoStageAdvance adv(this);
this->nameExpression(outputColor, "outputColor");
this->nameExpression(outputCoverage, "outputCoverage");
// Enclose custom code in a block to avoid namespace conflicts
SkString openBrace;
openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name());
fFS.codeAppend(openBrace.c_str());
fVS.codeAppendf("// Primitive Processor %s\n", proc.name());
SkASSERT(!fGeometryProcessor);
fGeometryProcessor = proc.createGLSLInstance(*this->glslCaps());
SkSTArray<4, SamplerHandle> texSamplers(proc.numTextures());
SkSTArray<2, SamplerHandle> bufferSamplers(proc.numBuffers());
this->emitSamplers(proc, &texSamplers, &bufferSamplers);
GrGLSLGeometryProcessor::EmitArgs args(&fVS,
&fFS,
this->varyingHandler(),
this->uniformHandler(),
this->glslCaps(),
proc,
outputColor->c_str(),
outputCoverage->c_str(),
texSamplers.begin(),
bufferSamplers.begin(),
fCoordTransforms,
&fOutCoords);
fGeometryProcessor->emitCode(args);
// We have to check that effects and the code they emit are consistent, ie if an effect
// asks for dst color, then the emit code needs to follow suit
SkDEBUGCODE(verify(proc);)
示例14: generateMipmaps
void GrGLProgram::generateMipmaps(const GrPrimitiveProcessor& primProc,
const GrPipeline& pipeline) {
this->generateMipmaps(primProc, pipeline.getAllowSRGBInputs());
GrFragmentProcessor::Iter iter(pipeline);
while (const GrFragmentProcessor* fp = iter.next()) {
this->generateMipmaps(*fp, pipeline.getAllowSRGBInputs());
}
if (primProc.getPixelLocalStorageState() !=
GrPixelLocalStorageState::kDraw_GrPixelLocalStorageState) {
const GrXferProcessor& xp = pipeline.getXferProcessor();
this->generateMipmaps(xp, pipeline.getAllowSRGBInputs());
}
}
示例15: gen_frag_proc_and_meta_keys
static bool gen_frag_proc_and_meta_keys(const GrPrimitiveProcessor& primProc,
const GrFragmentProcessor& fp,
const GrGLSLCaps& glslCaps,
GrProcessorKeyBuilder* b) {
for (int i = 0; i < fp.numChildProcessors(); ++i) {
if (!gen_frag_proc_and_meta_keys(primProc, fp.childProcessor(i), glslCaps, b)) {
return false;
}
}
fp.getGLSLProcessorKey(glslCaps, b);
return gen_meta_key(fp, glslCaps, primProc.getTransformKey(fp.coordTransforms(),
fp.numTransformsExclChildren()), b);
}