Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "SkTypes.h" |
| 9 | |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 10 | #include "GrBackendSurface.h" |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 11 | #include "GrBackendTextureImageGenerator.h" |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 12 | #include "GrContext.h" |
| 13 | #include "GrContextPriv.h" |
| 14 | #include "GrGpu.h" |
| 15 | #include "GrRenderTargetContext.h" |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 16 | #include "GrSemaphore.h" |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 17 | #include "GrSurfaceProxyPriv.h" |
| 18 | #include "GrTest.h" |
| 19 | #include "GrTexturePriv.h" |
| 20 | #include "GrTextureProxy.h" |
| 21 | #include "SkCanvas.h" |
| 22 | #include "SkImage_Base.h" |
| 23 | #include "SkGpuDevice.h" |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 24 | #include "SkPoint.h" |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 25 | #include "SkSurface.h" |
| 26 | #include "SkSurface_Gpu.h" |
| 27 | #include "Test.h" |
| 28 | |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 29 | static constexpr int kSize = 8; |
| 30 | |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 31 | // Test that the correct mip map states are on the GrTextures when wrapping GrBackendTextures in |
| 32 | // SkImages and SkSurfaces |
| 33 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrWrappedMipMappedTest, reporter, ctxInfo) { |
| 34 | GrContext* context = ctxInfo.grContext(); |
Brian Salomon | c7fe0f7 | 2018-05-11 10:14:21 -0400 | [diff] [blame] | 35 | if (!context->contextPriv().caps()->mipMapSupport()) { |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 36 | return; |
| 37 | } |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 38 | GrGpu* gpu = context->contextPriv().getGpu(); |
| 39 | |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 40 | for (auto mipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) { |
| 41 | for (auto isRT : {false, true}) { |
| 42 | // CreateTestingOnlyBackendTexture currently doesn't support uploading data to mip maps |
| 43 | // so we don't send any. However, we pretend there is data for the checks below which is |
| 44 | // fine since we are never actually using these textures for any work on the gpu. |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 45 | GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( |
Robert Phillips | 57e0828 | 2017-11-16 14:59:48 -0500 | [diff] [blame] | 46 | nullptr, kSize, kSize, kRGBA_8888_GrPixelConfig, isRT, mipMapped); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 47 | |
Robert Phillips | e0070c0 | 2017-11-13 12:47:24 -0500 | [diff] [blame] | 48 | sk_sp<GrTextureProxy> proxy; |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 49 | sk_sp<SkImage> image; |
| 50 | if (isRT) { |
| 51 | sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture( |
| 52 | context, |
| 53 | backendTex, |
| 54 | kTopLeft_GrSurfaceOrigin, |
| 55 | 0, |
Greg Daniel | faa095e | 2017-12-19 13:15:02 -0500 | [diff] [blame] | 56 | kRGBA_8888_SkColorType, |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 57 | nullptr, |
| 58 | nullptr); |
| 59 | |
| 60 | SkGpuDevice* device = ((SkSurface_Gpu*)surface.get())->getDevice(); |
Robert Phillips | e0070c0 | 2017-11-13 12:47:24 -0500 | [diff] [blame] | 61 | proxy = device->accessRenderTargetContext()->asTextureProxyRef(); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 62 | } else { |
| 63 | image = SkImage::MakeFromTexture(context, backendTex, |
| 64 | kTopLeft_GrSurfaceOrigin, |
Greg Daniel | f5d8758 | 2017-12-18 14:48:15 -0500 | [diff] [blame] | 65 | kRGBA_8888_SkColorType, |
| 66 | kPremul_SkAlphaType, nullptr, |
| 67 | nullptr, nullptr); |
Robert Phillips | e0070c0 | 2017-11-13 12:47:24 -0500 | [diff] [blame] | 68 | proxy = as_IB(image)->asTextureProxyRef(); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 69 | } |
| 70 | REPORTER_ASSERT(reporter, proxy); |
| 71 | if (!proxy) { |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 72 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 73 | return; |
| 74 | } |
| 75 | |
| 76 | REPORTER_ASSERT(reporter, proxy->priv().isInstantiated()); |
| 77 | |
| 78 | GrTexture* texture = proxy->priv().peekTexture(); |
| 79 | REPORTER_ASSERT(reporter, texture); |
| 80 | if (!texture) { |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 81 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 82 | return; |
| 83 | } |
| 84 | |
| 85 | if (GrMipMapped::kYes == mipMapped) { |
Greg Daniel | e252f08 | 2017-10-23 16:05:23 -0400 | [diff] [blame] | 86 | REPORTER_ASSERT(reporter, GrMipMapped::kYes == texture->texturePriv().mipMapped()); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 87 | if (isRT) { |
| 88 | REPORTER_ASSERT(reporter, texture->texturePriv().mipMapsAreDirty()); |
| 89 | } else { |
| 90 | REPORTER_ASSERT(reporter, !texture->texturePriv().mipMapsAreDirty()); |
| 91 | } |
| 92 | } else { |
Greg Daniel | e252f08 | 2017-10-23 16:05:23 -0400 | [diff] [blame] | 93 | REPORTER_ASSERT(reporter, GrMipMapped::kNo == texture->texturePriv().mipMapped()); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 94 | } |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 95 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 100 | // Test that we correctly copy or don't copy GrBackendTextures in the GrBackendTextureImageGenerator |
| 101 | // based on if we will use mips in the draw and the mip status of the GrBackendTexture. |
| 102 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrBackendTextureImageMipMappedTest, reporter, ctxInfo) { |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 103 | GrContext* context = ctxInfo.grContext(); |
Brian Salomon | c7fe0f7 | 2018-05-11 10:14:21 -0400 | [diff] [blame] | 104 | if (!context->contextPriv().caps()->mipMapSupport()) { |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 105 | return; |
| 106 | } |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 107 | GrGpu* gpu = context->contextPriv().getGpu(); |
| 108 | |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 109 | for (auto mipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) { |
| 110 | for (auto willUseMips : {false, true}) { |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 111 | GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 112 | nullptr, kSize, kSize, kRGBA_8888_GrPixelConfig, false, mipMapped); |
| 113 | |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 114 | sk_sp<SkImage> image = SkImage::MakeFromTexture(context, backendTex, |
| 115 | kTopLeft_GrSurfaceOrigin, |
Greg Daniel | f5d8758 | 2017-12-18 14:48:15 -0500 | [diff] [blame] | 116 | kRGBA_8888_SkColorType, |
| 117 | kPremul_SkAlphaType, nullptr, |
| 118 | nullptr, nullptr); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 119 | |
| 120 | GrTextureProxy* proxy = as_IB(image)->peekProxy(); |
| 121 | REPORTER_ASSERT(reporter, proxy); |
| 122 | if (!proxy) { |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 123 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 124 | return; |
| 125 | } |
| 126 | |
| 127 | REPORTER_ASSERT(reporter, proxy->priv().isInstantiated()); |
| 128 | |
| 129 | sk_sp<GrTexture> texture = sk_ref_sp(proxy->priv().peekTexture()); |
| 130 | REPORTER_ASSERT(reporter, texture); |
| 131 | if (!texture) { |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 132 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 133 | return; |
| 134 | } |
| 135 | |
| 136 | std::unique_ptr<SkImageGenerator> imageGen = GrBackendTextureImageGenerator::Make( |
Brian Osman | 052ef69 | 2018-03-27 09:56:31 -0400 | [diff] [blame] | 137 | texture, kTopLeft_GrSurfaceOrigin, nullptr, kRGBA_8888_SkColorType, |
| 138 | kPremul_SkAlphaType, nullptr); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 139 | REPORTER_ASSERT(reporter, imageGen); |
| 140 | if (!imageGen) { |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 141 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 142 | return; |
| 143 | } |
| 144 | |
| 145 | SkIPoint origin = SkIPoint::Make(0,0); |
| 146 | // The transfer function behavior isn't used in the generator so set we set it |
| 147 | // arbitrarily here. |
| 148 | SkTransferFunctionBehavior behavior = SkTransferFunctionBehavior::kIgnore; |
| 149 | SkImageInfo imageInfo = SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, |
| 150 | kPremul_SkAlphaType); |
| 151 | sk_sp<GrTextureProxy> genProxy = imageGen->generateTexture(context, imageInfo, |
| 152 | origin, behavior, |
| 153 | willUseMips); |
| 154 | |
| 155 | REPORTER_ASSERT(reporter, genProxy); |
| 156 | if (!genProxy) { |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 157 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 158 | return; |
| 159 | } |
| 160 | |
Greg Daniel | e728f67 | 2018-01-17 10:52:04 -0500 | [diff] [blame] | 161 | if (GrSurfaceProxy::LazyState::kNot != genProxy->lazyInstantiationState()) { |
| 162 | genProxy->priv().doLazyInstantiation(context->contextPriv().resourceProvider()); |
Greg Daniel | f6f7b67 | 2018-02-15 13:06:26 -0500 | [diff] [blame] | 163 | } else if (!genProxy->priv().isInstantiated()) { |
| 164 | genProxy->instantiate(context->contextPriv().resourceProvider()); |
Greg Daniel | e728f67 | 2018-01-17 10:52:04 -0500 | [diff] [blame] | 165 | } |
| 166 | |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 167 | REPORTER_ASSERT(reporter, genProxy->priv().isInstantiated()); |
Greg Daniel | bddcc95 | 2018-01-24 13:22:24 -0500 | [diff] [blame] | 168 | if (!genProxy->priv().isInstantiated()) { |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 169 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | bddcc95 | 2018-01-24 13:22:24 -0500 | [diff] [blame] | 170 | return; |
| 171 | } |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 172 | |
| 173 | GrTexture* genTexture = genProxy->priv().peekTexture(); |
| 174 | REPORTER_ASSERT(reporter, genTexture); |
| 175 | if (!genTexture) { |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 176 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 177 | return; |
| 178 | } |
| 179 | |
Robert Phillips | b67821d | 2017-12-13 15:00:45 -0500 | [diff] [blame] | 180 | GrBackendTexture genBackendTex = genTexture->getBackendTexture(); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 181 | |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 182 | if (kOpenGL_GrBackend == genBackendTex.backend()) { |
| 183 | GrGLTextureInfo genTexInfo; |
| 184 | GrGLTextureInfo origTexInfo; |
| 185 | if (genBackendTex.getGLTextureInfo(&genTexInfo) && |
| 186 | backendTex.getGLTextureInfo(&origTexInfo)) { |
| 187 | if (willUseMips && GrMipMapped::kNo == mipMapped) { |
| 188 | // We did a copy so the texture IDs should be different |
| 189 | REPORTER_ASSERT(reporter, origTexInfo.fID != genTexInfo.fID); |
| 190 | } else { |
| 191 | REPORTER_ASSERT(reporter, origTexInfo.fID == genTexInfo.fID); |
| 192 | } |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 193 | } else { |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 194 | ERRORF(reporter, "Failed to get GrGLTextureInfo"); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 195 | } |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 196 | #ifdef SK_VULKAN |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 197 | } else if (kVulkan_GrBackend == genBackendTex.backend()) { |
| 198 | GrVkImageInfo genImageInfo; |
| 199 | GrVkImageInfo origImageInfo; |
| 200 | if (genBackendTex.getVkImageInfo(&genImageInfo) && |
| 201 | backendTex.getVkImageInfo(&origImageInfo)) { |
| 202 | if (willUseMips && GrMipMapped::kNo == mipMapped) { |
| 203 | // We did a copy so the texture IDs should be different |
| 204 | REPORTER_ASSERT(reporter, origImageInfo.fImage != genImageInfo.fImage); |
| 205 | } else { |
| 206 | REPORTER_ASSERT(reporter, origImageInfo.fImage == genImageInfo.fImage); |
| 207 | } |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 208 | } else { |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 209 | ERRORF(reporter, "Failed to get GrVkImageInfo"); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 210 | } |
| 211 | #endif |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 212 | } else { |
| 213 | REPORTER_ASSERT(reporter, false); |
| 214 | } |
| 215 | |
| 216 | // Must make sure the uses of the backend texture have finished (we possibly have a |
Greg Daniel | 26b50a4 | 2018-03-08 09:49:58 -0500 | [diff] [blame] | 217 | // queued up copy) before we delete the backend texture. |
| 218 | context->flush(); |
| 219 | gpu->testingOnly_flushGpuAndSync(); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 220 | |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 221 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 222 | } |
| 223 | } |
| 224 | } |
| 225 | |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 226 | // Test that when we call makeImageSnapshot on an SkSurface we retains the same mip status as the |
| 227 | // resource we took the snapshot of. |
| 228 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrImageSnapshotMipMappedTest, reporter, ctxInfo) { |
| 229 | GrContext* context = ctxInfo.grContext(); |
Brian Salomon | c7fe0f7 | 2018-05-11 10:14:21 -0400 | [diff] [blame] | 230 | if (!context->contextPriv().caps()->mipMapSupport()) { |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 231 | return; |
| 232 | } |
| 233 | |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 234 | auto resourceProvider = context->contextPriv().resourceProvider(); |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 235 | GrGpu* gpu = context->contextPriv().getGpu(); |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 236 | |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 237 | for (auto willUseMips : {false, true}) { |
| 238 | for (auto isWrapped : {false, true}) { |
| 239 | GrMipMapped mipMapped = willUseMips ? GrMipMapped::kYes : GrMipMapped::kNo; |
| 240 | sk_sp<SkSurface> surface; |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 241 | GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( |
Robert Phillips | d21b2a5 | 2017-12-12 13:01:25 -0500 | [diff] [blame] | 242 | nullptr, kSize, kSize, kRGBA_8888_GrPixelConfig, true, mipMapped); |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 243 | if (isWrapped) { |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 244 | surface = SkSurface::MakeFromBackendTexture(context, |
| 245 | backendTex, |
| 246 | kTopLeft_GrSurfaceOrigin, |
| 247 | 0, |
Greg Daniel | faa095e | 2017-12-19 13:15:02 -0500 | [diff] [blame] | 248 | kRGBA_8888_SkColorType, |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 249 | nullptr, |
| 250 | nullptr); |
| 251 | } else { |
| 252 | SkImageInfo info = SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, |
| 253 | kPremul_SkAlphaType); |
| 254 | surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info, 0, |
| 255 | kTopLeft_GrSurfaceOrigin, nullptr, |
| 256 | willUseMips); |
| 257 | } |
| 258 | REPORTER_ASSERT(reporter, surface); |
| 259 | if (!surface) { |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 260 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 261 | } |
| 262 | SkGpuDevice* device = ((SkSurface_Gpu*)surface.get())->getDevice(); |
| 263 | GrTextureProxy* texProxy = device->accessRenderTargetContext()->asTextureProxy(); |
| 264 | REPORTER_ASSERT(reporter, mipMapped == texProxy->mipMapped()); |
| 265 | |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 266 | texProxy->instantiate(resourceProvider); |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 267 | GrTexture* texture = texProxy->priv().peekTexture(); |
| 268 | REPORTER_ASSERT(reporter, mipMapped == texture->texturePriv().mipMapped()); |
| 269 | |
| 270 | sk_sp<SkImage> image = surface->makeImageSnapshot(); |
| 271 | REPORTER_ASSERT(reporter, image); |
| 272 | if (!image) { |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 273 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 274 | } |
| 275 | texProxy = as_IB(image)->peekProxy(); |
| 276 | REPORTER_ASSERT(reporter, mipMapped == texProxy->mipMapped()); |
| 277 | |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 278 | texProxy->instantiate(resourceProvider); |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 279 | texture = texProxy->priv().peekTexture(); |
| 280 | REPORTER_ASSERT(reporter, mipMapped == texture->texturePriv().mipMapped()); |
| 281 | |
| 282 | // Must flush the context to make sure all the cmds (copies, etc.) from above are sent |
| 283 | // to the gpu before we delete the backendHandle. |
| 284 | context->flush(); |
Greg Daniel | d2d367d | 2018-04-16 10:24:45 -0400 | [diff] [blame] | 285 | gpu->testingOnly_flushGpuAndSync(); |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 286 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 287 | } |
| 288 | } |
| 289 | } |