Exemplo n.º 1
0
static const GrGLContext* get_gl_context(SkCanvas* canvas) {
    // This bench exclusively tests GL calls directly
    if (NULL == canvas->getGrContext()) {
        return NULL;
    }
    GrContext* context = canvas->getGrContext();

    GrTestTarget tt;
    context->getTestTarget(&tt);
    if (!tt.target()) {
        SkDebugf("Couldn't get Gr test target.");
        return NULL;
    }

    const GrGLContext* ctx = tt.glContext();
    if (!ctx) {
        SkDebugf("Couldn't get an interface\n");
        return NULL;
    }

    // We only care about gpus with drawArraysInstanced support
    if (!ctx->interface()->fFunctions.fDrawArraysInstanced) {
        return NULL;
    }
    return ctx;
}
DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, context) {
    GrSurfaceDesc desc;
    desc.fFlags = kRenderTarget_GrSurfaceFlag;
    desc.fWidth = 800;
    desc.fHeight = 800;
    desc.fConfig = kSkia8888_GrPixelConfig;
    desc.fOrigin = kTopLeft_GrSurfaceOrigin;
    SkAutoTUnref<GrTexture> texture(context->textureProvider()->createApproxTexture(desc));
    GrTestTarget tt;
    GrRenderTarget* rt = texture->asRenderTarget();
    context->getTestTarget(&tt, rt);
    GrDrawTarget* dt = tt.target();
    GrResourceProvider* rp = tt.resourceProvider();

    test_path(dt, rt, rp, create_path_0());
    test_path(dt, rt, rp, create_path_1());
    test_path(dt, rt, rp, create_path_2());
    test_path(dt, rt, rp, create_path_3());
    test_path(dt, rt, rp, create_path_4());
    test_path(dt, rt, rp, create_path_5());
    test_path(dt, rt, rp, create_path_6());
    test_path(dt, rt, rp, create_path_7());
    test_path(dt, rt, rp, create_path_8());
    test_path(dt, rt, rp, create_path_9());
    test_path(dt, rt, rp, create_path_10());
    test_path(dt, rt, rp, create_path_11());
    test_path(dt, rt, rp, create_path_12());
    test_path(dt, rt, rp, create_path_13());
    test_path(dt, rt, rp, create_path_14());
    test_path(dt, rt, rp, create_path_15());
}
DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) {
    sk_sp<GrDrawContext> drawContext(ctxInfo.grContext()->newDrawContext(SkBackingFit::kApprox,
                                                                         800, 800,
                                                                         kSkia8888_GrPixelConfig,
                                                                         0,
                                                                         kTopLeft_GrSurfaceOrigin));
    if (!drawContext) {
        return;
    }

    GrTestTarget tt;
    ctxInfo.grContext()->getTestTarget(&tt, drawContext);
    GrDrawTarget* dt = tt.target();
    GrResourceProvider* rp = tt.resourceProvider();

    test_path(dt, drawContext.get(), rp, create_path_0());
    test_path(dt, drawContext.get(), rp, create_path_1());
    test_path(dt, drawContext.get(), rp, create_path_2());
    test_path(dt, drawContext.get(), rp, create_path_3());
    test_path(dt, drawContext.get(), rp, create_path_4());
    test_path(dt, drawContext.get(), rp, create_path_5());
    test_path(dt, drawContext.get(), rp, create_path_6());
    test_path(dt, drawContext.get(), rp, create_path_7());
    test_path(dt, drawContext.get(), rp, create_path_8());
    test_path(dt, drawContext.get(), rp, create_path_9());
    test_path(dt, drawContext.get(), rp, create_path_10());
    test_path(dt, drawContext.get(), rp, create_path_11());
    test_path(dt, drawContext.get(), rp, create_path_12());
    test_path(dt, drawContext.get(), rp, create_path_13());
    test_path(dt, drawContext.get(), rp, create_path_14());
    test_path(dt, drawContext.get(), rp, create_path_15());
}
DEF_GPUTEST(TessellatingPathRendererTests, reporter, factory) {
    GrContext* context = factory->get(static_cast<GrContextFactory::GLContextType>(0));
    if (nullptr == context) {
        return;
    }
    GrSurfaceDesc desc;
    desc.fFlags = kRenderTarget_GrSurfaceFlag;
    desc.fWidth = 800;
    desc.fHeight = 800;
    desc.fConfig = kSkia8888_GrPixelConfig;
    desc.fOrigin = kTopLeft_GrSurfaceOrigin;
    SkAutoTUnref<GrTexture> texture(context->textureProvider()->createApproxTexture(desc));
    GrTestTarget tt;
    GrRenderTarget* rt = texture->asRenderTarget();
    context->getTestTarget(&tt, rt);
    GrDrawTarget* dt = tt.target();
    GrResourceProvider* rp = tt.resourceProvider();

    test_path(dt, rt, rp, create_path_0());
    test_path(dt, rt, rp, create_path_1());
    test_path(dt, rt, rp, create_path_2());
    test_path(dt, rt, rp, create_path_3());
    test_path(dt, rt, rp, create_path_4());
    test_path(dt, rt, rp, create_path_5());
    test_path(dt, rt, rp, create_path_6());
    test_path(dt, rt, rp, create_path_7());
    test_path(dt, rt, rp, create_path_8());
    test_path(dt, rt, rp, create_path_9());
    test_path(dt, rt, rp, create_path_10());
    test_path(dt, rt, rp, create_path_11());
    test_path(dt, rt, rp, create_path_12());
    test_path(dt, rt, rp, create_path_13());
    test_path(dt, rt, rp, create_path_14());
    test_path(dt, rt, rp, create_path_15());
}
Exemplo n.º 5
0
DEF_GPUTEST(GLPrograms, reporter, factory) {
    // Set a locale that would cause shader compilation to fail because of , as decimal separator.
    // skbug 3330
#ifdef SK_BUILD_FOR_WIN
    GrAutoLocaleSetter als("sv-SE");
#else
    GrAutoLocaleSetter als("sv_SE.UTF-8");
#endif

    // We suppress prints to avoid spew
    GrContextOptions opts;
    opts.fSuppressPrints = true;
    GrContextFactory debugFactory(opts);
    for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
        GrContext* context = debugFactory.get(static_cast<GrContextFactory::GLContextType>(type));
        if (context) {
            GrGLGpu* gpu = static_cast<GrGLGpu*>(context->getGpu());

            /*
             * For the time being, we only support the test with desktop GL or for android on
             * ARM platforms
             * TODO When we run ES 3.00 GLSL in more places, test again
             */
            int maxStages;
            if (kGL_GrGLStandard == gpu->glStandard() ||
                kARM_GrGLVendor == gpu->ctxInfo().vendor()) {
                maxStages = 6;
            } else if (kTegra3_GrGLRenderer == gpu->ctxInfo().renderer() ||
                       kOther_GrGLRenderer == gpu->ctxInfo().renderer()) {
                maxStages = 1;
            } else {
                return;
            }
#if SK_ANGLE
            // Some long shaders run out of temporary registers in the D3D compiler on ANGLE.
            if (type == GrContextFactory::kANGLE_GLContextType) {
                maxStages = 2;
            }
#endif
#if SK_COMMAND_BUFFER
            // Some long shaders run out of temporary registers in the D3D compiler on ANGLE.
            // TODO(hendrikw): This only needs to happen with the ANGLE comand buffer backend.
            if (type == GrContextFactory::kCommandBuffer_GLContextType) {
                maxStages = 2;
            }
#endif
            GrTestTarget testTarget;
            context->getTestTarget(&testTarget);
            REPORTER_ASSERT(reporter, GrDrawingManager::ProgramUnitTest(
                                            context, testTarget.target(), maxStages));
        }
    }
}
DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(AADistanceFieldPathRenderer, reporter, ctxInfo) {
    // The DF PR only works with contexts that support derivatives
    if (!ctxInfo.grContext()->caps()->shaderCaps()->shaderDerivativeSupport()) {
        return;
    }
    sk_sp<GrDrawContext> drawContext(ctxInfo.grContext()->newDrawContext(SkBackingFit::kApprox,
                                                                         800, 800,
                                                                         kSkia8888_GrPixelConfig,
                                                                         0,
                                                                         kTopLeft_GrSurfaceOrigin));
    if (!drawContext) {
        return;
    }

    GrAADistanceFieldPathRenderer dfpr;
    GrTestTarget tt;
    ctxInfo.grContext()->getTestTarget(&tt, drawContext);
    GrResourceProvider* rp = tt.resourceProvider();

    test_far_from_origin(drawContext.get(), &dfpr, rp);
    ctxInfo.grContext()->flush();
}