void GrGLConvolutionEffect::setData(const GrGLProgramDataManager& pdman, const GrProcessor& processor) { const GrConvolutionEffect& conv = processor.cast<GrConvolutionEffect>(); GrTexture& texture = *conv.texture(0); // the code we generated was for a specific kernel radius SkASSERT(conv.radius() == fRadius); float imageIncrement[2] = { 0 }; float ySign = texture.origin() != kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f; switch (conv.direction()) { case Gr1DKernelEffect::kX_Direction: imageIncrement[0] = 1.0f / texture.width(); break; case Gr1DKernelEffect::kY_Direction: imageIncrement[1] = ySign / texture.height(); break; default: SkFAIL("Unknown filter direction."); } pdman.set2fv(fImageIncrementUni, 1, imageIncrement); if (conv.useBounds()) { const float* bounds = conv.bounds(); if (Gr1DKernelEffect::kY_Direction == conv.direction() && texture.origin() != kTopLeft_GrSurfaceOrigin) { pdman.set2f(fBoundsUni, 1.0f - bounds[1], 1.0f - bounds[0]); } else { pdman.set2f(fBoundsUni, bounds[0], bounds[1]); } } pdman.set1fv(fKernelUni, this->width(), conv.kernel()); }
void GrGLBicubicEffect::onSetData(const GrGLProgramDataManager& pdman, const GrProcessor& processor) { const GrBicubicEffect& bicubicEffect = processor.cast<GrBicubicEffect>(); const GrTexture& texture = *processor.texture(0); float imageIncrement[2]; imageIncrement[0] = 1.0f / texture.width(); imageIncrement[1] = 1.0f / texture.height(); pdman.set2fv(fImageIncrementUni, 1, imageIncrement); pdman.setMatrix4f(fCoefficientsUni, bicubicEffect.coefficients()); fDomain.setData(pdman, bicubicEffect.domain(), texture.origin()); }