node.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. /*
  2. * Copyright 2011-2016 Blender Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include "graph/node.h"
  17. #include "graph/node_type.h"
  18. #include "util/util_foreach.h"
  19. #include "util/util_md5.h"
  20. #include "util/util_param.h"
  21. #include "util/util_transform.h"
  22. CCL_NAMESPACE_BEGIN
  23. /* Node Type */
  24. Node::Node(const NodeType *type_, ustring name_) : name(name_), type(type_)
  25. {
  26. assert(type);
  27. /* assign non-empty name, convenient for debugging */
  28. if (name.empty()) {
  29. name = type->name;
  30. }
  31. /* initialize default values */
  32. foreach (const SocketType &socket, type->inputs) {
  33. set_default_value(socket);
  34. }
  35. }
  36. Node::~Node()
  37. {
  38. }
  39. template<typename T> static T &get_socket_value(const Node *node, const SocketType &socket)
  40. {
  41. return (T &)*(((char *)node) + socket.struct_offset);
  42. }
  43. #ifndef NDEBUG
  44. static bool is_socket_float3(const SocketType &socket)
  45. {
  46. return socket.type == SocketType::COLOR || socket.type == SocketType::POINT ||
  47. socket.type == SocketType::VECTOR || socket.type == SocketType::NORMAL;
  48. }
  49. static bool is_socket_array_float3(const SocketType &socket)
  50. {
  51. return socket.type == SocketType::COLOR_ARRAY || socket.type == SocketType::POINT_ARRAY ||
  52. socket.type == SocketType::VECTOR_ARRAY || socket.type == SocketType::NORMAL_ARRAY;
  53. }
  54. #endif
  55. /* set values */
  56. void Node::set(const SocketType &input, bool value)
  57. {
  58. assert(input.type == SocketType::BOOLEAN);
  59. get_socket_value<bool>(this, input) = value;
  60. }
  61. void Node::set(const SocketType &input, int value)
  62. {
  63. assert((input.type == SocketType::INT || input.type == SocketType::ENUM));
  64. get_socket_value<int>(this, input) = value;
  65. }
  66. void Node::set(const SocketType &input, uint value)
  67. {
  68. assert(input.type == SocketType::UINT);
  69. get_socket_value<uint>(this, input) = value;
  70. }
  71. void Node::set(const SocketType &input, float value)
  72. {
  73. assert(input.type == SocketType::FLOAT);
  74. get_socket_value<float>(this, input) = value;
  75. }
  76. void Node::set(const SocketType &input, float2 value)
  77. {
  78. assert(input.type == SocketType::FLOAT);
  79. get_socket_value<float2>(this, input) = value;
  80. }
  81. void Node::set(const SocketType &input, float3 value)
  82. {
  83. assert(is_socket_float3(input));
  84. get_socket_value<float3>(this, input) = value;
  85. }
  86. void Node::set(const SocketType &input, const char *value)
  87. {
  88. set(input, ustring(value));
  89. }
  90. void Node::set(const SocketType &input, ustring value)
  91. {
  92. if (input.type == SocketType::STRING) {
  93. get_socket_value<ustring>(this, input) = value;
  94. }
  95. else if (input.type == SocketType::ENUM) {
  96. const NodeEnum &enm = *input.enum_values;
  97. if (enm.exists(value)) {
  98. get_socket_value<int>(this, input) = enm[value];
  99. }
  100. else {
  101. assert(0);
  102. }
  103. }
  104. else {
  105. assert(0);
  106. }
  107. }
  108. void Node::set(const SocketType &input, const Transform &value)
  109. {
  110. assert(input.type == SocketType::TRANSFORM);
  111. get_socket_value<Transform>(this, input) = value;
  112. }
  113. void Node::set(const SocketType &input, Node *value)
  114. {
  115. assert(input.type == SocketType::TRANSFORM);
  116. get_socket_value<Node *>(this, input) = value;
  117. }
  118. /* set array values */
  119. void Node::set(const SocketType &input, array<bool> &value)
  120. {
  121. assert(input.type == SocketType::BOOLEAN_ARRAY);
  122. get_socket_value<array<bool>>(this, input).steal_data(value);
  123. }
  124. void Node::set(const SocketType &input, array<int> &value)
  125. {
  126. assert(input.type == SocketType::INT_ARRAY);
  127. get_socket_value<array<int>>(this, input).steal_data(value);
  128. }
  129. void Node::set(const SocketType &input, array<float> &value)
  130. {
  131. assert(input.type == SocketType::FLOAT_ARRAY);
  132. get_socket_value<array<float>>(this, input).steal_data(value);
  133. }
  134. void Node::set(const SocketType &input, array<float2> &value)
  135. {
  136. assert(input.type == SocketType::FLOAT_ARRAY);
  137. get_socket_value<array<float2>>(this, input).steal_data(value);
  138. }
  139. void Node::set(const SocketType &input, array<float3> &value)
  140. {
  141. assert(is_socket_array_float3(input));
  142. get_socket_value<array<float3>>(this, input).steal_data(value);
  143. }
  144. void Node::set(const SocketType &input, array<ustring> &value)
  145. {
  146. assert(input.type == SocketType::STRING_ARRAY);
  147. get_socket_value<array<ustring>>(this, input).steal_data(value);
  148. }
  149. void Node::set(const SocketType &input, array<Transform> &value)
  150. {
  151. assert(input.type == SocketType::TRANSFORM_ARRAY);
  152. get_socket_value<array<Transform>>(this, input).steal_data(value);
  153. }
  154. void Node::set(const SocketType &input, array<Node *> &value)
  155. {
  156. assert(input.type == SocketType::TRANSFORM_ARRAY);
  157. get_socket_value<array<Node *>>(this, input).steal_data(value);
  158. }
  159. /* get values */
  160. bool Node::get_bool(const SocketType &input) const
  161. {
  162. assert(input.type == SocketType::BOOLEAN);
  163. return get_socket_value<bool>(this, input);
  164. }
  165. int Node::get_int(const SocketType &input) const
  166. {
  167. assert(input.type == SocketType::INT || input.type == SocketType::ENUM);
  168. return get_socket_value<int>(this, input);
  169. }
  170. uint Node::get_uint(const SocketType &input) const
  171. {
  172. assert(input.type == SocketType::UINT);
  173. return get_socket_value<uint>(this, input);
  174. }
  175. float Node::get_float(const SocketType &input) const
  176. {
  177. assert(input.type == SocketType::FLOAT);
  178. return get_socket_value<float>(this, input);
  179. }
  180. float2 Node::get_float2(const SocketType &input) const
  181. {
  182. assert(input.type == SocketType::FLOAT);
  183. return get_socket_value<float2>(this, input);
  184. }
  185. float3 Node::get_float3(const SocketType &input) const
  186. {
  187. assert(is_socket_float3(input));
  188. return get_socket_value<float3>(this, input);
  189. }
  190. ustring Node::get_string(const SocketType &input) const
  191. {
  192. if (input.type == SocketType::STRING) {
  193. return get_socket_value<ustring>(this, input);
  194. }
  195. else if (input.type == SocketType::ENUM) {
  196. const NodeEnum &enm = *input.enum_values;
  197. int intvalue = get_socket_value<int>(this, input);
  198. return (enm.exists(intvalue)) ? enm[intvalue] : ustring();
  199. }
  200. else {
  201. assert(0);
  202. return ustring();
  203. }
  204. }
  205. Transform Node::get_transform(const SocketType &input) const
  206. {
  207. assert(input.type == SocketType::TRANSFORM);
  208. return get_socket_value<Transform>(this, input);
  209. }
  210. Node *Node::get_node(const SocketType &input) const
  211. {
  212. assert(input.type == SocketType::NODE);
  213. return get_socket_value<Node *>(this, input);
  214. }
  215. /* get array values */
  216. const array<bool> &Node::get_bool_array(const SocketType &input) const
  217. {
  218. assert(input.type == SocketType::BOOLEAN_ARRAY);
  219. return get_socket_value<array<bool>>(this, input);
  220. }
  221. const array<int> &Node::get_int_array(const SocketType &input) const
  222. {
  223. assert(input.type == SocketType::INT_ARRAY);
  224. return get_socket_value<array<int>>(this, input);
  225. }
  226. const array<float> &Node::get_float_array(const SocketType &input) const
  227. {
  228. assert(input.type == SocketType::FLOAT_ARRAY);
  229. return get_socket_value<array<float>>(this, input);
  230. }
  231. const array<float2> &Node::get_float2_array(const SocketType &input) const
  232. {
  233. assert(input.type == SocketType::FLOAT_ARRAY);
  234. return get_socket_value<array<float2>>(this, input);
  235. }
  236. const array<float3> &Node::get_float3_array(const SocketType &input) const
  237. {
  238. assert(is_socket_array_float3(input));
  239. return get_socket_value<array<float3>>(this, input);
  240. }
  241. const array<ustring> &Node::get_string_array(const SocketType &input) const
  242. {
  243. assert(input.type == SocketType::STRING_ARRAY);
  244. return get_socket_value<array<ustring>>(this, input);
  245. }
  246. const array<Transform> &Node::get_transform_array(const SocketType &input) const
  247. {
  248. assert(input.type == SocketType::TRANSFORM_ARRAY);
  249. return get_socket_value<array<Transform>>(this, input);
  250. }
  251. const array<Node *> &Node::get_node_array(const SocketType &input) const
  252. {
  253. assert(input.type == SocketType::NODE_ARRAY);
  254. return get_socket_value<array<Node *>>(this, input);
  255. }
  256. /* generic value operations */
  257. bool Node::has_default_value(const SocketType &input) const
  258. {
  259. const void *src = input.default_value;
  260. void *dst = &get_socket_value<char>(this, input);
  261. return memcmp(dst, src, input.size()) == 0;
  262. }
  263. void Node::set_default_value(const SocketType &socket)
  264. {
  265. const void *src = socket.default_value;
  266. void *dst = ((char *)this) + socket.struct_offset;
  267. if (socket.size() > 0) {
  268. memcpy(dst, src, socket.size());
  269. }
  270. }
  271. template<typename T>
  272. static void copy_array(const Node *node,
  273. const SocketType &socket,
  274. const Node *other,
  275. const SocketType &other_socket)
  276. {
  277. const array<T> *src = (const array<T> *)(((char *)other) + other_socket.struct_offset);
  278. array<T> *dst = (array<T> *)(((char *)node) + socket.struct_offset);
  279. *dst = *src;
  280. }
  281. void Node::copy_value(const SocketType &socket, const Node &other, const SocketType &other_socket)
  282. {
  283. assert(socket.type == other_socket.type);
  284. if (socket.is_array()) {
  285. switch (socket.type) {
  286. case SocketType::BOOLEAN_ARRAY:
  287. copy_array<bool>(this, socket, &other, other_socket);
  288. break;
  289. case SocketType::FLOAT_ARRAY:
  290. copy_array<float>(this, socket, &other, other_socket);
  291. break;
  292. case SocketType::INT_ARRAY:
  293. copy_array<int>(this, socket, &other, other_socket);
  294. break;
  295. case SocketType::COLOR_ARRAY:
  296. copy_array<float3>(this, socket, &other, other_socket);
  297. break;
  298. case SocketType::VECTOR_ARRAY:
  299. copy_array<float3>(this, socket, &other, other_socket);
  300. break;
  301. case SocketType::POINT_ARRAY:
  302. copy_array<float3>(this, socket, &other, other_socket);
  303. break;
  304. case SocketType::NORMAL_ARRAY:
  305. copy_array<float3>(this, socket, &other, other_socket);
  306. break;
  307. case SocketType::POINT2_ARRAY:
  308. copy_array<float2>(this, socket, &other, other_socket);
  309. break;
  310. case SocketType::STRING_ARRAY:
  311. copy_array<ustring>(this, socket, &other, other_socket);
  312. break;
  313. case SocketType::TRANSFORM_ARRAY:
  314. copy_array<Transform>(this, socket, &other, other_socket);
  315. break;
  316. case SocketType::NODE_ARRAY:
  317. copy_array<void *>(this, socket, &other, other_socket);
  318. break;
  319. default:
  320. assert(0);
  321. break;
  322. }
  323. }
  324. else {
  325. const void *src = ((char *)&other) + other_socket.struct_offset;
  326. void *dst = ((char *)this) + socket.struct_offset;
  327. memcpy(dst, src, socket.size());
  328. }
  329. }
  330. template<typename T>
  331. static bool is_array_equal(const Node *node, const Node *other, const SocketType &socket)
  332. {
  333. const array<T> *a = (const array<T> *)(((char *)node) + socket.struct_offset);
  334. const array<T> *b = (const array<T> *)(((char *)other) + socket.struct_offset);
  335. return *a == *b;
  336. }
  337. template<typename T>
  338. static bool is_value_equal(const Node *node, const Node *other, const SocketType &socket)
  339. {
  340. const T *a = (const T *)(((char *)node) + socket.struct_offset);
  341. const T *b = (const T *)(((char *)other) + socket.struct_offset);
  342. return *a == *b;
  343. }
  344. bool Node::equals_value(const Node &other, const SocketType &socket) const
  345. {
  346. switch (socket.type) {
  347. case SocketType::BOOLEAN:
  348. return is_value_equal<bool>(this, &other, socket);
  349. case SocketType::FLOAT:
  350. return is_value_equal<float>(this, &other, socket);
  351. case SocketType::INT:
  352. return is_value_equal<int>(this, &other, socket);
  353. case SocketType::UINT:
  354. return is_value_equal<uint>(this, &other, socket);
  355. case SocketType::COLOR:
  356. return is_value_equal<float3>(this, &other, socket);
  357. case SocketType::VECTOR:
  358. return is_value_equal<float3>(this, &other, socket);
  359. case SocketType::POINT:
  360. return is_value_equal<float3>(this, &other, socket);
  361. case SocketType::NORMAL:
  362. return is_value_equal<float3>(this, &other, socket);
  363. case SocketType::POINT2:
  364. return is_value_equal<float2>(this, &other, socket);
  365. case SocketType::CLOSURE:
  366. return true;
  367. case SocketType::STRING:
  368. return is_value_equal<ustring>(this, &other, socket);
  369. case SocketType::ENUM:
  370. return is_value_equal<int>(this, &other, socket);
  371. case SocketType::TRANSFORM:
  372. return is_value_equal<Transform>(this, &other, socket);
  373. case SocketType::NODE:
  374. return is_value_equal<void *>(this, &other, socket);
  375. case SocketType::BOOLEAN_ARRAY:
  376. return is_array_equal<bool>(this, &other, socket);
  377. case SocketType::FLOAT_ARRAY:
  378. return is_array_equal<float>(this, &other, socket);
  379. case SocketType::INT_ARRAY:
  380. return is_array_equal<int>(this, &other, socket);
  381. case SocketType::COLOR_ARRAY:
  382. return is_array_equal<float3>(this, &other, socket);
  383. case SocketType::VECTOR_ARRAY:
  384. return is_array_equal<float3>(this, &other, socket);
  385. case SocketType::POINT_ARRAY:
  386. return is_array_equal<float3>(this, &other, socket);
  387. case SocketType::NORMAL_ARRAY:
  388. return is_array_equal<float3>(this, &other, socket);
  389. case SocketType::POINT2_ARRAY:
  390. return is_array_equal<float2>(this, &other, socket);
  391. case SocketType::STRING_ARRAY:
  392. return is_array_equal<ustring>(this, &other, socket);
  393. case SocketType::TRANSFORM_ARRAY:
  394. return is_array_equal<Transform>(this, &other, socket);
  395. case SocketType::NODE_ARRAY:
  396. return is_array_equal<void *>(this, &other, socket);
  397. case SocketType::UNDEFINED:
  398. return true;
  399. }
  400. return true;
  401. }
  402. /* equals */
  403. bool Node::equals(const Node &other) const
  404. {
  405. assert(type == other.type);
  406. foreach (const SocketType &socket, type->inputs) {
  407. if (!equals_value(other, socket))
  408. return false;
  409. }
  410. return true;
  411. }
  412. /* Hash */
  413. namespace {
  414. template<typename T> void value_hash(const Node *node, const SocketType &socket, MD5Hash &md5)
  415. {
  416. md5.append(((uint8_t *)node) + socket.struct_offset, socket.size());
  417. }
  418. void float3_hash(const Node *node, const SocketType &socket, MD5Hash &md5)
  419. {
  420. /* Don't compare 4th element used for padding. */
  421. md5.append(((uint8_t *)node) + socket.struct_offset, sizeof(float) * 3);
  422. }
  423. template<typename T> void array_hash(const Node *node, const SocketType &socket, MD5Hash &md5)
  424. {
  425. const array<T> &a = *(const array<T> *)(((char *)node) + socket.struct_offset);
  426. for (size_t i = 0; i < a.size(); i++) {
  427. md5.append((uint8_t *)&a[i], sizeof(T));
  428. }
  429. }
  430. void float3_array_hash(const Node *node, const SocketType &socket, MD5Hash &md5)
  431. {
  432. /* Don't compare 4th element used for padding. */
  433. const array<float3> &a = *(const array<float3> *)(((char *)node) + socket.struct_offset);
  434. for (size_t i = 0; i < a.size(); i++) {
  435. md5.append((uint8_t *)&a[i], sizeof(float) * 3);
  436. }
  437. }
  438. } // namespace
  439. void Node::hash(MD5Hash &md5)
  440. {
  441. md5.append(type->name.string());
  442. foreach (const SocketType &socket, type->inputs) {
  443. md5.append(socket.name.string());
  444. switch (socket.type) {
  445. case SocketType::BOOLEAN:
  446. value_hash<bool>(this, socket, md5);
  447. break;
  448. case SocketType::FLOAT:
  449. value_hash<float>(this, socket, md5);
  450. break;
  451. case SocketType::INT:
  452. value_hash<int>(this, socket, md5);
  453. break;
  454. case SocketType::UINT:
  455. value_hash<uint>(this, socket, md5);
  456. break;
  457. case SocketType::COLOR:
  458. float3_hash(this, socket, md5);
  459. break;
  460. case SocketType::VECTOR:
  461. float3_hash(this, socket, md5);
  462. break;
  463. case SocketType::POINT:
  464. float3_hash(this, socket, md5);
  465. break;
  466. case SocketType::NORMAL:
  467. float3_hash(this, socket, md5);
  468. break;
  469. case SocketType::POINT2:
  470. value_hash<float2>(this, socket, md5);
  471. break;
  472. case SocketType::CLOSURE:
  473. break;
  474. case SocketType::STRING:
  475. value_hash<ustring>(this, socket, md5);
  476. break;
  477. case SocketType::ENUM:
  478. value_hash<int>(this, socket, md5);
  479. break;
  480. case SocketType::TRANSFORM:
  481. value_hash<Transform>(this, socket, md5);
  482. break;
  483. case SocketType::NODE:
  484. value_hash<void *>(this, socket, md5);
  485. break;
  486. case SocketType::BOOLEAN_ARRAY:
  487. array_hash<bool>(this, socket, md5);
  488. break;
  489. case SocketType::FLOAT_ARRAY:
  490. array_hash<float>(this, socket, md5);
  491. break;
  492. case SocketType::INT_ARRAY:
  493. array_hash<int>(this, socket, md5);
  494. break;
  495. case SocketType::COLOR_ARRAY:
  496. float3_array_hash(this, socket, md5);
  497. break;
  498. case SocketType::VECTOR_ARRAY:
  499. float3_array_hash(this, socket, md5);
  500. break;
  501. case SocketType::POINT_ARRAY:
  502. float3_array_hash(this, socket, md5);
  503. break;
  504. case SocketType::NORMAL_ARRAY:
  505. float3_array_hash(this, socket, md5);
  506. break;
  507. case SocketType::POINT2_ARRAY:
  508. array_hash<float2>(this, socket, md5);
  509. break;
  510. case SocketType::STRING_ARRAY:
  511. array_hash<ustring>(this, socket, md5);
  512. break;
  513. case SocketType::TRANSFORM_ARRAY:
  514. array_hash<Transform>(this, socket, md5);
  515. break;
  516. case SocketType::NODE_ARRAY:
  517. array_hash<void *>(this, socket, md5);
  518. break;
  519. case SocketType::UNDEFINED:
  520. break;
  521. }
  522. }
  523. }
  524. namespace {
  525. template<typename T> size_t array_size_in_bytes(const Node *node, const SocketType &socket)
  526. {
  527. const array<T> &a = *(const array<T> *)(((char *)node) + socket.struct_offset);
  528. return a.size() * sizeof(T);
  529. }
  530. } // namespace
  531. size_t Node::get_total_size_in_bytes() const
  532. {
  533. size_t total_size = 0;
  534. foreach (const SocketType &socket, type->inputs) {
  535. switch (socket.type) {
  536. case SocketType::BOOLEAN:
  537. case SocketType::FLOAT:
  538. case SocketType::INT:
  539. case SocketType::UINT:
  540. case SocketType::COLOR:
  541. case SocketType::VECTOR:
  542. case SocketType::POINT:
  543. case SocketType::NORMAL:
  544. case SocketType::POINT2:
  545. case SocketType::CLOSURE:
  546. case SocketType::STRING:
  547. case SocketType::ENUM:
  548. case SocketType::TRANSFORM:
  549. case SocketType::NODE:
  550. total_size += socket.size();
  551. break;
  552. case SocketType::BOOLEAN_ARRAY:
  553. total_size += array_size_in_bytes<bool>(this, socket);
  554. break;
  555. case SocketType::FLOAT_ARRAY:
  556. total_size += array_size_in_bytes<float>(this, socket);
  557. break;
  558. case SocketType::INT_ARRAY:
  559. total_size += array_size_in_bytes<int>(this, socket);
  560. break;
  561. case SocketType::COLOR_ARRAY:
  562. total_size += array_size_in_bytes<float3>(this, socket);
  563. break;
  564. case SocketType::VECTOR_ARRAY:
  565. total_size += array_size_in_bytes<float3>(this, socket);
  566. break;
  567. case SocketType::POINT_ARRAY:
  568. total_size += array_size_in_bytes<float3>(this, socket);
  569. break;
  570. case SocketType::NORMAL_ARRAY:
  571. total_size += array_size_in_bytes<float3>(this, socket);
  572. break;
  573. case SocketType::POINT2_ARRAY:
  574. total_size += array_size_in_bytes<float2>(this, socket);
  575. break;
  576. case SocketType::STRING_ARRAY:
  577. total_size += array_size_in_bytes<ustring>(this, socket);
  578. break;
  579. case SocketType::TRANSFORM_ARRAY:
  580. total_size += array_size_in_bytes<Transform>(this, socket);
  581. break;
  582. case SocketType::NODE_ARRAY:
  583. total_size += array_size_in_bytes<void *>(this, socket);
  584. break;
  585. case SocketType::UNDEFINED:
  586. break;
  587. }
  588. }
  589. return total_size;
  590. }
  591. CCL_NAMESPACE_END