Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 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 | |
Robert Phillips | e19babf | 2020-04-06 13:57:30 -0400 | [diff] [blame] | 8 | #include "include/core/SkCanvas.h" |
Mike Klein | fe0aeb3 | 2019-05-20 10:55:11 -0500 | [diff] [blame] | 9 | #include "include/core/SkSurface.h" |
Robert Phillips | 02dc030 | 2019-07-02 17:58:27 -0400 | [diff] [blame] | 10 | #include "include/core/SkSurfaceCharacterization.h" |
Mike Klein | 4b432fa | 2019-06-06 11:44:05 -0500 | [diff] [blame] | 11 | #include "include/gpu/GrContext.h" |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 12 | #include "src/core/SkAutoPixmapStorage.h" |
Mike Klein | 4b432fa | 2019-06-06 11:44:05 -0500 | [diff] [blame] | 13 | #include "src/gpu/GrContextPriv.h" |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 14 | #include "src/image/SkImage_Base.h" |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 15 | #include "tests/Test.h" |
Robert Phillips | e3b6fe4 | 2019-09-11 11:26:46 -0400 | [diff] [blame] | 16 | #include "tests/TestUtils.h" |
| 17 | #include "tools/ToolUtils.h" |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 18 | |
Robert Phillips | 27eb525 | 2019-06-03 12:59:40 -0400 | [diff] [blame] | 19 | #ifdef SK_GL |
Robert Phillips | ee94693 | 2019-12-18 11:16:17 -0500 | [diff] [blame] | 20 | #include "src/gpu/gl/GrGLCaps.h" |
| 21 | #include "src/gpu/gl/GrGLDefines.h" |
Robert Phillips | 27eb525 | 2019-06-03 12:59:40 -0400 | [diff] [blame] | 22 | #include "src/gpu/gl/GrGLGpu.h" |
| 23 | #include "src/gpu/gl/GrGLUtil.h" |
| 24 | #endif |
| 25 | |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 26 | #ifdef SK_METAL |
| 27 | #include "include/gpu/mtl/GrMtlTypes.h" |
| 28 | #include "src/gpu/mtl/GrMtlCppUtil.h" |
| 29 | #endif |
| 30 | |
Greg Daniel | b2365d8 | 2020-05-13 15:32:04 -0400 | [diff] [blame] | 31 | static void wait_on_backend_work_to_finish(GrContext* context, bool* finishedCreate) { |
Greg Daniel | b577655 | 2020-06-19 20:21:08 -0400 | [diff] [blame] | 32 | context->submit(); |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 33 | while (finishedCreate && !(*finishedCreate)) { |
| 34 | context->checkAsyncWorkCompletion(); |
| 35 | } |
| 36 | if (finishedCreate) { |
| 37 | // The same boolean (pointed to by finishedCreate) is often used multiply and sequentially |
| 38 | // throughout our tests to create different backend textures. |
| 39 | // Reset it here so that it can be use to signal a future backend texture's creation |
| 40 | *finishedCreate = false; |
| 41 | } |
Greg Daniel | b2365d8 | 2020-05-13 15:32:04 -0400 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | static void delete_backend_texture(GrContext* context, const GrBackendTexture& backendTexture, |
| 45 | bool* finishedCreate) { |
| 46 | wait_on_backend_work_to_finish(context, finishedCreate); |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 47 | context->deleteBackendTexture(backendTexture); |
| 48 | } |
| 49 | |
Greg Daniel | b2365d8 | 2020-05-13 15:32:04 -0400 | [diff] [blame] | 50 | static void mark_signaled(void* context) { |
| 51 | *(bool*)context = true; |
| 52 | } |
| 53 | |
Robert Phillips | c1dbb4b | 2019-09-24 16:32:35 -0400 | [diff] [blame] | 54 | // Test wrapping of GrBackendObjects in SkSurfaces and SkImages (non-static since used in Mtl test) |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 55 | void test_wrapping(GrContext* context, skiatest::Reporter* reporter, |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 56 | std::function<GrBackendTexture (GrContext*, |
| 57 | GrMipMapped, |
| 58 | GrRenderable)> create, |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 59 | GrColorType grColorType, GrMipMapped mipMapped, GrRenderable renderable, |
| 60 | bool* finishedBECreate) { |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 61 | GrResourceCache* cache = context->priv().getResourceCache(); |
| 62 | |
| 63 | const int initialCount = cache->getResourceCount(); |
| 64 | |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 65 | GrBackendTexture backendTex = create(context, mipMapped, renderable); |
| 66 | if (!backendTex.isValid()) { |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 67 | ERRORF(reporter, "Couldn't create backendTexture for grColorType %d renderable %s\n", |
| 68 | grColorType, |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 69 | GrRenderable::kYes == renderable ? "yes" : "no"); |
| 70 | return; |
| 71 | } |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 72 | |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 73 | // Skia proper should know nothing about the new backend object |
| 74 | REPORTER_ASSERT(reporter, initialCount == cache->getResourceCount()); |
| 75 | |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 76 | SkColorType skColorType = GrColorTypeToSkColorType(grColorType); |
| 77 | |
| 78 | // Wrapping a backendTexture in an image requires an SkColorType |
| 79 | if (kUnknown_SkColorType == skColorType) { |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 80 | delete_backend_texture(context, backendTex, finishedBECreate); |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 81 | return; |
| 82 | } |
| 83 | |
Robert Phillips | d470e1b | 2019-09-04 15:05:35 -0400 | [diff] [blame] | 84 | if (GrRenderable::kYes == renderable && context->colorTypeSupportedAsSurface(skColorType)) { |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 85 | sk_sp<SkSurface> surf = SkSurface::MakeFromBackendTexture(context, |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 86 | backendTex, |
| 87 | kTopLeft_GrSurfaceOrigin, |
| 88 | 0, |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 89 | skColorType, |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 90 | nullptr, nullptr); |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 91 | if (!surf) { |
Robert Phillips | 9a30ee0 | 2020-04-29 08:58:39 -0400 | [diff] [blame] | 92 | ERRORF(reporter, "Couldn't make surface from backendTexture for %s\n", |
| 93 | ToolUtils::colortype_name(skColorType)); |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 94 | } else { |
| 95 | REPORTER_ASSERT(reporter, initialCount+1 == cache->getResourceCount()); |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 96 | } |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 97 | } |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 98 | |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 99 | { |
| 100 | sk_sp<SkImage> img = SkImage::MakeFromTexture(context, |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 101 | backendTex, |
| 102 | kTopLeft_GrSurfaceOrigin, |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 103 | skColorType, |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 104 | kPremul_SkAlphaType, |
| 105 | nullptr); |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 106 | if (!img) { |
Robert Phillips | 9a30ee0 | 2020-04-29 08:58:39 -0400 | [diff] [blame] | 107 | ERRORF(reporter, "Couldn't make image from backendTexture for %s\n", |
| 108 | ToolUtils::colortype_name(skColorType)); |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 109 | } else { |
| 110 | SkImage_Base* ib = as_IB(img); |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 111 | |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 112 | GrTextureProxy* proxy = ib->peekProxy(); |
| 113 | REPORTER_ASSERT(reporter, proxy); |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 114 | |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 115 | REPORTER_ASSERT(reporter, mipMapped == proxy->proxyMipMapped()); |
| 116 | REPORTER_ASSERT(reporter, proxy->isInstantiated()); |
| 117 | REPORTER_ASSERT(reporter, mipMapped == proxy->mipMapped()); |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 118 | |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 119 | REPORTER_ASSERT(reporter, initialCount+1 == cache->getResourceCount()); |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 120 | } |
| 121 | } |
| 122 | |
| 123 | REPORTER_ASSERT(reporter, initialCount == cache->getResourceCount()); |
| 124 | |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 125 | delete_backend_texture(context, backendTex, finishedBECreate); |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 126 | } |
| 127 | |
Robert Phillips | 9a30ee0 | 2020-04-29 08:58:39 -0400 | [diff] [blame] | 128 | static bool isBGRA8(const GrBackendFormat& format) { |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 129 | switch (format.backend()) { |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 130 | case GrBackendApi::kOpenGL: |
| 131 | #ifdef SK_GL |
| 132 | return format.asGLFormat() == GrGLFormat::kBGRA8; |
| 133 | #else |
| 134 | return false; |
| 135 | #endif |
| 136 | case GrBackendApi::kVulkan: { |
| 137 | #ifdef SK_VULKAN |
| 138 | VkFormat vkFormat; |
| 139 | format.asVkFormat(&vkFormat); |
| 140 | return vkFormat == VK_FORMAT_B8G8R8A8_UNORM; |
| 141 | #else |
| 142 | return false; |
| 143 | #endif |
| 144 | } |
Jim Van Verth | b01e12b | 2020-02-18 14:34:38 -0500 | [diff] [blame] | 145 | case GrBackendApi::kMetal: |
| 146 | #ifdef SK_METAL |
Robert Phillips | 9a30ee0 | 2020-04-29 08:58:39 -0400 | [diff] [blame] | 147 | return GrMtlFormatIsBGRA8(format.asMtlFormat()); |
Jim Van Verth | b01e12b | 2020-02-18 14:34:38 -0500 | [diff] [blame] | 148 | #else |
| 149 | return false; |
| 150 | #endif |
| 151 | case GrBackendApi::kDirect3D: |
| 152 | #ifdef SK_DIRECT3D |
| 153 | return false; // TODO |
| 154 | #else |
| 155 | return false; |
| 156 | #endif |
| 157 | case GrBackendApi::kDawn: |
Stephen White | 3624874 | 2020-06-10 22:24:57 -0400 | [diff] [blame] | 158 | #ifdef SK_DAWN |
| 159 | wgpu::TextureFormat dawnFormat; |
| 160 | format.asDawnFormat(&dawnFormat); |
| 161 | return dawnFormat == wgpu::TextureFormat::BGRA8Unorm; |
| 162 | #else |
Jim Van Verth | b01e12b | 2020-02-18 14:34:38 -0500 | [diff] [blame] | 163 | return false; |
Stephen White | 3624874 | 2020-06-10 22:24:57 -0400 | [diff] [blame] | 164 | #endif |
Robert Phillips | a27d625 | 2019-12-10 14:48:36 -0500 | [diff] [blame] | 165 | case GrBackendApi::kMock: { |
| 166 | SkImage::CompressionType compression = format.asMockCompressionType(); |
| 167 | if (compression != SkImage::CompressionType::kNone) { |
| 168 | return false; // No compressed formats are BGRA |
| 169 | } |
| 170 | |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 171 | return format.asMockColorType() == GrColorType::kBGRA_8888; |
Robert Phillips | a27d625 | 2019-12-10 14:48:36 -0500 | [diff] [blame] | 172 | } |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 173 | } |
| 174 | SkUNREACHABLE; |
| 175 | } |
| 176 | |
| 177 | static bool isRGB(const GrBackendFormat& format) { |
| 178 | switch (format.backend()) { |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 179 | case GrBackendApi::kOpenGL: |
| 180 | #ifdef SK_GL |
| 181 | return format.asGLFormat() == GrGLFormat::kRGB8; |
| 182 | #else |
| 183 | return false; |
| 184 | #endif |
| 185 | case GrBackendApi::kVulkan: { |
| 186 | #ifdef SK_VULKAN |
| 187 | VkFormat vkFormat; |
| 188 | format.asVkFormat(&vkFormat); |
| 189 | return vkFormat == VK_FORMAT_R8G8B8_UNORM; |
| 190 | #else |
| 191 | return false; |
| 192 | #endif |
| 193 | } |
Jim Van Verth | b01e12b | 2020-02-18 14:34:38 -0500 | [diff] [blame] | 194 | case GrBackendApi::kMetal: |
| 195 | return false; // Metal doesn't even pretend to support this |
| 196 | case GrBackendApi::kDirect3D: |
| 197 | return false; // Not supported in Direct3D 12 |
| 198 | case GrBackendApi::kDawn: |
| 199 | return false; |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 200 | case GrBackendApi::kMock: |
| 201 | return false; // No GrColorType::kRGB_888 |
| 202 | } |
| 203 | SkUNREACHABLE; |
| 204 | } |
| 205 | |
Robert Phillips | e3b6fe4 | 2019-09-11 11:26:46 -0400 | [diff] [blame] | 206 | static void check_solid_pixmap(skiatest::Reporter* reporter, |
| 207 | const SkColor4f& expected, const SkPixmap& actual, |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 208 | SkColorType ct, const char* label1, const char* label2) { |
Robert Phillips | e3b6fe4 | 2019-09-11 11:26:46 -0400 | [diff] [blame] | 209 | // we need 0.001f across the board just for noise |
| 210 | // we need 0.01f across the board for 1010102 |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 211 | const float tols[4] = { 0.01f, 0.01f, 0.01f, 0.01f }; |
Robert Phillips | 27eb525 | 2019-06-03 12:59:40 -0400 | [diff] [blame] | 212 | |
Robert Phillips | e3b6fe4 | 2019-09-11 11:26:46 -0400 | [diff] [blame] | 213 | auto error = std::function<ComparePixmapsErrorReporter>( |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 214 | [reporter, ct, label1, label2](int x, int y, const float diffs[4]) { |
Robert Phillips | e3b6fe4 | 2019-09-11 11:26:46 -0400 | [diff] [blame] | 215 | SkASSERT(x >= 0 && y >= 0); |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 216 | ERRORF(reporter, "%s %s %s - mismatch at %d, %d (%f, %f, %f %f)", |
| 217 | ToolUtils::colortype_name(ct), label1, label2, x, y, |
Robert Phillips | e3b6fe4 | 2019-09-11 11:26:46 -0400 | [diff] [blame] | 218 | diffs[0], diffs[1], diffs[2], diffs[3]); |
| 219 | }); |
| 220 | |
Brian Salomon | 28a8f28 | 2019-10-24 20:07:39 -0400 | [diff] [blame] | 221 | CheckSolidPixels(expected, actual, tols, error); |
Robert Phillips | 27eb525 | 2019-06-03 12:59:40 -0400 | [diff] [blame] | 222 | } |
| 223 | |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 224 | // What would raster do? |
Robert Phillips | e3b6fe4 | 2019-09-11 11:26:46 -0400 | [diff] [blame] | 225 | static SkColor4f get_expected_color(SkColor4f orig, SkColorType ct) { |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 226 | SkAlphaType at = SkColorTypeIsAlwaysOpaque(ct) ? kOpaque_SkAlphaType |
| 227 | : kPremul_SkAlphaType; |
Robert Phillips | e3b6fe4 | 2019-09-11 11:26:46 -0400 | [diff] [blame] | 228 | |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 229 | SkImageInfo ii = SkImageInfo::Make(2, 2, ct, at); |
| 230 | SkAutoPixmapStorage pm; |
| 231 | pm.alloc(ii); |
| 232 | pm.erase(orig); |
| 233 | SkColor tmp = pm.getColor(0, 0); |
| 234 | return SkColor4f::FromColor(tmp); |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 235 | } |
| 236 | |
Robert Phillips | c1dbb4b | 2019-09-24 16:32:35 -0400 | [diff] [blame] | 237 | static void check_mipmaps(GrContext* context, const GrBackendTexture& backendTex, |
| 238 | SkColorType skColorType, const SkColor4f expectedColors[6], |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 239 | skiatest::Reporter* reporter, const char* label); |
Robert Phillips | c1dbb4b | 2019-09-24 16:32:35 -0400 | [diff] [blame] | 240 | |
Robert Phillips | 0ee1034 | 2019-09-25 09:55:16 -0400 | [diff] [blame] | 241 | static void check_base_readbacks(GrContext* context, const GrBackendTexture& backendTex, |
| 242 | SkColorType skColorType, GrRenderable renderable, |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 243 | const SkColor4f& color, skiatest::Reporter* reporter, |
| 244 | const char* label) { |
| 245 | if (isRGB(backendTex.getBackendFormat())) { |
| 246 | // readPixels is busted for the RGB backend format (skbug.com/8862) |
| 247 | // TODO: add a GrColorType::kRGB_888 to fix the situation |
| 248 | return; |
| 249 | } |
Robert Phillips | 0ee1034 | 2019-09-25 09:55:16 -0400 | [diff] [blame] | 250 | |
| 251 | SkAlphaType at = SkColorTypeIsAlwaysOpaque(skColorType) ? kOpaque_SkAlphaType |
| 252 | : kPremul_SkAlphaType; |
| 253 | |
| 254 | SkColor4f expectedColor = get_expected_color(color, skColorType); |
| 255 | |
| 256 | SkAutoPixmapStorage actual; |
| 257 | |
| 258 | { |
| 259 | SkImageInfo readBackII = SkImageInfo::Make(32, 32, kRGBA_8888_SkColorType, |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 260 | kUnpremul_SkAlphaType); |
Robert Phillips | 0ee1034 | 2019-09-25 09:55:16 -0400 | [diff] [blame] | 261 | |
| 262 | SkAssertResult(actual.tryAlloc(readBackII)); |
| 263 | } |
| 264 | |
Robert Phillips | 0ee1034 | 2019-09-25 09:55:16 -0400 | [diff] [blame] | 265 | { |
| 266 | sk_sp<SkImage> img = SkImage::MakeFromTexture(context, |
| 267 | backendTex, |
| 268 | kTopLeft_GrSurfaceOrigin, |
| 269 | skColorType, |
| 270 | at, |
| 271 | nullptr); |
| 272 | if (img) { |
| 273 | actual.erase(SkColors::kTransparent); |
| 274 | bool result = img->readPixels(actual, 0, 0); |
| 275 | if (!result) { |
| 276 | // TODO: we need a better way to tell a priori if readPixels will work for an |
| 277 | // arbitrary colorType |
| 278 | #if 0 |
| 279 | ERRORF(reporter, "Couldn't readback from SkImage for colorType: %d\n", colorType); |
| 280 | #endif |
| 281 | } else { |
| 282 | check_solid_pixmap(reporter, expectedColor, actual, skColorType, |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 283 | label, "SkImage::readPixels"); |
Robert Phillips | 0ee1034 | 2019-09-25 09:55:16 -0400 | [diff] [blame] | 284 | } |
| 285 | } |
| 286 | } |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 287 | |
| 288 | // This will mark any mipmaps as dirty (bc that is what we do when we wrap a renderable |
| 289 | // backend texture) so it must be done last! |
| 290 | if (GrRenderable::kYes == renderable && context->colorTypeSupportedAsSurface(skColorType)) { |
| 291 | sk_sp<SkSurface> surf = SkSurface::MakeFromBackendTexture(context, |
| 292 | backendTex, |
| 293 | kTopLeft_GrSurfaceOrigin, |
| 294 | 0, |
| 295 | skColorType, |
| 296 | nullptr, nullptr); |
| 297 | if (surf) { |
| 298 | actual.erase(SkColors::kTransparent); |
| 299 | bool result = surf->readPixels(actual, 0, 0); |
| 300 | REPORTER_ASSERT(reporter, result); |
| 301 | |
| 302 | check_solid_pixmap(reporter, expectedColor, actual, skColorType, |
| 303 | label, "SkSurface::readPixels"); |
| 304 | } |
| 305 | } |
Robert Phillips | 0ee1034 | 2019-09-25 09:55:16 -0400 | [diff] [blame] | 306 | } |
| 307 | |
Robert Phillips | c1dbb4b | 2019-09-24 16:32:35 -0400 | [diff] [blame] | 308 | // Test initialization of GrBackendObjects to a specific color (non-static since used in Mtl test) |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 309 | void test_color_init(GrContext* context, skiatest::Reporter* reporter, |
| 310 | std::function<GrBackendTexture (GrContext*, |
| 311 | const SkColor4f&, |
| 312 | GrMipMapped, |
| 313 | GrRenderable)> create, |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 314 | GrColorType grColorType, const SkColor4f& color, |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 315 | GrMipMapped mipMapped, GrRenderable renderable, bool* finishedBECreate) { |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 316 | GrBackendTexture backendTex = create(context, color, mipMapped, renderable); |
| 317 | if (!backendTex.isValid()) { |
| 318 | // errors here should be reported by the test_wrapping test |
| 319 | return; |
| 320 | } |
| 321 | |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 322 | SkColorType skColorType = GrColorTypeToSkColorType(grColorType); |
| 323 | |
| 324 | // Can't wrap backend textures in images and surfaces w/o an SkColorType |
| 325 | if (kUnknown_SkColorType == skColorType) { |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 326 | // TODO: burrow in and scrappily check that data was uploaded! |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 327 | delete_backend_texture(context, backendTex, finishedBECreate); |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 328 | return; |
| 329 | } |
| 330 | |
Greg Daniel | b2365d8 | 2020-05-13 15:32:04 -0400 | [diff] [blame] | 331 | auto checkBackendTexture = [&](const SkColor4f& testColor) { |
| 332 | if (mipMapped == GrMipMapped::kYes) { |
| 333 | SkColor4f expectedColor = get_expected_color(testColor, skColorType); |
| 334 | SkColor4f expectedColors[6] = {expectedColor, expectedColor, expectedColor, |
| 335 | expectedColor, expectedColor, expectedColor}; |
| 336 | check_mipmaps(context, backendTex, skColorType, expectedColors, reporter, "colorinit"); |
| 337 | } |
Robert Phillips | c1dbb4b | 2019-09-24 16:32:35 -0400 | [diff] [blame] | 338 | |
Greg Daniel | b2365d8 | 2020-05-13 15:32:04 -0400 | [diff] [blame] | 339 | // The last step in this test will dirty the mipmaps so do it last |
| 340 | check_base_readbacks(context, backendTex, skColorType, renderable, testColor, reporter, |
| 341 | "colorinit"); |
| 342 | }; |
| 343 | |
| 344 | checkBackendTexture(color); |
| 345 | |
| 346 | // Make sure the initial create work has finished so we can test the update independently. |
| 347 | wait_on_backend_work_to_finish(context, finishedBECreate); |
| 348 | |
| 349 | SkColor4f newColor = {color.fB , color.fR, color.fG, color.fA }; |
| 350 | |
| 351 | // Reupload the new data and make sure everything still works. We test with an SkColorType so |
| 352 | // we may actually swizzle the input during the create path. The update does not do any swizzle |
| 353 | // of the passed in color. So we manually do it here so we get the same expected results. |
| 354 | SkColor4f swizzledColor = context->priv().caps()->getWriteSwizzle( |
| 355 | backendTex.getBackendFormat(), grColorType).applyTo(newColor); |
| 356 | context->updateBackendTexture(backendTex, swizzledColor, mark_signaled, finishedBECreate); |
| 357 | |
| 358 | checkBackendTexture(newColor); |
| 359 | |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 360 | delete_backend_texture(context, backendTex, finishedBECreate); |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 361 | } |
| 362 | |
Robert Phillips | c1dbb4b | 2019-09-24 16:32:35 -0400 | [diff] [blame] | 363 | // Draw the backend texture (wrapped in an SkImage) into an RGBA surface, attempting to access |
| 364 | // all the mipMap levels. |
| 365 | static void check_mipmaps(GrContext* context, const GrBackendTexture& backendTex, |
| 366 | SkColorType skColorType, const SkColor4f expectedColors[6], |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 367 | skiatest::Reporter* reporter, const char* label) { |
Robert Phillips | c1dbb4b | 2019-09-24 16:32:35 -0400 | [diff] [blame] | 368 | |
| 369 | #ifdef SK_GL |
| 370 | // skbug.com/9141 (RGBA_F32 mipmaps appear to be broken on some Mali devices) |
| 371 | if (GrBackendApi::kOpenGL == context->backend()) { |
| 372 | GrGLGpu* glGPU = static_cast<GrGLGpu*>(context->priv().getGpu()); |
| 373 | |
| 374 | if (kRGBA_F32_SkColorType == skColorType && |
| 375 | kGLES_GrGLStandard == glGPU->ctxInfo().standard()) { |
| 376 | return; |
| 377 | } |
| 378 | } |
| 379 | #endif |
| 380 | |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 381 | if (isRGB(backendTex.getBackendFormat())) { |
| 382 | // readPixels is busted for the RGB backend format (skbug.com/8862) |
| 383 | // TODO: add a GrColorType::kRGB_888 to fix the situation |
| 384 | return; |
| 385 | } |
| 386 | |
Robert Phillips | c1dbb4b | 2019-09-24 16:32:35 -0400 | [diff] [blame] | 387 | SkAlphaType at = SkColorTypeIsAlwaysOpaque(skColorType) ? kOpaque_SkAlphaType |
| 388 | : kPremul_SkAlphaType; |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 389 | |
Robert Phillips | c1dbb4b | 2019-09-24 16:32:35 -0400 | [diff] [blame] | 390 | sk_sp<SkImage> img = SkImage::MakeFromTexture(context, |
| 391 | backendTex, |
| 392 | kTopLeft_GrSurfaceOrigin, |
| 393 | skColorType, |
| 394 | at, |
| 395 | nullptr); |
| 396 | if (!img) { |
| 397 | return; |
| 398 | } |
| 399 | |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 400 | SkImageInfo readbackSurfaceII = SkImageInfo::Make(32, 32, kRGBA_8888_SkColorType, |
| 401 | kPremul_SkAlphaType); |
Robert Phillips | c1dbb4b | 2019-09-24 16:32:35 -0400 | [diff] [blame] | 402 | |
| 403 | sk_sp<SkSurface> surf = SkSurface::MakeRenderTarget(context, |
| 404 | SkBudgeted::kNo, |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 405 | readbackSurfaceII, 1, |
Robert Phillips | c1dbb4b | 2019-09-24 16:32:35 -0400 | [diff] [blame] | 406 | kTopLeft_GrSurfaceOrigin, |
| 407 | nullptr); |
| 408 | if (!surf) { |
| 409 | return; |
| 410 | } |
| 411 | |
| 412 | SkCanvas* canvas = surf->getCanvas(); |
| 413 | |
| 414 | SkPaint p; |
| 415 | p.setFilterQuality(kHigh_SkFilterQuality); |
| 416 | |
| 417 | int numMipLevels = 6; |
| 418 | |
| 419 | for (int i = 0, rectSize = 32; i < numMipLevels; ++i, rectSize /= 2) { |
| 420 | SkASSERT(rectSize >= 1); |
| 421 | |
| 422 | SkRect r = SkRect::MakeWH(rectSize, rectSize); |
| 423 | canvas->clear(SK_ColorTRANSPARENT); |
| 424 | canvas->drawImageRect(img, r, &p); |
| 425 | |
| 426 | SkImageInfo readbackII = SkImageInfo::Make(rectSize, rectSize, |
| 427 | kRGBA_8888_SkColorType, |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 428 | kUnpremul_SkAlphaType); |
Robert Phillips | c1dbb4b | 2019-09-24 16:32:35 -0400 | [diff] [blame] | 429 | SkAutoPixmapStorage actual2; |
| 430 | SkAssertResult(actual2.tryAlloc(readbackII)); |
| 431 | actual2.erase(SkColors::kTransparent); |
| 432 | |
| 433 | bool result = surf->readPixels(actual2, 0, 0); |
| 434 | REPORTER_ASSERT(reporter, result); |
| 435 | |
Robert Phillips | ee94693 | 2019-12-18 11:16:17 -0500 | [diff] [blame] | 436 | SkString str; |
| 437 | str.appendf("mip-level %d", i); |
| 438 | |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 439 | check_solid_pixmap(reporter, expectedColors[i], actual2, skColorType, |
Robert Phillips | ee94693 | 2019-12-18 11:16:17 -0500 | [diff] [blame] | 440 | label, str.c_str()); |
Robert Phillips | c1dbb4b | 2019-09-24 16:32:35 -0400 | [diff] [blame] | 441 | } |
| 442 | } |
| 443 | |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 444 | static int make_pixmaps(SkColorType skColorType, GrMipMapped mipMapped, |
| 445 | const SkColor4f colors[6], SkAutoPixmapStorage pixmaps[6]) { |
| 446 | int levelSize = 32; |
| 447 | int numMipLevels = mipMapped == GrMipMapped::kYes ? 6 : 1; |
| 448 | SkAlphaType at = SkColorTypeIsAlwaysOpaque(skColorType) ? kOpaque_SkAlphaType |
| 449 | : kPremul_SkAlphaType; |
| 450 | for (int level = 0; level < numMipLevels; ++level) { |
| 451 | SkImageInfo ii = SkImageInfo::Make(levelSize, levelSize, skColorType, at); |
| 452 | pixmaps[level].alloc(ii); |
| 453 | pixmaps[level].erase(colors[level]); |
| 454 | levelSize /= 2; |
| 455 | } |
| 456 | return numMipLevels; |
| 457 | } |
| 458 | |
| 459 | // Test initialization of GrBackendObjects using SkPixmaps |
| 460 | static void test_pixmap_init(GrContext* context, skiatest::Reporter* reporter, |
| 461 | std::function<GrBackendTexture (GrContext*, |
| 462 | const SkPixmap srcData[], |
| 463 | int numLevels, |
| 464 | GrRenderable)> create, |
| 465 | SkColorType skColorType, GrMipMapped mipMapped, |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 466 | GrRenderable renderable, bool* finishedBECreate) { |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 467 | SkAutoPixmapStorage pixmapMem[6]; |
| 468 | SkColor4f colors[6] = { |
| 469 | { 1.0f, 0.0f, 0.0f, 1.0f }, // R |
| 470 | { 0.0f, 1.0f, 0.0f, 0.9f }, // G |
| 471 | { 0.0f, 0.0f, 1.0f, 0.7f }, // B |
| 472 | { 0.0f, 1.0f, 1.0f, 0.5f }, // C |
| 473 | { 1.0f, 0.0f, 1.0f, 0.3f }, // M |
| 474 | { 1.0f, 1.0f, 0.0f, 0.2f }, // Y |
| 475 | }; |
| 476 | |
| 477 | int numMipLevels = make_pixmaps(skColorType, mipMapped, colors, pixmapMem); |
| 478 | SkASSERT(numMipLevels); |
| 479 | |
| 480 | // TODO: this is tedious. Should we pass in an array of SkBitmaps instead? |
| 481 | SkPixmap pixmaps[6]; |
| 482 | for (int i = 0; i < numMipLevels; ++i) { |
| 483 | pixmaps[i].reset(pixmapMem[i].info(), pixmapMem[i].addr(), pixmapMem[i].rowBytes()); |
| 484 | } |
| 485 | |
| 486 | GrBackendTexture backendTex = create(context, pixmaps, numMipLevels, renderable); |
| 487 | if (!backendTex.isValid()) { |
| 488 | // errors here should be reported by the test_wrapping test |
| 489 | return; |
| 490 | } |
| 491 | |
Robert Phillips | 9a30ee0 | 2020-04-29 08:58:39 -0400 | [diff] [blame] | 492 | if (skColorType == kBGRA_8888_SkColorType && !isBGRA8(backendTex.getBackendFormat())) { |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 493 | // When kBGRA is backed by an RGBA something goes wrong in the swizzling |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 494 | delete_backend_texture(context, backendTex, finishedBECreate); |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 495 | return; |
| 496 | } |
| 497 | |
Greg Daniel | b2365d8 | 2020-05-13 15:32:04 -0400 | [diff] [blame] | 498 | auto checkBackendTexture = [&](SkColor4f colors[6]) { |
| 499 | if (mipMapped == GrMipMapped::kYes) { |
| 500 | SkColor4f expectedColors[6] = { |
| 501 | get_expected_color(colors[0], skColorType), |
| 502 | get_expected_color(colors[1], skColorType), |
| 503 | get_expected_color(colors[2], skColorType), |
| 504 | get_expected_color(colors[3], skColorType), |
| 505 | get_expected_color(colors[4], skColorType), |
| 506 | get_expected_color(colors[5], skColorType), |
| 507 | }; |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 508 | |
Greg Daniel | b2365d8 | 2020-05-13 15:32:04 -0400 | [diff] [blame] | 509 | check_mipmaps(context, backendTex, skColorType, expectedColors, reporter, "pixmap"); |
| 510 | } |
| 511 | |
| 512 | // The last step in this test will dirty the mipmaps so do it last |
| 513 | check_base_readbacks(context, backendTex, skColorType, renderable, colors[0], reporter, |
| 514 | "pixmap"); |
| 515 | }; |
| 516 | |
| 517 | checkBackendTexture(colors); |
| 518 | |
| 519 | // Make sure the initial create work has finished so we can test the update independently. |
| 520 | wait_on_backend_work_to_finish(context, finishedBECreate); |
| 521 | |
| 522 | SkColor4f colorsNew[6] = { |
| 523 | {1.0f, 1.0f, 0.0f, 0.2f}, // Y |
| 524 | {1.0f, 0.0f, 0.0f, 1.0f}, // R |
| 525 | {0.0f, 1.0f, 0.0f, 0.9f}, // G |
| 526 | {0.0f, 0.0f, 1.0f, 0.7f}, // B |
| 527 | {0.0f, 1.0f, 1.0f, 0.5f}, // C |
| 528 | {1.0f, 0.0f, 1.0f, 0.3f}, // M |
| 529 | }; |
| 530 | make_pixmaps(skColorType, mipMapped, colorsNew, pixmapMem); |
| 531 | for (int i = 0; i < numMipLevels; ++i) { |
| 532 | pixmaps[i].reset(pixmapMem[i].info(), pixmapMem[i].addr(), pixmapMem[i].rowBytes()); |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 533 | } |
| 534 | |
Greg Daniel | b2365d8 | 2020-05-13 15:32:04 -0400 | [diff] [blame] | 535 | // Upload new data and make sure everything still works |
| 536 | context->updateBackendTexture(backendTex, pixmaps, numMipLevels, mark_signaled, |
| 537 | finishedBECreate); |
| 538 | |
| 539 | checkBackendTexture(colorsNew); |
| 540 | |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 541 | delete_backend_texture(context, backendTex, finishedBECreate); |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 542 | } |
| 543 | |
Robert Phillips | 02dc030 | 2019-07-02 17:58:27 -0400 | [diff] [blame] | 544 | enum class VkLayout { |
| 545 | kUndefined, |
| 546 | kReadOnlyOptimal, |
Robert Phillips | 02dc030 | 2019-07-02 17:58:27 -0400 | [diff] [blame] | 547 | }; |
| 548 | |
| 549 | void check_vk_layout(const GrBackendTexture& backendTex, VkLayout layout) { |
| 550 | #if defined(SK_VULKAN) && defined(SK_DEBUG) |
| 551 | VkImageLayout expected; |
| 552 | |
| 553 | switch (layout) { |
| 554 | case VkLayout::kUndefined: |
| 555 | expected = VK_IMAGE_LAYOUT_UNDEFINED; |
| 556 | break; |
| 557 | case VkLayout::kReadOnlyOptimal: |
| 558 | expected = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 559 | break; |
Robert Phillips | 02dc030 | 2019-07-02 17:58:27 -0400 | [diff] [blame] | 560 | default: |
| 561 | SkUNREACHABLE; |
| 562 | } |
| 563 | |
| 564 | GrVkImageInfo vkII; |
| 565 | |
| 566 | if (backendTex.getVkImageInfo(&vkII)) { |
| 567 | SkASSERT(expected == vkII.fImageLayout); |
| 568 | SkASSERT(VK_IMAGE_TILING_OPTIMAL == vkII.fImageTiling); |
| 569 | } |
| 570 | #endif |
| 571 | } |
| 572 | |
| 573 | /////////////////////////////////////////////////////////////////////////////// |
| 574 | // This test is a bit different from the others in this file. It is mainly checking that, for any |
| 575 | // SkSurface we can create in Ganesh, we can also create a backend texture that is compatible with |
| 576 | // its characterization and then create a new surface that wraps that backend texture. |
| 577 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CharacterizationBackendAllocationTest, reporter, ctxInfo) { |
| 578 | GrContext* context = ctxInfo.grContext(); |
| 579 | |
| 580 | for (int ct = 0; ct <= kLastEnum_SkColorType; ++ct) { |
| 581 | SkColorType colorType = static_cast<SkColorType>(ct); |
| 582 | |
| 583 | SkImageInfo ii = SkImageInfo::Make(32, 32, colorType, kPremul_SkAlphaType); |
| 584 | |
| 585 | for (auto origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin } ) { |
| 586 | for (bool mipMaps : { true, false } ) { |
| 587 | for (int sampleCount : {1, 2}) { |
| 588 | SkSurfaceCharacterization c; |
| 589 | |
| 590 | // Get a characterization, if possible |
| 591 | { |
| 592 | sk_sp<SkSurface> s = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, |
| 593 | ii, sampleCount, |
| 594 | origin, nullptr, mipMaps); |
| 595 | if (!s) { |
| 596 | continue; |
| 597 | } |
| 598 | |
| 599 | if (!s->characterize(&c)) { |
| 600 | continue; |
| 601 | } |
| 602 | |
| 603 | REPORTER_ASSERT(reporter, s->isCompatible(c)); |
| 604 | } |
| 605 | |
| 606 | // Test out uninitialized path |
| 607 | { |
| 608 | GrBackendTexture backendTex = context->createBackendTexture(c); |
| 609 | check_vk_layout(backendTex, VkLayout::kUndefined); |
| 610 | REPORTER_ASSERT(reporter, backendTex.isValid()); |
| 611 | REPORTER_ASSERT(reporter, c.isCompatible(backendTex)); |
| 612 | |
Robert Phillips | d5e80ca | 2019-07-29 14:11:35 -0400 | [diff] [blame] | 613 | { |
| 614 | GrBackendFormat format = context->defaultBackendFormat( |
| 615 | c.imageInfo().colorType(), |
| 616 | GrRenderable::kYes); |
| 617 | REPORTER_ASSERT(reporter, format == backendTex.getBackendFormat()); |
| 618 | } |
| 619 | |
Robert Phillips | 02dc030 | 2019-07-02 17:58:27 -0400 | [diff] [blame] | 620 | sk_sp<SkSurface> s2 = SkSurface::MakeFromBackendTexture(context, c, |
| 621 | backendTex); |
| 622 | REPORTER_ASSERT(reporter, s2); |
| 623 | REPORTER_ASSERT(reporter, s2->isCompatible(c)); |
| 624 | |
| 625 | s2 = nullptr; |
| 626 | context->deleteBackendTexture(backendTex); |
| 627 | } |
| 628 | |
| 629 | // Test out color-initialized path |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 630 | |
Robert Phillips | 02dc030 | 2019-07-02 17:58:27 -0400 | [diff] [blame] | 631 | { |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 632 | |
| 633 | bool finished = false; |
Robert Phillips | 02dc030 | 2019-07-02 17:58:27 -0400 | [diff] [blame] | 634 | GrBackendTexture backendTex = context->createBackendTexture(c, |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 635 | SkColors::kRed, |
| 636 | mark_signaled, |
| 637 | &finished); |
Greg Daniel | dddf709 | 2020-05-06 11:52:37 -0400 | [diff] [blame] | 638 | check_vk_layout(backendTex, VkLayout::kReadOnlyOptimal); |
Robert Phillips | 02dc030 | 2019-07-02 17:58:27 -0400 | [diff] [blame] | 639 | REPORTER_ASSERT(reporter, backendTex.isValid()); |
| 640 | REPORTER_ASSERT(reporter, c.isCompatible(backendTex)); |
| 641 | |
Robert Phillips | d5e80ca | 2019-07-29 14:11:35 -0400 | [diff] [blame] | 642 | { |
| 643 | GrBackendFormat format = context->defaultBackendFormat( |
| 644 | c.imageInfo().colorType(), |
| 645 | GrRenderable::kYes); |
| 646 | REPORTER_ASSERT(reporter, format == backendTex.getBackendFormat()); |
| 647 | } |
| 648 | |
Robert Phillips | 02dc030 | 2019-07-02 17:58:27 -0400 | [diff] [blame] | 649 | sk_sp<SkSurface> s2 = SkSurface::MakeFromBackendTexture(context, c, |
| 650 | backendTex); |
| 651 | REPORTER_ASSERT(reporter, s2); |
| 652 | REPORTER_ASSERT(reporter, s2->isCompatible(c)); |
| 653 | |
| 654 | s2 = nullptr; |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 655 | delete_backend_texture(context, backendTex, &finished); |
Robert Phillips | 02dc030 | 2019-07-02 17:58:27 -0400 | [diff] [blame] | 656 | } |
| 657 | } |
| 658 | } |
| 659 | } |
| 660 | } |
| 661 | } |
| 662 | |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 663 | /////////////////////////////////////////////////////////////////////////////// |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 664 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ColorTypeBackendAllocationTest, reporter, ctxInfo) { |
| 665 | GrContext* context = ctxInfo.grContext(); |
| 666 | const GrCaps* caps = context->priv().caps(); |
| 667 | |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 668 | constexpr SkColor4f kTransCol { 0, 0.25f, 0.75f, 0.5f }; |
Robert Phillips | bd1ef68 | 2019-05-31 12:48:49 -0400 | [diff] [blame] | 669 | constexpr SkColor4f kGrayCol { 0.75f, 0.75f, 0.75f, 0.75f }; |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 670 | |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 671 | struct { |
| 672 | SkColorType fColorType; |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 673 | SkColor4f fColor; |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 674 | } combinations[] = { |
Robert Phillips | ea1b30b | 2019-09-19 16:05:48 -0400 | [diff] [blame] | 675 | { kAlpha_8_SkColorType, kTransCol }, |
| 676 | { kRGB_565_SkColorType, SkColors::kRed }, |
| 677 | { kARGB_4444_SkColorType, SkColors::kGreen }, |
| 678 | { kRGBA_8888_SkColorType, SkColors::kBlue }, |
| 679 | { kRGB_888x_SkColorType, SkColors::kCyan }, |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 680 | // TODO: readback is busted when alpha = 0.5f (perhaps premul vs. unpremul) |
Robert Phillips | ea1b30b | 2019-09-19 16:05:48 -0400 | [diff] [blame] | 681 | { kBGRA_8888_SkColorType, { 1, 0, 0, 1.0f } }, |
Robert Phillips | 9a30ee0 | 2020-04-29 08:58:39 -0400 | [diff] [blame] | 682 | // TODO: readback is busted for *10A2 when alpha = 0.5f (perhaps premul vs. unpremul) |
| 683 | { kRGBA_1010102_SkColorType, { 0.25f, 0.5f, 0.75f, 1.0f }}, |
| 684 | { kBGRA_1010102_SkColorType, { 0.25f, 0.5f, 0.75f, 1.0f }}, |
| 685 | // RGB/BGR 101010x have no Ganesh correlate |
Robert Phillips | ea1b30b | 2019-09-19 16:05:48 -0400 | [diff] [blame] | 686 | { kRGB_101010x_SkColorType, { 0, 0.5f, 0, 0.5f } }, |
Mike Klein | f7eb054 | 2020-02-11 12:19:08 -0600 | [diff] [blame] | 687 | { kBGR_101010x_SkColorType, { 0, 0.5f, 0, 0.5f } }, |
Robert Phillips | ea1b30b | 2019-09-19 16:05:48 -0400 | [diff] [blame] | 688 | { kGray_8_SkColorType, kGrayCol }, |
| 689 | { kRGBA_F16Norm_SkColorType, SkColors::kLtGray }, |
| 690 | { kRGBA_F16_SkColorType, SkColors::kYellow }, |
| 691 | { kRGBA_F32_SkColorType, SkColors::kGray }, |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 692 | { kR8G8_unorm_SkColorType, { .25f, .75f, 0, 1 } }, |
Robert Phillips | ea1b30b | 2019-09-19 16:05:48 -0400 | [diff] [blame] | 693 | { kR16G16_unorm_SkColorType, SkColors::kGreen }, |
| 694 | { kA16_unorm_SkColorType, kTransCol }, |
| 695 | { kA16_float_SkColorType, kTransCol }, |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 696 | { kR16G16_float_SkColorType, { .25f, .75f, 0, 1 } }, |
Robert Phillips | ea1b30b | 2019-09-19 16:05:48 -0400 | [diff] [blame] | 697 | { kR16G16B16A16_unorm_SkColorType,{ .25f, .5f, .75f, 1 } }, |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 698 | }; |
| 699 | |
Brian Salomon | 4dea72a | 2019-12-18 10:43:10 -0500 | [diff] [blame] | 700 | static_assert(kLastEnum_SkColorType == SK_ARRAY_COUNT(combinations)); |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 701 | |
| 702 | for (auto combo : combinations) { |
| 703 | SkColorType colorType = combo.fColorType; |
| 704 | |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 705 | if (GrBackendApi::kMetal == context->backend()) { |
| 706 | // skbug.com/9086 (Metal caps may not be handling RGBA32 correctly) |
| 707 | if (kRGBA_F32_SkColorType == combo.fColorType) { |
| 708 | continue; |
| 709 | } |
| 710 | } |
| 711 | |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 712 | for (auto mipMapped : { GrMipMapped::kNo, GrMipMapped::kYes }) { |
| 713 | if (GrMipMapped::kYes == mipMapped && !caps->mipMapSupport()) { |
| 714 | continue; |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 715 | } |
| 716 | |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 717 | for (auto renderable : { GrRenderable::kNo, GrRenderable::kYes }) { |
Greg Daniel | 7bfc913 | 2019-08-14 14:23:53 -0400 | [diff] [blame] | 718 | if (!caps->getDefaultBackendFormat(SkColorTypeToGrColorType(colorType), |
| 719 | renderable).isValid()) { |
| 720 | continue; |
| 721 | } |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 722 | |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 723 | if (GrRenderable::kYes == renderable) { |
| 724 | if (kRGB_888x_SkColorType == combo.fColorType) { |
| 725 | // Ganesh can't perform the blends correctly when rendering this format |
| 726 | continue; |
| 727 | } |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 728 | } |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 729 | |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 730 | { |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 731 | auto uninitCreateMtd = [colorType](GrContext* context, GrMipMapped mipMapped, |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 732 | GrRenderable renderable) { |
Robert Phillips | 02dc030 | 2019-07-02 17:58:27 -0400 | [diff] [blame] | 733 | auto result = context->createBackendTexture(32, 32, colorType, |
| 734 | mipMapped, renderable, |
| 735 | GrProtected::kNo); |
| 736 | check_vk_layout(result, VkLayout::kUndefined); |
Robert Phillips | d5e80ca | 2019-07-29 14:11:35 -0400 | [diff] [blame] | 737 | |
| 738 | #ifdef SK_DEBUG |
| 739 | { |
| 740 | GrBackendFormat format = context->defaultBackendFormat(colorType, |
| 741 | renderable); |
| 742 | SkASSERT(format == result.getBackendFormat()); |
| 743 | } |
| 744 | #endif |
| 745 | |
Robert Phillips | 02dc030 | 2019-07-02 17:58:27 -0400 | [diff] [blame] | 746 | return result; |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 747 | }; |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 748 | |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 749 | test_wrapping(context, reporter, uninitCreateMtd, |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 750 | SkColorTypeToGrColorType(colorType), mipMapped, renderable, |
| 751 | nullptr); |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 752 | } |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 753 | |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 754 | bool finishedBackendCreation = false; |
| 755 | bool* finishedPtr = &finishedBackendCreation; |
| 756 | |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 757 | { |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 758 | |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 759 | auto createWithColorMtd = [colorType, finishedPtr](GrContext* context, |
| 760 | const SkColor4f& color, |
| 761 | GrMipMapped mipMapped, |
| 762 | GrRenderable renderable) { |
Robert Phillips | 02dc030 | 2019-07-02 17:58:27 -0400 | [diff] [blame] | 763 | auto result = context->createBackendTexture(32, 32, colorType, color, |
| 764 | mipMapped, renderable, |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 765 | GrProtected::kNo, |
| 766 | mark_signaled, |
| 767 | finishedPtr); |
Greg Daniel | dddf709 | 2020-05-06 11:52:37 -0400 | [diff] [blame] | 768 | check_vk_layout(result, VkLayout::kReadOnlyOptimal); |
Robert Phillips | d5e80ca | 2019-07-29 14:11:35 -0400 | [diff] [blame] | 769 | |
| 770 | #ifdef SK_DEBUG |
| 771 | { |
| 772 | GrBackendFormat format = context->defaultBackendFormat(colorType, |
| 773 | renderable); |
| 774 | SkASSERT(format == result.getBackendFormat()); |
| 775 | } |
| 776 | #endif |
| 777 | |
Robert Phillips | 02dc030 | 2019-07-02 17:58:27 -0400 | [diff] [blame] | 778 | return result; |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 779 | }; |
Brian Salomon | 85c3d68 | 2019-11-04 15:04:54 -0500 | [diff] [blame] | 780 | // We make our comparison color using SkPixmap::erase(color) on a pixmap of |
| 781 | // combo.fColorType and then calling SkPixmap::readPixels(). erase() will premul |
| 782 | // the color passed to it. However, createBackendTexture() that takes a |
| 783 | // SkColor4f is color type / alpha type unaware and will simply compute |
| 784 | // luminance from the r, g, b, channels. |
| 785 | SkColor4f color = combo.fColor; |
| 786 | if (colorType == kGray_8_SkColorType) { |
| 787 | color = {color.fR * color.fA, |
| 788 | color.fG * color.fA, |
| 789 | color.fB * color.fA, |
| 790 | 1.f}; |
| 791 | } |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 792 | test_color_init(context, reporter, createWithColorMtd, |
Brian Salomon | 85c3d68 | 2019-11-04 15:04:54 -0500 | [diff] [blame] | 793 | SkColorTypeToGrColorType(colorType), color, mipMapped, |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 794 | renderable, finishedPtr); |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 795 | } |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 796 | |
Robert Phillips | 9a30ee0 | 2020-04-29 08:58:39 -0400 | [diff] [blame] | 797 | { |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 798 | auto createWithSrcDataMtd = [finishedPtr](GrContext* context, |
| 799 | const SkPixmap srcData[], |
| 800 | int numLevels, |
| 801 | GrRenderable renderable) { |
Robert Phillips | 9a30ee0 | 2020-04-29 08:58:39 -0400 | [diff] [blame] | 802 | SkASSERT(srcData && numLevels); |
| 803 | auto result = context->createBackendTexture(srcData, numLevels, renderable, |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 804 | GrProtected::kNo, mark_signaled, |
| 805 | finishedPtr); |
Robert Phillips | 9a30ee0 | 2020-04-29 08:58:39 -0400 | [diff] [blame] | 806 | check_vk_layout(result, VkLayout::kReadOnlyOptimal); |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 807 | #ifdef SK_DEBUG |
Robert Phillips | 9a30ee0 | 2020-04-29 08:58:39 -0400 | [diff] [blame] | 808 | { |
| 809 | auto format = context->defaultBackendFormat(srcData[0].colorType(), |
| 810 | renderable); |
| 811 | SkASSERT(format == result.getBackendFormat()); |
| 812 | } |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 813 | #endif |
Robert Phillips | 9a30ee0 | 2020-04-29 08:58:39 -0400 | [diff] [blame] | 814 | return result; |
| 815 | }; |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 816 | |
Robert Phillips | 9a30ee0 | 2020-04-29 08:58:39 -0400 | [diff] [blame] | 817 | test_pixmap_init(context, reporter, createWithSrcDataMtd, colorType, mipMapped, |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 818 | renderable, finishedPtr); |
Robert Phillips | 9a30ee0 | 2020-04-29 08:58:39 -0400 | [diff] [blame] | 819 | } |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 820 | } |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 821 | } |
| 822 | } |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 823 | } |
| 824 | |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 825 | /////////////////////////////////////////////////////////////////////////////// |
| 826 | #ifdef SK_GL |
| 827 | |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 828 | DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GLBackendAllocationTest, reporter, ctxInfo) { |
| 829 | sk_gpu_test::GLTestContext* glCtx = ctxInfo.glContext(); |
| 830 | GrGLStandard standard = glCtx->gl()->fStandard; |
| 831 | GrContext* context = ctxInfo.grContext(); |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 832 | const GrGLCaps* glCaps = static_cast<const GrGLCaps*>(context->priv().caps()); |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 833 | |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 834 | constexpr SkColor4f kTransCol { 0, 0.25f, 0.75f, 0.5f }; |
Robert Phillips | bd1ef68 | 2019-05-31 12:48:49 -0400 | [diff] [blame] | 835 | constexpr SkColor4f kGrayCol { 0.75f, 0.75f, 0.75f, 0.75f }; |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 836 | |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 837 | struct { |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 838 | GrColorType fColorType; |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 839 | GrGLenum fFormat; |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 840 | SkColor4f fColor; |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 841 | } combinations[] = { |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 842 | { GrColorType::kRGBA_8888, GR_GL_RGBA8, SkColors::kRed }, |
| 843 | { GrColorType::kRGBA_8888_SRGB, GR_GL_SRGB8_ALPHA8, SkColors::kRed }, |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 844 | |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 845 | { GrColorType::kRGB_888x, GR_GL_RGBA8, SkColors::kYellow }, |
| 846 | { GrColorType::kRGB_888x, GR_GL_RGB8, SkColors::kCyan }, |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 847 | |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 848 | { GrColorType::kBGRA_8888, GR_GL_RGBA8, SkColors::kBlue }, |
| 849 | { GrColorType::kBGRA_8888, GR_GL_BGRA8, SkColors::kBlue }, |
| 850 | // TODO: readback is busted when alpha = 0.5f (perhaps premul vs. unpremul) |
Robert Phillips | 9a30ee0 | 2020-04-29 08:58:39 -0400 | [diff] [blame] | 851 | { GrColorType::kRGBA_1010102, GR_GL_RGB10_A2, { 0.25f, 0.5f, 0.75f, 1.f }}, |
| 852 | { GrColorType::kBGRA_1010102, GR_GL_RGB10_A2, { 0.25f, 0.5f, 0.75f, 1.f }}, |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 853 | { GrColorType::kBGR_565, GR_GL_RGB565, SkColors::kRed }, |
| 854 | { GrColorType::kABGR_4444, GR_GL_RGBA4, SkColors::kGreen }, |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 855 | |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 856 | { GrColorType::kAlpha_8, GR_GL_ALPHA8, kTransCol }, |
| 857 | { GrColorType::kAlpha_8, GR_GL_R8, kTransCol }, |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 858 | |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 859 | { GrColorType::kGray_8, GR_GL_LUMINANCE8, kGrayCol }, |
| 860 | { GrColorType::kGray_8, GR_GL_R8, kGrayCol }, |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 861 | |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 862 | { GrColorType::kRGBA_F32, GR_GL_RGBA32F, SkColors::kRed }, |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 863 | |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 864 | { GrColorType::kRGBA_F16_Clamped, GR_GL_RGBA16F, SkColors::kLtGray }, |
| 865 | { GrColorType::kRGBA_F16, GR_GL_RGBA16F, SkColors::kYellow }, |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 866 | |
Robert Phillips | d470e1b | 2019-09-04 15:05:35 -0400 | [diff] [blame] | 867 | { GrColorType::kRG_88, GR_GL_RG8, { 1, 0.5f, 0, 1 } }, |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 868 | { GrColorType::kAlpha_F16, GR_GL_R16F, { 1.0f, 0, 0, 0.5f } }, |
| 869 | { GrColorType::kAlpha_F16, GR_GL_LUMINANCE16F, kGrayCol }, |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 870 | |
Robert Phillips | 429f0d3 | 2019-09-11 17:03:28 -0400 | [diff] [blame] | 871 | { GrColorType::kAlpha_16, GR_GL_R16, kTransCol }, |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 872 | { GrColorType::kRG_1616, GR_GL_RG16, SkColors::kYellow }, |
Robert Phillips | 66a4603 | 2019-06-18 08:00:42 -0400 | [diff] [blame] | 873 | |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 874 | { GrColorType::kRGBA_16161616, GR_GL_RGBA16, SkColors::kLtGray }, |
| 875 | { GrColorType::kRG_F16, GR_GL_RG16F, SkColors::kYellow }, |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 876 | }; |
| 877 | |
| 878 | for (auto combo : combinations) { |
Brian Salomon | 0f39699 | 2020-06-19 19:51:21 -0400 | [diff] [blame] | 879 | for (GrGLenum target : {GR_GL_TEXTURE_2D, GR_GL_TEXTURE_RECTANGLE}) { |
| 880 | GrBackendFormat format = GrBackendFormat::MakeGL(combo.fFormat, target); |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 881 | |
Brian Salomon | 0f39699 | 2020-06-19 19:51:21 -0400 | [diff] [blame] | 882 | if (!glCaps->isFormatTexturable(format)) { |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 883 | continue; |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 884 | } |
| 885 | |
Brian Salomon | 0f39699 | 2020-06-19 19:51:21 -0400 | [diff] [blame] | 886 | if (GrColorType::kBGRA_8888 == combo.fColorType || |
| 887 | GrColorType::kBGRA_1010102 == combo.fColorType) { |
| 888 | // We allow using a GL_RGBA8 or GR_GL_RGB10_A2 texture as BGRA on desktop GL but not |
| 889 | // ES |
| 890 | if (kGL_GrGLStandard != standard && |
| 891 | (GR_GL_RGBA8 == combo.fFormat || GR_GL_RGB10_A2 == combo.fFormat)) { |
| 892 | continue; |
| 893 | } |
| 894 | } |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 895 | |
Brian Salomon | 0f39699 | 2020-06-19 19:51:21 -0400 | [diff] [blame] | 896 | for (auto mipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) { |
| 897 | if (GrMipMapped::kYes == mipMapped && |
| 898 | (!glCaps->mipMapSupport() || target == GR_GL_TEXTURE_RECTANGLE)) { |
| 899 | continue; |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 900 | } |
| 901 | |
Brian Salomon | 0f39699 | 2020-06-19 19:51:21 -0400 | [diff] [blame] | 902 | for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) { |
| 903 | if (GrRenderable::kYes == renderable) { |
| 904 | if (!glCaps->isFormatAsColorTypeRenderable(combo.fColorType, format)) { |
| 905 | continue; |
| 906 | } |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 907 | } |
| 908 | |
Brian Salomon | 0f39699 | 2020-06-19 19:51:21 -0400 | [diff] [blame] | 909 | { |
| 910 | auto uninitCreateMtd = [format](GrContext* context, GrMipMapped mipMapped, |
| 911 | GrRenderable renderable) { |
| 912 | return context->createBackendTexture(32, 32, format, mipMapped, |
| 913 | renderable, GrProtected::kNo); |
| 914 | }; |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 915 | |
Brian Salomon | 0f39699 | 2020-06-19 19:51:21 -0400 | [diff] [blame] | 916 | test_wrapping(context, reporter, uninitCreateMtd, combo.fColorType, |
| 917 | mipMapped, renderable, nullptr); |
Brian Salomon | 85c3d68 | 2019-11-04 15:04:54 -0500 | [diff] [blame] | 918 | } |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 919 | |
Brian Salomon | 0f39699 | 2020-06-19 19:51:21 -0400 | [diff] [blame] | 920 | { |
| 921 | // We're creating backend textures without specifying a color type "view" of |
| 922 | // them at the public API level. Therefore, Ganesh will not apply any |
| 923 | // swizzles before writing the color to the texture. However, our validation |
| 924 | // code does rely on interpreting the texture contents via a SkColorType and |
| 925 | // therefore swizzles may be applied during the read step. Ideally we'd |
| 926 | // update our validation code to use a "raw" read that doesn't impose a |
| 927 | // color type but for now we just munge the data we upload to match the |
| 928 | // expectation. |
| 929 | GrSwizzle swizzle; |
| 930 | switch (combo.fColorType) { |
| 931 | case GrColorType::kAlpha_8: |
| 932 | swizzle = GrSwizzle("aaaa"); |
| 933 | break; |
| 934 | case GrColorType::kAlpha_16: |
| 935 | swizzle = GrSwizzle("aaaa"); |
| 936 | break; |
| 937 | case GrColorType::kAlpha_F16: |
| 938 | swizzle = GrSwizzle("aaaa"); |
| 939 | break; |
| 940 | default: |
| 941 | break; |
| 942 | } |
| 943 | |
| 944 | bool finishedBackendCreation = false; |
| 945 | bool* finishedPtr = &finishedBackendCreation; |
| 946 | |
| 947 | auto createWithColorMtd = [format, swizzle, finishedPtr]( |
| 948 | GrContext* context, |
| 949 | const SkColor4f& color, |
| 950 | GrMipMapped mipMapped, |
| 951 | GrRenderable renderable) { |
| 952 | auto swizzledColor = swizzle.applyTo(color); |
| 953 | return context->createBackendTexture( |
| 954 | 32, 32, format, swizzledColor, mipMapped, renderable, |
| 955 | GrProtected::kNo, mark_signaled, finishedPtr); |
| 956 | }; |
| 957 | // We make our comparison color using SkPixmap::erase(color) on a pixmap of |
| 958 | // combo.fColorType and then calling SkPixmap::readPixels(). erase() will |
| 959 | // premul the color passed to it. However, createBackendTexture() that takes |
| 960 | // a SkColor4f is color type/alpha type unaware and will simply compute |
| 961 | // luminance from the r, g, b, channels. |
| 962 | SkColor4f color = combo.fColor; |
| 963 | if (combo.fColorType == GrColorType::kGray_8) { |
| 964 | color = {color.fR * color.fA, |
| 965 | color.fG * color.fA, |
| 966 | color.fB * color.fA, |
| 967 | 1.f}; |
| 968 | } |
| 969 | |
| 970 | test_color_init(context, reporter, createWithColorMtd, combo.fColorType, |
| 971 | color, mipMapped, renderable, finishedPtr); |
| 972 | } |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 973 | } |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 974 | } |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 975 | } |
| 976 | } |
| 977 | } |
| 978 | |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 979 | #endif |
| 980 | |
| 981 | /////////////////////////////////////////////////////////////////////////////// |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 982 | |
| 983 | #ifdef SK_VULKAN |
| 984 | |
| 985 | #include "src/gpu/vk/GrVkCaps.h" |
| 986 | |
| 987 | DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkBackendAllocationTest, reporter, ctxInfo) { |
| 988 | GrContext* context = ctxInfo.grContext(); |
| 989 | const GrVkCaps* vkCaps = static_cast<const GrVkCaps*>(context->priv().caps()); |
| 990 | |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 991 | constexpr SkColor4f kTransCol { 0, 0.25f, 0.75f, 0.5f }; |
Robert Phillips | 7f36798 | 2019-09-26 14:01:36 -0400 | [diff] [blame] | 992 | constexpr SkColor4f kGrayCol { 0.75f, 0.75f, 0.75f, 1 }; |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 993 | |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 994 | struct { |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 995 | GrColorType fColorType; |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 996 | VkFormat fFormat; |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 997 | SkColor4f fColor; |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 998 | } combinations[] = { |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 999 | { GrColorType::kRGBA_8888, VK_FORMAT_R8G8B8A8_UNORM, SkColors::kRed }, |
| 1000 | { GrColorType::kRGBA_8888_SRGB, VK_FORMAT_R8G8B8A8_SRGB, SkColors::kRed }, |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 1001 | |
Robert Phillips | bd1ef68 | 2019-05-31 12:48:49 -0400 | [diff] [blame] | 1002 | // In this configuration (i.e., an RGB_888x colortype with an RGBA8 backing format), |
| 1003 | // there is nothing to tell Skia to make the provided color opaque. Clients will need |
| 1004 | // to provide an opaque initialization color in this case. |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 1005 | { GrColorType::kRGB_888x, VK_FORMAT_R8G8B8A8_UNORM, SkColors::kYellow }, |
| 1006 | { GrColorType::kRGB_888x, VK_FORMAT_R8G8B8_UNORM, SkColors::kCyan }, |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 1007 | |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 1008 | { GrColorType::kBGRA_8888, VK_FORMAT_B8G8R8A8_UNORM, SkColors::kBlue }, |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 1009 | |
Robert Phillips | 9a30ee0 | 2020-04-29 08:58:39 -0400 | [diff] [blame] | 1010 | { GrColorType::kRGBA_1010102, VK_FORMAT_A2B10G10R10_UNORM_PACK32, |
| 1011 | { 0.25f, 0.5f, 0.75f, 1.0f }}, |
| 1012 | { GrColorType::kBGRA_1010102, VK_FORMAT_A2R10G10B10_UNORM_PACK32, |
| 1013 | { 0.25f, 0.5f, 0.75f, 1.0f }}, |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 1014 | { GrColorType::kBGR_565, VK_FORMAT_R5G6B5_UNORM_PACK16, SkColors::kRed }, |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 1015 | |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 1016 | { GrColorType::kABGR_4444, VK_FORMAT_R4G4B4A4_UNORM_PACK16, SkColors::kCyan }, |
| 1017 | { GrColorType::kABGR_4444, VK_FORMAT_B4G4R4A4_UNORM_PACK16, SkColors::kYellow }, |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 1018 | |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 1019 | { GrColorType::kAlpha_8, VK_FORMAT_R8_UNORM, kTransCol }, |
Robert Phillips | bd1ef68 | 2019-05-31 12:48:49 -0400 | [diff] [blame] | 1020 | // In this config (i.e., a Gray8 color type with an R8 backing format), there is nothing |
| 1021 | // to tell Skia this isn't an Alpha8 color type (so it will initialize the texture with |
| 1022 | // the alpha channel of the color). Clients should, in general, fill all the channels |
| 1023 | // of the provided color with the same value in such cases. |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 1024 | { GrColorType::kGray_8, VK_FORMAT_R8_UNORM, kGrayCol }, |
Robert Phillips | bd1ef68 | 2019-05-31 12:48:49 -0400 | [diff] [blame] | 1025 | |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 1026 | { GrColorType::kRGBA_F16_Clamped, VK_FORMAT_R16G16B16A16_SFLOAT, SkColors::kLtGray }, |
| 1027 | { GrColorType::kRGBA_F16, VK_FORMAT_R16G16B16A16_SFLOAT, SkColors::kYellow }, |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 1028 | |
Robert Phillips | d470e1b | 2019-09-04 15:05:35 -0400 | [diff] [blame] | 1029 | { GrColorType::kRG_88, VK_FORMAT_R8G8_UNORM, { 1, 0.5f, 0, 1 } }, |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 1030 | { GrColorType::kAlpha_F16, VK_FORMAT_R16_SFLOAT, { 1.0f, 0, 0, 0.5f }}, |
| 1031 | |
Robert Phillips | 429f0d3 | 2019-09-11 17:03:28 -0400 | [diff] [blame] | 1032 | { GrColorType::kAlpha_16, VK_FORMAT_R16_UNORM, kTransCol }, |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 1033 | { GrColorType::kRG_1616, VK_FORMAT_R16G16_UNORM, SkColors::kYellow }, |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 1034 | { GrColorType::kRGBA_16161616, VK_FORMAT_R16G16B16A16_UNORM, SkColors::kLtGray }, |
| 1035 | { GrColorType::kRG_F16, VK_FORMAT_R16G16_SFLOAT, SkColors::kYellow }, |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 1036 | }; |
| 1037 | |
| 1038 | for (auto combo : combinations) { |
Greg Daniel | 2f2caea | 2019-07-08 14:24:47 -0400 | [diff] [blame] | 1039 | if (!vkCaps->isVkFormatTexturable(combo.fFormat)) { |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 1040 | continue; |
| 1041 | } |
| 1042 | |
| 1043 | GrBackendFormat format = GrBackendFormat::MakeVk(combo.fFormat); |
| 1044 | |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 1045 | for (auto mipMapped : { GrMipMapped::kNo, GrMipMapped::kYes }) { |
| 1046 | if (GrMipMapped::kYes == mipMapped && !vkCaps->mipMapSupport()) { |
| 1047 | continue; |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 1048 | } |
| 1049 | |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 1050 | for (auto renderable : { GrRenderable::kNo, GrRenderable::kYes }) { |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 1051 | |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 1052 | if (GrRenderable::kYes == renderable) { |
Brian Salomon | 4eb38b7 | 2019-08-05 12:58:39 -0400 | [diff] [blame] | 1053 | // We must also check whether we allow rendering to the format using the |
| 1054 | // color type. |
Greg Daniel | 900583a | 2019-08-06 12:05:31 -0400 | [diff] [blame] | 1055 | if (!vkCaps->isFormatAsColorTypeRenderable( |
| 1056 | combo.fColorType, GrBackendFormat::MakeVk(combo.fFormat), 1)) { |
Brian Salomon | 4eb38b7 | 2019-08-05 12:58:39 -0400 | [diff] [blame] | 1057 | continue; |
| 1058 | } |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 1059 | } |
| 1060 | |
Robert Phillips | d34691b | 2019-09-24 13:38:43 -0400 | [diff] [blame] | 1061 | { |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 1062 | auto uninitCreateMtd = [format](GrContext* context, GrMipMapped mipMapped, |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 1063 | GrRenderable renderable) { |
Robert Phillips | d1d869d | 2019-06-07 14:21:31 -0400 | [diff] [blame] | 1064 | GrBackendTexture beTex = context->createBackendTexture(32, 32, format, |
| 1065 | mipMapped, |
Emircan Uysaler | 23ca4e7 | 2019-06-24 10:53:09 -0400 | [diff] [blame] | 1066 | renderable, |
| 1067 | GrProtected::kNo); |
Robert Phillips | 02dc030 | 2019-07-02 17:58:27 -0400 | [diff] [blame] | 1068 | check_vk_layout(beTex, VkLayout::kUndefined); |
Robert Phillips | d1d869d | 2019-06-07 14:21:31 -0400 | [diff] [blame] | 1069 | return beTex; |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 1070 | }; |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 1071 | |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 1072 | test_wrapping(context, reporter, uninitCreateMtd, |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 1073 | combo.fColorType, mipMapped, renderable, nullptr); |
Robert Phillips | b04b694 | 2019-05-21 17:24:31 -0400 | [diff] [blame] | 1074 | } |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 1075 | |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 1076 | { |
Brian Salomon | b450f3b | 2019-07-09 09:36:51 -0400 | [diff] [blame] | 1077 | // We're creating backend textures without specifying a color type "view" of |
| 1078 | // them at the public API level. Therefore, Ganesh will not apply any swizzles |
| 1079 | // before writing the color to the texture. However, our validation code does |
| 1080 | // rely on interpreting the texture contents via a SkColorType and therefore |
| 1081 | // swizzles may be applied during the read step. |
| 1082 | // Ideally we'd update our validation code to use a "raw" read that doesn't |
| 1083 | // impose a color type but for now we just munge the data we upload to match the |
| 1084 | // expectation. |
| 1085 | GrSwizzle swizzle; |
| 1086 | switch (combo.fColorType) { |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 1087 | case GrColorType::kAlpha_8: |
Brian Salomon | b450f3b | 2019-07-09 09:36:51 -0400 | [diff] [blame] | 1088 | SkASSERT(combo.fFormat == VK_FORMAT_R8_UNORM); |
| 1089 | swizzle = GrSwizzle("aaaa"); |
| 1090 | break; |
Robert Phillips | 429f0d3 | 2019-09-11 17:03:28 -0400 | [diff] [blame] | 1091 | case GrColorType::kAlpha_16: |
| 1092 | SkASSERT(combo.fFormat == VK_FORMAT_R16_UNORM); |
| 1093 | swizzle = GrSwizzle("aaaa"); |
| 1094 | break; |
Robert Phillips | 17a3a0b | 2019-09-18 13:56:54 -0400 | [diff] [blame] | 1095 | case GrColorType::kAlpha_F16: |
| 1096 | SkASSERT(combo.fFormat == VK_FORMAT_R16_SFLOAT); |
| 1097 | swizzle = GrSwizzle("aaaa"); |
| 1098 | break; |
Robert Phillips | b7f95d1 | 2019-07-26 11:13:19 -0400 | [diff] [blame] | 1099 | case GrColorType::kABGR_4444: |
Brian Salomon | b450f3b | 2019-07-09 09:36:51 -0400 | [diff] [blame] | 1100 | if (combo.fFormat == VK_FORMAT_B4G4R4A4_UNORM_PACK16) { |
| 1101 | swizzle = GrSwizzle("bgra"); |
| 1102 | } |
| 1103 | break; |
| 1104 | default: |
| 1105 | swizzle = GrSwizzle("rgba"); |
| 1106 | break; |
| 1107 | } |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 1108 | |
| 1109 | bool finishedBackendCreation = false; |
| 1110 | bool* finishedPtr = &finishedBackendCreation; |
| 1111 | |
| 1112 | auto createWithColorMtd = [format, swizzle, finishedPtr]( |
| 1113 | GrContext* context, const SkColor4f& color, GrMipMapped mipMapped, |
| 1114 | GrRenderable renderable) { |
Brian Salomon | b450f3b | 2019-07-09 09:36:51 -0400 | [diff] [blame] | 1115 | auto swizzledColor = swizzle.applyTo(color); |
Robert Phillips | d1d869d | 2019-06-07 14:21:31 -0400 | [diff] [blame] | 1116 | GrBackendTexture beTex = context->createBackendTexture(32, 32, format, |
Brian Salomon | b450f3b | 2019-07-09 09:36:51 -0400 | [diff] [blame] | 1117 | swizzledColor, |
| 1118 | mipMapped, |
Robert Phillips | da2e67a | 2019-07-01 15:04:06 -0400 | [diff] [blame] | 1119 | renderable, |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 1120 | GrProtected::kNo, |
| 1121 | mark_signaled, |
| 1122 | finishedPtr); |
Greg Daniel | dddf709 | 2020-05-06 11:52:37 -0400 | [diff] [blame] | 1123 | check_vk_layout(beTex, VkLayout::kReadOnlyOptimal); |
Robert Phillips | d1d869d | 2019-06-07 14:21:31 -0400 | [diff] [blame] | 1124 | return beTex; |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 1125 | }; |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 1126 | test_color_init(context, reporter, createWithColorMtd, |
Greg Daniel | c1ad77c | 2020-05-06 11:40:03 -0400 | [diff] [blame] | 1127 | combo.fColorType, combo.fColor, mipMapped, renderable, |
| 1128 | finishedPtr); |
Robert Phillips | 459b295 | 2019-05-23 09:38:27 -0400 | [diff] [blame] | 1129 | } |
Robert Phillips | efb9f14 | 2019-05-17 14:19:44 -0400 | [diff] [blame] | 1130 | } |
Robert Phillips | 0c6daf0 | 2019-05-16 12:43:11 -0400 | [diff] [blame] | 1131 | } |
| 1132 | } |
| 1133 | } |
| 1134 | |
| 1135 | #endif |