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 { |
Brian Salomon | 9457546 | 2018-06-21 17:00:26 -0400 | [diff] [blame] | 90 | #if 1 |
| 91 | // This is temporarily checks that the new image DOES have dirty MIP levels. See |
| 92 | // comment in SkImage_Gpu.cpp, new_wrapped_texture_common(). |
| 93 | REPORTER_ASSERT(reporter, texture->texturePriv().mipMapsAreDirty()); |
| 94 | #else |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 95 | REPORTER_ASSERT(reporter, !texture->texturePriv().mipMapsAreDirty()); |
Brian Salomon | 9457546 | 2018-06-21 17:00:26 -0400 | [diff] [blame] | 96 | #endif |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 97 | } |
| 98 | } else { |
Greg Daniel | e252f08 | 2017-10-23 16:05:23 -0400 | [diff] [blame] | 99 | REPORTER_ASSERT(reporter, GrMipMapped::kNo == texture->texturePriv().mipMapped()); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 100 | } |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 101 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 106 | // Test that we correctly copy or don't copy GrBackendTextures in the GrBackendTextureImageGenerator |
| 107 | // based on if we will use mips in the draw and the mip status of the GrBackendTexture. |
| 108 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrBackendTextureImageMipMappedTest, reporter, ctxInfo) { |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 109 | GrContext* context = ctxInfo.grContext(); |
Brian Salomon | c7fe0f7 | 2018-05-11 10:14:21 -0400 | [diff] [blame] | 110 | if (!context->contextPriv().caps()->mipMapSupport()) { |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 111 | return; |
| 112 | } |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 113 | GrGpu* gpu = context->contextPriv().getGpu(); |
| 114 | |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 115 | for (auto mipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) { |
| 116 | for (auto willUseMips : {false, true}) { |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 117 | GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 118 | nullptr, kSize, kSize, kRGBA_8888_GrPixelConfig, false, mipMapped); |
| 119 | |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 120 | sk_sp<SkImage> image = SkImage::MakeFromTexture(context, backendTex, |
| 121 | kTopLeft_GrSurfaceOrigin, |
Greg Daniel | f5d8758 | 2017-12-18 14:48:15 -0500 | [diff] [blame] | 122 | kRGBA_8888_SkColorType, |
| 123 | kPremul_SkAlphaType, nullptr, |
| 124 | nullptr, nullptr); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 125 | |
| 126 | GrTextureProxy* proxy = as_IB(image)->peekProxy(); |
| 127 | REPORTER_ASSERT(reporter, proxy); |
| 128 | if (!proxy) { |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 129 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 130 | return; |
| 131 | } |
| 132 | |
| 133 | REPORTER_ASSERT(reporter, proxy->priv().isInstantiated()); |
| 134 | |
| 135 | sk_sp<GrTexture> texture = sk_ref_sp(proxy->priv().peekTexture()); |
| 136 | REPORTER_ASSERT(reporter, texture); |
| 137 | if (!texture) { |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 138 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 139 | return; |
| 140 | } |
| 141 | |
| 142 | std::unique_ptr<SkImageGenerator> imageGen = GrBackendTextureImageGenerator::Make( |
Brian Osman | 052ef69 | 2018-03-27 09:56:31 -0400 | [diff] [blame] | 143 | texture, kTopLeft_GrSurfaceOrigin, nullptr, kRGBA_8888_SkColorType, |
| 144 | kPremul_SkAlphaType, nullptr); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 145 | REPORTER_ASSERT(reporter, imageGen); |
| 146 | if (!imageGen) { |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 147 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 148 | return; |
| 149 | } |
| 150 | |
| 151 | SkIPoint origin = SkIPoint::Make(0,0); |
| 152 | // The transfer function behavior isn't used in the generator so set we set it |
| 153 | // arbitrarily here. |
| 154 | SkTransferFunctionBehavior behavior = SkTransferFunctionBehavior::kIgnore; |
| 155 | SkImageInfo imageInfo = SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, |
| 156 | kPremul_SkAlphaType); |
| 157 | sk_sp<GrTextureProxy> genProxy = imageGen->generateTexture(context, imageInfo, |
| 158 | origin, behavior, |
| 159 | willUseMips); |
| 160 | |
| 161 | REPORTER_ASSERT(reporter, genProxy); |
| 162 | if (!genProxy) { |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 163 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 164 | return; |
| 165 | } |
| 166 | |
Greg Daniel | e728f67 | 2018-01-17 10:52:04 -0500 | [diff] [blame] | 167 | if (GrSurfaceProxy::LazyState::kNot != genProxy->lazyInstantiationState()) { |
| 168 | genProxy->priv().doLazyInstantiation(context->contextPriv().resourceProvider()); |
Greg Daniel | f6f7b67 | 2018-02-15 13:06:26 -0500 | [diff] [blame] | 169 | } else if (!genProxy->priv().isInstantiated()) { |
| 170 | genProxy->instantiate(context->contextPriv().resourceProvider()); |
Greg Daniel | e728f67 | 2018-01-17 10:52:04 -0500 | [diff] [blame] | 171 | } |
| 172 | |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 173 | REPORTER_ASSERT(reporter, genProxy->priv().isInstantiated()); |
Greg Daniel | bddcc95 | 2018-01-24 13:22:24 -0500 | [diff] [blame] | 174 | if (!genProxy->priv().isInstantiated()) { |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 175 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | bddcc95 | 2018-01-24 13:22:24 -0500 | [diff] [blame] | 176 | return; |
| 177 | } |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 178 | |
| 179 | GrTexture* genTexture = genProxy->priv().peekTexture(); |
| 180 | REPORTER_ASSERT(reporter, genTexture); |
| 181 | if (!genTexture) { |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 182 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 183 | return; |
| 184 | } |
| 185 | |
Robert Phillips | b67821d | 2017-12-13 15:00:45 -0500 | [diff] [blame] | 186 | GrBackendTexture genBackendTex = genTexture->getBackendTexture(); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 187 | |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 188 | if (kOpenGL_GrBackend == genBackendTex.backend()) { |
| 189 | GrGLTextureInfo genTexInfo; |
| 190 | GrGLTextureInfo origTexInfo; |
| 191 | if (genBackendTex.getGLTextureInfo(&genTexInfo) && |
| 192 | backendTex.getGLTextureInfo(&origTexInfo)) { |
| 193 | if (willUseMips && GrMipMapped::kNo == mipMapped) { |
| 194 | // We did a copy so the texture IDs should be different |
| 195 | REPORTER_ASSERT(reporter, origTexInfo.fID != genTexInfo.fID); |
| 196 | } else { |
| 197 | REPORTER_ASSERT(reporter, origTexInfo.fID == genTexInfo.fID); |
| 198 | } |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 199 | } else { |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 200 | ERRORF(reporter, "Failed to get GrGLTextureInfo"); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 201 | } |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 202 | #ifdef SK_VULKAN |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 203 | } else if (kVulkan_GrBackend == genBackendTex.backend()) { |
| 204 | GrVkImageInfo genImageInfo; |
| 205 | GrVkImageInfo origImageInfo; |
| 206 | if (genBackendTex.getVkImageInfo(&genImageInfo) && |
| 207 | backendTex.getVkImageInfo(&origImageInfo)) { |
| 208 | if (willUseMips && GrMipMapped::kNo == mipMapped) { |
| 209 | // We did a copy so the texture IDs should be different |
| 210 | REPORTER_ASSERT(reporter, origImageInfo.fImage != genImageInfo.fImage); |
| 211 | } else { |
| 212 | REPORTER_ASSERT(reporter, origImageInfo.fImage == genImageInfo.fImage); |
| 213 | } |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 214 | } else { |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 215 | ERRORF(reporter, "Failed to get GrVkImageInfo"); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 216 | } |
| 217 | #endif |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 218 | } else { |
| 219 | REPORTER_ASSERT(reporter, false); |
| 220 | } |
| 221 | |
| 222 | // 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] | 223 | // queued up copy) before we delete the backend texture. |
| 224 | context->flush(); |
| 225 | gpu->testingOnly_flushGpuAndSync(); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 226 | |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 227 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 228 | } |
| 229 | } |
| 230 | } |
| 231 | |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 232 | // Test that when we call makeImageSnapshot on an SkSurface we retains the same mip status as the |
| 233 | // resource we took the snapshot of. |
| 234 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrImageSnapshotMipMappedTest, reporter, ctxInfo) { |
| 235 | GrContext* context = ctxInfo.grContext(); |
Brian Salomon | c7fe0f7 | 2018-05-11 10:14:21 -0400 | [diff] [blame] | 236 | if (!context->contextPriv().caps()->mipMapSupport()) { |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 237 | return; |
| 238 | } |
| 239 | |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 240 | auto resourceProvider = context->contextPriv().resourceProvider(); |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 241 | GrGpu* gpu = context->contextPriv().getGpu(); |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 242 | |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 243 | for (auto willUseMips : {false, true}) { |
| 244 | for (auto isWrapped : {false, true}) { |
| 245 | GrMipMapped mipMapped = willUseMips ? GrMipMapped::kYes : GrMipMapped::kNo; |
| 246 | sk_sp<SkSurface> surface; |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 247 | GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( |
Robert Phillips | d21b2a5 | 2017-12-12 13:01:25 -0500 | [diff] [blame] | 248 | nullptr, kSize, kSize, kRGBA_8888_GrPixelConfig, true, mipMapped); |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 249 | if (isWrapped) { |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 250 | surface = SkSurface::MakeFromBackendTexture(context, |
| 251 | backendTex, |
| 252 | kTopLeft_GrSurfaceOrigin, |
| 253 | 0, |
Greg Daniel | faa095e | 2017-12-19 13:15:02 -0500 | [diff] [blame] | 254 | kRGBA_8888_SkColorType, |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 255 | nullptr, |
| 256 | nullptr); |
| 257 | } else { |
| 258 | SkImageInfo info = SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, |
| 259 | kPremul_SkAlphaType); |
| 260 | surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info, 0, |
| 261 | kTopLeft_GrSurfaceOrigin, nullptr, |
| 262 | willUseMips); |
| 263 | } |
| 264 | REPORTER_ASSERT(reporter, surface); |
| 265 | if (!surface) { |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 266 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 267 | } |
| 268 | SkGpuDevice* device = ((SkSurface_Gpu*)surface.get())->getDevice(); |
| 269 | GrTextureProxy* texProxy = device->accessRenderTargetContext()->asTextureProxy(); |
| 270 | REPORTER_ASSERT(reporter, mipMapped == texProxy->mipMapped()); |
| 271 | |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 272 | texProxy->instantiate(resourceProvider); |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 273 | GrTexture* texture = texProxy->priv().peekTexture(); |
| 274 | REPORTER_ASSERT(reporter, mipMapped == texture->texturePriv().mipMapped()); |
| 275 | |
| 276 | sk_sp<SkImage> image = surface->makeImageSnapshot(); |
| 277 | REPORTER_ASSERT(reporter, image); |
| 278 | if (!image) { |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 279 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 280 | } |
| 281 | texProxy = as_IB(image)->peekProxy(); |
| 282 | REPORTER_ASSERT(reporter, mipMapped == texProxy->mipMapped()); |
| 283 | |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 284 | texProxy->instantiate(resourceProvider); |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 285 | texture = texProxy->priv().peekTexture(); |
| 286 | REPORTER_ASSERT(reporter, mipMapped == texture->texturePriv().mipMapped()); |
| 287 | |
| 288 | // Must flush the context to make sure all the cmds (copies, etc.) from above are sent |
| 289 | // to the gpu before we delete the backendHandle. |
| 290 | context->flush(); |
Greg Daniel | d2d367d | 2018-04-16 10:24:45 -0400 | [diff] [blame] | 291 | gpu->testingOnly_flushGpuAndSync(); |
Brian Salomon | 26102cb | 2018-03-09 09:33:19 -0500 | [diff] [blame] | 292 | gpu->deleteTestingOnlyBackendTexture(backendTex); |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 293 | } |
| 294 | } |
| 295 | } |