bsalomon | 6e2aad4 | 2016-04-01 11:54:31 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "include/core/SkTypes.h" |
bsalomon | 6e2aad4 | 2016-04-01 11:54:31 -0700 | [diff] [blame] | 9 | |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 10 | #include "include/gpu/GrDirectContext.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "tests/Test.h" |
| 12 | #include "tools/gpu/GrContextFactory.h" |
bsalomon | 6e2aad4 | 2016-04-01 11:54:31 -0700 | [diff] [blame] | 13 | |
bsalomon | f2f1c17 | 2016-04-05 12:59:06 -0700 | [diff] [blame] | 14 | using namespace sk_gpu_test; |
bsalomon | 6e2aad4 | 2016-04-01 11:54:31 -0700 | [diff] [blame] | 15 | |
Brian Salomon | dcfca43 | 2017-11-15 15:48:03 -0500 | [diff] [blame] | 16 | DEF_GPUTEST(GrContext_abandonContext, reporter, options) { |
bsalomon | 6e2aad4 | 2016-04-01 11:54:31 -0700 | [diff] [blame] | 17 | for (int testType = 0; testType < 6; ++testType) { |
bsalomon | 85b4b53 | 2016-04-05 11:06:27 -0700 | [diff] [blame] | 18 | for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) { |
Brian Salomon | dcfca43 | 2017-11-15 15:48:03 -0500 | [diff] [blame] | 19 | GrContextFactory testFactory(options); |
bsalomon | 85b4b53 | 2016-04-05 11:06:27 -0700 | [diff] [blame] | 20 | GrContextFactory::ContextType ctxType = (GrContextFactory::ContextType) i; |
bsalomon | f2f1c17 | 2016-04-05 12:59:06 -0700 | [diff] [blame] | 21 | ContextInfo info = testFactory.getContextInfo(ctxType); |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 22 | if (auto context = info.directContext()) { |
bsalomon | 6e2aad4 | 2016-04-01 11:54:31 -0700 | [diff] [blame] | 23 | switch (testType) { |
| 24 | case 0: |
| 25 | context->abandonContext(); |
| 26 | break; |
| 27 | case 1: |
| 28 | context->releaseResourcesAndAbandonContext(); |
| 29 | break; |
| 30 | case 2: |
| 31 | context->abandonContext(); |
| 32 | context->abandonContext(); |
| 33 | break; |
| 34 | case 3: |
| 35 | context->abandonContext(); |
| 36 | context->releaseResourcesAndAbandonContext(); |
| 37 | break; |
| 38 | case 4: |
| 39 | context->releaseResourcesAndAbandonContext(); |
| 40 | context->abandonContext(); |
| 41 | break; |
| 42 | case 5: |
| 43 | context->releaseResourcesAndAbandonContext(); |
| 44 | context->releaseResourcesAndAbandonContext(); |
| 45 | break; |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | } |