本文整理汇总了C++中SkShader::asFragmentProcessor方法的典型用法代码示例。如果您正苦于以下问题:C++ SkShader::asFragmentProcessor方法的具体用法?C++ SkShader::asFragmentProcessor怎么用?C++ SkShader::asFragmentProcessor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkShader
的用法示例。
在下文中一共展示了SkShader::asFragmentProcessor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SkPaint2GrPaint
bool SkPaint2GrPaint(GrContext* context, GrRenderTarget* rt, const SkPaint& skPaint,
const SkMatrix& viewM, bool constantColor, GrPaint* grPaint) {
SkShader* shader = skPaint.getShader();
if (NULL == shader) {
return SkPaint2GrPaintNoShader(context, rt, skPaint, SkColor2GrColor(skPaint.getColor()),
constantColor, grPaint);
}
GrColor paintColor = SkColor2GrColor(skPaint.getColor());
// Start a new block here in order to preserve our context state after calling
// asFragmentProcessor(). Since these calls get passed back to the client, we don't really
// want them messing around with the context.
{
// Allow the shader to modify paintColor and also create an effect to be installed as
// the first color effect on the GrPaint.
GrFragmentProcessor* fp = NULL;
if (!shader->asFragmentProcessor(context, skPaint, viewM, NULL, &paintColor,
grPaint->getProcessorDataManager(), &fp)) {
return false;
}
if (fp) {
grPaint->addColorProcessor(fp)->unref();
constantColor = false;
}
}
// The grcolor is automatically set when calling asFragmentProcessor.
// If the shader can be seen as an effect it returns true and adds its effect to the grpaint.
return SkPaint2GrPaintNoShader(context, rt, skPaint, paintColor, constantColor, grPaint);
}
示例2: TestCreate
GrFragmentProcessor* GrPerlinNoiseEffect::TestCreate(SkRandom* random,
GrContext* context,
const GrCaps&,
GrTexture**) {
int numOctaves = random->nextRangeU(2, 10);
bool stitchTiles = random->nextBool();
SkScalar seed = SkIntToScalar(random->nextU());
SkISize tileSize = SkISize::Make(random->nextRangeU(4, 4096), random->nextRangeU(4, 4096));
SkScalar baseFrequencyX = random->nextRangeScalar(0.01f,
0.99f);
SkScalar baseFrequencyY = random->nextRangeScalar(0.01f,
0.99f);
SkShader* shader = random->nextBool() ?
SkPerlinNoiseShader::CreateFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves, seed,
stitchTiles ? &tileSize : NULL) :
SkPerlinNoiseShader::CreateTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed,
stitchTiles ? &tileSize : NULL);
SkPaint paint;
GrColor paintColor;
GrFragmentProcessor* effect;
SkAssertResult(shader->asFragmentProcessor(context, paint,
GrTest::TestMatrix(random), NULL,
&paintColor, &effect));
SkDELETE(shader);
return effect;
}
示例3: SkPaint2GrPaint
bool SkPaint2GrPaint(GrContext* context, GrRenderTarget* rt, const SkPaint& skPaint,
const SkMatrix& viewM, bool constantColor, GrPaint* grPaint) {
SkShader* shader = skPaint.getShader();
if (nullptr == shader) {
return SkPaint2GrPaintNoShader(context, rt, skPaint, SkColor2GrColor(skPaint.getColor()),
constantColor, grPaint);
}
GrColor paintColor = SkColor2GrColor(skPaint.getColor());
const GrFragmentProcessor* fp = shader->asFragmentProcessor(context, viewM, NULL,
skPaint.getFilterQuality(), grPaint->getProcessorDataManager());
if (!fp) {
return false;
}
grPaint->addColorFragmentProcessor(fp)->unref();
constantColor = false;
// The grcolor is automatically set when calling asFragmentProcessor.
// If the shader can be seen as an effect it returns true and adds its effect to the grpaint.
return SkPaint2GrPaintNoShader(context, rt, skPaint, paintColor, constantColor, grPaint);
}