PageRenderTime 59ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/frameworks/base/libs/hwui/DisplayListRenderer.cpp

https://gitlab.com/brian0218/rk3066_r-box_android4.2.2_sdk
C++ | 1281 lines | 1174 code | 76 blank | 31 comment | 93 complexity | 499adcc98b69fc8015aba92bbf041aed MD5 | raw file
  1. /*
  2. * Copyright (C) 2010 The Android Open Source Project
  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. #define LOG_TAG "OpenGLRenderer"
  17. #include <SkCamera.h>
  18. #include <private/hwui/DrawGlInfo.h>
  19. #include "DisplayListLogBuffer.h"
  20. #include "DisplayListRenderer.h"
  21. #include "Caches.h"
  22. namespace android {
  23. namespace uirenderer {
  24. ///////////////////////////////////////////////////////////////////////////////
  25. // Display list
  26. ///////////////////////////////////////////////////////////////////////////////
  27. const char* DisplayList::OP_NAMES[] = {
  28. "Save",
  29. "Restore",
  30. "RestoreToCount",
  31. "SaveLayer",
  32. "SaveLayerAlpha",
  33. "Translate",
  34. "Rotate",
  35. "Scale",
  36. "Skew",
  37. "SetMatrix",
  38. "ConcatMatrix",
  39. "ClipRect",
  40. "DrawDisplayList",
  41. "DrawLayer",
  42. "DrawBitmap",
  43. "DrawBitmapMatrix",
  44. "DrawBitmapRect",
  45. "DrawBitmapData",
  46. "DrawBitmapMesh",
  47. "DrawPatch",
  48. "DrawColor",
  49. "DrawRect",
  50. "DrawRoundRect",
  51. "DrawCircle",
  52. "DrawOval",
  53. "DrawArc",
  54. "DrawPath",
  55. "DrawLines",
  56. "DrawPoints",
  57. "DrawTextOnPath",
  58. "DrawPosText",
  59. "DrawText",
  60. "ResetShader",
  61. "SetupShader",
  62. "ResetColorFilter",
  63. "SetupColorFilter",
  64. "ResetShadow",
  65. "SetupShadow",
  66. "ResetPaintFilter",
  67. "SetupPaintFilter",
  68. "DrawGLFunction"
  69. };
  70. void DisplayList::outputLogBuffer(int fd) {
  71. DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
  72. if (logBuffer.isEmpty()) {
  73. return;
  74. }
  75. FILE *file = fdopen(fd, "a");
  76. fprintf(file, "\nRecent DisplayList operations\n");
  77. logBuffer.outputCommands(file, OP_NAMES);
  78. String8 cachesLog;
  79. Caches::getInstance().dumpMemoryUsage(cachesLog);
  80. fprintf(file, "\nCaches:\n%s", cachesLog.string());
  81. fprintf(file, "\n");
  82. fflush(file);
  83. }
  84. DisplayList::DisplayList(const DisplayListRenderer& recorder) :
  85. mTransformMatrix(NULL), mTransformCamera(NULL), mTransformMatrix3D(NULL),
  86. mStaticMatrix(NULL), mAnimationMatrix(NULL) {
  87. initFromDisplayListRenderer(recorder);
  88. }
  89. DisplayList::~DisplayList() {
  90. clearResources();
  91. }
  92. void DisplayList::destroyDisplayListDeferred(DisplayList* displayList) {
  93. if (displayList) {
  94. DISPLAY_LIST_LOGD("Deferring display list destruction");
  95. Caches::getInstance().deleteDisplayListDeferred(displayList);
  96. }
  97. }
  98. void DisplayList::clearResources() {
  99. sk_free((void*) mReader.base());
  100. mReader.setMemory(NULL, 0);
  101. delete mTransformMatrix;
  102. delete mTransformCamera;
  103. delete mTransformMatrix3D;
  104. delete mStaticMatrix;
  105. delete mAnimationMatrix;
  106. mTransformMatrix = NULL;
  107. mTransformCamera = NULL;
  108. mTransformMatrix3D = NULL;
  109. mStaticMatrix = NULL;
  110. mAnimationMatrix = NULL;
  111. Caches& caches = Caches::getInstance();
  112. caches.unregisterFunctors(mFunctorCount);
  113. caches.resourceCache.lock();
  114. for (size_t i = 0; i < mBitmapResources.size(); i++) {
  115. caches.resourceCache.decrementRefcountLocked(mBitmapResources.itemAt(i));
  116. }
  117. for (size_t i = 0; i < mOwnedBitmapResources.size(); i++) {
  118. SkBitmap* bitmap = mOwnedBitmapResources.itemAt(i);
  119. caches.resourceCache.decrementRefcountLocked(bitmap);
  120. caches.resourceCache.destructorLocked(bitmap);
  121. }
  122. for (size_t i = 0; i < mFilterResources.size(); i++) {
  123. caches.resourceCache.decrementRefcountLocked(mFilterResources.itemAt(i));
  124. }
  125. for (size_t i = 0; i < mShaders.size(); i++) {
  126. caches.resourceCache.decrementRefcountLocked(mShaders.itemAt(i));
  127. caches.resourceCache.destructorLocked(mShaders.itemAt(i));
  128. }
  129. for (size_t i = 0; i < mSourcePaths.size(); i++) {
  130. caches.resourceCache.decrementRefcountLocked(mSourcePaths.itemAt(i));
  131. }
  132. for (size_t i = 0; i < mLayers.size(); i++) {
  133. caches.resourceCache.decrementRefcountLocked(mLayers.itemAt(i));
  134. }
  135. caches.resourceCache.unlock();
  136. for (size_t i = 0; i < mPaints.size(); i++) {
  137. delete mPaints.itemAt(i);
  138. }
  139. for (size_t i = 0; i < mPaths.size(); i++) {
  140. SkPath* path = mPaths.itemAt(i);
  141. caches.pathCache.remove(path);
  142. delete path;
  143. }
  144. for (size_t i = 0; i < mMatrices.size(); i++) {
  145. delete mMatrices.itemAt(i);
  146. }
  147. mBitmapResources.clear();
  148. mOwnedBitmapResources.clear();
  149. mFilterResources.clear();
  150. mShaders.clear();
  151. mSourcePaths.clear();
  152. mPaints.clear();
  153. mPaths.clear();
  154. mMatrices.clear();
  155. mLayers.clear();
  156. }
  157. void DisplayList::reset() {
  158. clearResources();
  159. init();
  160. }
  161. void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing) {
  162. if (reusing) {
  163. // re-using display list - clear out previous allocations
  164. clearResources();
  165. }
  166. init();
  167. const SkWriter32& writer = recorder.writeStream();
  168. if (writer.size() == 0) {
  169. return;
  170. }
  171. mSize = writer.size();
  172. void* buffer = sk_malloc_throw(mSize);
  173. writer.flatten(buffer);
  174. mReader.setMemory(buffer, mSize);
  175. mFunctorCount = recorder.getFunctorCount();
  176. Caches& caches = Caches::getInstance();
  177. caches.registerFunctors(mFunctorCount);
  178. caches.resourceCache.lock();
  179. const Vector<SkBitmap*>& bitmapResources = recorder.getBitmapResources();
  180. for (size_t i = 0; i < bitmapResources.size(); i++) {
  181. SkBitmap* resource = bitmapResources.itemAt(i);
  182. mBitmapResources.add(resource);
  183. caches.resourceCache.incrementRefcountLocked(resource);
  184. }
  185. const Vector<SkBitmap*> &ownedBitmapResources = recorder.getOwnedBitmapResources();
  186. for (size_t i = 0; i < ownedBitmapResources.size(); i++) {
  187. SkBitmap* resource = ownedBitmapResources.itemAt(i);
  188. mOwnedBitmapResources.add(resource);
  189. caches.resourceCache.incrementRefcountLocked(resource);
  190. }
  191. const Vector<SkiaColorFilter*>& filterResources = recorder.getFilterResources();
  192. for (size_t i = 0; i < filterResources.size(); i++) {
  193. SkiaColorFilter* resource = filterResources.itemAt(i);
  194. mFilterResources.add(resource);
  195. caches.resourceCache.incrementRefcountLocked(resource);
  196. }
  197. const Vector<SkiaShader*>& shaders = recorder.getShaders();
  198. for (size_t i = 0; i < shaders.size(); i++) {
  199. SkiaShader* resource = shaders.itemAt(i);
  200. mShaders.add(resource);
  201. caches.resourceCache.incrementRefcountLocked(resource);
  202. }
  203. const SortedVector<SkPath*>& sourcePaths = recorder.getSourcePaths();
  204. for (size_t i = 0; i < sourcePaths.size(); i++) {
  205. mSourcePaths.add(sourcePaths.itemAt(i));
  206. caches.resourceCache.incrementRefcountLocked(sourcePaths.itemAt(i));
  207. }
  208. const Vector<Layer*>& layers = recorder.getLayers();
  209. for (size_t i = 0; i < layers.size(); i++) {
  210. mLayers.add(layers.itemAt(i));
  211. caches.resourceCache.incrementRefcountLocked(layers.itemAt(i));
  212. }
  213. caches.resourceCache.unlock();
  214. const Vector<SkPaint*>& paints = recorder.getPaints();
  215. for (size_t i = 0; i < paints.size(); i++) {
  216. mPaints.add(paints.itemAt(i));
  217. }
  218. const Vector<SkPath*>& paths = recorder.getPaths();
  219. for (size_t i = 0; i < paths.size(); i++) {
  220. mPaths.add(paths.itemAt(i));
  221. }
  222. const Vector<SkMatrix*>& matrices = recorder.getMatrices();
  223. for (size_t i = 0; i < matrices.size(); i++) {
  224. mMatrices.add(matrices.itemAt(i));
  225. }
  226. }
  227. void DisplayList::init() {
  228. mSize = 0;
  229. mIsRenderable = true;
  230. mFunctorCount = 0;
  231. mLeft = 0;
  232. mTop = 0;
  233. mRight = 0;
  234. mBottom = 0;
  235. mClipChildren = true;
  236. mAlpha = 1;
  237. mMultipliedAlpha = 255;
  238. mHasOverlappingRendering = true;
  239. mTranslationX = 0;
  240. mTranslationY = 0;
  241. mRotation = 0;
  242. mRotationX = 0;
  243. mRotationY= 0;
  244. mScaleX = 1;
  245. mScaleY = 1;
  246. mPivotX = 0;
  247. mPivotY = 0;
  248. mCameraDistance = 0;
  249. mMatrixDirty = false;
  250. mMatrixFlags = 0;
  251. mPrevWidth = -1;
  252. mPrevHeight = -1;
  253. mWidth = 0;
  254. mHeight = 0;
  255. mPivotExplicitlySet = false;
  256. mCaching = false;
  257. }
  258. size_t DisplayList::getSize() {
  259. return mSize;
  260. }
  261. /**
  262. * This function is a simplified version of replay(), where we simply retrieve and log the
  263. * display list. This function should remain in sync with the replay() function.
  264. */
  265. void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
  266. TextContainer text;
  267. uint32_t count = (level + 1) * 2;
  268. char indent[count + 1];
  269. for (uint32_t i = 0; i < count; i++) {
  270. indent[i] = ' ';
  271. }
  272. indent[count] = '\0';
  273. ALOGD("%sStart display list (%p, %s, render=%d)", (char*) indent + 2, this,
  274. mName.string(), isRenderable());
  275. ALOGD("%s%s %d", indent, "Save", SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
  276. int saveCount = renderer.getSaveCount() - 1;
  277. outputViewProperties(renderer, (char*) indent);
  278. mReader.rewind();
  279. while (!mReader.eof()) {
  280. int op = mReader.readInt();
  281. if (op & OP_MAY_BE_SKIPPED_MASK) {
  282. int skip = mReader.readInt();
  283. ALOGD("%sSkip %d", (char*) indent, skip);
  284. op &= ~OP_MAY_BE_SKIPPED_MASK;
  285. }
  286. switch (op) {
  287. case DrawGLFunction: {
  288. Functor *functor = (Functor *) getInt();
  289. ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], functor);
  290. }
  291. break;
  292. case Save: {
  293. int rendererNum = getInt();
  294. ALOGD("%s%s %d", (char*) indent, OP_NAMES[op], rendererNum);
  295. }
  296. break;
  297. case Restore: {
  298. ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
  299. }
  300. break;
  301. case RestoreToCount: {
  302. int restoreCount = saveCount + getInt();
  303. ALOGD("%s%s %d", (char*) indent, OP_NAMES[op], restoreCount);
  304. }
  305. break;
  306. case SaveLayer: {
  307. float f1 = getFloat();
  308. float f2 = getFloat();
  309. float f3 = getFloat();
  310. float f4 = getFloat();
  311. SkPaint* paint = getPaint(renderer);
  312. int flags = getInt();
  313. ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p, 0x%x", (char*) indent,
  314. OP_NAMES[op], f1, f2, f3, f4, paint, flags);
  315. }
  316. break;
  317. case SaveLayerAlpha: {
  318. float f1 = getFloat();
  319. float f2 = getFloat();
  320. float f3 = getFloat();
  321. float f4 = getFloat();
  322. int alpha = getInt();
  323. int flags = getInt();
  324. ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", (char*) indent,
  325. OP_NAMES[op], f1, f2, f3, f4, alpha, flags);
  326. }
  327. break;
  328. case Translate: {
  329. float f1 = getFloat();
  330. float f2 = getFloat();
  331. ALOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], f1, f2);
  332. }
  333. break;
  334. case Rotate: {
  335. float rotation = getFloat();
  336. ALOGD("%s%s %.2f", (char*) indent, OP_NAMES[op], rotation);
  337. }
  338. break;
  339. case Scale: {
  340. float sx = getFloat();
  341. float sy = getFloat();
  342. ALOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
  343. }
  344. break;
  345. case Skew: {
  346. float sx = getFloat();
  347. float sy = getFloat();
  348. ALOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
  349. }
  350. break;
  351. case SetMatrix: {
  352. SkMatrix* matrix = getMatrix();
  353. ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], matrix);
  354. }
  355. break;
  356. case ConcatMatrix: {
  357. SkMatrix* matrix = getMatrix();
  358. ALOGD("%s%s new concat %p: [%f, %f, %f] [%f, %f, %f] [%f, %f, %f]",
  359. (char*) indent, OP_NAMES[op], matrix, matrix->get(0), matrix->get(1),
  360. matrix->get(2), matrix->get(3), matrix->get(4), matrix->get(5),
  361. matrix->get(6), matrix->get(7), matrix->get(8));
  362. }
  363. break;
  364. case ClipRect: {
  365. float f1 = getFloat();
  366. float f2 = getFloat();
  367. float f3 = getFloat();
  368. float f4 = getFloat();
  369. int regionOp = getInt();
  370. ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d", (char*) indent, OP_NAMES[op],
  371. f1, f2, f3, f4, regionOp);
  372. }
  373. break;
  374. case DrawDisplayList: {
  375. DisplayList* displayList = getDisplayList();
  376. int32_t flags = getInt();
  377. ALOGD("%s%s %p, %dx%d, 0x%x %d", (char*) indent, OP_NAMES[op],
  378. displayList, mWidth, mHeight, flags, level + 1);
  379. renderer.outputDisplayList(displayList, level + 1);
  380. }
  381. break;
  382. case DrawLayer: {
  383. Layer* layer = (Layer*) getInt();
  384. float x = getFloat();
  385. float y = getFloat();
  386. SkPaint* paint = getPaint(renderer);
  387. ALOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
  388. layer, x, y, paint);
  389. }
  390. break;
  391. case DrawBitmap: {
  392. SkBitmap* bitmap = getBitmap();
  393. float x = getFloat();
  394. float y = getFloat();
  395. SkPaint* paint = getPaint(renderer);
  396. ALOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
  397. bitmap, x, y, paint);
  398. }
  399. break;
  400. case DrawBitmapMatrix: {
  401. SkBitmap* bitmap = getBitmap();
  402. SkMatrix* matrix = getMatrix();
  403. SkPaint* paint = getPaint(renderer);
  404. ALOGD("%s%s %p, %p, %p", (char*) indent, OP_NAMES[op],
  405. bitmap, matrix, paint);
  406. }
  407. break;
  408. case DrawBitmapRect: {
  409. SkBitmap* bitmap = getBitmap();
  410. float f1 = getFloat();
  411. float f2 = getFloat();
  412. float f3 = getFloat();
  413. float f4 = getFloat();
  414. float f5 = getFloat();
  415. float f6 = getFloat();
  416. float f7 = getFloat();
  417. float f8 = getFloat();
  418. SkPaint* paint = getPaint(renderer);
  419. ALOGD("%s%s %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
  420. (char*) indent, OP_NAMES[op], bitmap, f1, f2, f3, f4, f5, f6, f7, f8, paint);
  421. }
  422. break;
  423. case DrawBitmapData: {
  424. SkBitmap* bitmap = getBitmapData();
  425. float x = getFloat();
  426. float y = getFloat();
  427. SkPaint* paint = getPaint(renderer);
  428. ALOGD("%s%s %.2f, %.2f, %p", (char*) indent, OP_NAMES[op], x, y, paint);
  429. }
  430. break;
  431. case DrawBitmapMesh: {
  432. int verticesCount = 0;
  433. uint32_t colorsCount = 0;
  434. SkBitmap* bitmap = getBitmap();
  435. uint32_t meshWidth = getInt();
  436. uint32_t meshHeight = getInt();
  437. float* vertices = getFloats(verticesCount);
  438. bool hasColors = getInt();
  439. int* colors = hasColors ? getInts(colorsCount) : NULL;
  440. SkPaint* paint = getPaint(renderer);
  441. ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
  442. }
  443. break;
  444. case DrawPatch: {
  445. int32_t* xDivs = NULL;
  446. int32_t* yDivs = NULL;
  447. uint32_t* colors = NULL;
  448. uint32_t xDivsCount = 0;
  449. uint32_t yDivsCount = 0;
  450. int8_t numColors = 0;
  451. SkBitmap* bitmap = getBitmap();
  452. xDivs = getInts(xDivsCount);
  453. yDivs = getInts(yDivsCount);
  454. colors = getUInts(numColors);
  455. float left = getFloat();
  456. float top = getFloat();
  457. float right = getFloat();
  458. float bottom = getFloat();
  459. int alpha = getInt();
  460. SkXfermode::Mode mode = (SkXfermode::Mode) getInt();
  461. ALOGD("%s%s %.2f, %.2f, %.2f, %.2f", (char*) indent, OP_NAMES[op],
  462. left, top, right, bottom);
  463. }
  464. break;
  465. case DrawColor: {
  466. int color = getInt();
  467. int xferMode = getInt();
  468. ALOGD("%s%s 0x%x %d", (char*) indent, OP_NAMES[op], color, xferMode);
  469. }
  470. break;
  471. case DrawRect: {
  472. float f1 = getFloat();
  473. float f2 = getFloat();
  474. float f3 = getFloat();
  475. float f4 = getFloat();
  476. SkPaint* paint = getPaint(renderer);
  477. ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
  478. f1, f2, f3, f4, paint);
  479. }
  480. break;
  481. case DrawRoundRect: {
  482. float f1 = getFloat();
  483. float f2 = getFloat();
  484. float f3 = getFloat();
  485. float f4 = getFloat();
  486. float f5 = getFloat();
  487. float f6 = getFloat();
  488. SkPaint* paint = getPaint(renderer);
  489. ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
  490. (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, paint);
  491. }
  492. break;
  493. case DrawCircle: {
  494. float f1 = getFloat();
  495. float f2 = getFloat();
  496. float f3 = getFloat();
  497. SkPaint* paint = getPaint(renderer);
  498. ALOGD("%s%s %.2f, %.2f, %.2f, %p",
  499. (char*) indent, OP_NAMES[op], f1, f2, f3, paint);
  500. }
  501. break;
  502. case DrawOval: {
  503. float f1 = getFloat();
  504. float f2 = getFloat();
  505. float f3 = getFloat();
  506. float f4 = getFloat();
  507. SkPaint* paint = getPaint(renderer);
  508. ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p",
  509. (char*) indent, OP_NAMES[op], f1, f2, f3, f4, paint);
  510. }
  511. break;
  512. case DrawArc: {
  513. float f1 = getFloat();
  514. float f2 = getFloat();
  515. float f3 = getFloat();
  516. float f4 = getFloat();
  517. float f5 = getFloat();
  518. float f6 = getFloat();
  519. int i1 = getInt();
  520. SkPaint* paint = getPaint(renderer);
  521. ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d, %p",
  522. (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, i1, paint);
  523. }
  524. break;
  525. case DrawPath: {
  526. SkPath* path = getPath();
  527. SkPaint* paint = getPaint(renderer);
  528. ALOGD("%s%s %p, %p", (char*) indent, OP_NAMES[op], path, paint);
  529. }
  530. break;
  531. case DrawLines: {
  532. int count = 0;
  533. float* points = getFloats(count);
  534. SkPaint* paint = getPaint(renderer);
  535. ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
  536. }
  537. break;
  538. case DrawPoints: {
  539. int count = 0;
  540. float* points = getFloats(count);
  541. SkPaint* paint = getPaint(renderer);
  542. ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
  543. }
  544. break;
  545. case DrawTextOnPath: {
  546. getText(&text);
  547. int32_t count = getInt();
  548. SkPath* path = getPath();
  549. float hOffset = getFloat();
  550. float vOffset = getFloat();
  551. SkPaint* paint = getPaint(renderer);
  552. ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
  553. text.text(), text.length(), count, paint);
  554. }
  555. break;
  556. case DrawPosText: {
  557. getText(&text);
  558. int count = getInt();
  559. int positionsCount = 0;
  560. float* positions = getFloats(positionsCount);
  561. SkPaint* paint = getPaint(renderer);
  562. ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
  563. text.text(), text.length(), count, paint);
  564. }
  565. break;
  566. case DrawText: {
  567. getText(&text);
  568. int32_t count = getInt();
  569. float x = getFloat();
  570. float y = getFloat();
  571. int32_t positionsCount = 0;
  572. float* positions = getFloats(positionsCount);
  573. SkPaint* paint = getPaint(renderer);
  574. float length = getFloat();
  575. ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
  576. text.text(), text.length(), count, paint);
  577. }
  578. break;
  579. case ResetShader: {
  580. ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
  581. }
  582. break;
  583. case SetupShader: {
  584. SkiaShader* shader = getShader();
  585. ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], shader);
  586. }
  587. break;
  588. case ResetColorFilter: {
  589. ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
  590. }
  591. break;
  592. case SetupColorFilter: {
  593. SkiaColorFilter *colorFilter = getColorFilter();
  594. ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], colorFilter);
  595. }
  596. break;
  597. case ResetShadow: {
  598. ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
  599. }
  600. break;
  601. case SetupShadow: {
  602. float radius = getFloat();
  603. float dx = getFloat();
  604. float dy = getFloat();
  605. int color = getInt();
  606. ALOGD("%s%s %.2f, %.2f, %.2f, 0x%x", (char*) indent, OP_NAMES[op],
  607. radius, dx, dy, color);
  608. }
  609. break;
  610. case ResetPaintFilter: {
  611. ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
  612. }
  613. break;
  614. case SetupPaintFilter: {
  615. int clearBits = getInt();
  616. int setBits = getInt();
  617. ALOGD("%s%s 0x%x, 0x%x", (char*) indent, OP_NAMES[op], clearBits, setBits);
  618. }
  619. break;
  620. default:
  621. ALOGD("Display List error: op not handled: %s%s",
  622. (char*) indent, OP_NAMES[op]);
  623. break;
  624. }
  625. }
  626. ALOGD("%sDone (%p, %s)", (char*) indent + 2, this, mName.string());
  627. }
  628. void DisplayList::updateMatrix() {
  629. if (mMatrixDirty) {
  630. if (!mTransformMatrix) {
  631. mTransformMatrix = new SkMatrix();
  632. }
  633. if (mMatrixFlags == 0 || mMatrixFlags == TRANSLATION) {
  634. mTransformMatrix->reset();
  635. } else {
  636. if (!mPivotExplicitlySet) {
  637. if (mWidth != mPrevWidth || mHeight != mPrevHeight) {
  638. mPrevWidth = mWidth;
  639. mPrevHeight = mHeight;
  640. mPivotX = mPrevWidth / 2;
  641. mPivotY = mPrevHeight / 2;
  642. }
  643. }
  644. if ((mMatrixFlags & ROTATION_3D) == 0) {
  645. mTransformMatrix->setTranslate(mTranslationX, mTranslationY);
  646. mTransformMatrix->preRotate(mRotation, mPivotX, mPivotY);
  647. mTransformMatrix->preScale(mScaleX, mScaleY, mPivotX, mPivotY);
  648. } else {
  649. if (!mTransformCamera) {
  650. mTransformCamera = new Sk3DView();
  651. mTransformMatrix3D = new SkMatrix();
  652. }
  653. mTransformMatrix->reset();
  654. mTransformCamera->save();
  655. mTransformMatrix->preScale(mScaleX, mScaleY, mPivotX, mPivotY);
  656. mTransformCamera->rotateX(mRotationX);
  657. mTransformCamera->rotateY(mRotationY);
  658. mTransformCamera->rotateZ(-mRotation);
  659. mTransformCamera->getMatrix(mTransformMatrix3D);
  660. mTransformMatrix3D->preTranslate(-mPivotX, -mPivotY);
  661. mTransformMatrix3D->postTranslate(mPivotX + mTranslationX,
  662. mPivotY + mTranslationY);
  663. mTransformMatrix->postConcat(*mTransformMatrix3D);
  664. mTransformCamera->restore();
  665. }
  666. }
  667. mMatrixDirty = false;
  668. }
  669. }
  670. void DisplayList::outputViewProperties(OpenGLRenderer& renderer, char* indent) {
  671. updateMatrix();
  672. if (mLeft != 0 || mTop != 0) {
  673. ALOGD("%s%s %d, %d", indent, "Translate (left, top)", mLeft, mTop);
  674. }
  675. if (mStaticMatrix) {
  676. ALOGD("%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
  677. indent, "ConcatMatrix (static)", mStaticMatrix,
  678. mStaticMatrix->get(0), mStaticMatrix->get(1),
  679. mStaticMatrix->get(2), mStaticMatrix->get(3),
  680. mStaticMatrix->get(4), mStaticMatrix->get(5),
  681. mStaticMatrix->get(6), mStaticMatrix->get(7),
  682. mStaticMatrix->get(8));
  683. }
  684. if (mAnimationMatrix) {
  685. ALOGD("%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
  686. indent, "ConcatMatrix (animation)", mAnimationMatrix,
  687. mAnimationMatrix->get(0), mAnimationMatrix->get(1),
  688. mAnimationMatrix->get(2), mAnimationMatrix->get(3),
  689. mAnimationMatrix->get(4), mAnimationMatrix->get(5),
  690. mAnimationMatrix->get(6), mAnimationMatrix->get(7),
  691. mAnimationMatrix->get(8));
  692. }
  693. if (mMatrixFlags != 0) {
  694. if (mMatrixFlags == TRANSLATION) {
  695. ALOGD("%s%s %f, %f", indent, "Translate", mTranslationX, mTranslationY);
  696. } else {
  697. ALOGD("%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
  698. indent, "ConcatMatrix", mTransformMatrix,
  699. mTransformMatrix->get(0), mTransformMatrix->get(1),
  700. mTransformMatrix->get(2), mTransformMatrix->get(3),
  701. mTransformMatrix->get(4), mTransformMatrix->get(5),
  702. mTransformMatrix->get(6), mTransformMatrix->get(7),
  703. mTransformMatrix->get(8));
  704. }
  705. }
  706. if (mAlpha < 1 && !mCaching) {
  707. if (!mHasOverlappingRendering) {
  708. ALOGD("%s%s %.2f", indent, "SetAlpha", mAlpha);
  709. } else {
  710. int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
  711. if (mClipChildren) {
  712. flags |= SkCanvas::kClipToLayer_SaveFlag;
  713. }
  714. ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
  715. (float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
  716. mMultipliedAlpha, flags);
  717. }
  718. }
  719. if (mClipChildren) {
  720. ALOGD("%s%s %.2f, %.2f, %.2f, %.2f", indent, "ClipRect", 0.0f, 0.0f,
  721. (float) mRight - mLeft, (float) mBottom - mTop);
  722. }
  723. }
  724. void DisplayList::setViewProperties(OpenGLRenderer& renderer, uint32_t level) {
  725. #if DEBUG_DISPLAY_LIST
  726. uint32_t count = (level + 1) * 2;
  727. char indent[count + 1];
  728. for (uint32_t i = 0; i < count; i++) {
  729. indent[i] = ' ';
  730. }
  731. indent[count] = '\0';
  732. #endif
  733. updateMatrix();
  734. if (mLeft != 0 || mTop != 0) {
  735. DISPLAY_LIST_LOGD("%s%s %d, %d", indent, "Translate (left, top)", mLeft, mTop);
  736. renderer.translate(mLeft, mTop);
  737. }
  738. if (mStaticMatrix) {
  739. DISPLAY_LIST_LOGD(
  740. "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
  741. indent, "ConcatMatrix (static)", mStaticMatrix,
  742. mStaticMatrix->get(0), mStaticMatrix->get(1),
  743. mStaticMatrix->get(2), mStaticMatrix->get(3),
  744. mStaticMatrix->get(4), mStaticMatrix->get(5),
  745. mStaticMatrix->get(6), mStaticMatrix->get(7),
  746. mStaticMatrix->get(8));
  747. renderer.concatMatrix(mStaticMatrix);
  748. } else if (mAnimationMatrix) {
  749. DISPLAY_LIST_LOGD(
  750. "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
  751. indent, "ConcatMatrix (animation)", mAnimationMatrix,
  752. mAnimationMatrix->get(0), mAnimationMatrix->get(1),
  753. mAnimationMatrix->get(2), mAnimationMatrix->get(3),
  754. mAnimationMatrix->get(4), mAnimationMatrix->get(5),
  755. mAnimationMatrix->get(6), mAnimationMatrix->get(7),
  756. mAnimationMatrix->get(8));
  757. renderer.concatMatrix(mAnimationMatrix);
  758. }
  759. if (mMatrixFlags != 0) {
  760. if (mMatrixFlags == TRANSLATION) {
  761. DISPLAY_LIST_LOGD("%s%s %f, %f", indent, "Translate", mTranslationX, mTranslationY);
  762. renderer.translate(mTranslationX, mTranslationY);
  763. } else {
  764. DISPLAY_LIST_LOGD(
  765. "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
  766. indent, "ConcatMatrix", mTransformMatrix,
  767. mTransformMatrix->get(0), mTransformMatrix->get(1),
  768. mTransformMatrix->get(2), mTransformMatrix->get(3),
  769. mTransformMatrix->get(4), mTransformMatrix->get(5),
  770. mTransformMatrix->get(6), mTransformMatrix->get(7),
  771. mTransformMatrix->get(8));
  772. renderer.concatMatrix(mTransformMatrix);
  773. }
  774. }
  775. if (mAlpha < 1 && !mCaching) {
  776. if (!mHasOverlappingRendering) {
  777. DISPLAY_LIST_LOGD("%s%s %.2f", indent, "SetAlpha", mAlpha);
  778. renderer.setAlpha(mAlpha);
  779. } else {
  780. // TODO: should be able to store the size of a DL at record time and not
  781. // have to pass it into this call. In fact, this information might be in the
  782. // location/size info that we store with the new native transform data.
  783. int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
  784. if (mClipChildren) {
  785. flags |= SkCanvas::kClipToLayer_SaveFlag;
  786. }
  787. DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
  788. (float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
  789. mMultipliedAlpha, flags);
  790. renderer.saveLayerAlpha(0, 0, mRight - mLeft, mBottom - mTop,
  791. mMultipliedAlpha, flags);
  792. }
  793. }
  794. if (mClipChildren) {
  795. DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f", indent, "ClipRect", 0.0f, 0.0f,
  796. (float) mRight - mLeft, (float) mBottom - mTop);
  797. renderer.clipRect(0, 0, mRight - mLeft, mBottom - mTop,
  798. SkRegion::kIntersect_Op);
  799. }
  800. }
  801. /**
  802. * Changes to replay(), specifically those involving opcode or parameter changes, should be mimicked
  803. * in the output() function, since that function processes the same list of opcodes for the
  804. * purposes of logging display list info for a given view.
  805. */
  806. status_t DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, uint32_t level) {
  807. status_t drawGlStatus = DrawGlInfo::kStatusDone;
  808. TextContainer text;
  809. mReader.rewind();
  810. #if DEBUG_DISPLAY_LIST
  811. uint32_t count = (level + 1) * 2;
  812. char indent[count + 1];
  813. for (uint32_t i = 0; i < count; i++) {
  814. indent[i] = ' ';
  815. }
  816. indent[count] = '\0';
  817. Rect* clipRect = renderer.getClipRect();
  818. DISPLAY_LIST_LOGD("%sStart display list (%p, %s), clipRect: %.0f, %.f, %.0f, %.0f",
  819. (char*) indent + 2, this, mName.string(), clipRect->left, clipRect->top,
  820. clipRect->right, clipRect->bottom);
  821. #endif
  822. renderer.startMark(mName.string());
  823. int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
  824. DISPLAY_LIST_LOGD("%s%s %d %d", indent, "Save",
  825. SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag, restoreTo);
  826. setViewProperties(renderer, level);
  827. if (renderer.quickRejectNoScissor(0, 0, mWidth, mHeight)) {
  828. DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, "RestoreToCount", restoreTo);
  829. renderer.restoreToCount(restoreTo);
  830. renderer.endMark();
  831. return drawGlStatus;
  832. }
  833. DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
  834. int saveCount = renderer.getSaveCount() - 1;
  835. while (!mReader.eof()) {
  836. int op = mReader.readInt();
  837. if (op & OP_MAY_BE_SKIPPED_MASK) {
  838. int32_t skip = mReader.readInt();
  839. if (CC_LIKELY(flags & kReplayFlag_ClipChildren)) {
  840. mReader.skip(skip);
  841. DISPLAY_LIST_LOGD("%s%s skipping %d bytes", (char*) indent,
  842. OP_NAMES[op & ~OP_MAY_BE_SKIPPED_MASK], skip);
  843. continue;
  844. } else {
  845. op &= ~OP_MAY_BE_SKIPPED_MASK;
  846. }
  847. }
  848. logBuffer.writeCommand(level, op);
  849. #if DEBUG_DISPLAY_LIST_OPS_AS_EVENTS
  850. Caches::getInstance().eventMark(strlen(OP_NAMES[op]), OP_NAMES[op]);
  851. #endif
  852. switch (op) {
  853. case DrawGLFunction: {
  854. Functor *functor = (Functor *) getInt();
  855. DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], functor);
  856. renderer.startMark("GL functor");
  857. drawGlStatus |= renderer.callDrawGLFunction(functor, dirty);
  858. renderer.endMark();
  859. }
  860. break;
  861. case Save: {
  862. int32_t rendererNum = getInt();
  863. DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, OP_NAMES[op], rendererNum);
  864. renderer.save(rendererNum);
  865. }
  866. break;
  867. case Restore: {
  868. DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
  869. renderer.restore();
  870. }
  871. break;
  872. case RestoreToCount: {
  873. int32_t restoreCount = saveCount + getInt();
  874. DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, OP_NAMES[op], restoreCount);
  875. renderer.restoreToCount(restoreCount);
  876. }
  877. break;
  878. case SaveLayer: {
  879. float f1 = getFloat();
  880. float f2 = getFloat();
  881. float f3 = getFloat();
  882. float f4 = getFloat();
  883. SkPaint* paint = getPaint(renderer);
  884. int32_t flags = getInt();
  885. DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p, 0x%x", (char*) indent,
  886. OP_NAMES[op], f1, f2, f3, f4, paint, flags);
  887. renderer.saveLayer(f1, f2, f3, f4, paint, flags);
  888. }
  889. break;
  890. case SaveLayerAlpha: {
  891. float f1 = getFloat();
  892. float f2 = getFloat();
  893. float f3 = getFloat();
  894. float f4 = getFloat();
  895. int32_t alpha = getInt();
  896. int32_t flags = getInt();
  897. DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", (char*) indent,
  898. OP_NAMES[op], f1, f2, f3, f4, alpha, flags);
  899. renderer.saveLayerAlpha(f1, f2, f3, f4, alpha, flags);
  900. }
  901. break;
  902. case Translate: {
  903. float f1 = getFloat();
  904. float f2 = getFloat();
  905. DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], f1, f2);
  906. renderer.translate(f1, f2);
  907. }
  908. break;
  909. case Rotate: {
  910. float rotation = getFloat();
  911. DISPLAY_LIST_LOGD("%s%s %.2f", (char*) indent, OP_NAMES[op], rotation);
  912. renderer.rotate(rotation);
  913. }
  914. break;
  915. case Scale: {
  916. float sx = getFloat();
  917. float sy = getFloat();
  918. DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
  919. renderer.scale(sx, sy);
  920. }
  921. break;
  922. case Skew: {
  923. float sx = getFloat();
  924. float sy = getFloat();
  925. DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
  926. renderer.skew(sx, sy);
  927. }
  928. break;
  929. case SetMatrix: {
  930. SkMatrix* matrix = getMatrix();
  931. DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], matrix);
  932. renderer.setMatrix(matrix);
  933. }
  934. break;
  935. case ConcatMatrix: {
  936. SkMatrix* matrix = getMatrix();
  937. DISPLAY_LIST_LOGD(
  938. "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
  939. (char*) indent, OP_NAMES[op], matrix,
  940. matrix->get(0), matrix->get(1), matrix->get(2),
  941. matrix->get(3), matrix->get(4), matrix->get(5),
  942. matrix->get(6), matrix->get(7), matrix->get(8));
  943. renderer.concatMatrix(matrix);
  944. }
  945. break;
  946. case ClipRect: {
  947. float f1 = getFloat();
  948. float f2 = getFloat();
  949. float f3 = getFloat();
  950. float f4 = getFloat();
  951. int32_t regionOp = getInt();
  952. DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d", (char*) indent, OP_NAMES[op],
  953. f1, f2, f3, f4, regionOp);
  954. renderer.clipRect(f1, f2, f3, f4, (SkRegion::Op) regionOp);
  955. }
  956. break;
  957. case DrawDisplayList: {
  958. DisplayList* displayList = getDisplayList();
  959. int32_t flags = getInt();
  960. DISPLAY_LIST_LOGD("%s%s %p, %dx%d, 0x%x %d", (char*) indent, OP_NAMES[op],
  961. displayList, mWidth, mHeight, flags, level + 1);
  962. drawGlStatus |= renderer.drawDisplayList(displayList, dirty, flags, level + 1);
  963. }
  964. break;
  965. case DrawLayer: {
  966. int oldAlpha = -1;
  967. Layer* layer = (Layer*) getInt();
  968. float x = getFloat();
  969. float y = getFloat();
  970. SkPaint* paint = getPaint(renderer);
  971. if (mCaching && mMultipliedAlpha < 255) {
  972. oldAlpha = layer->getAlpha();
  973. layer->setAlpha(mMultipliedAlpha);
  974. }
  975. DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
  976. layer, x, y, paint);
  977. drawGlStatus |= renderer.drawLayer(layer, x, y, paint);
  978. if (oldAlpha >= 0) {
  979. layer->setAlpha(oldAlpha);
  980. }
  981. }
  982. break;
  983. case DrawBitmap: {
  984. int oldAlpha = -1;
  985. SkBitmap* bitmap = getBitmap();
  986. float x = getFloat();
  987. float y = getFloat();
  988. SkPaint* paint = getPaint(renderer);
  989. if (mCaching && mMultipliedAlpha < 255) {
  990. oldAlpha = paint->getAlpha();
  991. paint->setAlpha(mMultipliedAlpha);
  992. }
  993. DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
  994. bitmap, x, y, paint);
  995. drawGlStatus |= renderer.drawBitmap(bitmap, x, y, paint);
  996. if (oldAlpha >= 0) {
  997. paint->setAlpha(oldAlpha);
  998. }
  999. }
  1000. break;
  1001. case DrawBitmapMatrix: {
  1002. SkBitmap* bitmap = getBitmap();
  1003. SkMatrix* matrix = getMatrix();
  1004. SkPaint* paint = getPaint(renderer);
  1005. DISPLAY_LIST_LOGD("%s%s %p, %p, %p", (char*) indent, OP_NAMES[op],
  1006. bitmap, matrix, paint);
  1007. drawGlStatus |= renderer.drawBitmap(bitmap, matrix, paint);
  1008. }
  1009. break;
  1010. case DrawBitmapRect: {
  1011. SkBitmap* bitmap = getBitmap();
  1012. float f1 = getFloat();
  1013. float f2 = getFloat();
  1014. float f3 = getFloat();
  1015. float f4 = getFloat();
  1016. float f5 = getFloat();
  1017. float f6 = getFloat();
  1018. float f7 = getFloat();
  1019. float f8 = getFloat();
  1020. SkPaint* paint = getPaint(renderer);
  1021. DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
  1022. (char*) indent, OP_NAMES[op], bitmap,
  1023. f1, f2, f3, f4, f5, f6, f7, f8,paint);
  1024. drawGlStatus |= renderer.drawBitmap(bitmap, f1, f2, f3, f4, f5, f6, f7, f8, paint);
  1025. }
  1026. break;
  1027. case DrawBitmapData: {
  1028. SkBitmap* bitmap = getBitmapData();
  1029. float x = getFloat();
  1030. float y = getFloat();
  1031. SkPaint* paint = getPaint(renderer);
  1032. DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
  1033. bitmap, x, y, paint);
  1034. drawGlStatus |= renderer.drawBitmap(bitmap, x, y, paint);
  1035. }
  1036. break;
  1037. case DrawBitmapMesh: {
  1038. int32_t verticesCount = 0;
  1039. uint32_t colorsCount = 0;
  1040. SkBitmap* bitmap = getBitmap();
  1041. uint32_t meshWidth = getInt();
  1042. uint32_t meshHeight = getInt();
  1043. float* vertices = getFloats(verticesCount);
  1044. bool hasColors = getInt();
  1045. int32_t* colors = hasColors ? getInts(colorsCount) : NULL;
  1046. SkPaint* paint = getPaint(renderer);
  1047. DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
  1048. drawGlStatus |= renderer.drawBitmapMesh(bitmap, meshWidth, meshHeight, vertices,
  1049. colors, paint);
  1050. }
  1051. break;
  1052. case DrawPatch: {
  1053. int32_t* xDivs = NULL;
  1054. int32_t* yDivs = NULL;
  1055. uint32_t* colors = NULL;
  1056. uint32_t xDivsCount = 0;
  1057. uint32_t yDivsCount = 0;
  1058. int8_t numColors = 0;
  1059. SkBitmap* bitmap = getBitmap();
  1060. xDivs = getInts(xDivsCount);
  1061. yDivs = getInts(yDivsCount);
  1062. colors = getUInts(numColors);
  1063. float left = getFloat();
  1064. float top = getFloat();
  1065. float right = getFloat();
  1066. float bottom = getFloat();
  1067. int alpha = getInt();
  1068. SkXfermode::Mode mode = (SkXfermode::Mode) getInt();
  1069. DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
  1070. drawGlStatus |= renderer.drawPatch(bitmap, xDivs, yDivs, colors,
  1071. xDivsCount, yDivsCount, numColors, left, top, right, bottom,
  1072. alpha, mode);
  1073. }
  1074. break;
  1075. case DrawColor: {
  1076. int32_t color = getInt();
  1077. int32_t xferMode = getInt();
  1078. DISPLAY_LIST_LOGD("%s%s 0x%x %d", (char*) indent, OP_NAMES[op], color, xferMode);
  1079. drawGlStatus |= renderer.drawColor(color, (SkXfermode::Mode) xferMode);
  1080. }
  1081. break;
  1082. case DrawRect: {
  1083. float f1 = getFloat();
  1084. float f2 = getFloat();
  1085. float f3 = getFloat();
  1086. float f4 = getFloat();
  1087. SkPaint* paint = getPaint(renderer);
  1088. DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
  1089. f1, f2, f3, f4, paint);
  1090. drawGlStatus |= renderer.drawRect(f1, f2, f3, f4, paint);
  1091. }
  1092. break;
  1093. case DrawRoundRect: {
  1094. float f1 = getFloat();
  1095. float f2 = getFloat();
  1096. float f3 = getFloat();
  1097. float f4 = getFloat();
  1098. float f5 = getFloat();
  1099. float f6 = getFloat();
  1100. SkPaint* paint = getPaint(renderer);
  1101. DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
  1102. (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, paint);
  1103. drawGlStatus |= renderer.drawRoundRect(f1, f2, f3, f4, f5, f6, paint);
  1104. }
  1105. break;
  1106. case DrawCircle: {
  1107. float f1 = getFloat();
  1108. float f2 = getFloat();
  1109. float f3 = getFloat();
  1110. SkPaint* paint = getPaint(renderer);
  1111. DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %p",
  1112. (char*) indent, OP_NAMES[op], f1, f2, f3, paint);
  1113. drawGlStatus |= renderer.drawCircle(f1, f2, f3, paint);
  1114. }
  1115. break;
  1116. case DrawOval: {
  1117. float f1 = getFloat();
  1118. float f2 = getFloat();
  1119. float f3 = getFloat();
  1120. float f4 = getFloat();
  1121. SkPaint* paint = getPaint(renderer);
  1122. DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p",
  1123. (char*) indent, OP_NAMES[op], f1, f2, f3, f4, paint);
  1124. drawGlStatus |= renderer.drawOval(f1, f2, f3, f4, paint);
  1125. }
  1126. break;
  1127. case DrawArc: {
  1128. float f1 = getFloat();
  1129. float f2 = getFloat();
  1130. float f3 = getFloat();
  1131. float f4 = getFloat();
  1132. float f5 = getFloat();
  1133. float f6 = getFloat();
  1134. int32_t i1 = getInt();
  1135. SkPaint* paint = getPaint(renderer);
  1136. DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d, %p",
  1137. (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, i1, paint);
  1138. drawGlStatus |= renderer.drawArc(f1, f2, f3, f4, f5, f6, i1 == 1, paint);
  1139. }
  1140. break;
  1141. case DrawPath: {
  1142. SkPath* path = getPath();
  1143. SkPaint* paint = getPaint(renderer);
  1144. DISPLAY_LIST_LOGD("%s%s %p, %p", (char*) indent, OP_NAMES[op], path, paint);
  1145. drawGlStatus |= renderer.drawPath(path, paint);
  1146. }
  1147. break;
  1148. case DrawLines: {
  1149. int32_t count = 0;
  1150. float* points = getFloats(count);
  1151. SkPaint* paint = getPaint(renderer);
  1152. DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
  1153. drawGlStatus |= renderer.drawLines(points, count, paint);
  1154. }
  1155. break;
  1156. case DrawPoints: {
  1157. int32_t count = 0;
  1158. float* points = getFloats(count);
  1159. SkPaint* paint = getPaint(renderer);
  1160. DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
  1161. drawGlStatus |= renderer.drawPoints(points, count, paint);
  1162. }
  1163. break;
  1164. case DrawTextOnPath: {
  1165. getText(&text);
  1166. int32_t count = getInt();
  1167. SkPath* path = getPath();
  1168. float hOffset = getFloat();
  1169. float vOffset = getFloat();
  1170. SkPaint* paint = getPaint(renderer);
  1171. DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
  1172. text.text(), text.length(), count, paint);
  1173. drawGlStatus |= renderer.drawTextOnPath(text.text(), text.length(), count, path,
  1174. hOffset, vOffset, paint);
  1175. }
  1176. break;
  1177. case DrawPosText: {
  1178. getText(&text);
  1179. int32_t count = getInt();
  1180. int32_t positionsCount = 0;
  1181. float* positions = getFloats(positionsCount);
  1182. SkPaint* paint = getPaint(renderer);
  1183. DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %p", (char*) indent,
  1184. OP_NAMES[op], text.text(), text.length(), count, paint);
  1185. drawGlStatus |= renderer.drawPosText(text.text(), text.length(), count,
  1186. positions, paint);
  1187. }
  1188. break;
  1189. case DrawText: {
  1190. getText(&text);
  1191. int32_t count = getInt();
  1192. float x = getFloat();
  1193. float y = getFloat();
  1194. int32_t positionsCount = 0;
  1195. float* positions = getFloats(positionsCount);
  1196. SkPaint* paint = getPaint(renderer);
  1197. float length = getFloat();
  1198. DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %.2f, %.2f, %p, %.2f", (char*) indent,
  1199. OP_NAMES[op], text.text(), text.length(), count, x, y, paint, length);
  1200. drawGlStatus |= renderer.drawText(text.text(), text.length(), count,
  1201. x, y, positions, paint, length);
  1202. }
  1203. break;
  1204. case ResetShader: {
  1205. DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);