RenderNode.cpp revision f7483e3af0513a1baa8341d403df2e0c0896a9ff
1/* 2 * Copyright (C) 2014 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 17#define ATRACE_TAG ATRACE_TAG_VIEW 18 19#include "RenderNode.h" 20 21#include <SkCanvas.h> 22#include <algorithm> 23 24#include <utils/Trace.h> 25 26#include "Debug.h" 27#include "DisplayListOp.h" 28#include "DisplayListLogBuffer.h" 29 30namespace android { 31namespace uirenderer { 32 33void RenderNode::outputLogBuffer(int fd) { 34 DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance(); 35 if (logBuffer.isEmpty()) { 36 return; 37 } 38 39 FILE *file = fdopen(fd, "a"); 40 41 fprintf(file, "\nRecent DisplayList operations\n"); 42 logBuffer.outputCommands(file); 43 44 String8 cachesLog; 45 Caches::getInstance().dumpMemoryUsage(cachesLog); 46 fprintf(file, "\nCaches:\n%s", cachesLog.string()); 47 fprintf(file, "\n"); 48 49 fflush(file); 50} 51 52RenderNode::RenderNode() 53 : mDestroyed(false) 54 , mNeedsPropertiesSync(false) 55 , mNeedsDisplayListDataSync(false) 56 , mDisplayListData(0) 57 , mStagingDisplayListData(0) { 58} 59 60RenderNode::~RenderNode() { 61 LOG_ALWAYS_FATAL_IF(mDestroyed, "Double destroyed DisplayList %p", this); 62 63 mDestroyed = true; 64 delete mDisplayListData; 65 delete mStagingDisplayListData; 66} 67 68void RenderNode::setStagingDisplayList(DisplayListData* data) { 69 mNeedsDisplayListDataSync = true; 70 delete mStagingDisplayListData; 71 mStagingDisplayListData = data; 72 if (mStagingDisplayListData) { 73 Caches::getInstance().registerFunctors(mStagingDisplayListData->functorCount); 74 } 75} 76 77/** 78 * This function is a simplified version of replay(), where we simply retrieve and log the 79 * display list. This function should remain in sync with the replay() function. 80 */ 81void RenderNode::output(uint32_t level) { 82 ALOGD("%*sStart display list (%p, %s, render=%d)", (level - 1) * 2, "", this, 83 mName.string(), isRenderable()); 84 ALOGD("%*s%s %d", level * 2, "", "Save", 85 SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag); 86 87 properties().debugOutputProperties(level); 88 int flags = DisplayListOp::kOpLogFlag_Recurse; 89 for (unsigned int i = 0; i < mDisplayListData->displayListOps.size(); i++) { 90 mDisplayListData->displayListOps[i]->output(level, flags); 91 } 92 93 ALOGD("%*sDone (%p, %s)", (level - 1) * 2, "", this, mName.string()); 94} 95 96void RenderNode::prepareTree(TreeInfo& info) { 97 ATRACE_CALL(); 98 99 prepareTreeImpl(info); 100} 101 102void RenderNode::prepareTreeImpl(TreeInfo& info) { 103 pushStagingChanges(info); 104 prepareSubTree(info, mDisplayListData); 105} 106 107void RenderNode::pushStagingChanges(TreeInfo& info) { 108 if (mNeedsPropertiesSync) { 109 mNeedsPropertiesSync = false; 110 mProperties = mStagingProperties; 111 } 112 if (mNeedsDisplayListDataSync) { 113 mNeedsDisplayListDataSync = false; 114 // Do a push pass on the old tree to handle freeing DisplayListData 115 // that are no longer used 116 TreeInfo oldTreeInfo = {0}; 117 prepareSubTree(oldTreeInfo, mDisplayListData); 118 // TODO: The damage for the old tree should be accounted for 119 delete mDisplayListData; 120 mDisplayListData = mStagingDisplayListData; 121 mStagingDisplayListData = 0; 122 } 123} 124 125void RenderNode::prepareSubTree(TreeInfo& info, DisplayListData* subtree) { 126 if (subtree) { 127 if (!info.hasFunctors) { 128 info.hasFunctors = subtree->functorCount; 129 } 130 for (size_t i = 0; i < subtree->children().size(); i++) { 131 RenderNode* childNode = subtree->children()[i]->mDisplayList; 132 childNode->prepareTreeImpl(info); 133 } 134 } 135} 136 137/* 138 * For property operations, we pass a savecount of 0, since the operations aren't part of the 139 * displaylist, and thus don't have to compensate for the record-time/playback-time discrepancy in 140 * base saveCount (i.e., how RestoreToCount uses saveCount + properties().getCount()) 141 */ 142#define PROPERTY_SAVECOUNT 0 143 144template <class T> 145void RenderNode::setViewProperties(OpenGLRenderer& renderer, T& handler) { 146#if DEBUG_DISPLAY_LIST 147 properties().debugOutputProperties(handler.level() + 1); 148#endif 149 if (properties().getLeft() != 0 || properties().getTop() != 0) { 150 renderer.translate(properties().getLeft(), properties().getTop()); 151 } 152 if (properties().getStaticMatrix()) { 153 renderer.concatMatrix(properties().getStaticMatrix()); 154 } else if (properties().getAnimationMatrix()) { 155 renderer.concatMatrix(properties().getAnimationMatrix()); 156 } 157 if (properties().hasTransformMatrix()) { 158 if (properties().isTransformTranslateOnly()) { 159 renderer.translate(properties().getTranslationX(), properties().getTranslationY()); 160 } else { 161 renderer.concatMatrix(*properties().getTransformMatrix()); 162 } 163 } 164 bool clipToBoundsNeeded = properties().getCaching() ? false : properties().getClipToBounds(); 165 if (properties().getAlpha() < 1) { 166 if (properties().getCaching()) { 167 renderer.setOverrideLayerAlpha(properties().getAlpha()); 168 } else if (!properties().getHasOverlappingRendering()) { 169 renderer.scaleAlpha(properties().getAlpha()); 170 } else { 171 // TODO: should be able to store the size of a DL at record time and not 172 // have to pass it into this call. In fact, this information might be in the 173 // location/size info that we store with the new native transform data. 174 int saveFlags = SkCanvas::kHasAlphaLayer_SaveFlag; 175 if (clipToBoundsNeeded) { 176 saveFlags |= SkCanvas::kClipToLayer_SaveFlag; 177 clipToBoundsNeeded = false; // clipping done by saveLayer 178 } 179 180 SaveLayerOp* op = new (handler.allocator()) SaveLayerOp( 181 0, 0, properties().getWidth(), properties().getHeight(), 182 properties().getAlpha() * 255, saveFlags); 183 handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds()); 184 } 185 } 186 if (clipToBoundsNeeded) { 187 ClipRectOp* op = new (handler.allocator()) ClipRectOp( 188 0, 0, properties().getWidth(), properties().getHeight(), SkRegion::kIntersect_Op); 189 handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds()); 190 } 191 192 if (CC_UNLIKELY(properties().hasClippingPath())) { 193 // TODO: optimize for round rect/circle clipping 194 const SkPath* path = properties().getClippingPath(); 195 ClipPathOp* op = new (handler.allocator()) ClipPathOp(path, SkRegion::kIntersect_Op); 196 handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds()); 197 } 198} 199 200/** 201 * Apply property-based transformations to input matrix 202 * 203 * If true3dTransform is set to true, the transform applied to the input matrix will use true 4x4 204 * matrix computation instead of the Skia 3x3 matrix + camera hackery. 205 */ 206void RenderNode::applyViewPropertyTransforms(mat4& matrix, bool true3dTransform) { 207 if (properties().getLeft() != 0 || properties().getTop() != 0) { 208 matrix.translate(properties().getLeft(), properties().getTop()); 209 } 210 if (properties().getStaticMatrix()) { 211 mat4 stat(*properties().getStaticMatrix()); 212 matrix.multiply(stat); 213 } else if (properties().getAnimationMatrix()) { 214 mat4 anim(*properties().getAnimationMatrix()); 215 matrix.multiply(anim); 216 } 217 if (properties().hasTransformMatrix()) { 218 if (properties().isTransformTranslateOnly()) { 219 matrix.translate(properties().getTranslationX(), properties().getTranslationY(), 220 true3dTransform ? properties().getTranslationZ() : 0.0f); 221 } else { 222 if (!true3dTransform) { 223 matrix.multiply(*properties().getTransformMatrix()); 224 } else { 225 mat4 true3dMat; 226 true3dMat.loadTranslate( 227 properties().getPivotX() + properties().getTranslationX(), 228 properties().getPivotY() + properties().getTranslationY(), 229 properties().getTranslationZ()); 230 true3dMat.rotate(properties().getRotationX(), 1, 0, 0); 231 true3dMat.rotate(properties().getRotationY(), 0, 1, 0); 232 true3dMat.rotate(properties().getRotation(), 0, 0, 1); 233 true3dMat.scale(properties().getScaleX(), properties().getScaleY(), 1); 234 true3dMat.translate(-properties().getPivotX(), -properties().getPivotY()); 235 236 matrix.multiply(true3dMat); 237 } 238 } 239 } 240} 241 242/** 243 * Organizes the DisplayList hierarchy to prepare for background projection reordering. 244 * 245 * This should be called before a call to defer() or drawDisplayList() 246 * 247 * Each DisplayList that serves as a 3d root builds its list of composited children, 248 * which are flagged to not draw in the standard draw loop. 249 */ 250void RenderNode::computeOrdering() { 251 ATRACE_CALL(); 252 mProjectedNodes.clear(); 253 254 // TODO: create temporary DDLOp and call computeOrderingImpl on top DisplayList so that 255 // transform properties are applied correctly to top level children 256 if (mDisplayListData == NULL) return; 257 for (unsigned int i = 0; i < mDisplayListData->children().size(); i++) { 258 DrawDisplayListOp* childOp = mDisplayListData->children()[i]; 259 childOp->mDisplayList->computeOrderingImpl(childOp, 260 &mProjectedNodes, &mat4::identity()); 261 } 262} 263 264void RenderNode::computeOrderingImpl( 265 DrawDisplayListOp* opState, 266 Vector<DrawDisplayListOp*>* compositedChildrenOfProjectionSurface, 267 const mat4* transformFromProjectionSurface) { 268 mProjectedNodes.clear(); 269 if (mDisplayListData == NULL || mDisplayListData->isEmpty()) return; 270 271 // TODO: should avoid this calculation in most cases 272 // TODO: just calculate single matrix, down to all leaf composited elements 273 Matrix4 localTransformFromProjectionSurface(*transformFromProjectionSurface); 274 localTransformFromProjectionSurface.multiply(opState->mTransformFromParent); 275 276 if (properties().getProjectBackwards()) { 277 // composited projectee, flag for out of order draw, save matrix, and store in proj surface 278 opState->mSkipInOrderDraw = true; 279 opState->mTransformFromCompositingAncestor.load(localTransformFromProjectionSurface); 280 compositedChildrenOfProjectionSurface->add(opState); 281 } else { 282 // standard in order draw 283 opState->mSkipInOrderDraw = false; 284 } 285 286 if (mDisplayListData->children().size() > 0) { 287 const bool isProjectionReceiver = mDisplayListData->projectionReceiveIndex >= 0; 288 bool haveAppliedPropertiesToProjection = false; 289 for (unsigned int i = 0; i < mDisplayListData->children().size(); i++) { 290 DrawDisplayListOp* childOp = mDisplayListData->children()[i]; 291 RenderNode* child = childOp->mDisplayList; 292 293 Vector<DrawDisplayListOp*>* projectionChildren = NULL; 294 const mat4* projectionTransform = NULL; 295 if (isProjectionReceiver && !child->properties().getProjectBackwards()) { 296 // if receiving projections, collect projecting descendent 297 298 // Note that if a direct descendent is projecting backwards, we pass it's 299 // grandparent projection collection, since it shouldn't project onto it's 300 // parent, where it will already be drawing. 301 projectionChildren = &mProjectedNodes; 302 projectionTransform = &mat4::identity(); 303 } else { 304 if (!haveAppliedPropertiesToProjection) { 305 applyViewPropertyTransforms(localTransformFromProjectionSurface); 306 haveAppliedPropertiesToProjection = true; 307 } 308 projectionChildren = compositedChildrenOfProjectionSurface; 309 projectionTransform = &localTransformFromProjectionSurface; 310 } 311 child->computeOrderingImpl(childOp, projectionChildren, projectionTransform); 312 } 313 } 314} 315 316class DeferOperationHandler { 317public: 318 DeferOperationHandler(DeferStateStruct& deferStruct, int level) 319 : mDeferStruct(deferStruct), mLevel(level) {} 320 inline void operator()(DisplayListOp* operation, int saveCount, bool clipToBounds) { 321 operation->defer(mDeferStruct, saveCount, mLevel, clipToBounds); 322 } 323 inline LinearAllocator& allocator() { return *(mDeferStruct.mAllocator); } 324 inline void startMark(const char* name) {} // do nothing 325 inline void endMark() {} 326 inline int level() { return mLevel; } 327 inline int replayFlags() { return mDeferStruct.mReplayFlags; } 328 329private: 330 DeferStateStruct& mDeferStruct; 331 const int mLevel; 332}; 333 334void RenderNode::deferNodeTree(DeferStateStruct& deferStruct) { 335 DeferOperationHandler handler(deferStruct, 0); 336 if (properties().getTranslationZ() > 0.0f) issueDrawShadowOperation(Matrix4::identity(), handler); 337 issueOperations<DeferOperationHandler>(deferStruct.mRenderer, handler); 338} 339 340void RenderNode::deferNodeInParent(DeferStateStruct& deferStruct, const int level) { 341 DeferOperationHandler handler(deferStruct, level); 342 issueOperations<DeferOperationHandler>(deferStruct.mRenderer, handler); 343} 344 345class ReplayOperationHandler { 346public: 347 ReplayOperationHandler(ReplayStateStruct& replayStruct, int level) 348 : mReplayStruct(replayStruct), mLevel(level) {} 349 inline void operator()(DisplayListOp* operation, int saveCount, bool clipToBounds) { 350#if DEBUG_DISPLAY_LIST_OPS_AS_EVENTS 351 properties().getReplayStruct().mRenderer.eventMark(operation->name()); 352#endif 353 operation->replay(mReplayStruct, saveCount, mLevel, clipToBounds); 354 } 355 inline LinearAllocator& allocator() { return *(mReplayStruct.mAllocator); } 356 inline void startMark(const char* name) { 357 mReplayStruct.mRenderer.startMark(name); 358 } 359 inline void endMark() { 360 mReplayStruct.mRenderer.endMark(); 361 DISPLAY_LIST_LOGD("%*sDone (%p, %s), returning %d", level * 2, "", this, mName.string(), 362 mReplayStruct.mDrawGlStatus); 363 } 364 inline int level() { return mLevel; } 365 inline int replayFlags() { return mReplayStruct.mReplayFlags; } 366 367private: 368 ReplayStateStruct& mReplayStruct; 369 const int mLevel; 370}; 371 372void RenderNode::replayNodeTree(ReplayStateStruct& replayStruct) { 373 ReplayOperationHandler handler(replayStruct, 0); 374 if (properties().getTranslationZ() > 0.0f) issueDrawShadowOperation(Matrix4::identity(), handler); 375 issueOperations<ReplayOperationHandler>(replayStruct.mRenderer, handler); 376} 377 378void RenderNode::replayNodeInParent(ReplayStateStruct& replayStruct, const int level) { 379 ReplayOperationHandler handler(replayStruct, level); 380 issueOperations<ReplayOperationHandler>(replayStruct.mRenderer, handler); 381} 382 383void RenderNode::buildZSortedChildList(Vector<ZDrawDisplayListOpPair>& zTranslatedNodes) { 384 if (mDisplayListData == NULL || mDisplayListData->children().size() == 0) return; 385 386 for (unsigned int i = 0; i < mDisplayListData->children().size(); i++) { 387 DrawDisplayListOp* childOp = mDisplayListData->children()[i]; 388 RenderNode* child = childOp->mDisplayList; 389 float childZ = child->properties().getTranslationZ(); 390 391 if (childZ != 0.0f) { 392 zTranslatedNodes.add(ZDrawDisplayListOpPair(childZ, childOp)); 393 childOp->mSkipInOrderDraw = true; 394 } else if (!child->properties().getProjectBackwards()) { 395 // regular, in order drawing DisplayList 396 childOp->mSkipInOrderDraw = false; 397 } 398 } 399 400 // Z sort 3d children (stable-ness makes z compare fall back to standard drawing order) 401 std::stable_sort(zTranslatedNodes.begin(), zTranslatedNodes.end()); 402} 403 404template <class T> 405void RenderNode::issueDrawShadowOperation(const Matrix4& transformFromParent, T& handler) { 406 if (properties().getAlpha() <= 0.0f) return; 407 408 mat4 shadowMatrixXY(transformFromParent); 409 applyViewPropertyTransforms(shadowMatrixXY); 410 411 // Z matrix needs actual 3d transformation, so mapped z values will be correct 412 mat4 shadowMatrixZ(transformFromParent); 413 applyViewPropertyTransforms(shadowMatrixZ, true); 414 415 const SkPath* outlinePath = properties().getOutline().getPath(); 416 const RevealClip& revealClip = properties().getRevealClip(); 417 const SkPath* revealClipPath = revealClip.hasConvexClip() 418 ? revealClip.getPath() : NULL; // only pass the reveal clip's path if it's convex 419 420 /** 421 * The drawing area of the caster is always the same as the its perimeter (which 422 * the shadow system uses) *except* in the inverse clip case. Inform the shadow 423 * system that the caster's drawing area (as opposed to its perimeter) has been 424 * clipped, so that it knows the caster can't be opaque. 425 */ 426 bool casterUnclipped = !revealClip.willClip() || revealClip.hasConvexClip(); 427 428 DisplayListOp* shadowOp = new (handler.allocator()) DrawShadowOp( 429 shadowMatrixXY, shadowMatrixZ, 430 properties().getAlpha(), casterUnclipped, 431 properties().getWidth(), properties().getHeight(), 432 outlinePath, revealClipPath); 433 handler(shadowOp, PROPERTY_SAVECOUNT, properties().getClipToBounds()); 434} 435 436#define SHADOW_DELTA 0.1f 437 438template <class T> 439void RenderNode::issueOperationsOf3dChildren(const Vector<ZDrawDisplayListOpPair>& zTranslatedNodes, 440 ChildrenSelectMode mode, OpenGLRenderer& renderer, T& handler) { 441 const int size = zTranslatedNodes.size(); 442 if (size == 0 443 || (mode == kNegativeZChildren && zTranslatedNodes[0].key > 0.0f) 444 || (mode == kPositiveZChildren && zTranslatedNodes[size - 1].key < 0.0f)) { 445 // no 3d children to draw 446 return; 447 } 448 449 /** 450 * Draw shadows and (potential) casters mostly in order, but allow the shadows of casters 451 * with very similar Z heights to draw together. 452 * 453 * This way, if Views A & B have the same Z height and are both casting shadows, the shadows are 454 * underneath both, and neither's shadow is drawn on top of the other. 455 */ 456 const size_t nonNegativeIndex = findNonNegativeIndex(zTranslatedNodes); 457 size_t drawIndex, shadowIndex, endIndex; 458 if (mode == kNegativeZChildren) { 459 drawIndex = 0; 460 endIndex = nonNegativeIndex; 461 shadowIndex = endIndex; // draw no shadows 462 } else { 463 drawIndex = nonNegativeIndex; 464 endIndex = size; 465 shadowIndex = drawIndex; // potentially draw shadow for each pos Z child 466 } 467 float lastCasterZ = 0.0f; 468 while (shadowIndex < endIndex || drawIndex < endIndex) { 469 if (shadowIndex < endIndex) { 470 DrawDisplayListOp* casterOp = zTranslatedNodes[shadowIndex].value; 471 RenderNode* caster = casterOp->mDisplayList; 472 const float casterZ = zTranslatedNodes[shadowIndex].key; 473 // attempt to render the shadow if the caster about to be drawn is its caster, 474 // OR if its caster's Z value is similar to the previous potential caster 475 if (shadowIndex == drawIndex || casterZ - lastCasterZ < SHADOW_DELTA) { 476 caster->issueDrawShadowOperation(casterOp->mTransformFromParent, handler); 477 478 lastCasterZ = casterZ; // must do this even if current caster not casting a shadow 479 shadowIndex++; 480 continue; 481 } 482 } 483 484 // only the actual child DL draw needs to be in save/restore, 485 // since it modifies the renderer's matrix 486 int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag); 487 488 DrawDisplayListOp* childOp = zTranslatedNodes[drawIndex].value; 489 RenderNode* child = childOp->mDisplayList; 490 491 renderer.concatMatrix(childOp->mTransformFromParent); 492 childOp->mSkipInOrderDraw = false; // this is horrible, I'm so sorry everyone 493 handler(childOp, renderer.getSaveCount() - 1, properties().getClipToBounds()); 494 childOp->mSkipInOrderDraw = true; 495 496 renderer.restoreToCount(restoreTo); 497 drawIndex++; 498 } 499} 500 501template <class T> 502void RenderNode::issueOperationsOfProjectedChildren(OpenGLRenderer& renderer, T& handler) { 503 for (size_t i = 0; i < mProjectedNodes.size(); i++) { 504 DrawDisplayListOp* childOp = mProjectedNodes[i]; 505 506 // matrix save, concat, and restore can be done safely without allocating operations 507 int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag); 508 renderer.concatMatrix(childOp->mTransformFromCompositingAncestor); 509 childOp->mSkipInOrderDraw = false; // this is horrible, I'm so sorry everyone 510 handler(childOp, renderer.getSaveCount() - 1, properties().getClipToBounds()); 511 childOp->mSkipInOrderDraw = true; 512 renderer.restoreToCount(restoreTo); 513 } 514} 515 516/** 517 * This function serves both defer and replay modes, and will organize the displayList's component 518 * operations for a single frame: 519 * 520 * Every 'simple' state operation that affects just the matrix and alpha (or other factors of 521 * DeferredDisplayState) may be issued directly to the renderer, but complex operations (with custom 522 * defer logic) and operations in displayListOps are issued through the 'handler' which handles the 523 * defer vs replay logic, per operation 524 */ 525template <class T> 526void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) { 527 const int level = handler.level(); 528 if (CC_UNLIKELY(mDestroyed)) { // temporary debug logging 529 ALOGW("Error: %s is drawing after destruction", mName.string()); 530 CRASH(); 531 } 532 if (mDisplayListData->isEmpty() || properties().getAlpha() <= 0) { 533 DISPLAY_LIST_LOGD("%*sEmpty display list (%p, %s)", level * 2, "", this, mName.string()); 534 return; 535 } 536 537 handler.startMark(mName.string()); 538 539#if DEBUG_DISPLAY_LIST 540 Rect* clipRect = renderer.getClipRect(); 541 DISPLAY_LIST_LOGD("%*sStart display list (%p, %s), clipRect: %.0f, %.0f, %.0f, %.0f", 542 level * 2, "", this, mName.string(), clipRect->left, clipRect->top, 543 clipRect->right, clipRect->bottom); 544#endif 545 546 LinearAllocator& alloc = handler.allocator(); 547 int restoreTo = renderer.getSaveCount(); 548 handler(new (alloc) SaveOp(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag), 549 PROPERTY_SAVECOUNT, properties().getClipToBounds()); 550 551 DISPLAY_LIST_LOGD("%*sSave %d %d", (level + 1) * 2, "", 552 SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag, restoreTo); 553 554 setViewProperties<T>(renderer, handler); 555 556 bool quickRejected = properties().getClipToBounds() 557 && renderer.quickRejectConservative(0, 0, properties().getWidth(), properties().getHeight()); 558 if (!quickRejected) { 559 Vector<ZDrawDisplayListOpPair> zTranslatedNodes; 560 buildZSortedChildList(zTranslatedNodes); 561 562 // for 3d root, draw children with negative z values 563 issueOperationsOf3dChildren(zTranslatedNodes, kNegativeZChildren, renderer, handler); 564 565 DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance(); 566 const int saveCountOffset = renderer.getSaveCount() - 1; 567 const int projectionReceiveIndex = mDisplayListData->projectionReceiveIndex; 568 for (unsigned int i = 0; i < mDisplayListData->displayListOps.size(); i++) { 569 DisplayListOp *op = mDisplayListData->displayListOps[i]; 570 571#if DEBUG_DISPLAY_LIST 572 op->output(level + 1); 573#endif 574 logBuffer.writeCommand(level, op->name()); 575 handler(op, saveCountOffset, properties().getClipToBounds()); 576 577 if (CC_UNLIKELY(i == projectionReceiveIndex && mProjectedNodes.size() > 0)) { 578 issueOperationsOfProjectedChildren(renderer, handler); 579 } 580 } 581 582 // for 3d root, draw children with positive z values 583 issueOperationsOf3dChildren(zTranslatedNodes, kPositiveZChildren, renderer, handler); 584 } 585 586 DISPLAY_LIST_LOGD("%*sRestoreToCount %d", (level + 1) * 2, "", restoreTo); 587 handler(new (alloc) RestoreToCountOp(restoreTo), 588 PROPERTY_SAVECOUNT, properties().getClipToBounds()); 589 renderer.setOverrideLayerAlpha(1.0f); 590 591 handler.endMark(); 592} 593 594} /* namespace uirenderer */ 595} /* namespace android */ 596