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 |
(...skipping 28 matching lines...) Expand all Loading... |
39 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext
Type)i; | 39 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext
Type)i; |
40 GrContext* context = testFactory.get(glCtxType); | 40 GrContext* context = testFactory.get(glCtxType); |
41 if (context) { | 41 if (context) { |
42 REPORTER_ASSERT( | 42 REPORTER_ASSERT( |
43 reporter, | 43 reporter, |
44 !context->caps()->shaderCaps()->pathRenderingSupport()); | 44 !context->caps()->shaderCaps()->pathRenderingSupport()); |
45 } | 45 } |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
| 49 DEF_GPUTEST(GrContextFactory_RequiredSRGBSupport, reporter, /*factory*/) { |
| 50 // Test that if sRGB support is requested, the context always has that capab
ility |
| 51 // or the context creation fails. Also test that if the creation fails, a co
ntext |
| 52 // created without that flag would not have had sRGB support. |
| 53 GrContextFactory testFactory; |
| 54 // Test that if sRGB is requested, caps are in sync. |
| 55 for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { |
| 56 GrContextFactory::GLContextType glCtxType = static_cast<GrContextFactory
::GLContextType>(i); |
| 57 GrContext* context = |
| 58 testFactory.get(glCtxType, |
| 59 GrContextFactory::kRequireSRGBSupport_GLContextOptio
ns); |
| 60 |
| 61 if (context) { |
| 62 REPORTER_ASSERT(reporter, context->caps()->srgbSupport()); |
| 63 } else { |
| 64 context = testFactory.get(glCtxType); |
| 65 if (context) { |
| 66 REPORTER_ASSERT(reporter, !context->caps()->srgbSupport()); |
| 67 } |
| 68 } |
| 69 } |
| 70 } |
| 71 |
49 DEF_GPUTEST(GrContextFactory_abandon, reporter, /*factory*/) { | 72 DEF_GPUTEST(GrContextFactory_abandon, reporter, /*factory*/) { |
50 GrContextFactory testFactory; | 73 GrContextFactory testFactory; |
51 for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { | 74 for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { |
52 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext
Type) i; | 75 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext
Type) i; |
53 GrContextFactory::ContextInfo info1 = | 76 GrContextFactory::ContextInfo info1 = |
54 testFactory.getContextInfo(glCtxType); | 77 testFactory.getContextInfo(glCtxType); |
55 if (!info1.fGrContext) { | 78 if (!info1.fGrContext) { |
56 continue; | 79 continue; |
57 } | 80 } |
58 REPORTER_ASSERT(reporter, info1.fGLContext); | 81 REPORTER_ASSERT(reporter, info1.fGLContext); |
59 // 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. |
60 info1.fGrContext->ref(); | 83 info1.fGrContext->ref(); |
61 testFactory.abandonContexts(); | 84 testFactory.abandonContexts(); |
62 | 85 |
63 // Test that we get different context after abandon. | 86 // Test that we get different context after abandon. |
64 GrContextFactory::ContextInfo info2 = | 87 GrContextFactory::ContextInfo info2 = |
65 testFactory.getContextInfo(glCtxType); | 88 testFactory.getContextInfo(glCtxType); |
66 REPORTER_ASSERT(reporter, info2.fGrContext); | 89 REPORTER_ASSERT(reporter, info2.fGrContext); |
67 REPORTER_ASSERT(reporter, info2.fGLContext); | 90 REPORTER_ASSERT(reporter, info2.fGLContext); |
68 REPORTER_ASSERT(reporter, info1.fGrContext != info2.fGrContext); | 91 REPORTER_ASSERT(reporter, info1.fGrContext != info2.fGrContext); |
69 // fGLContext should also change, but it also could get the same address
. | 92 // fGLContext should also change, but it also could get the same address
. |
70 | 93 |
71 info1.fGrContext->unref(); | 94 info1.fGrContext->unref(); |
72 } | 95 } |
73 } | 96 } |
74 | 97 |
75 #endif | 98 #endif |
OLD | NEW |