aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/GpuLayerCacheTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/GpuLayerCacheTest.cpp')
-rw-r--r--tests/GpuLayerCacheTest.cpp126
1 files changed, 67 insertions, 59 deletions
diff --git a/tests/GpuLayerCacheTest.cpp b/tests/GpuLayerCacheTest.cpp
index d5c2dde4ad..8da2b9ea8d 100644
--- a/tests/GpuLayerCacheTest.cpp
+++ b/tests/GpuLayerCacheTest.cpp
@@ -49,92 +49,100 @@ static void create_layers(skiatest::Reporter* reporter,
// locking & unlocking textures).
// TODO: need to add checks on VRAM usage!
DEF_GPUTEST(GpuLayerCache, reporter, factory) {
+ for (int i= 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
+ GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType) i;
- GrContext* context = factory->get(GrContextFactory::kNative_GLContextType);
- if (NULL == context) {
- return;
- }
+ if (!GrContextFactory::IsRenderingGLContext(glCtxType)) {
+ continue;
+ }
- SkPictureRecorder recorder;
- recorder.beginRecording(1, 1);
- SkAutoTUnref<const SkPicture> picture(recorder.endRecording());
+ GrContext* context = factory->get(glCtxType);
- GrLayerCache cache(context);
+ if (NULL == context) {
+ continue;
+ }
- create_layers(reporter, &cache, *picture);
+ SkPictureRecorder recorder;
+ recorder.beginRecording(1, 1);
+ SkAutoTUnref<const SkPicture> picture(recorder.endRecording());
- // Lock the layers making them all 512x512
- GrTextureDesc desc;
- desc.fWidth = 512;
- desc.fHeight = 512;
- desc.fConfig = kSkia8888_GrPixelConfig;
+ GrLayerCache cache(context);
- for (int i = 0; i < kNumLayers; ++i) {
- GrCachedLayer* layer = cache.findLayer(picture, i);
- REPORTER_ASSERT(reporter, NULL != layer);
+ create_layers(reporter, &cache, *picture);
+
+ // Lock the layers making them all 512x512
+ GrTextureDesc desc;
+ desc.fWidth = 512;
+ desc.fHeight = 512;
+ desc.fConfig = kSkia8888_GrPixelConfig;
- bool foundInCache = cache.lock(layer, desc);
- REPORTER_ASSERT(reporter, !foundInCache);
- foundInCache = cache.lock(layer, desc);
- REPORTER_ASSERT(reporter, foundInCache);
+ for (int i = 0; i < kNumLayers; ++i) {
+ GrCachedLayer* layer = cache.findLayer(picture, i);
+ REPORTER_ASSERT(reporter, NULL != layer);
- REPORTER_ASSERT(reporter, NULL != layer->texture());
+ bool foundInCache = cache.lock(layer, desc);
+ REPORTER_ASSERT(reporter, !foundInCache);
+ foundInCache = cache.lock(layer, desc);
+ REPORTER_ASSERT(reporter, foundInCache);
+
+ REPORTER_ASSERT(reporter, NULL != layer->texture());
#if USE_ATLAS
- // The first 4 layers should be in the atlas (and thus have non-empty
- // rects)
- if (i < 4) {
- REPORTER_ASSERT(reporter, layer->isAtlased());
- } else {
+ // The first 4 layers should be in the atlas (and thus have non-empty
+ // rects)
+ if (i < 4) {
+ REPORTER_ASSERT(reporter, layer->isAtlased());
+ } else {
#endif
REPORTER_ASSERT(reporter, !layer->isAtlased());
#if USE_ATLAS
- }
+ }
#endif
- }
+ }
- // Unlock the textures
- for (int i = 0; i < kNumLayers; ++i) {
- GrCachedLayer* layer = cache.findLayer(picture, i);
- REPORTER_ASSERT(reporter, NULL != layer);
+ // Unlock the textures
+ for (int i = 0; i < kNumLayers; ++i) {
+ GrCachedLayer* layer = cache.findLayer(picture, i);
+ REPORTER_ASSERT(reporter, NULL != layer);
- cache.unlock(layer);
- }
+ cache.unlock(layer);
+ }
- for (int i = 0; i < kNumLayers; ++i) {
- GrCachedLayer* layer = cache.findLayer(picture, i);
- REPORTER_ASSERT(reporter, NULL != layer);
+ for (int i = 0; i < kNumLayers; ++i) {
+ GrCachedLayer* layer = cache.findLayer(picture, i);
+ REPORTER_ASSERT(reporter, NULL != layer);
#if USE_ATLAS
- // The first 4 layers should be in the atlas (and thus do not
- // currently unlock). The final layer should be unlocked.
- if (i < 4) {
- REPORTER_ASSERT(reporter, NULL != layer->texture());
- REPORTER_ASSERT(reporter, layer->isAtlased());
- } else {
+ // The first 4 layers should be in the atlas (and thus do not
+ // currently unlock). The final layer should be unlocked.
+ if (i < 4) {
+ REPORTER_ASSERT(reporter, NULL != layer->texture());
+ REPORTER_ASSERT(reporter, layer->isAtlased());
+ } else {
#endif
- REPORTER_ASSERT(reporter, NULL == layer->texture());
- REPORTER_ASSERT(reporter, !layer->isAtlased());
+ REPORTER_ASSERT(reporter, NULL == layer->texture());
+ REPORTER_ASSERT(reporter, !layer->isAtlased());
#if USE_ATLAS
- }
+ }
#endif
- }
+ }
- // Free them all SkGpuDevice-style. This will not free up the
- // atlas' texture but will eliminate all the layers.
- cache.purge(picture);
+ // Free them all SkGpuDevice-style. This will not free up the
+ // atlas' texture but will eliminate all the layers.
+ cache.purge(picture);
- REPORTER_ASSERT(reporter, GetNumLayers::NumLayers(&cache) == 0);
- // TODO: add VRAM/resource cache check here
+ REPORTER_ASSERT(reporter, GetNumLayers::NumLayers(&cache) == 0);
+ // TODO: add VRAM/resource cache check here
#if 0
- // Re-create the layers
- create_layers(reporter, &cache, picture);
+ // Re-create the layers
+ create_layers(reporter, &cache, picture);
- // Free them again GrContext-style. This should free up everything.
- cache.freeAll();
+ // Free them again GrContext-style. This should free up everything.
+ cache.freeAll();
- REPORTER_ASSERT(reporter, GetNumLayers::NumLayers(&cache) == 0);
- // TODO: add VRAM/resource cache check here
+ REPORTER_ASSERT(reporter, GetNumLayers::NumLayers(&cache) == 0);
+ // TODO: add VRAM/resource cache check here
#endif
+ }
}
#endif