From 51279987957a64d0f1a9cf7d299a8689734a0e50 Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Wed, 23 Aug 2017 10:12:00 -0400 Subject: Add an (optional) SkTaskGroup to GrContext GrContextOptions has an SkExecutor field, allowing clients to supply a thread pool. If present, the GrContext will create an SkTaskGroup that can be used for internal threading work. Bug: skia: Change-Id: I8b01245515a21a83f9fe838caf0a01c9a26c0003 Reviewed-on: https://skia-review.googlesource.com/37580 Reviewed-by: Greg Daniel Reviewed-by: Mike Klein Commit-Queue: Brian Osman --- tests/GrContextFactoryTest.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests/GrContextFactoryTest.cpp') diff --git a/tests/GrContextFactoryTest.cpp b/tests/GrContextFactoryTest.cpp index 098b2d61a9..a6291cf42d 100644 --- a/tests/GrContextFactoryTest.cpp +++ b/tests/GrContextFactoryTest.cpp @@ -10,7 +10,9 @@ #if SK_SUPPORT_GPU #include "GrContextFactory.h" +#include "GrContextPriv.h" #include "GrCaps.h" +#include "SkExecutor.h" #include "Test.h" using namespace sk_gpu_test; @@ -139,6 +141,30 @@ DEF_GPUTEST(GrContextFactory_sharedContexts, reporter, /*factory*/) { } } +DEF_GPUTEST(GrContextFactory_executorAndTaskGroup, reporter, /*factory*/) { + // Verify that contexts have a task group iff we supply an executor with context options + GrContextOptions contextOptions; + contextOptions.fExecutor = nullptr; + GrContextFactory serialFactory(contextOptions); + + std::unique_ptr threadPool = SkExecutor::MakeThreadPool(1); + contextOptions.fExecutor = threadPool.get(); + GrContextFactory threadedFactory(contextOptions); + + for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) { + GrContextFactory::ContextType ctxType = static_cast(i); + ContextInfo serialInfo = serialFactory.getContextInfo(ctxType); + if (GrContext* serialContext = serialInfo.grContext()) { + REPORTER_ASSERT(reporter, nullptr == serialContext->contextPriv().getTaskGroup()); + } + + ContextInfo threadedInfo = threadedFactory.getContextInfo(ctxType); + if (GrContext* threadedContext = threadedInfo.grContext()) { + REPORTER_ASSERT(reporter, nullptr != threadedContext->contextPriv().getTaskGroup()); + } + } +} + DEF_GPUTEST_FOR_ALL_CONTEXTS(GrContextDump, reporter, ctxInfo) { // Ensure that GrContext::dump doesn't assert (which is possible, if the JSON code is wrong) SkString result = ctxInfo.grContext()->dump(); -- cgit v1.2.3