Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [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 | |
Herb Derby | 4f505f9 | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 8 | #include <chrono> |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 9 | #include <err.h> |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 10 | #include <iostream> |
Herb Derby | 97be88f | 2018-03-21 16:23:49 -0400 | [diff] [blame] | 11 | #include <memory> |
| 12 | #include <string> |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 13 | #include <sys/types.h> |
Herb Derby | 67c47f2 | 2018-02-07 17:47:59 -0500 | [diff] [blame] | 14 | #include <sys/uio.h> |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 15 | #include <sys/wait.h> |
Herb Derby | 97be88f | 2018-03-21 16:23:49 -0400 | [diff] [blame] | 16 | #include <thread> |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 17 | #include <unistd.h> |
Herb Derby | 97be88f | 2018-03-21 16:23:49 -0400 | [diff] [blame] | 18 | |
Mike Klein | 8a23202 | 2018-05-02 13:54:11 +0000 | [diff] [blame] | 19 | #include "SkGraphics.h" |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 20 | #include "SkRemoteGlyphCache.h" |
| 21 | #include "SkScalerContext.h" |
Herb Derby | 97be88f | 2018-03-21 16:23:49 -0400 | [diff] [blame] | 22 | #include "SkSurface.h" |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 23 | |
Herb Derby | 97be88f | 2018-03-21 16:23:49 -0400 | [diff] [blame] | 24 | static std::string gSkpName; |
Herb Derby | 9d02182 | 2018-02-02 12:54:55 -0500 | [diff] [blame] | 25 | static bool gUseGpu = true; |
| 26 | static bool gPurgeFontCaches = true; |
| 27 | static bool gUseProcess = true; |
| 28 | |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 29 | class ServerDiscardableManager : public SkStrikeServer::DiscardableHandleManager { |
| 30 | public: |
| 31 | ServerDiscardableManager() = default; |
| 32 | ~ServerDiscardableManager() override = default; |
| 33 | |
| 34 | SkDiscardableHandleId createHandle() override { return ++nextHandleId; } |
| 35 | bool lockHandle(SkDiscardableHandleId handleId) override { |
| 36 | return handleId > lastPurgedHandleId; |
| 37 | } |
| 38 | void purgeAll() { lastPurgedHandleId = nextHandleId; } |
| 39 | |
| 40 | private: |
| 41 | SkDiscardableHandleId nextHandleId = 0u; |
| 42 | SkDiscardableHandleId lastPurgedHandleId = 0u; |
| 43 | }; |
| 44 | |
| 45 | class ClientDiscardableManager : public SkStrikeClient::DiscardableHandleManager { |
| 46 | public: |
| 47 | class ScopedPurgeCache { |
| 48 | public: |
| 49 | ScopedPurgeCache(ClientDiscardableManager* manager) : fManager(manager) { |
| 50 | if (fManager) fManager->allowPurging = true; |
| 51 | } |
| 52 | ~ScopedPurgeCache() { |
| 53 | if (fManager) fManager->allowPurging = false; |
| 54 | } |
| 55 | |
| 56 | private: |
| 57 | ClientDiscardableManager* fManager; |
| 58 | }; |
| 59 | |
| 60 | ClientDiscardableManager() = default; |
| 61 | ~ClientDiscardableManager() override = default; |
| 62 | |
| 63 | bool deleteHandle(SkDiscardableHandleId) override { return allowPurging; } |
| 64 | |
| 65 | private: |
| 66 | bool allowPurging = false; |
| 67 | }; |
| 68 | |
Herb Derby | 209a5f3 | 2018-04-05 16:57:25 -0400 | [diff] [blame] | 69 | static bool write_SkData(int fd, const SkData& data) { |
| 70 | size_t size = data.size(); |
| 71 | ssize_t bytesWritten = ::write(fd, &size, sizeof(size)); |
| 72 | if (bytesWritten < 0) { |
| 73 | err(1,"Failed write %zu", size); |
| 74 | return false; |
Herb Derby | 67c47f2 | 2018-02-07 17:47:59 -0500 | [diff] [blame] | 75 | } |
| 76 | |
Herb Derby | 209a5f3 | 2018-04-05 16:57:25 -0400 | [diff] [blame] | 77 | bytesWritten = ::write(fd, data.data(), data.size()); |
| 78 | if (bytesWritten < 0) { |
| 79 | err(1,"Failed write %zu", size); |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | return true; |
| 84 | } |
| 85 | |
| 86 | static sk_sp<SkData> read_SkData(int fd) { |
Herb Derby | 209a5f3 | 2018-04-05 16:57:25 -0400 | [diff] [blame] | 87 | size_t size; |
| 88 | ssize_t readSize = ::read(fd, &size, sizeof(size)); |
| 89 | if (readSize <= 0) { |
Herb Derby | 97be88f | 2018-03-21 16:23:49 -0400 | [diff] [blame] | 90 | if (readSize < 0) { |
Herb Derby | 209a5f3 | 2018-04-05 16:57:25 -0400 | [diff] [blame] | 91 | err(1, "Failed read %zu", size); |
Herb Derby | 67c47f2 | 2018-02-07 17:47:59 -0500 | [diff] [blame] | 92 | } |
Herb Derby | 209a5f3 | 2018-04-05 16:57:25 -0400 | [diff] [blame] | 93 | return nullptr; |
Herb Derby | 67c47f2 | 2018-02-07 17:47:59 -0500 | [diff] [blame] | 94 | } |
| 95 | |
Herb Derby | 209a5f3 | 2018-04-05 16:57:25 -0400 | [diff] [blame] | 96 | auto out = SkData::MakeUninitialized(size); |
| 97 | auto data = (uint8_t*)out->data(); |
| 98 | |
| 99 | size_t totalRead = 0; |
| 100 | while (totalRead < size) { |
| 101 | ssize_t sizeRead; |
| 102 | sizeRead = ::read(fd, &data[totalRead], size - totalRead); |
| 103 | if (sizeRead <= 0) { |
| 104 | if (readSize < 0) { |
| 105 | err(1, "Failed read %zu", size); |
| 106 | } |
| 107 | return nullptr; |
| 108 | } |
| 109 | totalRead += sizeRead; |
| 110 | } |
| 111 | |
| 112 | return out; |
| 113 | } |
Herb Derby | 67c47f2 | 2018-02-07 17:47:59 -0500 | [diff] [blame] | 114 | |
Herb Derby | 39e45df | 2018-03-27 14:40:53 -0400 | [diff] [blame] | 115 | class Timer { |
| 116 | public: |
| 117 | void start() { |
| 118 | fStart = std::chrono::high_resolution_clock::now(); |
| 119 | } |
| 120 | |
| 121 | void stop() { |
| 122 | auto end = std::chrono::high_resolution_clock::now(); |
| 123 | fElapsedSeconds += end - fStart; |
| 124 | } |
| 125 | |
| 126 | double elapsedSeconds() { |
| 127 | return fElapsedSeconds.count(); |
| 128 | } |
| 129 | |
| 130 | private: |
| 131 | decltype(std::chrono::high_resolution_clock::now()) fStart; |
| 132 | std::chrono::duration<double> fElapsedSeconds{0.0}; |
| 133 | }; |
| 134 | |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 135 | static bool push_font_data(const SkPicture& pic, SkStrikeServer* strikeServer, int writeFd) { |
Herb Derby | 97be88f | 2018-03-21 16:23:49 -0400 | [diff] [blame] | 136 | SkMatrix deviceMatrix = SkMatrix::I(); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 137 | const SkIRect bounds = pic.cullRect().round(); |
| 138 | const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
| 139 | SkTextBlobCacheDiffCanvas filter(bounds.width(), bounds.height(), deviceMatrix, props, |
| 140 | strikeServer); |
Mike Klein | 8a23202 | 2018-05-02 13:54:11 +0000 | [diff] [blame] | 141 | pic.playback(&filter); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 142 | |
| 143 | std::vector<uint8_t> fontData; |
| 144 | strikeServer->writeStrikeData(&fontData); |
| 145 | auto data = SkData::MakeWithoutCopy(fontData.data(), fontData.size()); |
| 146 | return write_SkData(writeFd, *data); |
Herb Derby | 67c47f2 | 2018-02-07 17:47:59 -0500 | [diff] [blame] | 147 | } |
| 148 | |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 149 | static void final_draw(std::string outFilename, SkData* picData, SkStrikeClient* client, |
| 150 | ClientDiscardableManager* discardableManager, int readFd, int writeFd) { |
| 151 | SkDeserialProcs procs; |
| 152 | auto decode = [](const void* data, size_t length, void* ctx) -> sk_sp<SkTypeface> { |
| 153 | return reinterpret_cast<SkStrikeClient*>(ctx)->deserializeTypeface(data, length); |
| 154 | }; |
| 155 | procs.fTypefaceProc = decode; |
| 156 | procs.fTypefaceCtx = client; |
Herb Derby | 67c47f2 | 2018-02-07 17:47:59 -0500 | [diff] [blame] | 157 | |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 158 | auto pic = SkPicture::MakeFromData(picData, &procs); |
Herb Derby | 4f505f9 | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 159 | |
| 160 | auto cullRect = pic->cullRect(); |
| 161 | auto r = cullRect.round(); |
Herb Derby | 4f505f9 | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 162 | |
Herb Derby | d08c682 | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 163 | auto s = SkSurface::MakeRasterN32Premul(r.width(), r.height()); |
Herb Derby | 4f505f9 | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 164 | auto c = s->getCanvas(); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 165 | auto picUnderTest = SkPicture::MakeFromData(picData, &procs); |
Herb Derby | d08c682 | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 166 | |
Herb Derby | 39e45df | 2018-03-27 14:40:53 -0400 | [diff] [blame] | 167 | Timer drawTime; |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 168 | auto randomData = SkData::MakeUninitialized(1u); |
Herb Derby | 39e45df | 2018-03-27 14:40:53 -0400 | [diff] [blame] | 169 | for (int i = 0; i < 100; i++) { |
Herb Derby | 9d02182 | 2018-02-02 12:54:55 -0500 | [diff] [blame] | 170 | if (gPurgeFontCaches) { |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 171 | ClientDiscardableManager::ScopedPurgeCache purge(discardableManager); |
Herb Derby | 9d02182 | 2018-02-02 12:54:55 -0500 | [diff] [blame] | 172 | SkGraphics::PurgeFontCache(); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 173 | SkASSERT(SkGraphics::GetFontCacheUsed() == 0u); |
Herb Derby | 9d02182 | 2018-02-02 12:54:55 -0500 | [diff] [blame] | 174 | } |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 175 | |
Herb Derby | 39e45df | 2018-03-27 14:40:53 -0400 | [diff] [blame] | 176 | drawTime.start(); |
Herb Derby | 97be88f | 2018-03-21 16:23:49 -0400 | [diff] [blame] | 177 | if (client != nullptr) { |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 178 | // Kick the renderer to send us the fonts. |
| 179 | write_SkData(writeFd, *randomData); |
| 180 | auto fontData = read_SkData(readFd); |
| 181 | if (fontData && !fontData->isEmpty()) { |
| 182 | if (!client->readStrikeData(fontData->data(), fontData->size())) |
| 183 | SK_ABORT("Bad serialization"); |
| 184 | } |
Herb Derby | 67c47f2 | 2018-02-07 17:47:59 -0500 | [diff] [blame] | 185 | } |
Herb Derby | d08c682 | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 186 | c->drawPicture(picUnderTest); |
Herb Derby | 39e45df | 2018-03-27 14:40:53 -0400 | [diff] [blame] | 187 | drawTime.stop(); |
Herb Derby | d08c682 | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 188 | } |
Herb Derby | 4f505f9 | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 189 | |
Herb Derby | 9d02182 | 2018-02-02 12:54:55 -0500 | [diff] [blame] | 190 | std::cout << "useProcess: " << gUseProcess |
| 191 | << " useGPU: " << gUseGpu |
| 192 | << " purgeCache: " << gPurgeFontCaches << std::endl; |
Herb Derby | 67c47f2 | 2018-02-07 17:47:59 -0500 | [diff] [blame] | 193 | fprintf(stderr, "%s use GPU %s elapsed time %8.6f s\n", gSkpName.c_str(), |
Herb Derby | 39e45df | 2018-03-27 14:40:53 -0400 | [diff] [blame] | 194 | gUseGpu ? "true" : "false", drawTime.elapsedSeconds()); |
Herb Derby | 4f505f9 | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 195 | |
| 196 | auto i = s->makeImageSnapshot(); |
| 197 | auto data = i->encodeToData(); |
| 198 | SkFILEWStream f(outFilename.c_str()); |
| 199 | f.write(data->data(), data->size()); |
| 200 | } |
| 201 | |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 202 | static void gpu(int readFd, int writeFd) { |
| 203 | |
Herb Derby | 39e45df | 2018-03-27 14:40:53 -0400 | [diff] [blame] | 204 | if (gUseGpu) { |
Herb Derby | 209a5f3 | 2018-04-05 16:57:25 -0400 | [diff] [blame] | 205 | auto picData = read_SkData(readFd); |
Herb Derby | 39e45df | 2018-03-27 14:40:53 -0400 | [diff] [blame] | 206 | if (picData == nullptr) { |
| 207 | return; |
| 208 | } |
| 209 | |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 210 | sk_sp<ClientDiscardableManager> discardableManager = sk_make_sp<ClientDiscardableManager>(); |
| 211 | SkStrikeClient strikeClient(discardableManager); |
Herb Derby | 39e45df | 2018-03-27 14:40:53 -0400 | [diff] [blame] | 212 | |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 213 | final_draw("test.png", picData.get(), &strikeClient, discardableManager.get(), readFd, |
| 214 | writeFd); |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 215 | } |
| 216 | |
Herb Derby | 209a5f3 | 2018-04-05 16:57:25 -0400 | [diff] [blame] | 217 | ::close(writeFd); |
| 218 | ::close(readFd); |
| 219 | |
Herb Derby | 97be88f | 2018-03-21 16:23:49 -0400 | [diff] [blame] | 220 | printf("GPU is exiting\n"); |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 221 | } |
| 222 | |
Herb Derby | b2922f6 | 2018-01-26 16:47:54 -0500 | [diff] [blame] | 223 | static int renderer( |
| 224 | const std::string& skpName, int readFd, int writeFd) |
| 225 | { |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 226 | ServerDiscardableManager discardableManager; |
| 227 | SkStrikeServer server(&discardableManager); |
Herb Derby | 209a5f3 | 2018-04-05 16:57:25 -0400 | [diff] [blame] | 228 | auto closeAll = [readFd, writeFd]() { |
| 229 | ::close(writeFd); |
| 230 | ::close(readFd); |
| 231 | }; |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 232 | |
Herb Derby | 67c47f2 | 2018-02-07 17:47:59 -0500 | [diff] [blame] | 233 | auto skpData = SkData::MakeFromFileName(skpName.c_str()); |
| 234 | std::cout << "skp stream is " << skpData->size() << " bytes long " << std::endl; |
Herb Derby | 4f505f9 | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 235 | |
Herb Derby | 9d02182 | 2018-02-02 12:54:55 -0500 | [diff] [blame] | 236 | sk_sp<SkData> stream; |
| 237 | if (gUseGpu) { |
Herb Derby | 67c47f2 | 2018-02-07 17:47:59 -0500 | [diff] [blame] | 238 | auto pic = SkPicture::MakeFromData(skpData.get()); |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 239 | SkSerialProcs procs; |
| 240 | auto encode = [](SkTypeface* tf, void* ctx) -> sk_sp<SkData> { |
| 241 | return reinterpret_cast<SkStrikeServer*>(ctx)->serializeTypeface(tf); |
| 242 | }; |
| 243 | procs.fTypefaceProc = encode; |
| 244 | procs.fTypefaceCtx = &server; |
| 245 | |
Herb Derby | 9d02182 | 2018-02-02 12:54:55 -0500 | [diff] [blame] | 246 | stream = pic->serialize(&procs); |
Herb Derby | 97be88f | 2018-03-21 16:23:49 -0400 | [diff] [blame] | 247 | |
Herb Derby | 209a5f3 | 2018-04-05 16:57:25 -0400 | [diff] [blame] | 248 | if (!write_SkData(writeFd, *stream)) { |
| 249 | closeAll(); |
Herb Derby | 97be88f | 2018-03-21 16:23:49 -0400 | [diff] [blame] | 250 | return 1; |
| 251 | } |
| 252 | |
Herb Derby | 209a5f3 | 2018-04-05 16:57:25 -0400 | [diff] [blame] | 253 | while (true) { |
| 254 | auto inBuffer = read_SkData(readFd); |
| 255 | if (inBuffer == nullptr) { |
| 256 | closeAll(); |
| 257 | return 0; |
| 258 | } |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 259 | if (gPurgeFontCaches) discardableManager.purgeAll(); |
| 260 | push_font_data(*pic.get(), &server, writeFd); |
Herb Derby | 209a5f3 | 2018-04-05 16:57:25 -0400 | [diff] [blame] | 261 | } |
Herb Derby | 9d02182 | 2018-02-02 12:54:55 -0500 | [diff] [blame] | 262 | } else { |
Herb Derby | 67c47f2 | 2018-02-07 17:47:59 -0500 | [diff] [blame] | 263 | stream = skpData; |
Khushal | 38a0843 | 2018-05-02 10:29:37 -0700 | [diff] [blame] | 264 | final_draw("test-correct.png", stream.get(), nullptr, nullptr, -1, -1); |
Herb Derby | 209a5f3 | 2018-04-05 16:57:25 -0400 | [diff] [blame] | 265 | closeAll(); |
Herb Derby | 4f505f9 | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 266 | return 0; |
| 267 | } |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | int main(int argc, char** argv) { |
Herb Derby | 67c47f2 | 2018-02-07 17:47:59 -0500 | [diff] [blame] | 271 | std::string skpName = argc > 1 ? std::string{argv[1]} : std::string{"skps/desk_nytimes.skp"}; |
Herb Derby | 9d02182 | 2018-02-02 12:54:55 -0500 | [diff] [blame] | 272 | int mode = argc > 2 ? atoi(argv[2]) : -1; |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 273 | printf("skp: %s\n", skpName.c_str()); |
| 274 | |
Herb Derby | 67c47f2 | 2018-02-07 17:47:59 -0500 | [diff] [blame] | 275 | gSkpName = skpName; |
| 276 | |
Herb Derby | 97be88f | 2018-03-21 16:23:49 -0400 | [diff] [blame] | 277 | enum direction : int {kRead = 0, kWrite = 1}; |
| 278 | |
| 279 | |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 280 | int render_to_gpu[2], |
| 281 | gpu_to_render[2]; |
| 282 | |
Herb Derby | 9d02182 | 2018-02-02 12:54:55 -0500 | [diff] [blame] | 283 | for (int m = 0; m < 8; m++) { |
| 284 | int r = pipe(render_to_gpu); |
| 285 | if (r < 0) { |
| 286 | perror("Can't write picture from render to GPU "); |
| 287 | return 1; |
Herb Derby | d08c682 | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 288 | } |
Herb Derby | 9d02182 | 2018-02-02 12:54:55 -0500 | [diff] [blame] | 289 | r = pipe(gpu_to_render); |
| 290 | if (r < 0) { |
| 291 | perror("Can't write picture from render to GPU "); |
| 292 | return 1; |
| 293 | } |
| 294 | |
| 295 | gPurgeFontCaches = (m & 4) == 4; |
| 296 | gUseGpu = (m & 2) == 2; |
| 297 | gUseProcess = (m & 1) == 1; |
| 298 | |
| 299 | if (mode >= 0 && mode < 8 && mode != m) { |
| 300 | continue; |
| 301 | } |
| 302 | |
| 303 | if (gUseProcess) { |
| 304 | pid_t child = fork(); |
| 305 | SkGraphics::Init(); |
| 306 | |
| 307 | if (child == 0) { |
Herb Derby | 97be88f | 2018-03-21 16:23:49 -0400 | [diff] [blame] | 308 | close(gpu_to_render[kRead]); |
| 309 | close(render_to_gpu[kWrite]); |
| 310 | gpu(render_to_gpu[kRead], gpu_to_render[kWrite]); |
Herb Derby | 9d02182 | 2018-02-02 12:54:55 -0500 | [diff] [blame] | 311 | } else { |
Herb Derby | 97be88f | 2018-03-21 16:23:49 -0400 | [diff] [blame] | 312 | close(render_to_gpu[kRead]); |
| 313 | close(gpu_to_render[kWrite]); |
| 314 | renderer(skpName, gpu_to_render[kRead], render_to_gpu[kWrite]); |
Herb Derby | 9d02182 | 2018-02-02 12:54:55 -0500 | [diff] [blame] | 315 | waitpid(child, nullptr, 0); |
| 316 | } |
| 317 | } else { |
| 318 | SkGraphics::Init(); |
| 319 | std::thread(gpu, render_to_gpu[kRead], gpu_to_render[kWrite]).detach(); |
| 320 | renderer(skpName, gpu_to_render[kRead], render_to_gpu[kWrite]); |
| 321 | } |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 322 | } |
| 323 | |
Mike Klein | a8a51ce | 2018-01-09 12:34:11 -0500 | [diff] [blame] | 324 | return 0; |
| 325 | } |
| 326 | |