当前位置: 首页>>代码示例>>C++>>正文


C++ SkShader::asFragmentProcessor方法代码示例

本文整理汇总了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);
}
开发者ID:huqingyu,项目名称:skia,代码行数:31,代码来源:SkGr.cpp

示例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;
}
开发者ID:Arternis,项目名称:skia,代码行数:30,代码来源:SkPerlinNoiseShader.cpp

示例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);
}
开发者ID:tiftof,项目名称:skia,代码行数:22,代码来源:SkGr.cpp


注:本文中的SkShader::asFragmentProcessor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。