OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "Test.h" | 8 #if SK_SUPPORT_GPU |
9 | 9 |
10 // This is a GPU test | |
11 #if SK_SUPPORT_GPU | |
12 #include "GrContextFactory.h" | 10 #include "GrContextFactory.h" |
13 #include "SkGpuDevice.h" | 11 #include "SkGpuDevice.h" |
| 12 #include "Test.h" |
| 13 #include "TestClassDef.h" |
14 | 14 |
15 static const int gWidth = 640; | 15 static const int gWidth = 640; |
16 static const int gHeight = 480; | 16 static const int gHeight = 480; |
17 | 17 |
18 //////////////////////////////////////////////////////////////////////////////// | 18 //////////////////////////////////////////////////////////////////////////////// |
19 static void test_cache(skiatest::Reporter* reporter, | 19 static void test_cache(skiatest::Reporter* reporter, |
20 GrContext* context, | 20 GrContext* context, |
21 SkCanvas* canvas) { | 21 SkCanvas* canvas) { |
22 const SkIRect size = SkIRect::MakeWH(gWidth, gHeight); | 22 const SkIRect size = SkIRect::MakeWH(gWidth, gHeight); |
23 | 23 |
(...skipping 27 matching lines...) Expand all Loading... |
51 | 51 |
52 size_t curCacheSize = context->getGpuTextureCacheBytes(); | 52 size_t curCacheSize = context->getGpuTextureCacheBytes(); |
53 | 53 |
54 // we should never go over the size limit | 54 // we should never go over the size limit |
55 REPORTER_ASSERT(reporter, curCacheSize <= maxCacheSize); | 55 REPORTER_ASSERT(reporter, curCacheSize <= maxCacheSize); |
56 } | 56 } |
57 | 57 |
58 context->setTextureCacheLimits(oldMaxNum, oldMaxBytes); | 58 context->setTextureCacheLimits(oldMaxNum, oldMaxBytes); |
59 } | 59 } |
60 | 60 |
61 //////////////////////////////////////////////////////////////////////////////// | 61 DEF_GPUTEST(ResourceCache, reporter, factory) { |
62 static void TestResourceCache(skiatest::Reporter* reporter, GrContextFactory* fa
ctory) { | |
63 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { | 62 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { |
64 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G
LContextType>(type); | 63 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G
LContextType>(type); |
65 if (!GrContextFactory::IsRenderingGLContext(glType)) { | 64 if (!GrContextFactory::IsRenderingGLContext(glType)) { |
66 continue; | 65 continue; |
67 } | 66 } |
68 GrContext* context = factory->get(glType); | 67 GrContext* context = factory->get(glType); |
69 if (NULL == context) { | 68 if (NULL == context) { |
70 continue; | 69 continue; |
71 } | 70 } |
72 | 71 |
73 GrTextureDesc desc; | 72 GrTextureDesc desc; |
74 desc.fConfig = kSkia8888_GrPixelConfig; | 73 desc.fConfig = kSkia8888_GrPixelConfig; |
75 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 74 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
76 desc.fWidth = gWidth; | 75 desc.fWidth = gWidth; |
77 desc.fHeight = gHeight; | 76 desc.fHeight = gHeight; |
78 | 77 |
79 SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc, NUL
L, 0)); | 78 SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc, NUL
L, 0)); |
80 SkAutoTUnref<SkGpuDevice> device(SkNEW_ARGS(SkGpuDevice, (context, textu
re.get()))); | 79 SkAutoTUnref<SkGpuDevice> device(SkNEW_ARGS(SkGpuDevice, (context, textu
re.get()))); |
81 SkCanvas canvas(device.get()); | 80 SkCanvas canvas(device.get()); |
82 | 81 |
83 test_cache(reporter, context, &canvas); | 82 test_cache(reporter, context, &canvas); |
84 } | 83 } |
85 } | 84 } |
86 | 85 |
87 //////////////////////////////////////////////////////////////////////////////// | |
88 #include "TestClassDef.h" | |
89 DEFINE_GPUTESTCLASS("ResourceCache", ResourceCacheTestClass, TestResourceCache) | |
90 | |
91 #endif | 86 #endif |
OLD | NEW |