| 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 here to ensure SK_SUPPORT_GPU is set correctly before it is examined. | 8 // Include here to ensure SK_SUPPORT_GPU is set correctly before it is examined. |
| 9 #include "SkTypes.h" | 9 #include "SkTypes.h" |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "SkCanvas.h" | 23 #include "SkCanvas.h" |
| 24 #include "SkGr.h" | 24 #include "SkGr.h" |
| 25 #include "SkMessageBus.h" | 25 #include "SkMessageBus.h" |
| 26 #include "SkSurface.h" | 26 #include "SkSurface.h" |
| 27 #include "Test.h" | 27 #include "Test.h" |
| 28 | 28 |
| 29 static const int gWidth = 640; | 29 static const int gWidth = 640; |
| 30 static const int gHeight = 480; | 30 static const int gHeight = 480; |
| 31 | 31 |
| 32 //////////////////////////////////////////////////////////////////////////////// | 32 //////////////////////////////////////////////////////////////////////////////// |
| 33 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheCache, reporter, context) { | 33 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheCache, reporter, ctxInfo) { |
| 34 GrContext* context = ctxInfo.fGrContext; |
| 34 GrSurfaceDesc desc; | 35 GrSurfaceDesc desc; |
| 35 desc.fConfig = kSkia8888_GrPixelConfig; | 36 desc.fConfig = kSkia8888_GrPixelConfig; |
| 36 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 37 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 37 desc.fWidth = gWidth; | 38 desc.fWidth = gWidth; |
| 38 desc.fHeight = gHeight; | 39 desc.fHeight = gHeight; |
| 39 SkImageInfo info = SkImageInfo::MakeN32Premul(gWidth, gHeight); | 40 SkImageInfo info = SkImageInfo::MakeN32Premul(gWidth, gHeight); |
| 40 auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info)); | 41 auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info)); |
| 41 SkCanvas* canvas = surface->getCanvas(); | 42 SkCanvas* canvas = surface->getCanvas(); |
| 42 | 43 |
| 43 const SkIRect size = SkIRect::MakeWH(gWidth, gHeight); | 44 const SkIRect size = SkIRect::MakeWH(gWidth, gHeight); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 72 size_t curCacheSize; | 73 size_t curCacheSize; |
| 73 context->getResourceCacheUsage(nullptr, &curCacheSize); | 74 context->getResourceCacheUsage(nullptr, &curCacheSize); |
| 74 | 75 |
| 75 // we should never go over the size limit | 76 // we should never go over the size limit |
| 76 REPORTER_ASSERT(reporter, curCacheSize <= maxCacheSize); | 77 REPORTER_ASSERT(reporter, curCacheSize <= maxCacheSize); |
| 77 } | 78 } |
| 78 | 79 |
| 79 context->setResourceCacheLimits(oldMaxNum, oldMaxBytes); | 80 context->setResourceCacheLimits(oldMaxNum, oldMaxBytes); |
| 80 } | 81 } |
| 81 | 82 |
| 82 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheStencilBuffers, reporter, contex
t) { | 83 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheStencilBuffers, reporter, ctxInf
o) { |
| 84 GrContext* context = ctxInfo.fGrContext; |
| 83 GrSurfaceDesc smallDesc; | 85 GrSurfaceDesc smallDesc; |
| 84 smallDesc.fFlags = kRenderTarget_GrSurfaceFlag; | 86 smallDesc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 85 smallDesc.fConfig = kSkia8888_GrPixelConfig; | 87 smallDesc.fConfig = kSkia8888_GrPixelConfig; |
| 86 smallDesc.fWidth = 4; | 88 smallDesc.fWidth = 4; |
| 87 smallDesc.fHeight = 4; | 89 smallDesc.fHeight = 4; |
| 88 smallDesc.fSampleCnt = 0; | 90 smallDesc.fSampleCnt = 0; |
| 89 | 91 |
| 90 GrTextureProvider* cache = context->textureProvider(); | 92 GrTextureProvider* cache = context->textureProvider(); |
| 91 GrResourceProvider* resourceProvider = context->resourceProvider(); | 93 GrResourceProvider* resourceProvider = context->resourceProvider(); |
| 92 // Test that two budgeted RTs with the same desc share a stencil buffer. | 94 // Test that two budgeted RTs with the same desc share a stencil buffer. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 REPORTER_ASSERT(reporter, | 181 REPORTER_ASSERT(reporter, |
| 180 smallMSAART0 && smallMSAART1 && | 182 smallMSAART0 && smallMSAART1 && |
| 181 smallMSAART0->asRenderTarget() && | 183 smallMSAART0->asRenderTarget() && |
| 182 smallMSAART1->asRenderTarget() && | 184 smallMSAART1->asRenderTarget() && |
| 183 resourceProvider->attachStencilAttachment(smallMSAART0->
asRenderTarget()) != | 185 resourceProvider->attachStencilAttachment(smallMSAART0->
asRenderTarget()) != |
| 184 resourceProvider->attachStencilAttachment(smallMSAART1->
asRenderTarget())); | 186 resourceProvider->attachStencilAttachment(smallMSAART1->
asRenderTarget())); |
| 185 } | 187 } |
| 186 } | 188 } |
| 187 } | 189 } |
| 188 | 190 |
| 189 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, cont
ext) { | 191 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, ctxI
nfo) { |
| 192 GrContext* context = ctxInfo.fGrContext; |
| 190 GrGpu* gpu = context->getGpu(); | 193 GrGpu* gpu = context->getGpu(); |
| 191 // this test is only valid for GL | 194 // this test is only valid for GL |
| 192 if (!gpu || !gpu->glContextForTesting()) { | 195 if (!gpu || !gpu->glContextForTesting()) { |
| 193 return; | 196 return; |
| 194 } | 197 } |
| 195 | 198 |
| 196 GrBackendObject texHandles[2]; | 199 GrBackendObject texHandles[2]; |
| 197 static const int kW = 100; | 200 static const int kW = 100; |
| 198 static const int kH = 100; | 201 static const int kH = 100; |
| 199 | 202 |
| (...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 test_cache_chained_purge(reporter); | 1311 test_cache_chained_purge(reporter); |
| 1309 test_resource_size_changed(reporter); | 1312 test_resource_size_changed(reporter); |
| 1310 test_timestamp_wrap(reporter); | 1313 test_timestamp_wrap(reporter); |
| 1311 test_flush(reporter); | 1314 test_flush(reporter); |
| 1312 test_large_resource_count(reporter); | 1315 test_large_resource_count(reporter); |
| 1313 test_custom_data(reporter); | 1316 test_custom_data(reporter); |
| 1314 test_abandoned(reporter); | 1317 test_abandoned(reporter); |
| 1315 } | 1318 } |
| 1316 | 1319 |
| 1317 #endif | 1320 #endif |
| OLD | NEW |