void GrGLVertexBuilder::emitAttributes(const GrGeometryProcessor& gp) { int vaCount = gp.numAttribs(); for (int i = 0; i < vaCount; i++) { this->addAttribute(&gp.getAttrib(i)); } return; }
static inline void GenKey(const GrGeometryProcessor& gp, const GrBatchTracker& bt, const GrGLSLCaps&, GrProcessorKeyBuilder* b) { const BatchTracker& local = bt.cast<BatchTracker>(); uint32_t key = local.fInputColorType << 16; key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 : 0x0; key |= ComputePosKey(gp.viewMatrix()) << 1; b->add32(key); }
void GrGLSLVaryingHandler::emitAttributes(const GrGeometryProcessor& gp) { int vaCount = gp.numVertexAttributes(); for (int i = 0; i < vaCount; i++) { this->addAttribute(gp.vertexAttribute(i).asShaderVar()); } int iaCount = gp.numInstanceAttributes(); for (int i = 0; i < iaCount; i++) { this->addAttribute(gp.instanceAttribute(i).asShaderVar()); } }
void GrGLSLVaryingHandler::emitAttributes(const GrGeometryProcessor& gp) { int vaCount = gp.numAttribs(); for (int i = 0; i < vaCount; i++) { const GrGeometryProcessor::Attribute& attr = gp.getAttrib(i); this->addAttribute(GrShaderVar(attr.fName, GrVertexAttribTypeToSLType(attr.fType), GrShaderVar::kAttribute_TypeModifier, GrShaderVar::kNonArray, attr.fPrecision)); } }
static inline void GenKey(const GrGeometryProcessor& gp, const GrBatchTracker& bt, const GrGLCaps&, GrProcessorKeyBuilder* b) { const GrDistanceFieldTextureEffect& dfTexEffect = gp.cast<GrDistanceFieldTextureEffect>(); const DistanceFieldBatchTracker& local = bt.cast<DistanceFieldBatchTracker>(); uint32_t key = dfTexEffect.getFlags(); key |= local.fInputColorType << 16; key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 << 24: 0x0; key |= ComputePosKey(gp.viewMatrix()) << 25; b->add32(key); }
static inline void GenKey(const GrGeometryProcessor& gp, const GrBatchTracker& bt, const GrGLCaps&, GrProcessorKeyBuilder* b) { const DefaultGeoProc& def = gp.cast<DefaultGeoProc>(); const BatchTracker& local = bt.cast<BatchTracker>(); uint32_t key = def.fFlags; key |= local.fInputColorType << 8 | local.fInputCoverageType << 16; key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 << 24 : 0x0; key |= ComputePosKey(gp.viewMatrix()) << 25; b->add32(key); }
static inline void GenKey(const GrGeometryProcessor& gp, const GrGLSLCaps&, GrProcessorKeyBuilder* b) { const GrDistanceFieldA8TextGeoProc& dfTexEffect = gp.cast<GrDistanceFieldA8TextGeoProc>(); uint32_t key = dfTexEffect.getFlags(); key |= dfTexEffect.colorIgnored() << 16; key |= ComputePosKey(dfTexEffect.viewMatrix()) << 25; b->add32(key); // Currently we hardcode numbers to convert atlas coordinates to normalized floating point SkASSERT(gp.numTextures() == 1); GrTexture* atlas = gp.textureAccess(0).getTexture(); SkASSERT(atlas); b->add32(atlas->width()); b->add32(atlas->height()); }
void GrGLVertexShaderBuilder::emitAttributes(const GrGeometryProcessor& gp) { const GrGeometryProcessor::VertexAttribArray& vars = gp.getVertexAttribs(); int numAttributes = vars.count(); for (int a = 0; a < numAttributes; ++a) { this->addAttribute(vars[a]); } }
void GrGLVertexBuilder::emitAttributes(const GrGeometryProcessor& gp) { const GrGeometryProcessor::VertexAttribArray& v = gp.getAttribs(); int vaCount = v.count(); for (int i = 0; i < vaCount; i++) { this->addAttribute(&v[i]); } return; }
void GrAtlasTextOp::flush(GrMeshDrawOp::Target* target, FlushInfo* flushInfo) const { if (!flushInfo->fGlyphsToFlush) { return; } auto atlasManager = target->atlasManager(); GrGeometryProcessor* gp = flushInfo->fGeometryProcessor.get(); GrMaskFormat maskFormat = this->maskFormat(); unsigned int numActiveProxies; const sk_sp<GrTextureProxy>* proxies = atlasManager->getProxies(maskFormat, &numActiveProxies); SkASSERT(proxies); if (gp->numTextureSamplers() != (int) numActiveProxies) { // During preparation the number of atlas pages has increased. // Update the proxies used in the GP to match. for (unsigned i = gp->numTextureSamplers(); i < numActiveProxies; ++i) { flushInfo->fFixedDynamicState->fPrimitiveProcessorTextures[i] = proxies[i].get(); } if (this->usesDistanceFields()) { if (this->isLCD()) { reinterpret_cast<GrDistanceFieldLCDTextGeoProc*>(gp)->addNewProxies( proxies, numActiveProxies, GrSamplerState::ClampBilerp()); } else { reinterpret_cast<GrDistanceFieldA8TextGeoProc*>(gp)->addNewProxies( proxies, numActiveProxies, GrSamplerState::ClampBilerp()); } } else { GrSamplerState samplerState = fNeedsGlyphTransform ? GrSamplerState::ClampBilerp() : GrSamplerState::ClampNearest(); reinterpret_cast<GrBitmapTextGeoProc*>(gp)->addNewProxies(proxies, numActiveProxies, samplerState); } } int maxGlyphsPerDraw = static_cast<int>(flushInfo->fIndexBuffer->gpuMemorySize() / sizeof(uint16_t) / 6); GrMesh* mesh = target->allocMesh(GrPrimitiveType::kTriangles); mesh->setIndexedPatterned(flushInfo->fIndexBuffer.get(), kIndicesPerGlyph, kVerticesPerGlyph, flushInfo->fGlyphsToFlush, maxGlyphsPerDraw); mesh->setVertexData(flushInfo->fVertexBuffer.get(), flushInfo->fVertexOffset); target->draw(flushInfo->fGeometryProcessor, flushInfo->fPipeline, flushInfo->fFixedDynamicState, mesh); flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush; flushInfo->fGlyphsToFlush = 0; }
static uint32_t gen_attrib_key(const GrGeometryProcessor& proc) { uint32_t key = 0; const GrGeometryProcessor::VertexAttribArray& vars = proc.getVertexAttribs(); int numAttributes = vars.count(); SkASSERT(numAttributes <= 2); for (int a = 0; a < numAttributes; ++a) { uint32_t value = 1 << a; key |= value; } return key; }
static inline void GenKey(const GrGeometryProcessor& proc, const GrBatchTracker& bt, const GrGLCaps&, GrProcessorKeyBuilder* b) { const BitmapTextBatchTracker& local = bt.cast<BitmapTextBatchTracker>(); // We have to put the optional vertex attribute as part of the key. See the comment // on addVertexAttrib. // TODO When we have deferred geometry we can fix this const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>(); uint32_t key = 0; key |= SkToBool(gp.inColor()) ? 0x1 : 0x0; key |= local.fUsesLocalCoords && proc.localMatrix().hasPerspective() ? 0x2 : 0x0; key |= gp.maskFormat() == kARGB_GrMaskFormat ? 0x4 : 0x0; key |= ComputePosKey(gp.viewMatrix()) << 3; b->add32(local.fInputColorType << 16 | key); }