Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 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 | |
Mike Reed | ac9f0c9 | 2020-12-23 10:11:33 -0500 | [diff] [blame] | 8 | #include "include/core/SkBitmap.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 9 | #include "include/core/SkGraphics.h" |
| 10 | #include "include/core/SkSurface.h" |
| 11 | #include "include/core/SkTextBlob.h" |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 12 | #include "include/gpu/GrDirectContext.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "include/private/SkMutex.h" |
| 14 | #include "src/core/SkDraw.h" |
| 15 | #include "src/core/SkRemoteGlyphCache.h" |
Herb Derby | 81e84a6 | 2020-02-14 11:47:35 -0500 | [diff] [blame] | 16 | #include "src/core/SkScalerCache.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 17 | #include "src/core/SkStrikeCache.h" |
Herb Derby | d249e8c | 2019-06-03 11:36:01 -0400 | [diff] [blame] | 18 | #include "src/core/SkStrikeSpec.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 19 | #include "src/core/SkSurfacePriv.h" |
| 20 | #include "src/core/SkTypeface_remote.h" |
Robert Phillips | cc44feb | 2021-07-06 12:21:37 -0400 | [diff] [blame] | 21 | #include "src/gpu/GrCaps.h" |
Adlai Holler | a069304 | 2020-10-14 11:23:11 -0400 | [diff] [blame] | 22 | #include "src/gpu/GrDirectContextPriv.h" |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 23 | #include "src/gpu/GrRecordingContextPriv.h" |
Herb Derby | bf2dd2a | 2021-03-04 10:13:22 -0500 | [diff] [blame] | 24 | #include "src/gpu/text/GrSDFTControl.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 25 | #include "tests/Test.h" |
| 26 | #include "tools/Resources.h" |
| 27 | #include "tools/ToolUtils.h" |
| 28 | #include "tools/fonts/TestEmptyTypeface.h" |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 29 | |
| 30 | class DiscardableManager : public SkStrikeServer::DiscardableHandleManager, |
| 31 | public SkStrikeClient::DiscardableHandleManager { |
| 32 | public: |
Khushal | d416083 | 2018-05-23 18:16:00 -0700 | [diff] [blame] | 33 | DiscardableManager() { sk_bzero(&fCacheMissCount, sizeof(fCacheMissCount)); } |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 34 | ~DiscardableManager() override = default; |
| 35 | |
| 36 | // Server implementation. |
| 37 | SkDiscardableHandleId createHandle() override { |
Herb Derby | 9b86955 | 2019-05-10 12:16:17 -0400 | [diff] [blame] | 38 | SkAutoMutexExclusive l(fMutex); |
Khushal | 3de67bd | 2019-03-15 14:43:15 -0700 | [diff] [blame] | 39 | |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 40 | // Handles starts as locked. |
| 41 | fLockedHandles.add(++fNextHandleId); |
| 42 | return fNextHandleId; |
| 43 | } |
| 44 | bool lockHandle(SkDiscardableHandleId id) override { |
Herb Derby | 9b86955 | 2019-05-10 12:16:17 -0400 | [diff] [blame] | 45 | SkAutoMutexExclusive l(fMutex); |
Khushal | 3de67bd | 2019-03-15 14:43:15 -0700 | [diff] [blame] | 46 | |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 47 | if (id <= fLastDeletedHandleId) return false; |
| 48 | fLockedHandles.add(id); |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | // Client implementation. |
Khushal | 3de67bd | 2019-03-15 14:43:15 -0700 | [diff] [blame] | 53 | bool deleteHandle(SkDiscardableHandleId id) override { |
Herb Derby | 9b86955 | 2019-05-10 12:16:17 -0400 | [diff] [blame] | 54 | SkAutoMutexExclusive l(fMutex); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 55 | |
Khushal | 3de67bd | 2019-03-15 14:43:15 -0700 | [diff] [blame] | 56 | return id <= fLastDeletedHandleId; |
| 57 | } |
| 58 | |
Herb Derby | e5ed50b | 2021-02-03 14:29:54 -0500 | [diff] [blame] | 59 | void notifyCacheMiss(SkStrikeClient::CacheMissType type, int fontSize) override { |
Herb Derby | 9b86955 | 2019-05-10 12:16:17 -0400 | [diff] [blame] | 60 | SkAutoMutexExclusive l(fMutex); |
Khushal | 3de67bd | 2019-03-15 14:43:15 -0700 | [diff] [blame] | 61 | |
| 62 | fCacheMissCount[type]++; |
| 63 | } |
| 64 | bool isHandleDeleted(SkDiscardableHandleId id) override { |
Herb Derby | 9b86955 | 2019-05-10 12:16:17 -0400 | [diff] [blame] | 65 | SkAutoMutexExclusive l(fMutex); |
Khushal | 3de67bd | 2019-03-15 14:43:15 -0700 | [diff] [blame] | 66 | |
| 67 | return id <= fLastDeletedHandleId; |
| 68 | } |
| 69 | |
| 70 | void unlockAll() { |
Herb Derby | 9b86955 | 2019-05-10 12:16:17 -0400 | [diff] [blame] | 71 | SkAutoMutexExclusive l(fMutex); |
Khushal | 3de67bd | 2019-03-15 14:43:15 -0700 | [diff] [blame] | 72 | |
| 73 | fLockedHandles.reset(); |
| 74 | } |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 75 | void unlockAndDeleteAll() { |
Herb Derby | 9b86955 | 2019-05-10 12:16:17 -0400 | [diff] [blame] | 76 | SkAutoMutexExclusive l(fMutex); |
Khushal | 3de67bd | 2019-03-15 14:43:15 -0700 | [diff] [blame] | 77 | |
| 78 | fLockedHandles.reset(); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 79 | fLastDeletedHandleId = fNextHandleId; |
| 80 | } |
Khushal | 3de67bd | 2019-03-15 14:43:15 -0700 | [diff] [blame] | 81 | const SkTHashSet<SkDiscardableHandleId>& lockedHandles() const { |
Herb Derby | 9b86955 | 2019-05-10 12:16:17 -0400 | [diff] [blame] | 82 | SkAutoMutexExclusive l(fMutex); |
Khushal | 3de67bd | 2019-03-15 14:43:15 -0700 | [diff] [blame] | 83 | |
| 84 | return fLockedHandles; |
| 85 | } |
| 86 | SkDiscardableHandleId handleCount() { |
Herb Derby | 9b86955 | 2019-05-10 12:16:17 -0400 | [diff] [blame] | 87 | SkAutoMutexExclusive l(fMutex); |
Khushal | 3de67bd | 2019-03-15 14:43:15 -0700 | [diff] [blame] | 88 | |
| 89 | return fNextHandleId; |
| 90 | } |
| 91 | int cacheMissCount(uint32_t type) { |
Herb Derby | 9b86955 | 2019-05-10 12:16:17 -0400 | [diff] [blame] | 92 | SkAutoMutexExclusive l(fMutex); |
Khushal | 3de67bd | 2019-03-15 14:43:15 -0700 | [diff] [blame] | 93 | |
| 94 | return fCacheMissCount[type]; |
| 95 | } |
Khushal | fa8ff09 | 2018-06-06 17:46:38 -0700 | [diff] [blame] | 96 | bool hasCacheMiss() const { |
Herb Derby | 9b86955 | 2019-05-10 12:16:17 -0400 | [diff] [blame] | 97 | SkAutoMutexExclusive l(fMutex); |
Khushal | 3de67bd | 2019-03-15 14:43:15 -0700 | [diff] [blame] | 98 | |
Khushal | fa8ff09 | 2018-06-06 17:46:38 -0700 | [diff] [blame] | 99 | for (uint32_t i = 0; i <= SkStrikeClient::CacheMissType::kLast; ++i) { |
Hal Canary | e107faa | 2019-10-23 12:52:33 -0400 | [diff] [blame] | 100 | if (fCacheMissCount[i] > 0) { return true; } |
Khushal | fa8ff09 | 2018-06-06 17:46:38 -0700 | [diff] [blame] | 101 | } |
| 102 | return false; |
| 103 | } |
Herb Derby | e384a1e | 2019-05-21 11:27:40 -0400 | [diff] [blame] | 104 | void resetCacheMissCounts() { |
| 105 | SkAutoMutexExclusive l(fMutex); |
| 106 | sk_bzero(&fCacheMissCount, sizeof(fCacheMissCount)); |
| 107 | } |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 108 | |
| 109 | private: |
Khushal | 3de67bd | 2019-03-15 14:43:15 -0700 | [diff] [blame] | 110 | // The tests below run in parallel on multiple threads and use the same |
| 111 | // process global SkStrikeCache. So the implementation needs to be |
| 112 | // thread-safe. |
| 113 | mutable SkMutex fMutex; |
| 114 | |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 115 | SkDiscardableHandleId fNextHandleId = 0u; |
| 116 | SkDiscardableHandleId fLastDeletedHandleId = 0u; |
| 117 | SkTHashSet<SkDiscardableHandleId> fLockedHandles; |
Khushal | d416083 | 2018-05-23 18:16:00 -0700 | [diff] [blame] | 118 | int fCacheMissCount[SkStrikeClient::CacheMissType::kLast + 1u]; |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | sk_sp<SkTextBlob> buildTextBlob(sk_sp<SkTypeface> tf, int glyphCount) { |
Mike Reed | 2ed7820 | 2018-11-21 15:10:08 -0500 | [diff] [blame] | 122 | SkFont font; |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 123 | font.setTypeface(tf); |
Ben Wagner | 5785e4a | 2019-05-07 16:50:29 -0400 | [diff] [blame] | 124 | font.setHinting(SkFontHinting::kNormal); |
Mike Reed | 2ed7820 | 2018-11-21 15:10:08 -0500 | [diff] [blame] | 125 | font.setSize(1u); |
| 126 | font.setEdging(SkFont::Edging::kAntiAlias); |
| 127 | font.setSubpixel(true); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 128 | |
| 129 | SkTextBlobBuilder builder; |
| 130 | SkRect bounds = SkRect::MakeWH(10, 10); |
| 131 | const auto& runBuffer = builder.allocRunPosH(font, glyphCount, 0, &bounds); |
| 132 | SkASSERT(runBuffer.utf8text == nullptr); |
| 133 | SkASSERT(runBuffer.clusters == nullptr); |
| 134 | |
| 135 | for (int i = 0; i < glyphCount; i++) { |
| 136 | runBuffer.glyphs[i] = static_cast<SkGlyphID>(i); |
| 137 | runBuffer.pos[i] = SkIntToScalar(i); |
| 138 | } |
| 139 | return builder.make(); |
| 140 | } |
| 141 | |
Chris Dalton | f9a90a2 | 2018-08-28 14:17:55 -0600 | [diff] [blame] | 142 | static void compare_blobs(const SkBitmap& expected, const SkBitmap& actual, |
| 143 | skiatest::Reporter* reporter, int tolerance = 0) { |
| 144 | SkASSERT(expected.width() == actual.width()); |
| 145 | SkASSERT(expected.height() == actual.height()); |
| 146 | for (int i = 0; i < expected.width(); ++i) { |
| 147 | for (int j = 0; j < expected.height(); ++j) { |
| 148 | SkColor expectedColor = expected.getColor(i, j); |
| 149 | SkColor actualColor = actual.getColor(i, j); |
| 150 | if (0 == tolerance) { |
| 151 | REPORTER_ASSERT(reporter, expectedColor == actualColor); |
| 152 | } else { |
| 153 | for (int k = 0; k < 4; ++k) { |
| 154 | int expectedChannel = (expectedColor >> (k*8)) & 0xff; |
| 155 | int actualChannel = (actualColor >> (k*8)) & 0xff; |
| 156 | REPORTER_ASSERT(reporter, abs(expectedChannel - actualChannel) <= tolerance); |
| 157 | } |
| 158 | } |
| 159 | } |
Khushal | 51371a4 | 2018-05-17 10:41:40 -0700 | [diff] [blame] | 160 | } |
Chris Dalton | f9a90a2 | 2018-08-28 14:17:55 -0600 | [diff] [blame] | 161 | } |
Khushal | 51371a4 | 2018-05-17 10:41:40 -0700 | [diff] [blame] | 162 | |
Robert Phillips | e94b4e1 | 2020-07-23 13:54:35 -0400 | [diff] [blame] | 163 | sk_sp<SkSurface> MakeSurface(int width, int height, GrRecordingContext* rContext) { |
Herb Derby | c341500 | 2018-11-08 16:40:26 -0500 | [diff] [blame] | 164 | const SkImageInfo info = |
| 165 | SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType); |
Robert Phillips | e94b4e1 | 2020-07-23 13:54:35 -0400 | [diff] [blame] | 166 | return SkSurface::MakeRenderTarget(rContext, SkBudgeted::kNo, info); |
Herb Derby | c341500 | 2018-11-08 16:40:26 -0500 | [diff] [blame] | 167 | } |
| 168 | |
John Stiles | ec9b4aa | 2020-08-07 13:05:14 -0400 | [diff] [blame] | 169 | SkSurfaceProps FindSurfaceProps(GrRecordingContext* rContext) { |
Robert Phillips | e94b4e1 | 2020-07-23 13:54:35 -0400 | [diff] [blame] | 170 | auto surface = MakeSurface(1, 1, rContext); |
Herb Derby | c341500 | 2018-11-08 16:40:26 -0500 | [diff] [blame] | 171 | return surface->props(); |
| 172 | } |
| 173 | |
Ravi Mistry | cd21d67 | 2018-05-29 21:45:46 +0000 | [diff] [blame] | 174 | SkBitmap RasterBlob(sk_sp<SkTextBlob> blob, int width, int height, const SkPaint& paint, |
Robert Phillips | e94b4e1 | 2020-07-23 13:54:35 -0400 | [diff] [blame] | 175 | GrRecordingContext* rContext, const SkMatrix* matrix = nullptr, |
Herb Derby | 1a9971e | 2018-07-19 13:41:15 -0400 | [diff] [blame] | 176 | SkScalar x = 0) { |
Robert Phillips | e94b4e1 | 2020-07-23 13:54:35 -0400 | [diff] [blame] | 177 | auto surface = MakeSurface(width, height, rContext); |
Ravi Mistry | cd21d67 | 2018-05-29 21:45:46 +0000 | [diff] [blame] | 178 | if (matrix) surface->getCanvas()->concat(*matrix); |
Herb Derby | b1dbbc8 | 2019-03-22 17:05:14 -0400 | [diff] [blame] | 179 | surface->getCanvas()->drawTextBlob(blob.get(), x, height/2, paint); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 180 | SkBitmap bitmap; |
Ravi Mistry | cd21d67 | 2018-05-29 21:45:46 +0000 | [diff] [blame] | 181 | bitmap.allocN32Pixels(width, height); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 182 | surface->readPixels(bitmap, 0, 0); |
| 183 | return bitmap; |
| 184 | } |
| 185 | |
| 186 | DEF_TEST(SkRemoteGlyphCache_TypefaceSerialization, reporter) { |
| 187 | sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>(); |
| 188 | SkStrikeServer server(discardableManager.get()); |
Herb Derby | feb9fa9 | 2018-06-01 16:47:21 -0400 | [diff] [blame] | 189 | SkStrikeClient client(discardableManager, false); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 190 | |
| 191 | auto server_tf = SkTypeface::MakeDefault(); |
| 192 | auto tf_data = server.serializeTypeface(server_tf.get()); |
| 193 | |
| 194 | auto client_tf = client.deserializeTypeface(tf_data->data(), tf_data->size()); |
| 195 | REPORTER_ASSERT(reporter, client_tf); |
Khushal | d416083 | 2018-05-23 18:16:00 -0700 | [diff] [blame] | 196 | REPORTER_ASSERT(reporter, static_cast<SkTypefaceProxy*>(client_tf.get())->remoteTypefaceID() == |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 197 | server_tf->uniqueID()); |
Khushal | 3e7548c | 2018-05-23 15:45:01 -0700 | [diff] [blame] | 198 | |
| 199 | // Must unlock everything on termination, otherwise valgrind complains about memory leaks. |
| 200 | discardableManager->unlockAndDeleteAll(); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 201 | } |
| 202 | |
Khushal | 3e7548c | 2018-05-23 15:45:01 -0700 | [diff] [blame] | 203 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_StrikeSerialization, reporter, ctxInfo) { |
Robert Phillips | e94b4e1 | 2020-07-23 13:54:35 -0400 | [diff] [blame] | 204 | auto dContext = ctxInfo.directContext(); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 205 | sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>(); |
| 206 | SkStrikeServer server(discardableManager.get()); |
Herb Derby | feb9fa9 | 2018-06-01 16:47:21 -0400 | [diff] [blame] | 207 | SkStrikeClient client(discardableManager, false); |
Khushal | 51371a4 | 2018-05-17 10:41:40 -0700 | [diff] [blame] | 208 | const SkPaint paint; |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 209 | |
| 210 | // Server. |
| 211 | auto serverTf = SkTypeface::MakeFromName("monospace", SkFontStyle()); |
| 212 | auto serverTfData = server.serializeTypeface(serverTf.get()); |
| 213 | |
| 214 | int glyphCount = 10; |
| 215 | auto serverBlob = buildTextBlob(serverTf, glyphCount); |
Robert Phillips | e94b4e1 | 2020-07-23 13:54:35 -0400 | [diff] [blame] | 216 | auto props = FindSurfaceProps(dContext); |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 217 | std::unique_ptr<SkCanvas> cache_diff_canvas = server.makeAnalysisCanvas( |
| 218 | 10, 10, props, nullptr, dContext->supportsDistanceFieldText()); |
| 219 | cache_diff_canvas->drawTextBlob(serverBlob.get(), 0, 0, paint); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 220 | |
| 221 | std::vector<uint8_t> serverStrikeData; |
| 222 | server.writeStrikeData(&serverStrikeData); |
| 223 | |
| 224 | // Client. |
| 225 | auto clientTf = client.deserializeTypeface(serverTfData->data(), serverTfData->size()); |
| 226 | REPORTER_ASSERT(reporter, |
| 227 | client.readStrikeData(serverStrikeData.data(), serverStrikeData.size())); |
| 228 | auto clientBlob = buildTextBlob(clientTf, glyphCount); |
| 229 | |
Robert Phillips | e94b4e1 | 2020-07-23 13:54:35 -0400 | [diff] [blame] | 230 | SkBitmap expected = RasterBlob(serverBlob, 10, 10, paint, dContext); |
| 231 | SkBitmap actual = RasterBlob(clientBlob, 10, 10, paint, dContext); |
Chris Dalton | f9a90a2 | 2018-08-28 14:17:55 -0600 | [diff] [blame] | 232 | compare_blobs(expected, actual, reporter); |
Khushal | fa8ff09 | 2018-06-06 17:46:38 -0700 | [diff] [blame] | 233 | REPORTER_ASSERT(reporter, !discardableManager->hasCacheMiss()); |
Khushal | 3e7548c | 2018-05-23 15:45:01 -0700 | [diff] [blame] | 234 | |
| 235 | // Must unlock everything on termination, otherwise valgrind complains about memory leaks. |
| 236 | discardableManager->unlockAndDeleteAll(); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 237 | } |
| 238 | |
Herb Derby | aca2b9e | 2018-08-28 15:33:19 -0400 | [diff] [blame] | 239 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_ReleaseTypeFace, reporter, ctxInfo) { |
| 240 | sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>(); |
| 241 | SkStrikeServer server(discardableManager.get()); |
| 242 | SkStrikeClient client(discardableManager, false); |
| 243 | |
| 244 | // Server. |
Mike Klein | 0cffcbf9 | 2019-03-20 11:08:46 -0500 | [diff] [blame] | 245 | auto serverTf = TestEmptyTypeface::Make(); |
Herb Derby | aca2b9e | 2018-08-28 15:33:19 -0400 | [diff] [blame] | 246 | auto serverTfData = server.serializeTypeface(serverTf.get()); |
| 247 | REPORTER_ASSERT(reporter, serverTf->unique()); |
| 248 | |
| 249 | { |
| 250 | const SkPaint paint; |
| 251 | int glyphCount = 10; |
| 252 | auto serverBlob = buildTextBlob(serverTf, glyphCount); |
Ben Wagner | ae4bb98 | 2020-09-24 14:49:00 -0400 | [diff] [blame] | 253 | const SkSurfaceProps props; |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 254 | std::unique_ptr<SkCanvas> cache_diff_canvas = server.makeAnalysisCanvas( |
| 255 | 10, 10, props, nullptr, ctxInfo.directContext()->supportsDistanceFieldText()); |
| 256 | cache_diff_canvas->drawTextBlob(serverBlob.get(), 0, 0, paint); |
Herb Derby | aca2b9e | 2018-08-28 15:33:19 -0400 | [diff] [blame] | 257 | REPORTER_ASSERT(reporter, !serverTf->unique()); |
| 258 | |
| 259 | std::vector<uint8_t> serverStrikeData; |
| 260 | server.writeStrikeData(&serverStrikeData); |
| 261 | } |
| 262 | REPORTER_ASSERT(reporter, serverTf->unique()); |
| 263 | |
| 264 | // Must unlock everything on termination, otherwise valgrind complains about memory leaks. |
| 265 | discardableManager->unlockAndDeleteAll(); |
| 266 | } |
| 267 | |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 268 | DEF_TEST(SkRemoteGlyphCache_StrikeLockingServer, reporter) { |
| 269 | sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>(); |
| 270 | SkStrikeServer server(discardableManager.get()); |
Herb Derby | feb9fa9 | 2018-06-01 16:47:21 -0400 | [diff] [blame] | 271 | SkStrikeClient client(discardableManager, false); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 272 | |
| 273 | auto serverTf = SkTypeface::MakeFromName("monospace", SkFontStyle()); |
| 274 | server.serializeTypeface(serverTf.get()); |
| 275 | int glyphCount = 10; |
| 276 | auto serverBlob = buildTextBlob(serverTf, glyphCount); |
| 277 | |
Ben Wagner | ae4bb98 | 2020-09-24 14:49:00 -0400 | [diff] [blame] | 278 | const SkSurfaceProps props; |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 279 | std::unique_ptr<SkCanvas> cache_diff_canvas = |
| 280 | server.makeAnalysisCanvas(10, 10, props, nullptr, true); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 281 | SkPaint paint; |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 282 | cache_diff_canvas->drawTextBlob(serverBlob.get(), 0, 0, paint); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 283 | |
| 284 | // The strike from the blob should be locked after it has been drawn on the canvas. |
| 285 | REPORTER_ASSERT(reporter, discardableManager->handleCount() == 1u); |
| 286 | REPORTER_ASSERT(reporter, discardableManager->lockedHandles().count() == 1u); |
| 287 | |
| 288 | // Write the strike data and unlock everything. Re-analyzing the blob should lock the handle |
| 289 | // again. |
| 290 | std::vector<uint8_t> fontData; |
| 291 | server.writeStrikeData(&fontData); |
| 292 | discardableManager->unlockAll(); |
| 293 | REPORTER_ASSERT(reporter, discardableManager->lockedHandles().count() == 0u); |
| 294 | |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 295 | cache_diff_canvas->drawTextBlob(serverBlob.get(), 0, 0, paint); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 296 | REPORTER_ASSERT(reporter, discardableManager->handleCount() == 1u); |
| 297 | REPORTER_ASSERT(reporter, discardableManager->lockedHandles().count() == 1u); |
Khushal | 3e7548c | 2018-05-23 15:45:01 -0700 | [diff] [blame] | 298 | |
| 299 | // Must unlock everything on termination, otherwise valgrind complains about memory leaks. |
| 300 | discardableManager->unlockAndDeleteAll(); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | DEF_TEST(SkRemoteGlyphCache_StrikeDeletionServer, reporter) { |
| 304 | sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>(); |
| 305 | SkStrikeServer server(discardableManager.get()); |
Herb Derby | feb9fa9 | 2018-06-01 16:47:21 -0400 | [diff] [blame] | 306 | SkStrikeClient client(discardableManager, false); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 307 | |
| 308 | auto serverTf = SkTypeface::MakeFromName("monospace", SkFontStyle()); |
| 309 | server.serializeTypeface(serverTf.get()); |
| 310 | int glyphCount = 10; |
| 311 | auto serverBlob = buildTextBlob(serverTf, glyphCount); |
| 312 | |
Ben Wagner | ae4bb98 | 2020-09-24 14:49:00 -0400 | [diff] [blame] | 313 | const SkSurfaceProps props; |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 314 | std::unique_ptr<SkCanvas> cache_diff_canvas = |
| 315 | server.makeAnalysisCanvas(10, 10, props, nullptr, true); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 316 | SkPaint paint; |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 317 | cache_diff_canvas->drawTextBlob(serverBlob.get(), 0, 0, paint); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 318 | REPORTER_ASSERT(reporter, discardableManager->handleCount() == 1u); |
| 319 | |
| 320 | // Write the strike data and delete all the handles. Re-analyzing the blob should create new |
| 321 | // handles. |
| 322 | std::vector<uint8_t> fontData; |
| 323 | server.writeStrikeData(&fontData); |
Khushal | 498a9b2 | 2019-09-04 16:19:22 -0700 | [diff] [blame] | 324 | |
| 325 | // Another analysis pass, to ensure that deleting handles after a complete cache hit still |
| 326 | // works. This is a regression test for crbug.com/999682. |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 327 | cache_diff_canvas->drawTextBlob(serverBlob.get(), 0, 0, paint); |
Khushal | 498a9b2 | 2019-09-04 16:19:22 -0700 | [diff] [blame] | 328 | server.writeStrikeData(&fontData); |
| 329 | REPORTER_ASSERT(reporter, discardableManager->handleCount() == 1u); |
| 330 | |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 331 | discardableManager->unlockAndDeleteAll(); |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 332 | cache_diff_canvas->drawTextBlob(serverBlob.get(), 0, 0, paint); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 333 | REPORTER_ASSERT(reporter, discardableManager->handleCount() == 2u); |
Khushal | 3e7548c | 2018-05-23 15:45:01 -0700 | [diff] [blame] | 334 | |
| 335 | // Must unlock everything on termination, otherwise valgrind complains about memory leaks. |
| 336 | discardableManager->unlockAndDeleteAll(); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | DEF_TEST(SkRemoteGlyphCache_StrikePinningClient, reporter) { |
| 340 | sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>(); |
| 341 | SkStrikeServer server(discardableManager.get()); |
Herb Derby | feb9fa9 | 2018-06-01 16:47:21 -0400 | [diff] [blame] | 342 | SkStrikeClient client(discardableManager, false); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 343 | |
| 344 | // Server. |
| 345 | auto serverTf = SkTypeface::MakeFromName("monospace", SkFontStyle()); |
| 346 | auto serverTfData = server.serializeTypeface(serverTf.get()); |
| 347 | |
| 348 | int glyphCount = 10; |
| 349 | auto serverBlob = buildTextBlob(serverTf, glyphCount); |
| 350 | |
Ben Wagner | ae4bb98 | 2020-09-24 14:49:00 -0400 | [diff] [blame] | 351 | const SkSurfaceProps props; |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 352 | std::unique_ptr<SkCanvas> cache_diff_canvas = |
| 353 | server.makeAnalysisCanvas(10, 10, props, nullptr, true); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 354 | SkPaint paint; |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 355 | cache_diff_canvas->drawTextBlob(serverBlob.get(), 0, 0, paint); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 356 | |
| 357 | std::vector<uint8_t> serverStrikeData; |
| 358 | server.writeStrikeData(&serverStrikeData); |
| 359 | |
| 360 | // Client. |
| 361 | REPORTER_ASSERT(reporter, |
| 362 | client.readStrikeData(serverStrikeData.data(), serverStrikeData.size())); |
| 363 | auto* clientTf = client.deserializeTypeface(serverTfData->data(), serverTfData->size()).get(); |
| 364 | |
| 365 | // The cache remains alive until it is pinned in the discardable manager. |
| 366 | SkGraphics::PurgeFontCache(); |
| 367 | REPORTER_ASSERT(reporter, !clientTf->unique()); |
| 368 | |
| 369 | // Once the strike is unpinned and purged, SkStrikeClient should be the only owner of the |
| 370 | // clientTf. |
| 371 | discardableManager->unlockAndDeleteAll(); |
| 372 | SkGraphics::PurgeFontCache(); |
| 373 | REPORTER_ASSERT(reporter, clientTf->unique()); |
Khushal | 3e7548c | 2018-05-23 15:45:01 -0700 | [diff] [blame] | 374 | |
| 375 | // Must unlock everything on termination, otherwise valgrind complains about memory leaks. |
| 376 | discardableManager->unlockAndDeleteAll(); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 377 | } |
Khushal | b2e7127 | 2018-05-15 12:59:48 -0700 | [diff] [blame] | 378 | |
| 379 | DEF_TEST(SkRemoteGlyphCache_ClientMemoryAccounting, reporter) { |
| 380 | sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>(); |
| 381 | SkStrikeServer server(discardableManager.get()); |
Herb Derby | feb9fa9 | 2018-06-01 16:47:21 -0400 | [diff] [blame] | 382 | SkStrikeClient client(discardableManager, false); |
Khushal | b2e7127 | 2018-05-15 12:59:48 -0700 | [diff] [blame] | 383 | |
| 384 | // Server. |
| 385 | auto serverTf = SkTypeface::MakeFromName("monospace", SkFontStyle()); |
| 386 | auto serverTfData = server.serializeTypeface(serverTf.get()); |
| 387 | |
| 388 | int glyphCount = 10; |
| 389 | auto serverBlob = buildTextBlob(serverTf, glyphCount); |
| 390 | |
Ben Wagner | ae4bb98 | 2020-09-24 14:49:00 -0400 | [diff] [blame] | 391 | const SkSurfaceProps props; |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 392 | std::unique_ptr<SkCanvas> cache_diff_canvas = |
| 393 | server.makeAnalysisCanvas(10, 10, props, nullptr, true); |
Khushal | b2e7127 | 2018-05-15 12:59:48 -0700 | [diff] [blame] | 394 | SkPaint paint; |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 395 | cache_diff_canvas->drawTextBlob(serverBlob.get(), 0, 0, paint); |
Khushal | b2e7127 | 2018-05-15 12:59:48 -0700 | [diff] [blame] | 396 | |
| 397 | std::vector<uint8_t> serverStrikeData; |
| 398 | server.writeStrikeData(&serverStrikeData); |
| 399 | |
| 400 | // Client. |
| 401 | REPORTER_ASSERT(reporter, |
| 402 | client.readStrikeData(serverStrikeData.data(), serverStrikeData.size())); |
Khushal | 3e7548c | 2018-05-23 15:45:01 -0700 | [diff] [blame] | 403 | |
| 404 | // Must unlock everything on termination, otherwise valgrind complains about memory leaks. |
| 405 | discardableManager->unlockAndDeleteAll(); |
Khushal | b2e7127 | 2018-05-15 12:59:48 -0700 | [diff] [blame] | 406 | } |
Khushal | 51371a4 | 2018-05-17 10:41:40 -0700 | [diff] [blame] | 407 | |
Khushal | cf33b1b | 2018-08-29 16:16:25 -0700 | [diff] [blame] | 408 | DEF_TEST(SkRemoteGlyphCache_PurgesServerEntries, reporter) { |
| 409 | sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>(); |
| 410 | SkStrikeServer server(discardableManager.get()); |
| 411 | server.setMaxEntriesInDescriptorMapForTesting(1u); |
| 412 | SkStrikeClient client(discardableManager, false); |
| 413 | |
| 414 | { |
| 415 | auto serverTf = SkTypeface::MakeFromName("monospace", SkFontStyle()); |
| 416 | int glyphCount = 10; |
| 417 | auto serverBlob = buildTextBlob(serverTf, glyphCount); |
| 418 | |
Ben Wagner | ae4bb98 | 2020-09-24 14:49:00 -0400 | [diff] [blame] | 419 | const SkSurfaceProps props; |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 420 | std::unique_ptr<SkCanvas> cache_diff_canvas = |
| 421 | server.makeAnalysisCanvas(10, 10, props, nullptr, true); |
Khushal | cf33b1b | 2018-08-29 16:16:25 -0700 | [diff] [blame] | 422 | SkPaint paint; |
Herb Derby | a4c7883 | 2019-08-27 16:03:45 -0400 | [diff] [blame] | 423 | REPORTER_ASSERT(reporter, server.remoteStrikeMapSizeForTesting() == 0u); |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 424 | cache_diff_canvas->drawTextBlob(serverBlob.get(), 0, 0, paint); |
Herb Derby | a4c7883 | 2019-08-27 16:03:45 -0400 | [diff] [blame] | 425 | REPORTER_ASSERT(reporter, server.remoteStrikeMapSizeForTesting() == 1u); |
Khushal | cf33b1b | 2018-08-29 16:16:25 -0700 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | // Serialize to release the lock from the strike server and delete all current |
| 429 | // handles. |
| 430 | std::vector<uint8_t> fontData; |
| 431 | server.writeStrikeData(&fontData); |
| 432 | discardableManager->unlockAndDeleteAll(); |
| 433 | |
| 434 | // Use a different typeface. Creating a new strike should evict the previous |
| 435 | // one. |
| 436 | { |
| 437 | auto serverTf = SkTypeface::MakeFromName("Georgia", SkFontStyle()); |
| 438 | int glyphCount = 10; |
| 439 | auto serverBlob = buildTextBlob(serverTf, glyphCount); |
| 440 | |
Ben Wagner | ae4bb98 | 2020-09-24 14:49:00 -0400 | [diff] [blame] | 441 | const SkSurfaceProps props; |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 442 | std::unique_ptr<SkCanvas> cache_diff_canvas = |
| 443 | server.makeAnalysisCanvas(10, 10, props, nullptr, true); |
Khushal | cf33b1b | 2018-08-29 16:16:25 -0700 | [diff] [blame] | 444 | SkPaint paint; |
Herb Derby | a4c7883 | 2019-08-27 16:03:45 -0400 | [diff] [blame] | 445 | REPORTER_ASSERT(reporter, server.remoteStrikeMapSizeForTesting() == 1u); |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 446 | cache_diff_canvas->drawTextBlob(serverBlob.get(), 0, 0, paint); |
Herb Derby | a4c7883 | 2019-08-27 16:03:45 -0400 | [diff] [blame] | 447 | REPORTER_ASSERT(reporter, server.remoteStrikeMapSizeForTesting() == 1u); |
Khushal | cf33b1b | 2018-08-29 16:16:25 -0700 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | // Must unlock everything on termination, otherwise valgrind complains about memory leaks. |
| 451 | discardableManager->unlockAndDeleteAll(); |
| 452 | } |
| 453 | |
Khushal | 3e7548c | 2018-05-23 15:45:01 -0700 | [diff] [blame] | 454 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextAsPath, reporter, ctxInfo) { |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 455 | auto direct = ctxInfo.directContext(); |
Khushal | 51371a4 | 2018-05-17 10:41:40 -0700 | [diff] [blame] | 456 | sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>(); |
| 457 | SkStrikeServer server(discardableManager.get()); |
Herb Derby | feb9fa9 | 2018-06-01 16:47:21 -0400 | [diff] [blame] | 458 | SkStrikeClient client(discardableManager, false); |
Khushal | 51371a4 | 2018-05-17 10:41:40 -0700 | [diff] [blame] | 459 | SkPaint paint; |
| 460 | paint.setStyle(SkPaint::kStroke_Style); |
| 461 | paint.setStrokeWidth(0); |
Herb Derby | d249e8c | 2019-06-03 11:36:01 -0400 | [diff] [blame] | 462 | REPORTER_ASSERT(reporter, |
Herb Derby | 36a54c1 | 2019-06-06 10:50:56 -0400 | [diff] [blame] | 463 | SkStrikeSpec::ShouldDrawAsPath(paint, SkFont(), SkMatrix::I())); |
Khushal | 51371a4 | 2018-05-17 10:41:40 -0700 | [diff] [blame] | 464 | |
| 465 | // Server. |
| 466 | auto serverTf = SkTypeface::MakeFromName("monospace", SkFontStyle()); |
| 467 | auto serverTfData = server.serializeTypeface(serverTf.get()); |
| 468 | |
| 469 | int glyphCount = 10; |
| 470 | auto serverBlob = buildTextBlob(serverTf, glyphCount); |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 471 | auto props = FindSurfaceProps(direct); |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 472 | std::unique_ptr<SkCanvas> cache_diff_canvas = server.makeAnalysisCanvas( |
| 473 | 10, 10, props, nullptr, direct->supportsDistanceFieldText()); |
| 474 | cache_diff_canvas->drawTextBlob(serverBlob.get(), 0, 0, paint); |
Khushal | 51371a4 | 2018-05-17 10:41:40 -0700 | [diff] [blame] | 475 | |
| 476 | std::vector<uint8_t> serverStrikeData; |
| 477 | server.writeStrikeData(&serverStrikeData); |
| 478 | |
| 479 | // Client. |
| 480 | auto clientTf = client.deserializeTypeface(serverTfData->data(), serverTfData->size()); |
| 481 | REPORTER_ASSERT(reporter, |
| 482 | client.readStrikeData(serverStrikeData.data(), serverStrikeData.size())); |
| 483 | auto clientBlob = buildTextBlob(clientTf, glyphCount); |
| 484 | |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 485 | SkBitmap expected = RasterBlob(serverBlob, 10, 10, paint, direct); |
| 486 | SkBitmap actual = RasterBlob(clientBlob, 10, 10, paint, direct); |
Chris Dalton | f9a90a2 | 2018-08-28 14:17:55 -0600 | [diff] [blame] | 487 | compare_blobs(expected, actual, reporter, 1); |
Khushal | fa8ff09 | 2018-06-06 17:46:38 -0700 | [diff] [blame] | 488 | REPORTER_ASSERT(reporter, !discardableManager->hasCacheMiss()); |
Khushal | 3e7548c | 2018-05-23 15:45:01 -0700 | [diff] [blame] | 489 | |
| 490 | // Must unlock everything on termination, otherwise valgrind complains about memory leaks. |
| 491 | discardableManager->unlockAndDeleteAll(); |
Khushal | 51371a4 | 2018-05-17 10:41:40 -0700 | [diff] [blame] | 492 | } |
Khushal | 3e7548c | 2018-05-23 15:45:01 -0700 | [diff] [blame] | 493 | |
Herb Derby | 8e318fd | 2018-08-29 11:04:18 -0400 | [diff] [blame] | 494 | sk_sp<SkTextBlob> make_blob_causing_fallback( |
| 495 | sk_sp<SkTypeface> targetTf, const SkTypeface* glyphTf, skiatest::Reporter* reporter) { |
Mike Reed | 70914f5 | 2018-11-23 13:08:33 -0500 | [diff] [blame] | 496 | SkFont font; |
| 497 | font.setSubpixel(true); |
| 498 | font.setSize(96); |
Ben Wagner | 5785e4a | 2019-05-07 16:50:29 -0400 | [diff] [blame] | 499 | font.setHinting(SkFontHinting::kNormal); |
Mike Reed | 70914f5 | 2018-11-23 13:08:33 -0500 | [diff] [blame] | 500 | font.setTypeface(targetTf); |
Herb Derby | 8e318fd | 2018-08-29 11:04:18 -0400 | [diff] [blame] | 501 | |
Herb Derby | d249e8c | 2019-06-03 11:36:01 -0400 | [diff] [blame] | 502 | REPORTER_ASSERT(reporter, |
Herb Derby | 36a54c1 | 2019-06-06 10:50:56 -0400 | [diff] [blame] | 503 | !SkStrikeSpec::ShouldDrawAsPath(SkPaint(), font, SkMatrix::I())); |
Herb Derby | 8e318fd | 2018-08-29 11:04:18 -0400 | [diff] [blame] | 504 | |
| 505 | char s[] = "Skia"; |
| 506 | int runSize = strlen(s); |
| 507 | |
| 508 | SkTextBlobBuilder builder; |
| 509 | SkRect bounds = SkRect::MakeIWH(100, 100); |
Mike Reed | 70914f5 | 2018-11-23 13:08:33 -0500 | [diff] [blame] | 510 | const auto& runBuffer = builder.allocRunPosH(font, runSize, 10, &bounds); |
Herb Derby | 8e318fd | 2018-08-29 11:04:18 -0400 | [diff] [blame] | 511 | SkASSERT(runBuffer.utf8text == nullptr); |
| 512 | SkASSERT(runBuffer.clusters == nullptr); |
| 513 | |
Mike Reed | 64670cb | 2019-04-16 11:37:38 -0700 | [diff] [blame] | 514 | SkFont(sk_ref_sp(glyphTf)).textToGlyphs(s, strlen(s), SkTextEncoding::kUTF8, |
| 515 | runBuffer.glyphs, runSize); |
Herb Derby | 8e318fd | 2018-08-29 11:04:18 -0400 | [diff] [blame] | 516 | |
| 517 | SkRect glyphBounds; |
Mike Reed | 70914f5 | 2018-11-23 13:08:33 -0500 | [diff] [blame] | 518 | font.getWidths(runBuffer.glyphs, 1, nullptr, &glyphBounds); |
Herb Derby | 8e318fd | 2018-08-29 11:04:18 -0400 | [diff] [blame] | 519 | |
Herb Derby | 5fd955e | 2019-01-16 11:23:29 -0500 | [diff] [blame] | 520 | REPORTER_ASSERT(reporter, glyphBounds.width() > SkStrikeCommon::kSkSideTooBigForAtlas); |
Herb Derby | 8e318fd | 2018-08-29 11:04:18 -0400 | [diff] [blame] | 521 | |
| 522 | for (int i = 0; i < runSize; i++) { |
| 523 | runBuffer.pos[i] = i * 10; |
| 524 | } |
| 525 | |
| 526 | return builder.make(); |
| 527 | } |
| 528 | |
| 529 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextAsMaskWithPathFallback, |
| 530 | reporter, ctxInfo) { |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 531 | auto direct = ctxInfo.directContext(); |
Herb Derby | 8e318fd | 2018-08-29 11:04:18 -0400 | [diff] [blame] | 532 | sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>(); |
| 533 | SkStrikeServer server(discardableManager.get()); |
| 534 | SkStrikeClient client(discardableManager, false); |
| 535 | |
| 536 | SkPaint paint; |
| 537 | |
| 538 | auto serverTf = MakeResourceAsTypeface("fonts/HangingS.ttf"); |
| 539 | // TODO: when the cq bots can handle this font remove the check. |
| 540 | if (serverTf == nullptr) { |
| 541 | return; |
| 542 | } |
| 543 | auto serverTfData = server.serializeTypeface(serverTf.get()); |
| 544 | |
| 545 | auto serverBlob = make_blob_causing_fallback(serverTf, serverTf.get(), reporter); |
| 546 | |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 547 | auto props = FindSurfaceProps(direct); |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 548 | std::unique_ptr<SkCanvas> cache_diff_canvas = server.makeAnalysisCanvas( |
| 549 | 10, 10, props, nullptr, direct->supportsDistanceFieldText()); |
| 550 | cache_diff_canvas->drawTextBlob(serverBlob.get(), 0, 0, paint); |
Herb Derby | 8e318fd | 2018-08-29 11:04:18 -0400 | [diff] [blame] | 551 | |
| 552 | std::vector<uint8_t> serverStrikeData; |
| 553 | server.writeStrikeData(&serverStrikeData); |
| 554 | |
| 555 | // Client. |
| 556 | auto clientTf = client.deserializeTypeface(serverTfData->data(), serverTfData->size()); |
| 557 | REPORTER_ASSERT(reporter, |
| 558 | client.readStrikeData(serverStrikeData.data(), serverStrikeData.size())); |
| 559 | |
| 560 | auto clientBlob = make_blob_causing_fallback(clientTf, serverTf.get(), reporter); |
| 561 | |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 562 | SkBitmap expected = RasterBlob(serverBlob, 10, 10, paint, direct); |
| 563 | SkBitmap actual = RasterBlob(clientBlob, 10, 10, paint, direct); |
Herb Derby | 8e318fd | 2018-08-29 11:04:18 -0400 | [diff] [blame] | 564 | compare_blobs(expected, actual, reporter); |
| 565 | REPORTER_ASSERT(reporter, !discardableManager->hasCacheMiss()); |
Herb Derby | 8e318fd | 2018-08-29 11:04:18 -0400 | [diff] [blame] | 566 | |
| 567 | // Must unlock everything on termination, otherwise valgrind complains about memory leaks. |
| 568 | discardableManager->unlockAndDeleteAll(); |
| 569 | } |
| 570 | |
Herb Derby | b1dbbc8 | 2019-03-22 17:05:14 -0400 | [diff] [blame] | 571 | #if 0 |
| 572 | // TODO: turn this one when I figure out how to deal with the pixel variance from linear |
| 573 | // interpolation from GPU to GPU. |
| 574 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextAsSDFTWithAllARGBFallback, |
| 575 | reporter, ctxInfo) { |
| 576 | sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>(); |
| 577 | SkStrikeServer server(discardableManager.get()); |
| 578 | SkStrikeClient client(discardableManager, false); |
| 579 | |
| 580 | SkPaint paint; |
| 581 | |
| 582 | auto serverTf = ToolUtils::planet_typeface(); |
| 583 | // TODO: when the cq bots can handle this font remove the check. |
| 584 | if (serverTf == nullptr) { |
| 585 | return; |
| 586 | } |
| 587 | auto serverTfData = server.serializeTypeface(serverTf.get()); |
| 588 | |
| 589 | auto makeBlob = [&reporter](sk_sp<SkTypeface> typeface) { |
| 590 | SkFont font; |
| 591 | font.setSubpixel(true); |
| 592 | font.setSize(96); |
Ben Wagner | 5785e4a | 2019-05-07 16:50:29 -0400 | [diff] [blame] | 593 | font.setHinting(SkFontHinting::kNormal); |
Herb Derby | b1dbbc8 | 2019-03-22 17:05:14 -0400 | [diff] [blame] | 594 | font.setTypeface(typeface); |
| 595 | |
| 596 | REPORTER_ASSERT(reporter, !SkDraw::ShouldDrawTextAsPaths(font, SkPaint(), SkMatrix::I())); |
| 597 | |
| 598 | // Mercury to Uranus. |
| 599 | SkGlyphID glyphs[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
| 600 | |
| 601 | SkTextBlobBuilder builder; |
| 602 | SkRect bounds = SkRect::MakeIWH(100, 100); |
| 603 | const auto& runBuffer = builder.allocRunPosH(font, SK_ARRAY_COUNT(glyphs), 100, &bounds); |
| 604 | SkASSERT(runBuffer.utf8text == nullptr); |
| 605 | SkASSERT(runBuffer.clusters == nullptr); |
| 606 | |
| 607 | std::copy(std::begin(glyphs), std::end(glyphs), runBuffer.glyphs); |
| 608 | |
| 609 | for (size_t i = 0; i < SK_ARRAY_COUNT(glyphs); i++) { |
| 610 | runBuffer.pos[i] = i * 100; |
| 611 | } |
| 612 | |
| 613 | return builder.make(); |
| 614 | }; |
| 615 | |
| 616 | auto serverBlob = makeBlob(serverTf); |
| 617 | |
| 618 | auto props = FindSurfaceProps(ctxInfo.grContext()); |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 619 | std::unique_ptr<SkCanvas> cache_diff_canvas = server.makeAnalysisCanvas( |
| 620 | 10, 10, props, nullptr, ctxInfo.directContext()->supportsDistanceFieldText()); |
| 621 | cache_diff_canvas->drawTextBlob(serverBlob.get(), 0, 400, paint); |
Herb Derby | b1dbbc8 | 2019-03-22 17:05:14 -0400 | [diff] [blame] | 622 | |
| 623 | std::vector<uint8_t> serverStrikeData; |
| 624 | server.writeStrikeData(&serverStrikeData); |
| 625 | |
| 626 | // Client. |
| 627 | auto clientTf = client.deserializeTypeface(serverTfData->data(), serverTfData->size()); |
| 628 | REPORTER_ASSERT(reporter, |
| 629 | client.readStrikeData(serverStrikeData.data(), serverStrikeData.size())); |
| 630 | |
| 631 | auto clientBlob = makeBlob(clientTf); |
| 632 | |
| 633 | SkBitmap expected = RasterBlob(serverBlob, 800, 800, paint, ctxInfo.grContext()); |
| 634 | SkBitmap actual = RasterBlob(clientBlob, 800, 800, paint, ctxInfo.grContext()); |
| 635 | |
| 636 | // Pixel variance can be high because of the atlas placement, and large scaling in the linear |
| 637 | // interpolation. |
| 638 | compare_blobs(expected, actual, reporter, 36); |
| 639 | REPORTER_ASSERT(reporter, !discardableManager->hasCacheMiss()); |
Herb Derby | b1dbbc8 | 2019-03-22 17:05:14 -0400 | [diff] [blame] | 640 | |
| 641 | // Must unlock everything on termination, otherwise valgrind complains about memory leaks. |
| 642 | discardableManager->unlockAndDeleteAll(); |
| 643 | } |
| 644 | #endif |
| 645 | |
Herb Derby | 1a9971e | 2018-07-19 13:41:15 -0400 | [diff] [blame] | 646 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextXY, reporter, ctxInfo) { |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 647 | auto direct = ctxInfo.directContext(); |
Herb Derby | 1a9971e | 2018-07-19 13:41:15 -0400 | [diff] [blame] | 648 | sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>(); |
| 649 | SkStrikeServer server(discardableManager.get()); |
| 650 | SkStrikeClient client(discardableManager, false); |
| 651 | SkPaint paint; |
| 652 | paint.setAntiAlias(true); |
Herb Derby | 1a9971e | 2018-07-19 13:41:15 -0400 | [diff] [blame] | 653 | |
| 654 | // Server. |
| 655 | auto serverTf = SkTypeface::MakeFromName("monospace", SkFontStyle()); |
| 656 | auto serverTfData = server.serializeTypeface(serverTf.get()); |
| 657 | |
| 658 | int glyphCount = 10; |
| 659 | auto serverBlob = buildTextBlob(serverTf, glyphCount); |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 660 | auto props = FindSurfaceProps(direct); |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 661 | std::unique_ptr<SkCanvas> cache_diff_canvas = server.makeAnalysisCanvas( |
| 662 | 10, 10, props, nullptr, direct->supportsDistanceFieldText()); |
| 663 | cache_diff_canvas->drawTextBlob(serverBlob.get(), 0.5, 0, paint); |
Herb Derby | 1a9971e | 2018-07-19 13:41:15 -0400 | [diff] [blame] | 664 | |
| 665 | std::vector<uint8_t> serverStrikeData; |
| 666 | server.writeStrikeData(&serverStrikeData); |
| 667 | |
| 668 | // Client. |
| 669 | auto clientTf = client.deserializeTypeface(serverTfData->data(), serverTfData->size()); |
| 670 | REPORTER_ASSERT(reporter, |
| 671 | client.readStrikeData(serverStrikeData.data(), serverStrikeData.size())); |
| 672 | auto clientBlob = buildTextBlob(clientTf, glyphCount); |
| 673 | |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 674 | SkBitmap expected = RasterBlob(serverBlob, 10, 10, paint, direct, nullptr, 0.5); |
| 675 | SkBitmap actual = RasterBlob(clientBlob, 10, 10, paint, direct, nullptr, 0.5); |
Chris Dalton | f9a90a2 | 2018-08-28 14:17:55 -0600 | [diff] [blame] | 676 | compare_blobs(expected, actual, reporter); |
Herb Derby | 1a9971e | 2018-07-19 13:41:15 -0400 | [diff] [blame] | 677 | REPORTER_ASSERT(reporter, !discardableManager->hasCacheMiss()); |
Herb Derby | 1a9971e | 2018-07-19 13:41:15 -0400 | [diff] [blame] | 678 | |
| 679 | // Must unlock everything on termination, otherwise valgrind complains about memory leaks. |
| 680 | discardableManager->unlockAndDeleteAll(); |
| 681 | } |
| 682 | |
Khushal | 3e7548c | 2018-05-23 15:45:01 -0700 | [diff] [blame] | 683 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextAsDFT, reporter, ctxInfo) { |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 684 | auto direct = ctxInfo.directContext(); |
Chris Dalton | 89d460f | 2021-06-08 10:46:36 -0600 | [diff] [blame] | 685 | if (!direct->priv().caps()->shaderCaps()->supportsDistanceFieldText()) { |
| 686 | return; |
| 687 | } |
Khushal | 3e7548c | 2018-05-23 15:45:01 -0700 | [diff] [blame] | 688 | sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>(); |
| 689 | SkStrikeServer server(discardableManager.get()); |
Herb Derby | feb9fa9 | 2018-06-01 16:47:21 -0400 | [diff] [blame] | 690 | SkStrikeClient client(discardableManager, false); |
Khushal | 3e7548c | 2018-05-23 15:45:01 -0700 | [diff] [blame] | 691 | SkPaint paint; |
Mike Reed | f2b074e | 2018-12-03 16:52:59 -0500 | [diff] [blame] | 692 | SkFont font; |
Khushal | 3e7548c | 2018-05-23 15:45:01 -0700 | [diff] [blame] | 693 | |
Jim Van Verth | ce3cf80 | 2019-10-10 11:06:20 -0400 | [diff] [blame] | 694 | // A scale transform forces fallback to dft. |
Mike Reed | 1f60733 | 2020-05-21 12:11:27 -0400 | [diff] [blame] | 695 | SkMatrix matrix = SkMatrix::Scale(16, 16); |
Herb Derby | bf2dd2a | 2021-03-04 10:13:22 -0500 | [diff] [blame] | 696 | GrSDFTControl control = direct->priv().asRecordingContext()->priv().getSDFTControl(true); |
| 697 | REPORTER_ASSERT(reporter, control.drawingType(font, paint, matrix) == GrSDFTControl::kSDFT); |
Khushal | 3e7548c | 2018-05-23 15:45:01 -0700 | [diff] [blame] | 698 | |
| 699 | // Server. |
| 700 | auto serverTf = SkTypeface::MakeFromName("monospace", SkFontStyle()); |
| 701 | auto serverTfData = server.serializeTypeface(serverTf.get()); |
| 702 | |
| 703 | int glyphCount = 10; |
| 704 | auto serverBlob = buildTextBlob(serverTf, glyphCount); |
Ben Wagner | ae4bb98 | 2020-09-24 14:49:00 -0400 | [diff] [blame] | 705 | const SkSurfaceProps props; |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 706 | std::unique_ptr<SkCanvas> cache_diff_canvas = server.makeAnalysisCanvas( |
| 707 | 10, 10, props, nullptr, direct->supportsDistanceFieldText()); |
| 708 | cache_diff_canvas->concat(matrix); |
| 709 | cache_diff_canvas->drawTextBlob(serverBlob.get(), 0, 0, paint); |
Khushal | 3e7548c | 2018-05-23 15:45:01 -0700 | [diff] [blame] | 710 | |
| 711 | std::vector<uint8_t> serverStrikeData; |
| 712 | server.writeStrikeData(&serverStrikeData); |
| 713 | |
| 714 | // Client. |
| 715 | auto clientTf = client.deserializeTypeface(serverTfData->data(), serverTfData->size()); |
| 716 | REPORTER_ASSERT(reporter, |
| 717 | client.readStrikeData(serverStrikeData.data(), serverStrikeData.size())); |
| 718 | auto clientBlob = buildTextBlob(clientTf, glyphCount); |
| 719 | |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 720 | SkBitmap expected = RasterBlob(serverBlob, 10, 10, paint, direct, &matrix); |
| 721 | SkBitmap actual = RasterBlob(clientBlob, 10, 10, paint, direct, &matrix); |
Chris Dalton | f9a90a2 | 2018-08-28 14:17:55 -0600 | [diff] [blame] | 722 | compare_blobs(expected, actual, reporter); |
Khushal | fa8ff09 | 2018-06-06 17:46:38 -0700 | [diff] [blame] | 723 | REPORTER_ASSERT(reporter, !discardableManager->hasCacheMiss()); |
Khushal | 3e7548c | 2018-05-23 15:45:01 -0700 | [diff] [blame] | 724 | |
| 725 | // Must unlock everything on termination, otherwise valgrind complains about memory leaks. |
| 726 | discardableManager->unlockAndDeleteAll(); |
| 727 | } |
Khushal | d416083 | 2018-05-23 18:16:00 -0700 | [diff] [blame] | 728 | |
| 729 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_CacheMissReporting, reporter, ctxInfo) { |
| 730 | sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>(); |
| 731 | SkStrikeServer server(discardableManager.get()); |
Herb Derby | feb9fa9 | 2018-06-01 16:47:21 -0400 | [diff] [blame] | 732 | SkStrikeClient client(discardableManager, false); |
Khushal | d416083 | 2018-05-23 18:16:00 -0700 | [diff] [blame] | 733 | |
| 734 | auto serverTf = SkTypeface::MakeFromName("monospace", SkFontStyle()); |
| 735 | auto tfData = server.serializeTypeface(serverTf.get()); |
| 736 | auto clientTf = client.deserializeTypeface(tfData->data(), tfData->size()); |
| 737 | REPORTER_ASSERT(reporter, clientTf); |
| 738 | int glyphCount = 10; |
| 739 | auto clientBlob = buildTextBlob(clientTf, glyphCount); |
| 740 | |
| 741 | // Raster the client-side blob without the glyph data, we should get cache miss notifications. |
Ravi Mistry | cd21d67 | 2018-05-29 21:45:46 +0000 | [diff] [blame] | 742 | SkPaint paint; |
| 743 | SkMatrix matrix = SkMatrix::I(); |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 744 | RasterBlob(clientBlob, 10, 10, paint, ctxInfo.directContext(), &matrix); |
Khushal | d416083 | 2018-05-23 18:16:00 -0700 | [diff] [blame] | 745 | REPORTER_ASSERT(reporter, |
| 746 | discardableManager->cacheMissCount(SkStrikeClient::kFontMetrics) == 1); |
| 747 | REPORTER_ASSERT(reporter, |
| 748 | discardableManager->cacheMissCount(SkStrikeClient::kGlyphMetrics) == 10); |
| 749 | |
| 750 | // There shouldn't be any image or path requests, since we mark the glyph as empty on a cache |
| 751 | // miss. |
| 752 | REPORTER_ASSERT(reporter, discardableManager->cacheMissCount(SkStrikeClient::kGlyphImage) == 0); |
| 753 | REPORTER_ASSERT(reporter, discardableManager->cacheMissCount(SkStrikeClient::kGlyphPath) == 0); |
| 754 | |
| 755 | // Must unlock everything on termination, otherwise valgrind complains about memory leaks. |
| 756 | discardableManager->unlockAndDeleteAll(); |
| 757 | } |
Herb Derby | 65b7bfc | 2018-06-05 13:32:12 -0400 | [diff] [blame] | 758 | |
Herb Derby | e384a1e | 2019-05-21 11:27:40 -0400 | [diff] [blame] | 759 | sk_sp<SkTextBlob> MakeEmojiBlob(sk_sp<SkTypeface> serverTf, SkScalar textSize, |
| 760 | sk_sp<SkTypeface> clientTf = nullptr) { |
| 761 | SkFont font; |
| 762 | font.setTypeface(serverTf); |
| 763 | font.setSize(textSize); |
| 764 | |
| 765 | const char* text = ToolUtils::emoji_sample_text(); |
| 766 | SkFont serverFont = font; |
| 767 | auto blob = SkTextBlob::MakeFromText(text, strlen(text), font); |
| 768 | if (clientTf == nullptr) return blob; |
| 769 | |
| 770 | SkSerialProcs s_procs; |
| 771 | s_procs.fTypefaceProc = [](SkTypeface*, void* ctx) -> sk_sp<SkData> { |
| 772 | return SkData::MakeUninitialized(1u); |
| 773 | }; |
| 774 | auto serialized = blob->serialize(s_procs); |
| 775 | |
| 776 | SkDeserialProcs d_procs; |
| 777 | d_procs.fTypefaceCtx = &clientTf; |
| 778 | d_procs.fTypefaceProc = [](const void* data, size_t length, void* ctx) -> sk_sp<SkTypeface> { |
| 779 | return *(static_cast<sk_sp<SkTypeface>*>(ctx)); |
| 780 | }; |
| 781 | return SkTextBlob::Deserialize(serialized->data(), serialized->size(), d_procs); |
| 782 | } |
| 783 | |
| 784 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_TypefaceWithNoPaths, reporter, ctxInfo) { |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 785 | auto direct = ctxInfo.directContext(); |
Herb Derby | e384a1e | 2019-05-21 11:27:40 -0400 | [diff] [blame] | 786 | sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>(); |
| 787 | SkStrikeServer server(discardableManager.get()); |
| 788 | SkStrikeClient client(discardableManager, false); |
| 789 | |
| 790 | auto serverTf = ToolUtils::emoji_typeface(); |
| 791 | auto serverTfData = server.serializeTypeface(serverTf.get()); |
| 792 | auto clientTf = client.deserializeTypeface(serverTfData->data(), serverTfData->size()); |
| 793 | |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 794 | auto props = FindSurfaceProps(direct); |
| 795 | std::unique_ptr<SkCanvas> cache_diff_canvas = server.makeAnalysisCanvas( |
| 796 | 500, 500, props, nullptr, direct->supportsDistanceFieldText()); |
Mike Reed | 69aaee0 | 2019-05-30 11:40:51 +0000 | [diff] [blame] | 797 | for (SkScalar textSize : { 70, 180, 270, 340}) { |
Herb Derby | e384a1e | 2019-05-21 11:27:40 -0400 | [diff] [blame] | 798 | auto serverBlob = MakeEmojiBlob(serverTf, textSize); |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 799 | |
Herb Derby | e384a1e | 2019-05-21 11:27:40 -0400 | [diff] [blame] | 800 | SkPaint paint; |
Michael Ludwig | 97f85bb | 2021-05-06 08:59:26 -0400 | [diff] [blame] | 801 | cache_diff_canvas->drawTextBlob(serverBlob.get(), 100, 100, paint); |
Herb Derby | e384a1e | 2019-05-21 11:27:40 -0400 | [diff] [blame] | 802 | |
| 803 | std::vector<uint8_t> serverStrikeData; |
| 804 | server.writeStrikeData(&serverStrikeData); |
Herb Derby | f5e9b42 | 2019-10-22 16:06:22 -0400 | [diff] [blame] | 805 | if (!serverStrikeData.empty()) { |
| 806 | REPORTER_ASSERT(reporter, |
| 807 | client.readStrikeData(serverStrikeData.data(), |
| 808 | serverStrikeData.size())); |
| 809 | } |
Herb Derby | e384a1e | 2019-05-21 11:27:40 -0400 | [diff] [blame] | 810 | auto clientBlob = MakeEmojiBlob(serverTf, textSize, clientTf); |
| 811 | REPORTER_ASSERT(reporter, clientBlob); |
| 812 | |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 813 | RasterBlob(clientBlob, 500, 500, paint, direct); |
Herb Derby | e384a1e | 2019-05-21 11:27:40 -0400 | [diff] [blame] | 814 | REPORTER_ASSERT(reporter, !discardableManager->hasCacheMiss()); |
Herb Derby | e384a1e | 2019-05-21 11:27:40 -0400 | [diff] [blame] | 815 | discardableManager->resetCacheMissCounts(); |
| 816 | } |
| 817 | |
| 818 | // Must unlock everything on termination, otherwise valgrind complains about memory leaks. |
| 819 | discardableManager->unlockAndDeleteAll(); |
| 820 | } |