aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/GrContextFactoryTest.cpp
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-08-23 10:12:00 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-23 14:33:25 +0000
commit51279987957a64d0f1a9cf7d299a8689734a0e50 (patch)
tree83d4c96ff5de8598a1025c58ac513f21650a8b99 /tests/GrContextFactoryTest.cpp
parentdb816992bb979850853965e0f03565a535204e7d (diff)
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 <egdaniel@google.com> Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tests/GrContextFactoryTest.cpp')
-rw-r--r--tests/GrContextFactoryTest.cpp26
1 files changed, 26 insertions, 0 deletions
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<SkExecutor> threadPool = SkExecutor::MakeThreadPool(1);
+ contextOptions.fExecutor = threadPool.get();
+ GrContextFactory threadedFactory(contextOptions);
+
+ for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
+ GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::ContextType>(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();