本文整理汇总了C++中GrGLSLProgramDataManager::set1f方法的典型用法代码示例。如果您正苦于以下问题:C++ GrGLSLProgramDataManager::set1f方法的具体用法?C++ GrGLSLProgramDataManager::set1f怎么用?C++ GrGLSLProgramDataManager::set1f使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrGLSLProgramDataManager
的用法示例。
在下文中一共展示了GrGLSLProgramDataManager::set1f方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SkIntToScalar
void GrColorCubeEffect::GLSLProcessor::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& proc) {
const GrColorCubeEffect& colorCube = proc.cast<GrColorCubeEffect>();
SkScalar size = SkIntToScalar(colorCube.colorCubeSize());
pdman.set1f(fColorCubeSizeUni, SkScalarToFloat(size));
pdman.set1f(fColorCubeInvSizeUni, SkScalarToFloat(SkScalarInvert(size)));
}
示例2: onSetData
void onSetData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& _proc) override {
const GrMagnifierEffect& _outer = _proc.cast<GrMagnifierEffect>();
{
pdman.set1f(fXInvZoomVar, (_outer.xInvZoom()));
pdman.set1f(fYInvZoomVar, (_outer.yInvZoom()));
pdman.set1f(fXInvInsetVar, (_outer.xInvInset()));
pdman.set1f(fYInvInsetVar, (_outer.yInvInset()));
}
GrSurfaceProxy& srcProxy = *_outer.textureSampler(0).proxy();
GrTexture& src = *srcProxy.peekTexture();
(void)src;
auto bounds = _outer.bounds();
(void)bounds;
UniformHandle& boundsUniform = fBoundsUniformVar;
(void)boundsUniform;
auto srcRect = _outer.srcRect();
(void)srcRect;
UniformHandle& xInvZoom = fXInvZoomVar;
(void)xInvZoom;
UniformHandle& yInvZoom = fYInvZoomVar;
(void)yInvZoom;
UniformHandle& xInvInset = fXInvInsetVar;
(void)xInvInset;
UniformHandle& yInvInset = fYInvInsetVar;
(void)yInvInset;
UniformHandle& offset = fOffsetVar;
(void)offset;
SkScalar invW = 1.0f / src.width();
SkScalar invH = 1.0f / src.height();
{
SkScalar y = srcRect.y() * invH;
if (srcProxy.origin() != kTopLeft_GrSurfaceOrigin) {
y = 1.0f - (srcRect.height() / bounds.height()) - y;
}
pdman.set2f(offset, srcRect.x() * invW, y);
}
{
SkScalar y = bounds.y() * invH;
if (srcProxy.origin() != kTopLeft_GrSurfaceOrigin) {
y = 1.0f - bounds.height() * invH;
}
pdman.set4f(boundsUniform,
bounds.x() * invW,
y,
SkIntToScalar(src.width()) / bounds.width(),
SkIntToScalar(src.height()) / bounds.height());
}
}
示例3: onSetData
void GrGLMorphologyEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& proc) {
const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>();
GrTexture& texture = *m.texture(0);
// the code we generated was for a specific kernel radius, direction and bound usage
SkASSERT(m.radius() == fRadius);
SkASSERT(m.direction() == fDirection);
SkASSERT(m.useRange() == fUseRange);
float pixelSize = 0.0f;
switch (fDirection) {
case Gr1DKernelEffect::kX_Direction:
pixelSize = 1.0f / texture.width();
break;
case Gr1DKernelEffect::kY_Direction:
pixelSize = 1.0f / texture.height();
break;
default:
SkFAIL("Unknown filter direction.");
}
pdman.set1f(fPixelSizeUni, pixelSize);
if (fUseRange) {
const float* range = m.range();
if (fDirection && texture.origin() == kBottomLeft_GrSurfaceOrigin) {
pdman.set2f(fRangeUni, 1.0f - range[1], 1.0f - range[0]);
} else {
pdman.set2f(fRangeUni, range[0], range[1]);
}
}
}
示例4: onSetData
void GrGLMorphologyEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& proc) {
const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>();
GrTexture& texture = *m.texture(0);
float pixelSize = 0.0f;
switch (m.direction()) {
case Gr1DKernelEffect::kX_Direction:
pixelSize = 1.0f / texture.width();
break;
case Gr1DKernelEffect::kY_Direction:
pixelSize = 1.0f / texture.height();
break;
default:
SkFAIL("Unknown filter direction.");
}
pdman.set1f(fPixelSizeUni, pixelSize);
if (m.useRange()) {
const float* range = m.range();
if (m.direction() && texture.origin() == kBottomLeft_GrSurfaceOrigin) {
pdman.set2f(fRangeUni, 1.0f - range[1], 1.0f - range[0]);
} else {
pdman.set2f(fRangeUni, range[0], range[1]);
}
}
}
示例5: setData
void setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& gp,
FPCoordTransformIter&& transformIter) override {
const DefaultGeoProc& dgp = gp.cast<DefaultGeoProc>();
if (!dgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dgp.viewMatrix())) {
fViewMatrix = dgp.viewMatrix();
float viewMatrix[3 * 3];
GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
if (dgp.color() != fColor && !dgp.hasVertexColor()) {
float c[4];
GrColorToRGBAFloat(dgp.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = dgp.color();
}
if (dgp.coverage() != fCoverage && !dgp.hasVertexCoverage()) {
pdman.set1f(fCoverageUniform, GrNormalizeByteToFloat(dgp.coverage()));
fCoverage = dgp.coverage();
}
this->setTransformDataHelper(dgp.fLocalMatrix, pdman, &transformIter);
if (dgp.linearizeColor() && dgp.fColorSpaceXform) {
fColorSpaceHelper.setData(pdman, dgp.fColorSpaceXform.get());
}
}
示例6: onSetData
void GrGLMorphologyEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& proc) {
const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>();
GrSurfaceProxy* proxy = m.textureSampler(0).proxy();
GrTexture& texture = *proxy->peekTexture();
float pixelSize = 0.0f;
switch (m.direction()) {
case GrMorphologyEffect::Direction::kX:
pixelSize = 1.0f / texture.width();
break;
case GrMorphologyEffect::Direction::kY:
pixelSize = 1.0f / texture.height();
break;
default:
SK_ABORT("Unknown filter direction.");
}
pdman.set1f(fPixelSizeUni, pixelSize);
if (m.useRange()) {
const float* range = m.range();
if (GrMorphologyEffect::Direction::kY == m.direction() &&
proxy->origin() == kBottomLeft_GrSurfaceOrigin) {
pdman.set2f(fRangeUni, 1.0f - (range[1]*pixelSize), 1.0f - (range[0]*pixelSize));
} else {
pdman.set2f(fRangeUni, range[0] * pixelSize, range[1] * pixelSize);
}
}
}
示例7: setData
virtual void setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& gp) override {
const PLSFinishEffect& fe = gp.cast<PLSFinishEffect>();
pdman.set1f(fUseEvenOdd, fe.fUseEvenOdd);
if (fe.color() != fColor && !fe.colorIgnored()) {
GrGLfloat c[4];
GrColorToRGBAFloat(fe.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = fe.color();
}
}
示例8: onSetData
void GrGLMatrixConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) {
const GrMatrixConvolutionEffect& conv = processor.cast<GrMatrixConvolutionEffect>();
GrTexture& texture = *conv.texture(0);
// the code we generated was for a specific kernel size
SkASSERT(conv.kernelSize() == fKernelSize);
float imageIncrement[2];
float ySign = texture.origin() == kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
imageIncrement[0] = 1.0f / texture.width();
imageIncrement[1] = ySign / texture.height();
pdman.set2fv(fImageIncrementUni, 1, imageIncrement);
pdman.set2fv(fKernelOffsetUni, 1, conv.kernelOffset());
pdman.set1fv(fKernelUni, fKernelSize.width() * fKernelSize.height(), conv.kernel());
pdman.set1f(fGainUni, conv.gain());
pdman.set1f(fBiasUni, conv.bias());
fDomain.setData(pdman, conv.domain(), texture.origin());
}
示例9: setData
void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc) override {
#ifdef SK_GAMMA_APPLY_TO_A8
const GrDistanceFieldA8TextGeoProc& dfTexEffect = proc.cast<GrDistanceFieldA8TextGeoProc>();
float distanceAdjust = dfTexEffect.getDistanceAdjust();
if (distanceAdjust != fDistanceAdjust) {
pdman.set1f(fDistanceAdjustUni, distanceAdjust);
fDistanceAdjust = distanceAdjust;
}
#endif
const GrDistanceFieldA8TextGeoProc& dfa8gp = proc.cast<GrDistanceFieldA8TextGeoProc>();
if (!dfa8gp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dfa8gp.viewMatrix())) {
fViewMatrix = dfa8gp.viewMatrix();
float viewMatrix[3 * 3];
GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
}
示例10: onSetData
void GrGLMatrixConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& processor) {
const GrMatrixConvolutionEffect& conv = processor.cast<GrMatrixConvolutionEffect>();
GrSurfaceProxy* proxy = conv.textureSampler(0).proxy();
GrTexture* texture = proxy->priv().peekTexture();
float imageIncrement[2];
float ySign = proxy->origin() == kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
imageIncrement[0] = 1.0f / texture->width();
imageIncrement[1] = ySign / texture->height();
pdman.set2fv(fImageIncrementUni, 1, imageIncrement);
pdman.set2fv(fKernelOffsetUni, 1, conv.kernelOffset());
int kernelCount = conv.kernelSize().width() * conv.kernelSize().height();
int arrayCount = (kernelCount + 3) / 4;
SkASSERT(4 * arrayCount >= kernelCount);
pdman.set4fv(fKernelUni, arrayCount, conv.kernel());
pdman.set1f(fGainUni, conv.gain());
pdman.set1f(fBiasUni, conv.bias());
fDomain.setData(pdman, conv.domain(), proxy);
}
示例11: setData
void setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& primProc) override {
const GrQuadEffect& qe = primProc.cast<GrQuadEffect>();
if (!qe.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(qe.viewMatrix())) {
fViewMatrix = qe.viewMatrix();
float viewMatrix[3 * 3];
GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
if (qe.color() != fColor) {
float c[4];
GrColorToRGBAFloat(qe.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = qe.color();
}
if (qe.coverageScale() != 0xff && qe.coverageScale() != fCoverageScale) {
pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(qe.coverageScale()));
fCoverageScale = qe.coverageScale();
}
}
示例12: onSetData
void onSetData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& _proc) override {
const GrRectBlurEffect& _outer = _proc.cast<GrRectBlurEffect>();
{
const SkRect rectValue = _outer.rect();
pdman.set4fv(fRectVar, 1, (float*)&rectValue);
}
UniformHandle& rect = fRectVar;
(void)rect;
auto sigma = _outer.sigma();
(void)sigma;
GrSurfaceProxy& blurProfileProxy = *_outer.textureSampler(0).proxy();
GrTexture& blurProfile = *blurProfileProxy.priv().peekTexture();
(void)blurProfile;
UniformHandle& proxyRectHalf = fProxyRectHalfVar;
(void)proxyRectHalf;
UniformHandle& proxyRectFloat = fProxyRectFloatVar;
(void)proxyRectFloat;
UniformHandle& profileSize = fProfileSizeVar;
(void)profileSize;
pdman.set1f(profileSize, SkScalarCeilToScalar(6 * sigma));
}
示例13: setData
void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc,
FPCoordTransformIter&& transformIter) override {
const GrDistanceFieldA8TextGeoProc& dfa8gp = proc.cast<GrDistanceFieldA8TextGeoProc>();
#ifdef SK_GAMMA_APPLY_TO_A8
float distanceAdjust = dfa8gp.getDistanceAdjust();
if (distanceAdjust != fDistanceAdjust) {
fDistanceAdjust = distanceAdjust;
pdman.set1f(fDistanceAdjustUni, distanceAdjust);
}
#endif
SkASSERT(dfa8gp.numTextureSamplers() >= 1);
GrTexture* atlas = dfa8gp.textureSampler(0).peekTexture();
SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height()));
if (fAtlasSize.fWidth != atlas->width() || fAtlasSize.fHeight != atlas->height()) {
fAtlasSize.set(atlas->width(), atlas->height());
pdman.set2f(fAtlasSizeInvUniform, 1.0f / atlas->width(), 1.0f / atlas->height());
}
this->setTransformDataHelper(dfa8gp.localMatrix(), pdman, &transformIter);
}
示例14: setData
void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& primProc,
FPCoordTransformIter&& transformIter) override {
const GrConicEffect& ce = primProc.cast<GrConicEffect>();
if (!ce.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(ce.viewMatrix())) {
fViewMatrix = ce.viewMatrix();
float viewMatrix[3 * 3];
GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
if (ce.color() != fColor) {
float c[4];
GrColorToRGBAFloat(ce.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = ce.color();
}
if (ce.coverageScale() != 0xff && ce.coverageScale() != fCoverageScale) {
pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(ce.coverageScale()));
fCoverageScale = ce.coverageScale();
}
this->setTransformDataHelper(ce.localMatrix(), pdman, &transformIter);
}
示例15: setData
void setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& gp) override {
const DefaultGeoProc& dgp = gp.cast<DefaultGeoProc>();
if (!dgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dgp.viewMatrix())) {
fViewMatrix = dgp.viewMatrix();
float viewMatrix[3 * 3];
GrGLSLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
}
if (dgp.color() != fColor && !dgp.hasVertexColor()) {
float c[4];
GrColorToRGBAFloat(dgp.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = dgp.color();
}
if (!dgp.coverageWillBeIgnored() &&
dgp.coverage() != fCoverage && !dgp.hasVertexCoverage()) {
pdman.set1f(fCoverageUniform, GrNormalizeByteToFloat(dgp.coverage()));
fCoverage = dgp.coverage();
}
}