| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkTypes.h" | 8 #include "SkTypes.h" |
| 9 | 9 |
| 10 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
| 11 | 11 |
| 12 #include "GrContextFactory.h" | 12 #include "GrContextFactory.h" |
| 13 #include "GrCaps.h" | 13 #include "GrCaps.h" |
| 14 #include "Test.h" | 14 #include "Test.h" |
| 15 | 15 |
| 16 using sk_gpu_test::GrContextFactory; | 16 using namespace sk_gpu_test; |
| 17 | 17 |
| 18 DEF_GPUTEST(GrContextFactory_NVPRContextOptionHasPathRenderingSupport, reporter,
/*factory*/) { | 18 DEF_GPUTEST(GrContextFactory_NVPRContextOptionHasPathRenderingSupport, reporter,
/*factory*/) { |
| 19 // Test that if NVPR is requested, the context always has path rendering | 19 // Test that if NVPR is requested, the context always has path rendering |
| 20 // or the context creation fails. | 20 // or the context creation fails. |
| 21 GrContextFactory testFactory; | 21 GrContextFactory testFactory; |
| 22 // Test that if NVPR is possible, caps are in sync. | 22 // Test that if NVPR is possible, caps are in sync. |
| 23 for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) { | 23 for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) { |
| 24 GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::Co
ntextType>(i); | 24 GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::Co
ntextType>(i); |
| 25 GrContext* context = testFactory.get(ctxType, | 25 GrContext* context = testFactory.get(ctxType, |
| 26 GrContextFactory::kEnableNVPR_Conte
xtOptions); | 26 GrContextFactory::kEnableNVPR_Conte
xtOptions); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 REPORTER_ASSERT(reporter, !context->caps()->srgbSupport()); | 67 REPORTER_ASSERT(reporter, !context->caps()->srgbSupport()); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 DEF_GPUTEST(GrContextFactory_abandon, reporter, /*factory*/) { | 73 DEF_GPUTEST(GrContextFactory_abandon, reporter, /*factory*/) { |
| 74 GrContextFactory testFactory; | 74 GrContextFactory testFactory; |
| 75 for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) { | 75 for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) { |
| 76 GrContextFactory::ContextType ctxType = (GrContextFactory::ContextType)
i; | 76 GrContextFactory::ContextType ctxType = (GrContextFactory::ContextType)
i; |
| 77 GrContextFactory::ContextInfo info1 = testFactory.getContextInfo(ctxType
); | 77 ContextInfo info1 = testFactory.getContextInfo(ctxType); |
| 78 if (!info1.fGrContext) { | 78 if (!info1.fGrContext) { |
| 79 continue; | 79 continue; |
| 80 } | 80 } |
| 81 REPORTER_ASSERT(reporter, info1.fGLContext); | 81 REPORTER_ASSERT(reporter, info1.fGLContext); |
| 82 // Ref for comparison. The API does not explicitly say that this stays
alive. | 82 // Ref for comparison. The API does not explicitly say that this stays
alive. |
| 83 info1.fGrContext->ref(); | 83 info1.fGrContext->ref(); |
| 84 testFactory.abandonContexts(); | 84 testFactory.abandonContexts(); |
| 85 | 85 |
| 86 // Test that we get different context after abandon. | 86 // Test that we get different context after abandon. |
| 87 GrContextFactory::ContextInfo info2 = | 87 ContextInfo info2 = testFactory.getContextInfo(ctxType); |
| 88 testFactory.getContextInfo(ctxType); | |
| 89 REPORTER_ASSERT(reporter, info2.fGrContext); | 88 REPORTER_ASSERT(reporter, info2.fGrContext); |
| 90 REPORTER_ASSERT(reporter, info2.fGLContext); | 89 REPORTER_ASSERT(reporter, info2.fGLContext); |
| 91 REPORTER_ASSERT(reporter, info1.fGrContext != info2.fGrContext); | 90 REPORTER_ASSERT(reporter, info1.fGrContext != info2.fGrContext); |
| 92 // fGLContext should also change, but it also could get the same address
. | 91 // fGLContext should also change, but it also could get the same address
. |
| 93 | 92 |
| 94 info1.fGrContext->unref(); | 93 info1.fGrContext->unref(); |
| 95 } | 94 } |
| 96 } | 95 } |
| 97 | 96 |
| 98 #endif | 97 #endif |
| OLD | NEW |