blob: f39da2a2fe424bad960631c5689f168fc5e75a45 [file] [log] [blame]
rileya@google.com2e2aedc2012-08-13 20:28:48 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "GrTextureStripAtlas.h"
bsalomonf276ac52015-10-09 13:36:42 -07009#include "GrContext.h"
Robert Phillips30f9bc62017-02-22 15:28:38 -050010#include "GrContextPriv.h"
Robert Phillips1afd4cd2018-01-08 13:40:32 -050011#include "GrProxyProvider.h"
Robert Phillips30f9bc62017-02-22 15:28:38 -050012#include "GrSurfaceContext.h"
bsalomonf276ac52015-10-09 13:36:42 -070013#include "SkGr.h"
rileya@google.com2e2aedc2012-08-13 20:28:48 +000014#include "SkPixelRef.h"
15#include "SkTSearch.h"
rileya@google.com2e2aedc2012-08-13 20:28:48 +000016
17#ifdef SK_DEBUG
18 #define VALIDATE this->validate()
19#else
20 #define VALIDATE
21#endif
22
cblume61214052016-01-26 09:10:48 -080023class GrTextureStripAtlas::Hash : public SkTDynamicHash<GrTextureStripAtlas::AtlasEntry,
joshualitt690fc752015-07-13 12:49:13 -070024 GrTextureStripAtlas::Desc> {};
robertphillips3d533ac2014-07-20 09:40:00 -070025
rileya@google.com2e2aedc2012-08-13 20:28:48 +000026int32_t GrTextureStripAtlas::gCacheCount = 0;
27
halcanary96fcdcc2015-08-27 07:41:13 -070028GrTextureStripAtlas::Hash* GrTextureStripAtlas::gAtlasCache = nullptr;
robertphillips@google.comcdb426d2012-09-24 19:33:59 +000029
robertphillips3d533ac2014-07-20 09:40:00 -070030GrTextureStripAtlas::Hash* GrTextureStripAtlas::GetCache() {
robertphillips@google.comcdb426d2012-09-24 19:33:59 +000031
halcanary96fcdcc2015-08-27 07:41:13 -070032 if (nullptr == gAtlasCache) {
halcanary385fe4d2015-08-26 13:07:48 -070033 gAtlasCache = new Hash;
robertphillips@google.comcdb426d2012-09-24 19:33:59 +000034 }
35
36 return gAtlasCache;
37}
38
39// Remove the specified atlas from the cache
sugoi@google.come0e385c2013-03-11 18:50:03 +000040void GrTextureStripAtlas::CleanUp(const GrContext*, void* info) {
bsalomon49f085d2014-09-05 13:34:00 -070041 SkASSERT(info);
robertphillips@google.comcdb426d2012-09-24 19:33:59 +000042
43 AtlasEntry* entry = static_cast<AtlasEntry*>(info);
44
45 // remove the cache entry
joshualitt690fc752015-07-13 12:49:13 -070046 GetCache()->remove(entry->fDesc);
robertphillips@google.comcdb426d2012-09-24 19:33:59 +000047
48 // remove the actual entry
halcanary385fe4d2015-08-26 13:07:48 -070049 delete entry;
robertphillips@google.comcdb426d2012-09-24 19:33:59 +000050
51 if (0 == GetCache()->count()) {
halcanary385fe4d2015-08-26 13:07:48 -070052 delete gAtlasCache;
halcanary96fcdcc2015-08-27 07:41:13 -070053 gAtlasCache = nullptr;
robertphillips@google.comcdb426d2012-09-24 19:33:59 +000054 }
55}
rileya@google.com2e2aedc2012-08-13 20:28:48 +000056
rileya@google.com2e2aedc2012-08-13 20:28:48 +000057GrTextureStripAtlas* GrTextureStripAtlas::GetAtlas(const GrTextureStripAtlas::Desc& desc) {
joshualitt690fc752015-07-13 12:49:13 -070058 AtlasEntry* entry = GetCache()->find(desc);
halcanary96fcdcc2015-08-27 07:41:13 -070059 if (nullptr == entry) {
halcanary385fe4d2015-08-26 13:07:48 -070060 entry = new AtlasEntry;
robertphillips@google.comcdb426d2012-09-24 19:33:59 +000061
halcanary385fe4d2015-08-26 13:07:48 -070062 entry->fAtlas = new GrTextureStripAtlas(desc);
joshualitt690fc752015-07-13 12:49:13 -070063 entry->fDesc = desc;
robertphillips@google.comcdb426d2012-09-24 19:33:59 +000064
65 desc.fContext->addCleanUp(CleanUp, entry);
66
robertphillips3d533ac2014-07-20 09:40:00 -070067 GetCache()->add(entry);
rileya@google.com2e2aedc2012-08-13 20:28:48 +000068 }
robertphillips@google.comcdb426d2012-09-24 19:33:59 +000069
70 return entry->fAtlas;
rileya@google.com2e2aedc2012-08-13 20:28:48 +000071}
72
rmistry@google.comfbfcd562012-08-23 18:09:54 +000073GrTextureStripAtlas::GrTextureStripAtlas(GrTextureStripAtlas::Desc desc)
bsalomon@google.com0797c2c2012-12-20 15:13:01 +000074 : fCacheKey(sk_atomic_inc(&gCacheCount))
rileya@google.com2e2aedc2012-08-13 20:28:48 +000075 , fLockedRows(0)
76 , fDesc(desc)
77 , fNumRows(desc.fHeight / desc.fRowHeight)
halcanary385fe4d2015-08-26 13:07:48 -070078 , fRows(new AtlasRow[fNumRows])
halcanary96fcdcc2015-08-27 07:41:13 -070079 , fLRUFront(nullptr)
80 , fLRUBack(nullptr) {
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +000081 SkASSERT(fNumRows * fDesc.fRowHeight == fDesc.fHeight);
rileya@google.com2e2aedc2012-08-13 20:28:48 +000082 this->initLRU();
bsalomonc6327a82014-10-27 12:53:08 -070083 fNormalizedYHeight = SK_Scalar1 / fDesc.fHeight;
rileya@google.com2e2aedc2012-08-13 20:28:48 +000084 VALIDATE;
85}
86
halcanary385fe4d2015-08-26 13:07:48 -070087GrTextureStripAtlas::~GrTextureStripAtlas() { delete[] fRows; }
rileya@google.com2e2aedc2012-08-13 20:28:48 +000088
Brian Salomon0e05a822017-07-25 09:43:22 -040089void GrTextureStripAtlas::lockRow(int row) {
90 // This should only be called on a row that is already locked.
91 SkASSERT(fRows[row].fLocks);
92 fRows[row].fLocks++;
93 ++fLockedRows;
94}
95
Robert Phillips30f9bc62017-02-22 15:28:38 -050096int GrTextureStripAtlas::lockRow(const SkBitmap& bitmap) {
rileya@google.com2e2aedc2012-08-13 20:28:48 +000097 VALIDATE;
98 if (0 == fLockedRows) {
99 this->lockTexture();
Robert Phillips30f9bc62017-02-22 15:28:38 -0500100 if (!fTexContext) {
joshualitt5f5a8d72015-02-25 14:09:45 -0800101 return -1;
102 }
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000103 }
104
Robert Phillips30f9bc62017-02-22 15:28:38 -0500105 int key = bitmap.getGenerationID();
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000106 int rowNumber = -1;
107 int index = this->searchByKey(key);
108
109 if (index >= 0) {
110 // We already have the data in a row, so we can just return that row
111 AtlasRow* row = fKeyTable[index];
112 if (0 == row->fLocks) {
113 this->removeFromLRU(row);
114 }
115 ++row->fLocks;
rileya@google.comb3e50f22012-08-20 17:43:08 +0000116 ++fLockedRows;
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000117
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000118 // Since all the rows are always stored in a contiguous array, we can save the memory
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000119 // required for storing row numbers and just compute it with some pointer arithmetic
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000120 rowNumber = static_cast<int>(row - fRows);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000121 } else {
122 // ~index is the index where we will insert the new key to keep things sorted
123 index = ~index;
124
125 // We don't have this data cached, so pick the least recently used row to copy into
126 AtlasRow* row = this->getLRU();
127
rileya@google.comb3e50f22012-08-20 17:43:08 +0000128 ++fLockedRows;
129
halcanary96fcdcc2015-08-27 07:41:13 -0700130 if (nullptr == row) {
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000131 // force a flush, which should unlock all the rows; then try again
Robert Phillips7ee385e2017-03-30 08:02:11 -0400132 fDesc.fContext->contextPriv().flush(nullptr); // tighten this up?
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000133 row = this->getLRU();
halcanary96fcdcc2015-08-27 07:41:13 -0700134 if (nullptr == row) {
rileya@google.comb3e50f22012-08-20 17:43:08 +0000135 --fLockedRows;
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000136 return -1;
137 }
138 }
139
140 this->removeFromLRU(row);
141
142 uint32_t oldKey = row->fKey;
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000143
144 // If we are writing into a row that already held bitmap data, we need to remove the
145 // reference to that genID which is stored in our sorted table of key values.
146 if (oldKey != kEmptyAtlasRowKey) {
147
148 // Find the entry in the list; if it's before the index where we plan on adding the new
149 // entry, we decrement since it will shift elements ahead of it back by one.
150 int oldIndex = this->searchByKey(oldKey);
rileya@google.comb3e50f22012-08-20 17:43:08 +0000151 if (oldIndex < index) {
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000152 --index;
153 }
154
155 fKeyTable.remove(oldIndex);
156 }
157
rileya@google.comb3e50f22012-08-20 17:43:08 +0000158 row->fKey = key;
159 row->fLocks = 1;
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000160 fKeyTable.insert(index, 1, &row);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000161 rowNumber = static_cast<int>(row - fRows);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000162
Robert Phillips30f9bc62017-02-22 15:28:38 -0500163 SkASSERT(bitmap.width() == fDesc.fWidth);
164 SkASSERT(bitmap.height() == fDesc.fRowHeight);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000165
166 // Pass in the kDontFlush flag, since we know we're writing to a part of this texture
167 // that is not currently in use
Robert Phillips30f9bc62017-02-22 15:28:38 -0500168 fTexContext->writePixels(bitmap.info(), bitmap.getPixels(), bitmap.rowBytes(),
169 0, rowNumber * fDesc.fRowHeight,
Robert Phillipse78b7252017-04-06 07:59:41 -0400170 GrContextPriv::kDontFlush_PixelOpsFlag);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000171 }
172
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000173 SkASSERT(rowNumber >= 0);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000174 VALIDATE;
175 return rowNumber;
176}
177
Robert Phillips30f9bc62017-02-22 15:28:38 -0500178sk_sp<GrTextureProxy> GrTextureStripAtlas::asTextureProxyRef() const {
179 return fTexContext->asTextureProxyRef();
180}
181
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000182void GrTextureStripAtlas::unlockRow(int row) {
183 VALIDATE;
184 --fRows[row].fLocks;
185 --fLockedRows;
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000186 SkASSERT(fRows[row].fLocks >= 0 && fLockedRows >= 0);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000187 if (0 == fRows[row].fLocks) {
188 this->appendLRU(fRows + row);
189 }
190 if (0 == fLockedRows) {
191 this->unlockTexture();
192 }
193 VALIDATE;
194}
195
196GrTextureStripAtlas::AtlasRow* GrTextureStripAtlas::getLRU() {
197 // Front is least-recently-used
198 AtlasRow* row = fLRUFront;
199 return row;
200}
201
202void GrTextureStripAtlas::lockTexture() {
skia.committer@gmail.com2859eb72012-12-21 02:01:28 +0000203
bsalomon8718aaf2015-02-19 07:24:21 -0800204 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
205 GrUniqueKey key;
206 GrUniqueKey::Builder builder(&key, kDomain, 1);
bsalomon24db3b12015-01-23 04:24:04 -0800207 builder[0] = static_cast<uint32_t>(fCacheKey);
208 builder.finish();
bsalomon@google.com0797c2c2012-12-20 15:13:01 +0000209
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500210 GrProxyProvider* proxyProvider = fDesc.fContext->contextPriv().proxyProvider();
211
212 sk_sp<GrTextureProxy> proxy = proxyProvider->findOrCreateProxyByUniqueKey(
Robert Phillips066f0202017-07-25 10:16:35 -0400213 key, kTopLeft_GrSurfaceOrigin);
Robert Phillipsd3749482017-03-14 09:17:43 -0400214 if (!proxy) {
Robert Phillipse44ef102017-07-21 15:37:19 -0400215 GrSurfaceDesc texDesc;
216 texDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
217 texDesc.fWidth = fDesc.fWidth;
218 texDesc.fHeight = fDesc.fHeight;
219 texDesc.fConfig = fDesc.fConfig;
220
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500221 proxy = GrSurfaceProxy::MakeDeferred(proxyProvider,
Robert Phillips26c90e02017-03-14 14:39:29 -0400222 texDesc, SkBackingFit::kExact,
Robert Phillipsd3749482017-03-14 09:17:43 -0400223 SkBudgeted::kYes,
224 GrResourceProvider::kNoPendingIO_Flag);
225 if (!proxy) {
joshualitt5f5a8d72015-02-25 14:09:45 -0800226 return;
227 }
ajuma95243eb2016-08-24 08:19:02 -0700228
Robert Phillipse44ef102017-07-21 15:37:19 -0400229 SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500230 proxyProvider->assignUniqueKeyToProxy(key, proxy.get());
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000231 // This is a new texture, so all of our cache info is now invalid
232 this->initLRU();
233 fKeyTable.rewind();
234 }
Robert Phillipsd3749482017-03-14 09:17:43 -0400235 SkASSERT(proxy);
236 fTexContext = fDesc.fContext->contextPriv().makeWrappedSurfaceContext(std::move(proxy),
237 nullptr);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000238}
239
240void GrTextureStripAtlas::unlockTexture() {
Robert Phillips30f9bc62017-02-22 15:28:38 -0500241 SkASSERT(fTexContext && 0 == fLockedRows);
242 fTexContext.reset();
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000243}
244
245void GrTextureStripAtlas::initLRU() {
halcanary96fcdcc2015-08-27 07:41:13 -0700246 fLRUFront = nullptr;
247 fLRUBack = nullptr;
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000248 // Initially all the rows are in the LRU list
249 for (int i = 0; i < fNumRows; ++i) {
250 fRows[i].fKey = kEmptyAtlasRowKey;
halcanary96fcdcc2015-08-27 07:41:13 -0700251 fRows[i].fNext = nullptr;
252 fRows[i].fPrev = nullptr;
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000253 this->appendLRU(fRows + i);
254 }
halcanary96fcdcc2015-08-27 07:41:13 -0700255 SkASSERT(nullptr == fLRUFront || nullptr == fLRUFront->fPrev);
256 SkASSERT(nullptr == fLRUBack || nullptr == fLRUBack->fNext);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000257}
258
259void GrTextureStripAtlas::appendLRU(AtlasRow* row) {
halcanary96fcdcc2015-08-27 07:41:13 -0700260 SkASSERT(nullptr == row->fPrev && nullptr == row->fNext);
261 if (nullptr == fLRUFront && nullptr == fLRUBack) {
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000262 fLRUFront = row;
263 fLRUBack = row;
264 } else {
265 row->fPrev = fLRUBack;
266 fLRUBack->fNext = row;
267 fLRUBack = row;
268 }
269}
270
271void GrTextureStripAtlas::removeFromLRU(AtlasRow* row) {
bsalomon49f085d2014-09-05 13:34:00 -0700272 SkASSERT(row);
273 if (row->fNext && row->fPrev) {
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000274 row->fPrev->fNext = row->fNext;
275 row->fNext->fPrev = row->fPrev;
276 } else {
halcanary96fcdcc2015-08-27 07:41:13 -0700277 if (nullptr == row->fNext) {
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000278 SkASSERT(row == fLRUBack);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000279 fLRUBack = row->fPrev;
rileya@google.comb3e50f22012-08-20 17:43:08 +0000280 if (fLRUBack) {
halcanary96fcdcc2015-08-27 07:41:13 -0700281 fLRUBack->fNext = nullptr;
rileya@google.comb3e50f22012-08-20 17:43:08 +0000282 }
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000283 }
halcanary96fcdcc2015-08-27 07:41:13 -0700284 if (nullptr == row->fPrev) {
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000285 SkASSERT(row == fLRUFront);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000286 fLRUFront = row->fNext;
rileya@google.comb3e50f22012-08-20 17:43:08 +0000287 if (fLRUFront) {
halcanary96fcdcc2015-08-27 07:41:13 -0700288 fLRUFront->fPrev = nullptr;
rileya@google.comb3e50f22012-08-20 17:43:08 +0000289 }
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000290 }
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000291 }
halcanary96fcdcc2015-08-27 07:41:13 -0700292 row->fNext = nullptr;
293 row->fPrev = nullptr;
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000294}
295
296int GrTextureStripAtlas::searchByKey(uint32_t key) {
297 AtlasRow target;
298 target.fKey = key;
bsalomon@google.com20f7f172013-05-17 19:05:03 +0000299 return SkTSearch<const AtlasRow,
300 GrTextureStripAtlas::KeyLess>((const AtlasRow**)fKeyTable.begin(),
301 fKeyTable.count(),
302 &target,
303 sizeof(AtlasRow*));
skia.committer@gmail.com845220b2013-05-20 11:51:35 +0000304}
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000305
306#ifdef SK_DEBUG
307void GrTextureStripAtlas::validate() {
308
309 // Our key table should be sorted
310 uint32_t prev = 1 > fKeyTable.count() ? 0 : fKeyTable[0]->fKey;
311 for (int i = 1; i < fKeyTable.count(); ++i) {
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000312 SkASSERT(prev < fKeyTable[i]->fKey);
313 SkASSERT(fKeyTable[i]->fKey != kEmptyAtlasRowKey);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000314 prev = fKeyTable[i]->fKey;
315 }
316
317 int lruCount = 0;
318 // Validate LRU pointers, and count LRU entries
halcanary96fcdcc2015-08-27 07:41:13 -0700319 SkASSERT(nullptr == fLRUFront || nullptr == fLRUFront->fPrev);
320 SkASSERT(nullptr == fLRUBack || nullptr == fLRUBack->fNext);
321 for (AtlasRow* r = fLRUFront; r != nullptr; r = r->fNext) {
322 if (nullptr == r->fNext) {
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000323 SkASSERT(r == fLRUBack);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000324 } else {
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000325 SkASSERT(r->fNext->fPrev == r);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000326 }
327 ++lruCount;
328 }
329
330 int rowLocks = 0;
331 int freeRows = 0;
332
333 for (int i = 0; i < fNumRows; ++i) {
334 rowLocks += fRows[i].fLocks;
335 if (0 == fRows[i].fLocks) {
336 ++freeRows;
337 bool inLRU = false;
338 // Step through the LRU and make sure it's present
halcanary96fcdcc2015-08-27 07:41:13 -0700339 for (AtlasRow* r = fLRUFront; r != nullptr; r = r->fNext) {
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000340 if (r == &fRows[i]) {
341 inLRU = true;
342 break;
343 }
344 }
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000345 SkASSERT(inLRU);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000346 } else {
347 // If we are locked, we should have a key
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000348 SkASSERT(kEmptyAtlasRowKey != fRows[i].fKey);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000349 }
350
351 // If we have a key != kEmptyAtlasRowKey, it should be in the key table
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000352 SkASSERT(fRows[i].fKey == kEmptyAtlasRowKey || this->searchByKey(fRows[i].fKey) >= 0);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000353 }
354
rileya@google.comb3e50f22012-08-20 17:43:08 +0000355 // Our count of locks should equal the sum of row locks, unless we ran out of rows and flushed,
356 // in which case we'll have one more lock than recorded in the rows (to represent the pending
357 // lock of a row; which ensures we don't unlock the texture prematurely).
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000358 SkASSERT(rowLocks == fLockedRows || rowLocks + 1 == fLockedRows);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000359
360 // We should have one lru entry for each free row
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000361 SkASSERT(freeRows == lruCount);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000362
363 // If we have locked rows, we should have a locked texture, otherwise
364 // it should be unlocked
365 if (fLockedRows == 0) {
Robert Phillips30f9bc62017-02-22 15:28:38 -0500366 SkASSERT(!fTexContext);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000367 } else {
Robert Phillips30f9bc62017-02-22 15:28:38 -0500368 SkASSERT(fTexContext);
rileya@google.com2e2aedc2012-08-13 20:28:48 +0000369 }
370}
371#endif