CoordinatedGraphicsArgumentCoders.cpp 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210
  1. /*
  2. * Copyright (C) 2011 Apple Inc. All rights reserved.
  3. * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
  4. * Copyright (C) 2012 Company 100, Inc.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
  16. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  17. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  18. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
  19. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  20. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  21. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  23. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  25. * THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #include "config.h"
  28. #include "CoordinatedGraphicsArgumentCoders.h"
  29. #if USE(COORDINATED_GRAPHICS)
  30. #include "WebCoordinatedSurface.h"
  31. #include "WebCoreArgumentCoders.h"
  32. #include <WebCore/Animation.h>
  33. #include <WebCore/Color.h>
  34. #include <WebCore/CoordinatedGraphicsState.h>
  35. #include <WebCore/FloatPoint3D.h>
  36. #include <WebCore/GraphicsLayerAnimation.h>
  37. #include <WebCore/IdentityTransformOperation.h>
  38. #include <WebCore/IntPoint.h>
  39. #include <WebCore/Length.h>
  40. #include <WebCore/Matrix3DTransformOperation.h>
  41. #include <WebCore/MatrixTransformOperation.h>
  42. #include <WebCore/PerspectiveTransformOperation.h>
  43. #include <WebCore/RotateTransformOperation.h>
  44. #include <WebCore/ScaleTransformOperation.h>
  45. #include <WebCore/SkewTransformOperation.h>
  46. #include <WebCore/SurfaceUpdateInfo.h>
  47. #include <WebCore/TimingFunction.h>
  48. #include <WebCore/TransformationMatrix.h>
  49. #include <WebCore/TranslateTransformOperation.h>
  50. #if ENABLE(CSS_FILTERS)
  51. #include <WebCore/FilterOperations.h>
  52. #endif
  53. #if ENABLE(CSS_SHADERS)
  54. #include "WebCustomFilterProgramProxy.h"
  55. #include <WebCore/CoordinatedCustomFilterOperation.h>
  56. #include <WebCore/CoordinatedCustomFilterProgram.h>
  57. #include <WebCore/CustomFilterArrayParameter.h>
  58. #include <WebCore/CustomFilterConstants.h>
  59. #include <WebCore/CustomFilterNumberParameter.h>
  60. #include <WebCore/CustomFilterOperation.h>
  61. #include <WebCore/CustomFilterProgram.h>
  62. #include <WebCore/CustomFilterProgramInfo.h>
  63. #include <WebCore/CustomFilterTransformParameter.h>
  64. #include <WebCore/CustomFilterValidatedProgram.h>
  65. #include <WebCore/ValidatedCustomFilterOperation.h>
  66. #endif
  67. #if USE(GRAPHICS_SURFACE)
  68. #include <WebCore/GraphicsSurface.h>
  69. #endif
  70. using namespace WebCore;
  71. using namespace WebKit;
  72. namespace CoreIPC {
  73. void ArgumentCoder<FloatPoint3D>::encode(ArgumentEncoder& encoder, const FloatPoint3D& floatPoint3D)
  74. {
  75. SimpleArgumentCoder<FloatPoint3D>::encode(encoder, floatPoint3D);
  76. }
  77. bool ArgumentCoder<FloatPoint3D>::decode(ArgumentDecoder& decoder, FloatPoint3D& floatPoint3D)
  78. {
  79. return SimpleArgumentCoder<FloatPoint3D>::decode(decoder, floatPoint3D);
  80. }
  81. void ArgumentCoder<Length>::encode(ArgumentEncoder& encoder, const Length& length)
  82. {
  83. SimpleArgumentCoder<Length>::encode(encoder, length);
  84. }
  85. bool ArgumentCoder<Length>::decode(ArgumentDecoder& decoder, Length& length)
  86. {
  87. return SimpleArgumentCoder<Length>::decode(decoder, length);
  88. }
  89. void ArgumentCoder<TransformationMatrix>::encode(ArgumentEncoder& encoder, const TransformationMatrix& transformationMatrix)
  90. {
  91. SimpleArgumentCoder<TransformationMatrix>::encode(encoder, transformationMatrix);
  92. }
  93. bool ArgumentCoder<TransformationMatrix>::decode(ArgumentDecoder& decoder, TransformationMatrix& transformationMatrix)
  94. {
  95. return SimpleArgumentCoder<TransformationMatrix>::decode(decoder, transformationMatrix);
  96. }
  97. #if ENABLE(CSS_FILTERS)
  98. void ArgumentCoder<WebCore::FilterOperations>::encode(ArgumentEncoder& encoder, const WebCore::FilterOperations& filters)
  99. {
  100. encoder << static_cast<uint32_t>(filters.size());
  101. for (size_t i = 0; i < filters.size(); ++i) {
  102. const FilterOperation* filter = filters.at(i);
  103. FilterOperation::OperationType type = filter->getOperationType();
  104. encoder.encodeEnum(type);
  105. switch (type) {
  106. case FilterOperation::GRAYSCALE:
  107. case FilterOperation::SEPIA:
  108. case FilterOperation::SATURATE:
  109. case FilterOperation::HUE_ROTATE:
  110. encoder << static_cast<double>(static_cast<const BasicColorMatrixFilterOperation*>(filter)->amount());
  111. break;
  112. case FilterOperation::INVERT:
  113. case FilterOperation::BRIGHTNESS:
  114. case FilterOperation::CONTRAST:
  115. case FilterOperation::OPACITY:
  116. encoder << static_cast<double>(static_cast<const BasicComponentTransferFilterOperation*>(filter)->amount());
  117. break;
  118. case FilterOperation::BLUR:
  119. ArgumentCoder<Length>::encode(encoder, static_cast<const BlurFilterOperation*>(filter)->stdDeviation());
  120. break;
  121. case FilterOperation::DROP_SHADOW: {
  122. const DropShadowFilterOperation* shadow = static_cast<const DropShadowFilterOperation*>(filter);
  123. ArgumentCoder<IntPoint>::encode(encoder, shadow->location());
  124. encoder << static_cast<int32_t>(shadow->stdDeviation());
  125. ArgumentCoder<Color>::encode(encoder, shadow->color());
  126. break;
  127. }
  128. #if ENABLE(CSS_SHADERS)
  129. case FilterOperation::CUSTOM:
  130. // Custom Filters are converted to VALIDATED_CUSTOM before reaching this point.
  131. ASSERT_NOT_REACHED();
  132. break;
  133. case FilterOperation::VALIDATED_CUSTOM: {
  134. const ValidatedCustomFilterOperation* customOperation = static_cast<const ValidatedCustomFilterOperation*>(filter);
  135. ASSERT(customOperation->validatedProgram());
  136. RefPtr<CustomFilterValidatedProgram> program = customOperation->validatedProgram();
  137. ASSERT(program->isInitialized());
  138. ASSERT(program->platformCompiledProgram());
  139. ASSERT(program->platformCompiledProgram()->client());
  140. WebCustomFilterProgramProxy* customFilterProgramProxy = static_cast<WebCustomFilterProgramProxy*>(program->platformCompiledProgram()->client());
  141. const CustomFilterProgramInfo& programInfo = program->programInfo();
  142. // FIXME: CustomFilterOperation should not need the meshType, it should just be encoded in the program itself.
  143. // https://bugs.webkit.org/show_bug.cgi?id=102529
  144. encoder.encodeEnum(programInfo.meshType());
  145. encoder << customFilterProgramProxy->id();
  146. CustomFilterParameterList parameters = customOperation->parameters();
  147. encoder << static_cast<uint32_t>(parameters.size());
  148. for (size_t i = 0; i < parameters.size(); ++i) {
  149. RefPtr<CustomFilterParameter> parameter = parameters[i];
  150. encoder << parameter->name();
  151. encoder.encodeEnum(parameter->parameterType());
  152. switch (parameter->parameterType()) {
  153. case CustomFilterParameter::ARRAY: {
  154. CustomFilterArrayParameter* arrayParameter = static_cast<CustomFilterArrayParameter*>(parameter.get());
  155. encoder << static_cast<uint32_t>(arrayParameter->size());
  156. for (size_t j = 0; j < arrayParameter->size(); ++j)
  157. encoder << arrayParameter->valueAt(j);
  158. break;
  159. }
  160. case CustomFilterParameter::NUMBER: {
  161. CustomFilterNumberParameter* nubmerParameter = static_cast<CustomFilterNumberParameter*>(parameter.get());
  162. encoder << static_cast<uint32_t>(nubmerParameter->size());
  163. for (size_t j = 0; j < nubmerParameter->size(); ++j)
  164. encoder << nubmerParameter->valueAt(j);
  165. break;
  166. }
  167. case CustomFilterParameter::TRANSFORM: {
  168. CustomFilterTransformParameter* transformParameter = static_cast<CustomFilterTransformParameter*>(parameter.get());
  169. ArgumentCoder<TransformOperations>::encode(encoder, transformParameter->operations());
  170. break;
  171. }
  172. default: {
  173. ASSERT_NOT_REACHED();
  174. break;
  175. }
  176. }
  177. }
  178. encoder << customOperation->meshRows();
  179. encoder << customOperation->meshColumns();
  180. break;
  181. }
  182. #endif
  183. default:
  184. break;
  185. }
  186. }
  187. }
  188. bool ArgumentCoder<WebCore::FilterOperations>::decode(ArgumentDecoder& decoder, WebCore::FilterOperations& filters)
  189. {
  190. uint32_t size;
  191. if (!decoder.decode(size))
  192. return false;
  193. Vector<RefPtr<FilterOperation> >& operations = filters.operations();
  194. for (size_t i = 0; i < size; ++i) {
  195. FilterOperation::OperationType type;
  196. RefPtr<FilterOperation> filter;
  197. if (!decoder.decodeEnum(type))
  198. return false;
  199. switch (type) {
  200. case FilterOperation::GRAYSCALE:
  201. case FilterOperation::SEPIA:
  202. case FilterOperation::SATURATE:
  203. case FilterOperation::HUE_ROTATE: {
  204. double value;
  205. if (!decoder.decode(value))
  206. return false;
  207. filter = BasicColorMatrixFilterOperation::create(value, type);
  208. break;
  209. }
  210. case FilterOperation::INVERT:
  211. case FilterOperation::BRIGHTNESS:
  212. case FilterOperation::CONTRAST:
  213. case FilterOperation::OPACITY: {
  214. double value;
  215. if (!decoder.decode(value))
  216. return false;
  217. filter = BasicComponentTransferFilterOperation::create(value, type);
  218. break;
  219. }
  220. case FilterOperation::BLUR: {
  221. Length length;
  222. if (!ArgumentCoder<Length>::decode(decoder, length))
  223. return false;
  224. filter = BlurFilterOperation::create(length, type);
  225. break;
  226. }
  227. case FilterOperation::DROP_SHADOW: {
  228. IntPoint location;
  229. int32_t stdDeviation;
  230. Color color;
  231. if (!ArgumentCoder<IntPoint>::decode(decoder, location))
  232. return false;
  233. if (!decoder.decode(stdDeviation))
  234. return false;
  235. if (!ArgumentCoder<Color>::decode(decoder, color))
  236. return false;
  237. filter = DropShadowFilterOperation::create(location, stdDeviation, color, type);
  238. break;
  239. }
  240. #if ENABLE(CSS_SHADERS)
  241. case FilterOperation::CUSTOM:
  242. // Custom Filters are converted to VALIDATED_CUSTOM before reaching this point.
  243. ASSERT_NOT_REACHED();
  244. break;
  245. case FilterOperation::VALIDATED_CUSTOM: {
  246. // FIXME: CustomFilterOperation should not need the meshType.
  247. // https://bugs.webkit.org/show_bug.cgi?id=102529
  248. CustomFilterMeshType meshType;
  249. if (!decoder.decodeEnum(meshType))
  250. return false;
  251. int programID = 0;
  252. if (!decoder.decode(programID))
  253. return false;
  254. uint32_t parametersSize;
  255. if (!decoder.decode(parametersSize))
  256. return false;
  257. CustomFilterParameterList parameters(parametersSize);
  258. for (size_t i = 0; i < parametersSize; ++i) {
  259. String name;
  260. CustomFilterParameter::ParameterType parameterType;
  261. if (!decoder.decode(name))
  262. return false;
  263. if (!decoder.decodeEnum(parameterType))
  264. return false;
  265. switch (parameterType) {
  266. case CustomFilterParameter::ARRAY: {
  267. RefPtr<CustomFilterArrayParameter> arrayParameter = CustomFilterArrayParameter::create(name);
  268. uint32_t arrayParameterSize;
  269. if (!decoder.decode(arrayParameterSize))
  270. return false;
  271. double arrayParameterValue;
  272. for (size_t j = 0; j < arrayParameterSize; ++j) {
  273. if (!decoder.decode(arrayParameterValue))
  274. return false;
  275. arrayParameter->addValue(arrayParameterValue);
  276. }
  277. parameters[i] = arrayParameter.release();
  278. break;
  279. }
  280. case CustomFilterParameter::NUMBER: {
  281. RefPtr<CustomFilterNumberParameter> numberParameter = CustomFilterNumberParameter::create(name);
  282. uint32_t numberParameterSize;
  283. if (!decoder.decode(numberParameterSize))
  284. return false;
  285. double numberParameterValue;
  286. for (size_t j = 0; j < numberParameterSize; ++j) {
  287. if (!decoder.decode(numberParameterValue))
  288. return false;
  289. numberParameter->addValue(numberParameterValue);
  290. }
  291. parameters[i] = numberParameter.release();
  292. break;
  293. }
  294. case CustomFilterParameter::TRANSFORM: {
  295. RefPtr<CustomFilterTransformParameter> transformParameter = CustomFilterTransformParameter::create(name);
  296. TransformOperations operations;
  297. if (!ArgumentCoder<TransformOperations>::decode(decoder, operations))
  298. return false;
  299. transformParameter->setOperations(operations);
  300. parameters[i] = transformParameter.release();
  301. break;
  302. }
  303. default: {
  304. ASSERT_NOT_REACHED();
  305. return false;
  306. }
  307. }
  308. }
  309. unsigned meshRows;
  310. unsigned meshColumns;
  311. if (!decoder.decode(meshRows))
  312. return false;
  313. if (!decoder.decode(meshColumns))
  314. return false;
  315. // At this point the Shaders are already validated, so we just use WebCustomFilterOperation for transportation.
  316. filter = CoordinatedCustomFilterOperation::create(0, programID, parameters, meshRows, meshColumns, meshType);
  317. break;
  318. }
  319. #endif
  320. default:
  321. break;
  322. }
  323. if (filter)
  324. operations.append(filter);
  325. }
  326. return true;
  327. }
  328. #endif
  329. #if ENABLE(CSS_SHADERS)
  330. void ArgumentCoder<WebCore::CustomFilterProgramInfo>::encode(ArgumentEncoder& encoder, const CustomFilterProgramInfo& programInfo)
  331. {
  332. encoder << programInfo.vertexShaderString();
  333. encoder << programInfo.fragmentShaderString();
  334. encoder.encodeEnum(programInfo.programType());
  335. encoder.encodeEnum(programInfo.meshType());
  336. const CustomFilterProgramMixSettings& mixSettings = programInfo.mixSettings();
  337. encoder.encodeEnum(mixSettings.blendMode);
  338. encoder.encodeEnum(mixSettings.compositeOperator);
  339. }
  340. bool ArgumentCoder<WebCore::CustomFilterProgramInfo>::decode(ArgumentDecoder& decoder, CustomFilterProgramInfo& programInfo)
  341. {
  342. String vertexShaderString;
  343. String fragmentShaderString;
  344. CustomFilterProgramType programType;
  345. CustomFilterMeshType meshType;
  346. CustomFilterProgramMixSettings mixSettings;
  347. if (!decoder.decode(vertexShaderString))
  348. return false;
  349. if (!decoder.decode(fragmentShaderString))
  350. return false;
  351. if (!decoder.decodeEnum(programType))
  352. return false;
  353. if (!decoder.decodeEnum(meshType))
  354. return false;
  355. if (!decoder.decodeEnum(mixSettings.blendMode))
  356. return false;
  357. if (!decoder.decodeEnum(mixSettings.compositeOperator))
  358. return false;
  359. programInfo = CustomFilterProgramInfo(vertexShaderString, fragmentShaderString, programType, mixSettings, meshType);
  360. return true;
  361. }
  362. #endif // ENABLE(CSS_SHADERS)
  363. void ArgumentCoder<TransformOperations>::encode(ArgumentEncoder& encoder, const TransformOperations& transformOperations)
  364. {
  365. encoder << static_cast<uint32_t>(transformOperations.size());
  366. for (size_t i = 0; i < transformOperations.size(); ++i) {
  367. const TransformOperation* operation = transformOperations.at(i);
  368. encoder.encodeEnum(operation->getOperationType());
  369. switch (operation->getOperationType()) {
  370. case TransformOperation::SCALE_X:
  371. case TransformOperation::SCALE_Y:
  372. case TransformOperation::SCALE:
  373. case TransformOperation::SCALE_Z:
  374. case TransformOperation::SCALE_3D:
  375. encoder << static_cast<const ScaleTransformOperation*>(operation)->x();
  376. encoder << static_cast<const ScaleTransformOperation*>(operation)->y();
  377. encoder << static_cast<const ScaleTransformOperation*>(operation)->z();
  378. break;
  379. case TransformOperation::TRANSLATE_X:
  380. case TransformOperation::TRANSLATE_Y:
  381. case TransformOperation::TRANSLATE:
  382. case TransformOperation::TRANSLATE_Z:
  383. case TransformOperation::TRANSLATE_3D:
  384. ArgumentCoder<Length>::encode(encoder, static_cast<const TranslateTransformOperation*>(operation)->x());
  385. ArgumentCoder<Length>::encode(encoder, static_cast<const TranslateTransformOperation*>(operation)->y());
  386. ArgumentCoder<Length>::encode(encoder, static_cast<const TranslateTransformOperation*>(operation)->z());
  387. break;
  388. case TransformOperation::ROTATE:
  389. case TransformOperation::ROTATE_X:
  390. case TransformOperation::ROTATE_Y:
  391. case TransformOperation::ROTATE_3D:
  392. encoder << static_cast<const RotateTransformOperation*>(operation)->x();
  393. encoder << static_cast<const RotateTransformOperation*>(operation)->y();
  394. encoder << static_cast<const RotateTransformOperation*>(operation)->z();
  395. encoder << static_cast<const RotateTransformOperation*>(operation)->angle();
  396. break;
  397. case TransformOperation::SKEW_X:
  398. case TransformOperation::SKEW_Y:
  399. case TransformOperation::SKEW:
  400. encoder << static_cast<const SkewTransformOperation*>(operation)->angleX();
  401. encoder << static_cast<const SkewTransformOperation*>(operation)->angleY();
  402. break;
  403. case TransformOperation::MATRIX:
  404. ArgumentCoder<TransformationMatrix>::encode(encoder, static_cast<const MatrixTransformOperation*>(operation)->matrix());
  405. break;
  406. case TransformOperation::MATRIX_3D:
  407. ArgumentCoder<TransformationMatrix>::encode(encoder, static_cast<const Matrix3DTransformOperation*>(operation)->matrix());
  408. break;
  409. case TransformOperation::PERSPECTIVE:
  410. ArgumentCoder<Length>::encode(encoder, static_cast<const PerspectiveTransformOperation*>(operation)->perspective());
  411. break;
  412. case TransformOperation::IDENTITY:
  413. break;
  414. case TransformOperation::NONE:
  415. ASSERT_NOT_REACHED();
  416. break;
  417. }
  418. }
  419. }
  420. bool ArgumentCoder<TransformOperations>::decode(ArgumentDecoder& decoder, TransformOperations& transformOperations)
  421. {
  422. uint32_t operationsSize;
  423. if (!decoder.decode(operationsSize))
  424. return false;
  425. for (size_t i = 0; i < operationsSize; ++i) {
  426. TransformOperation::OperationType operationType;
  427. if (!decoder.decodeEnum(operationType))
  428. return false;
  429. switch (operationType) {
  430. case TransformOperation::SCALE_X:
  431. case TransformOperation::SCALE_Y:
  432. case TransformOperation::SCALE:
  433. case TransformOperation::SCALE_Z:
  434. case TransformOperation::SCALE_3D: {
  435. double x, y, z;
  436. if (!decoder.decode(x))
  437. return false;
  438. if (!decoder.decode(y))
  439. return false;
  440. if (!decoder.decode(z))
  441. return false;
  442. transformOperations.operations().append(ScaleTransformOperation::create(x, y, z, operationType));
  443. break;
  444. }
  445. case TransformOperation::TRANSLATE_X:
  446. case TransformOperation::TRANSLATE_Y:
  447. case TransformOperation::TRANSLATE:
  448. case TransformOperation::TRANSLATE_Z:
  449. case TransformOperation::TRANSLATE_3D: {
  450. Length x, y, z;
  451. if (!ArgumentCoder<Length>::decode(decoder, x))
  452. return false;
  453. if (!ArgumentCoder<Length>::decode(decoder, y))
  454. return false;
  455. if (!ArgumentCoder<Length>::decode(decoder, z))
  456. return false;
  457. transformOperations.operations().append(TranslateTransformOperation::create(x, y, z, operationType));
  458. break;
  459. }
  460. case TransformOperation::ROTATE:
  461. case TransformOperation::ROTATE_X:
  462. case TransformOperation::ROTATE_Y:
  463. case TransformOperation::ROTATE_3D: {
  464. double x, y, z, angle;
  465. if (!decoder.decode(x))
  466. return false;
  467. if (!decoder.decode(y))
  468. return false;
  469. if (!decoder.decode(z))
  470. return false;
  471. if (!decoder.decode(angle))
  472. return false;
  473. transformOperations.operations().append(RotateTransformOperation::create(x, y, z, angle, operationType));
  474. break;
  475. }
  476. case TransformOperation::SKEW_X:
  477. case TransformOperation::SKEW_Y:
  478. case TransformOperation::SKEW: {
  479. double angleX, angleY;
  480. if (!decoder.decode(angleX))
  481. return false;
  482. if (!decoder.decode(angleY))
  483. return false;
  484. transformOperations.operations().append(SkewTransformOperation::create(angleX, angleY, operationType));
  485. break;
  486. }
  487. case TransformOperation::MATRIX: {
  488. TransformationMatrix matrix;
  489. if (!ArgumentCoder<TransformationMatrix>::decode(decoder, matrix))
  490. return false;
  491. transformOperations.operations().append(MatrixTransformOperation::create(matrix));
  492. break;
  493. }
  494. case TransformOperation::MATRIX_3D: {
  495. TransformationMatrix matrix;
  496. if (!ArgumentCoder<TransformationMatrix>::decode(decoder, matrix))
  497. return false;
  498. transformOperations.operations().append(Matrix3DTransformOperation::create(matrix));
  499. break;
  500. }
  501. case TransformOperation::PERSPECTIVE: {
  502. Length perspective;
  503. if (!ArgumentCoder<Length>::decode(decoder, perspective))
  504. return false;
  505. transformOperations.operations().append(PerspectiveTransformOperation::create(perspective));
  506. break;
  507. }
  508. case TransformOperation::IDENTITY:
  509. transformOperations.operations().append(IdentityTransformOperation::create());
  510. break;
  511. case TransformOperation::NONE:
  512. ASSERT_NOT_REACHED();
  513. break;
  514. }
  515. }
  516. return true;
  517. }
  518. static void encodeTimingFunction(ArgumentEncoder& encoder, const TimingFunction* timingFunction)
  519. {
  520. if (!timingFunction) {
  521. encoder.encodeEnum(TimingFunction::TimingFunctionType(-1));
  522. return;
  523. }
  524. TimingFunction::TimingFunctionType type = timingFunction ? timingFunction->type() : TimingFunction::LinearFunction;
  525. encoder.encodeEnum(type);
  526. switch (type) {
  527. case TimingFunction::LinearFunction:
  528. break;
  529. case TimingFunction::CubicBezierFunction: {
  530. const CubicBezierTimingFunction* cubic = static_cast<const CubicBezierTimingFunction*>(timingFunction);
  531. CubicBezierTimingFunction::TimingFunctionPreset bezierPreset = cubic->timingFunctionPreset();
  532. encoder.encodeEnum(bezierPreset);
  533. if (bezierPreset == CubicBezierTimingFunction::Custom) {
  534. encoder << cubic->x1();
  535. encoder << cubic->y1();
  536. encoder << cubic->x2();
  537. encoder << cubic->y2();
  538. }
  539. break;
  540. }
  541. case TimingFunction::StepsFunction: {
  542. const StepsTimingFunction* steps = static_cast<const StepsTimingFunction*>(timingFunction);
  543. encoder << static_cast<uint32_t>(steps->numberOfSteps());
  544. encoder << steps->stepAtStart();
  545. break;
  546. }
  547. }
  548. }
  549. bool decodeTimingFunction(ArgumentDecoder& decoder, RefPtr<TimingFunction>& timingFunction)
  550. {
  551. TimingFunction::TimingFunctionType type;
  552. if (!decoder.decodeEnum(type))
  553. return false;
  554. if (type == TimingFunction::TimingFunctionType(-1))
  555. return true;
  556. switch (type) {
  557. case TimingFunction::LinearFunction:
  558. timingFunction = LinearTimingFunction::create();
  559. return true;
  560. case TimingFunction::CubicBezierFunction: {
  561. double x1, y1, x2, y2;
  562. CubicBezierTimingFunction::TimingFunctionPreset bezierPreset;
  563. if (!decoder.decodeEnum(bezierPreset))
  564. return false;
  565. if (bezierPreset != CubicBezierTimingFunction::Custom) {
  566. timingFunction = CubicBezierTimingFunction::create(bezierPreset);
  567. return true;
  568. }
  569. if (!decoder.decode(x1))
  570. return false;
  571. if (!decoder.decode(y1))
  572. return false;
  573. if (!decoder.decode(x2))
  574. return false;
  575. if (!decoder.decode(y2))
  576. return false;
  577. timingFunction = CubicBezierTimingFunction::create(x1, y1, x2, y2);
  578. return true;
  579. }
  580. case TimingFunction::StepsFunction: {
  581. uint32_t numberOfSteps;
  582. bool stepAtStart;
  583. if (!decoder.decode(numberOfSteps))
  584. return false;
  585. if (!decoder.decode(stepAtStart))
  586. return false;
  587. timingFunction = StepsTimingFunction::create(numberOfSteps, stepAtStart);
  588. return true;
  589. }
  590. }
  591. return false;
  592. }
  593. void ArgumentCoder<GraphicsLayerAnimation>::encode(ArgumentEncoder& encoder, const GraphicsLayerAnimation& animation)
  594. {
  595. encoder << animation.name();
  596. encoder << animation.boxSize();
  597. encoder.encodeEnum(animation.state());
  598. encoder << animation.startTime();
  599. encoder << animation.pauseTime();
  600. encoder << animation.listsMatch();
  601. RefPtr<Animation> animationObject = animation.animation();
  602. encoder.encodeEnum(animationObject->direction());
  603. encoder << static_cast<uint32_t>(animationObject->fillMode());
  604. encoder << animationObject->duration();
  605. encoder << animationObject->iterationCount();
  606. encodeTimingFunction(encoder, animationObject->timingFunction().get());
  607. const KeyframeValueList& keyframes = animation.keyframes();
  608. encoder.encodeEnum(keyframes.property());
  609. encoder << static_cast<uint32_t>(keyframes.size());
  610. for (size_t i = 0; i < keyframes.size(); ++i) {
  611. const AnimationValue& value = keyframes.at(i);
  612. encoder << value.keyTime();
  613. encodeTimingFunction(encoder, value.timingFunction());
  614. switch (keyframes.property()) {
  615. case AnimatedPropertyOpacity:
  616. encoder << static_cast<const FloatAnimationValue&>(value).value();
  617. break;
  618. case AnimatedPropertyWebkitTransform:
  619. encoder << static_cast<const TransformAnimationValue&>(value).value();
  620. break;
  621. #if ENABLE(CSS_FILTERS)
  622. case AnimatedPropertyWebkitFilter:
  623. encoder << static_cast<const FilterAnimationValue&>(value).value();
  624. break;
  625. #endif
  626. default:
  627. break;
  628. }
  629. }
  630. }
  631. bool ArgumentCoder<GraphicsLayerAnimation>::decode(ArgumentDecoder& decoder, GraphicsLayerAnimation& animation)
  632. {
  633. String name;
  634. IntSize boxSize;
  635. GraphicsLayerAnimation::AnimationState state;
  636. double startTime;
  637. double pauseTime;
  638. bool listsMatch;
  639. Animation::AnimationDirection direction;
  640. unsigned fillMode;
  641. double duration;
  642. double iterationCount;
  643. RefPtr<TimingFunction> timingFunction;
  644. RefPtr<Animation> animationObject;
  645. if (!decoder.decode(name))
  646. return false;
  647. if (!decoder.decode(boxSize))
  648. return false;
  649. if (!decoder.decodeEnum(state))
  650. return false;
  651. if (!decoder.decode(startTime))
  652. return false;
  653. if (!decoder.decode(pauseTime))
  654. return false;
  655. if (!decoder.decode(listsMatch))
  656. return false;
  657. if (!decoder.decodeEnum(direction))
  658. return false;
  659. if (!decoder.decode(fillMode))
  660. return false;
  661. if (!decoder.decode(duration))
  662. return false;
  663. if (!decoder.decode(iterationCount))
  664. return false;
  665. if (!decodeTimingFunction(decoder, timingFunction))
  666. return false;
  667. animationObject = Animation::create();
  668. animationObject->setDirection(direction);
  669. animationObject->setFillMode(fillMode);
  670. animationObject->setDuration(duration);
  671. animationObject->setIterationCount(iterationCount);
  672. if (timingFunction)
  673. animationObject->setTimingFunction(timingFunction);
  674. AnimatedPropertyID property;
  675. if (!decoder.decodeEnum(property))
  676. return false;
  677. KeyframeValueList keyframes(property);
  678. unsigned keyframesSize;
  679. if (!decoder.decode(keyframesSize))
  680. return false;
  681. for (unsigned i = 0; i < keyframesSize; ++i) {
  682. float keyTime;
  683. RefPtr<TimingFunction> timingFunction;
  684. if (!decoder.decode(keyTime))
  685. return false;
  686. if (!decodeTimingFunction(decoder, timingFunction))
  687. return false;
  688. switch (property) {
  689. case AnimatedPropertyOpacity: {
  690. float value;
  691. if (!decoder.decode(value))
  692. return false;
  693. keyframes.insert(FloatAnimationValue::create(keyTime, value, timingFunction));
  694. break;
  695. }
  696. case AnimatedPropertyWebkitTransform: {
  697. TransformOperations transform;
  698. if (!decoder.decode(transform))
  699. return false;
  700. keyframes.insert(TransformAnimationValue::create(keyTime, transform, timingFunction));
  701. break;
  702. }
  703. #if ENABLE(CSS_FILTERS)
  704. case AnimatedPropertyWebkitFilter: {
  705. FilterOperations filter;
  706. if (!decoder.decode(filter))
  707. return false;
  708. keyframes.insert(FilterAnimationValue::create(keyTime, filter, timingFunction));
  709. break;
  710. }
  711. #endif
  712. default:
  713. break;
  714. }
  715. }
  716. animation = GraphicsLayerAnimation(name, keyframes, boxSize, animationObject.get(), startTime, listsMatch);
  717. animation.setState(state, pauseTime);
  718. return true;
  719. }
  720. void ArgumentCoder<GraphicsLayerAnimations>::encode(ArgumentEncoder& encoder, const GraphicsLayerAnimations& animations)
  721. {
  722. encoder << animations.animations();
  723. }
  724. bool ArgumentCoder<GraphicsLayerAnimations>::decode(ArgumentDecoder& decoder, GraphicsLayerAnimations& animations)
  725. {
  726. return decoder.decode(animations.animations());
  727. }
  728. #if USE(GRAPHICS_SURFACE)
  729. void ArgumentCoder<WebCore::GraphicsSurfaceToken>::encode(ArgumentEncoder& encoder, const WebCore::GraphicsSurfaceToken& token)
  730. {
  731. #if OS(DARWIN)
  732. encoder << Attachment(token.frontBufferHandle, MACH_MSG_TYPE_MOVE_SEND);
  733. encoder << Attachment(token.backBufferHandle, MACH_MSG_TYPE_MOVE_SEND);
  734. #elif OS(WINDOWS)
  735. encoder << reinterpret_cast<uint64_t>(token.frontBufferHandle);
  736. encoder << reinterpret_cast<uint64_t>(token.backBufferHandle);
  737. #elif OS(LINUX)
  738. encoder << token.frontBufferHandle;
  739. #elif OS(ORBIS)
  740. encoder << token.frontBufferHandle;
  741. #endif
  742. }
  743. bool ArgumentCoder<WebCore::GraphicsSurfaceToken>::decode(ArgumentDecoder& decoder, WebCore::GraphicsSurfaceToken& token)
  744. {
  745. #if OS(WINDOWS)
  746. uint64_t frontBufferHandle;
  747. if (!decoder.decode(frontBufferHandle))
  748. return false;
  749. token.frontBufferHandle = reinterpret_cast<GraphicsSurfaceToken::BufferHandle>(frontBufferHandle);
  750. uint64_t backBufferHandle;
  751. if (!decoder.decode(backBufferHandle))
  752. return false;
  753. token.backBufferHandle = reinterpret_cast<GraphicsSurfaceToken::BufferHandle>(backBufferHandle);
  754. #elif OS(DARWIN)
  755. Attachment frontAttachment, backAttachment;
  756. if (!decoder.decode(frontAttachment))
  757. return false;
  758. if (!decoder.decode(backAttachment))
  759. return false;
  760. token = GraphicsSurfaceToken(frontAttachment.port(), backAttachment.port());
  761. #elif OS(LINUX)
  762. if (!decoder.decode(token.frontBufferHandle))
  763. return false;
  764. #elif OS(ORBIS)
  765. if (!decoder.decode(token.frontBufferHandle))
  766. return false;
  767. #endif
  768. return true;
  769. }
  770. #endif
  771. void ArgumentCoder<SurfaceUpdateInfo>::encode(ArgumentEncoder& encoder, const SurfaceUpdateInfo& surfaceUpdateInfo)
  772. {
  773. SimpleArgumentCoder<SurfaceUpdateInfo>::encode(encoder, surfaceUpdateInfo);
  774. }
  775. bool ArgumentCoder<SurfaceUpdateInfo>::decode(ArgumentDecoder& decoder, SurfaceUpdateInfo& surfaceUpdateInfo)
  776. {
  777. return SimpleArgumentCoder<SurfaceUpdateInfo>::decode(decoder, surfaceUpdateInfo);
  778. }
  779. void ArgumentCoder<CoordinatedGraphicsLayerState>::encode(ArgumentEncoder& encoder, const CoordinatedGraphicsLayerState& state)
  780. {
  781. encoder << state.changeMask;
  782. if (state.flagsChanged)
  783. encoder << state.flags;
  784. if (state.positionChanged)
  785. encoder << state.pos;
  786. if (state.anchorPointChanged)
  787. encoder << state.anchorPoint;
  788. if (state.sizeChanged)
  789. encoder << state.size;
  790. if (state.transformChanged)
  791. encoder << state.transform;
  792. if (state.childrenTransformChanged)
  793. encoder << state.childrenTransform;
  794. if (state.contentsRectChanged)
  795. encoder << state.contentsRect;
  796. if (state.contentsTilingChanged) {
  797. encoder << state.contentsTileSize;
  798. encoder << state.contentsTilePhase;
  799. }
  800. if (state.opacityChanged)
  801. encoder << state.opacity;
  802. if (state.solidColorChanged)
  803. encoder << state.solidColor;
  804. if (state.debugBorderColorChanged)
  805. encoder << state.debugBorderColor;
  806. if (state.debugBorderWidthChanged)
  807. encoder << state.debugBorderWidth;
  808. #if ENABLE(CSS_FILTERS)
  809. if (state.filtersChanged)
  810. encoder << state.filters;
  811. #endif
  812. if (state.animationsChanged)
  813. encoder << state.animations;
  814. if (state.childrenChanged)
  815. encoder << state.children;
  816. encoder << state.tilesToCreate;
  817. encoder << state.tilesToRemove;
  818. if (state.replicaChanged)
  819. encoder << state.replica;
  820. if (state.maskChanged)
  821. encoder << state.mask;
  822. if (state.imageChanged)
  823. encoder << state.imageID;
  824. if (state.repaintCountChanged)
  825. encoder << state.repaintCount;
  826. encoder << state.tilesToUpdate;
  827. #if USE(GRAPHICS_SURFACE)
  828. if (state.canvasChanged) {
  829. encoder << state.canvasSize;
  830. encoder << state.canvasToken;
  831. encoder << state.canvasFrontBuffer;
  832. encoder << state.canvasSurfaceFlags;
  833. }
  834. #endif
  835. if (state.committedScrollOffsetChanged)
  836. encoder << state.committedScrollOffset;
  837. }
  838. bool ArgumentCoder<CoordinatedGraphicsLayerState>::decode(ArgumentDecoder& decoder, CoordinatedGraphicsLayerState& state)
  839. {
  840. if (!decoder.decode(state.changeMask))
  841. return false;
  842. if (state.flagsChanged && !decoder.decode(state.flags))
  843. return false;
  844. if (state.positionChanged && !decoder.decode(state.pos))
  845. return false;
  846. if (state.anchorPointChanged && !decoder.decode(state.anchorPoint))
  847. return false;
  848. if (state.sizeChanged && !decoder.decode(state.size))
  849. return false;
  850. if (state.transformChanged && !decoder.decode(state.transform))
  851. return false;
  852. if (state.childrenTransformChanged && !decoder.decode(state.childrenTransform))
  853. return false;
  854. if (state.contentsRectChanged && !decoder.decode(state.contentsRect))
  855. return false;
  856. if (state.contentsTilingChanged) {
  857. if (!decoder.decode(state.contentsTileSize))
  858. return false;
  859. if (!decoder.decode(state.contentsTilePhase))
  860. return false;
  861. }
  862. if (state.opacityChanged && !decoder.decode(state.opacity))
  863. return false;
  864. if (state.solidColorChanged && !decoder.decode(state.solidColor))
  865. return false;
  866. if (state.debugBorderColorChanged && !decoder.decode(state.debugBorderColor))
  867. return false;
  868. if (state.debugBorderWidthChanged && !decoder.decode(state.debugBorderWidth))
  869. return false;
  870. #if ENABLE(CSS_FILTERS)
  871. if (state.filtersChanged && !decoder.decode(state.filters))
  872. return false;
  873. #endif
  874. if (state.animationsChanged && !decoder.decode(state.animations))
  875. return false;
  876. if (state.childrenChanged && !decoder.decode(state.children))
  877. return false;
  878. if (!decoder.decode(state.tilesToCreate))
  879. return false;
  880. if (!decoder.decode(state.tilesToRemove))
  881. return false;
  882. if (state.replicaChanged && !decoder.decode(state.replica))
  883. return false;
  884. if (state.maskChanged && !decoder.decode(state.mask))
  885. return false;
  886. if (state.imageChanged && !decoder.decode(state.imageID))
  887. return false;
  888. if (state.repaintCountChanged && !decoder.decode(state.repaintCount))
  889. return false;
  890. if (!decoder.decode(state.tilesToUpdate))
  891. return false;
  892. #if USE(GRAPHICS_SURFACE)
  893. if (state.canvasChanged) {
  894. if (!decoder.decode(state.canvasSize))
  895. return false;
  896. if (!decoder.decode(state.canvasToken))
  897. return false;
  898. if (!decoder.decode(state.canvasFrontBuffer))
  899. return false;
  900. if (!decoder.decode(state.canvasSurfaceFlags))
  901. return false;
  902. }
  903. #endif
  904. if (state.committedScrollOffsetChanged && !decoder.decode(state.committedScrollOffset))
  905. return false;
  906. return true;
  907. }
  908. void ArgumentCoder<TileUpdateInfo>::encode(ArgumentEncoder& encoder, const TileUpdateInfo& updateInfo)
  909. {
  910. SimpleArgumentCoder<TileUpdateInfo>::encode(encoder, updateInfo);
  911. }
  912. bool ArgumentCoder<TileUpdateInfo>::decode(ArgumentDecoder& decoder, TileUpdateInfo& updateInfo)
  913. {
  914. return SimpleArgumentCoder<TileUpdateInfo>::decode(decoder, updateInfo);
  915. }
  916. void ArgumentCoder<TileCreationInfo>::encode(ArgumentEncoder& encoder, const TileCreationInfo& updateInfo)
  917. {
  918. SimpleArgumentCoder<TileCreationInfo>::encode(encoder, updateInfo);
  919. }
  920. bool ArgumentCoder<TileCreationInfo>::decode(ArgumentDecoder& decoder, TileCreationInfo& updateInfo)
  921. {
  922. return SimpleArgumentCoder<TileCreationInfo>::decode(decoder, updateInfo);
  923. }
  924. static void encodeCoordinatedSurface(ArgumentEncoder& encoder, const RefPtr<CoordinatedSurface>& surface)
  925. {
  926. bool isValidSurface = false;
  927. if (!surface) {
  928. encoder << isValidSurface;
  929. return;
  930. }
  931. WebCoordinatedSurface* webCoordinatedSurface = static_cast<WebCoordinatedSurface*>(surface.get());
  932. WebCoordinatedSurface::Handle handle;
  933. if (webCoordinatedSurface->createHandle(handle))
  934. isValidSurface = true;
  935. encoder << isValidSurface;
  936. if (isValidSurface)
  937. encoder << handle;
  938. }
  939. static bool decodeCoordinatedSurface(ArgumentDecoder& decoder, RefPtr<CoordinatedSurface>& surface)
  940. {
  941. bool isValidSurface;
  942. if (!decoder.decode(isValidSurface))
  943. return false;
  944. if (!isValidSurface)
  945. return true;
  946. WebCoordinatedSurface::Handle handle;
  947. if (!decoder.decode(handle))
  948. return false;
  949. surface = WebCoordinatedSurface::create(handle);
  950. return true;
  951. }
  952. void ArgumentCoder<CoordinatedGraphicsState>::encode(ArgumentEncoder& encoder, const CoordinatedGraphicsState& state)
  953. {
  954. encoder << state.rootCompositingLayer;
  955. encoder << state.scrollPosition;
  956. encoder << state.contentsSize;
  957. encoder << state.coveredRect;
  958. encoder << state.layersToCreate;
  959. encoder << state.layersToUpdate;
  960. encoder << state.layersToRemove;
  961. encoder << state.imagesToCreate;
  962. encoder << state.imagesToRemove;
  963. // We need to encode WebCoordinatedSurface::Handle right after it's creation.
  964. // That's why we cannot use simple std::pair encoder.
  965. encoder << static_cast<uint64_t>(state.imagesToUpdate.size());
  966. for (size_t i = 0; i < state.imagesToUpdate.size(); ++i) {
  967. encoder << state.imagesToUpdate[i].first;
  968. encodeCoordinatedSurface(encoder, state.imagesToUpdate[i].second);
  969. }
  970. encoder << state.imagesToClear;
  971. encoder << static_cast<uint64_t>(state.updateAtlasesToCreate.size());
  972. for (size_t i = 0; i < state.updateAtlasesToCreate.size(); ++i) {
  973. encoder << state.updateAtlasesToCreate[i].first;
  974. encodeCoordinatedSurface(encoder, state.updateAtlasesToCreate[i].second);
  975. }
  976. encoder << state.updateAtlasesToRemove;
  977. #if ENABLE(CSS_SHADERS)
  978. encoder << static_cast<uint64_t>(state.customFiltersToCreate.size());
  979. for (size_t i = 0; i < state.customFiltersToCreate.size(); ++i) {
  980. encoder << state.customFiltersToCreate[i].first;
  981. encoder << state.customFiltersToCreate[i].second;
  982. }
  983. encoder << state.customFiltersToRemove;
  984. #endif
  985. }
  986. bool ArgumentCoder<CoordinatedGraphicsState>::decode(ArgumentDecoder& decoder, CoordinatedGraphicsState& state)
  987. {
  988. if (!decoder.decode(state.rootCompositingLayer))
  989. return false;
  990. if (!decoder.decode(state.scrollPosition))
  991. return false;
  992. if (!decoder.decode(state.contentsSize))
  993. return false;
  994. if (!decoder.decode(state.coveredRect))
  995. return false;
  996. if (!decoder.decode(state.layersToCreate))
  997. return false;
  998. if (!decoder.decode(state.layersToUpdate))
  999. return false;
  1000. if (!decoder.decode(state.layersToRemove))
  1001. return false;
  1002. if (!decoder.decode(state.imagesToCreate))
  1003. return false;
  1004. if (!decoder.decode(state.imagesToRemove))
  1005. return false;
  1006. uint64_t sizeOfImagesToUpdate;
  1007. if (!decoder.decode(sizeOfImagesToUpdate))
  1008. return false;
  1009. for (uint64_t i = 0; i < sizeOfImagesToUpdate; ++i) {
  1010. CoordinatedImageBackingID imageID;
  1011. if (!decoder.decode(imageID))
  1012. return false;
  1013. RefPtr<CoordinatedSurface> surface;
  1014. if (!decodeCoordinatedSurface(decoder, surface))
  1015. return false;
  1016. state.imagesToUpdate.append(std::make_pair(imageID, surface.release()));
  1017. }
  1018. if (!decoder.decode(state.imagesToClear))
  1019. return false;
  1020. uint64_t sizeOfUpdateAtlasesToCreate;
  1021. if (!decoder.decode(sizeOfUpdateAtlasesToCreate))
  1022. return false;
  1023. for (uint64_t i = 0; i < sizeOfUpdateAtlasesToCreate; ++i) {
  1024. uint32_t atlasID;
  1025. if (!decoder.decode(atlasID))
  1026. return false;
  1027. RefPtr<CoordinatedSurface> surface;
  1028. if (!decodeCoordinatedSurface(decoder, surface))
  1029. return false;
  1030. state.updateAtlasesToCreate.append(std::make_pair(atlasID, surface.release()));
  1031. }
  1032. if (!decoder.decode(state.updateAtlasesToRemove))
  1033. return false;
  1034. #if ENABLE(CSS_SHADERS)
  1035. uint64_t sizeOfCustomFiltersToCreate;
  1036. if (!decoder.decode(sizeOfCustomFiltersToCreate))
  1037. return false;
  1038. for (uint64_t i = 0; i < sizeOfCustomFiltersToCreate; ++i) {
  1039. uint32_t filterID;
  1040. if (!decoder.decode(filterID))
  1041. return false;
  1042. CustomFilterProgramInfo filterInfo;
  1043. if (!decoder.decode(filterInfo))
  1044. return false;
  1045. state.customFiltersToCreate.append(std::make_pair(filterID, filterInfo));
  1046. }
  1047. if (!decoder.decode(state.customFiltersToRemove))
  1048. return false;
  1049. #endif
  1050. return true;
  1051. }
  1052. } // namespace CoreIPC
  1053. #endif // USE(COORDINATED_GRAPHICS)