John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 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 |
Chris Craik | 80d4902 | 2014-06-20 15:03:43 -0700 | [diff] [blame] | 18 | #define LOG_TAG "OpenGLRenderer" |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 19 | |
| 20 | #include "RenderNode.h" |
| 21 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 22 | #include <algorithm> |
John Reck | c25e506 | 2014-06-18 14:21:29 -0700 | [diff] [blame] | 23 | #include <string> |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 24 | |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 25 | #include <SkCanvas.h> |
| 26 | #include <algorithm> |
| 27 | |
| 28 | #include <utils/Trace.h> |
| 29 | |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 30 | #include "DamageAccumulator.h" |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 31 | #include "Debug.h" |
| 32 | #include "DisplayListOp.h" |
| 33 | #include "DisplayListLogBuffer.h" |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 34 | #include "LayerRenderer.h" |
| 35 | #include "OpenGLRenderer.h" |
Chris Craik | e0bb87d | 2014-04-22 17:55:41 -0700 | [diff] [blame] | 36 | #include "utils/MathUtils.h" |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 37 | |
| 38 | namespace android { |
| 39 | namespace uirenderer { |
| 40 | |
| 41 | void RenderNode::outputLogBuffer(int fd) { |
| 42 | DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance(); |
| 43 | if (logBuffer.isEmpty()) { |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | FILE *file = fdopen(fd, "a"); |
| 48 | |
| 49 | fprintf(file, "\nRecent DisplayList operations\n"); |
| 50 | logBuffer.outputCommands(file); |
| 51 | |
| 52 | String8 cachesLog; |
| 53 | Caches::getInstance().dumpMemoryUsage(cachesLog); |
| 54 | fprintf(file, "\nCaches:\n%s", cachesLog.string()); |
| 55 | fprintf(file, "\n"); |
| 56 | |
| 57 | fflush(file); |
| 58 | } |
| 59 | |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 60 | RenderNode::RenderNode() |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 61 | : mDirtyPropertyFields(0) |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 62 | , mNeedsDisplayListDataSync(false) |
| 63 | , mDisplayListData(0) |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 64 | , mStagingDisplayListData(0) |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 65 | , mNeedsAnimatorsSync(false) |
| 66 | , mLayer(0) { |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | RenderNode::~RenderNode() { |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 70 | delete mDisplayListData; |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 71 | delete mStagingDisplayListData; |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 72 | LayerRenderer::destroyLayerDeferred(mLayer); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 73 | } |
| 74 | |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 75 | void RenderNode::setStagingDisplayList(DisplayListData* data) { |
| 76 | mNeedsDisplayListDataSync = true; |
| 77 | delete mStagingDisplayListData; |
| 78 | mStagingDisplayListData = data; |
| 79 | if (mStagingDisplayListData) { |
| 80 | Caches::getInstance().registerFunctors(mStagingDisplayListData->functorCount); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 81 | } |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * This function is a simplified version of replay(), where we simply retrieve and log the |
| 86 | * display list. This function should remain in sync with the replay() function. |
| 87 | */ |
| 88 | void RenderNode::output(uint32_t level) { |
| 89 | ALOGD("%*sStart display list (%p, %s, render=%d)", (level - 1) * 2, "", this, |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 90 | getName(), isRenderable()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 91 | ALOGD("%*s%s %d", level * 2, "", "Save", |
| 92 | SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag); |
| 93 | |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 94 | properties().debugOutputProperties(level); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 95 | int flags = DisplayListOp::kOpLogFlag_Recurse; |
| 96 | for (unsigned int i = 0; i < mDisplayListData->displayListOps.size(); i++) { |
| 97 | mDisplayListData->displayListOps[i]->output(level, flags); |
| 98 | } |
| 99 | |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 100 | ALOGD("%*sDone (%p, %s)", (level - 1) * 2, "", this, getName()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 101 | } |
| 102 | |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 103 | int RenderNode::getDebugSize() { |
| 104 | int size = sizeof(RenderNode); |
| 105 | if (mStagingDisplayListData) { |
| 106 | size += mStagingDisplayListData->allocator.usedSize(); |
| 107 | } |
| 108 | if (mDisplayListData && mDisplayListData != mStagingDisplayListData) { |
| 109 | size += mDisplayListData->allocator.usedSize(); |
| 110 | } |
| 111 | return size; |
| 112 | } |
| 113 | |
John Reck | f4198b7 | 2014-04-09 17:00:04 -0700 | [diff] [blame] | 114 | void RenderNode::prepareTree(TreeInfo& info) { |
| 115 | ATRACE_CALL(); |
| 116 | |
| 117 | prepareTreeImpl(info); |
| 118 | } |
| 119 | |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 120 | void RenderNode::damageSelf(TreeInfo& info) { |
John Reck | ce9f308 | 2014-06-17 16:18:09 -0700 | [diff] [blame] | 121 | if (isRenderable()) { |
John Reck | 293e868 | 2014-06-17 10:34:02 -0700 | [diff] [blame] | 122 | if (properties().getClipDamageToBounds()) { |
John Reck | a447d29 | 2014-06-11 18:39:44 -0700 | [diff] [blame] | 123 | info.damageAccumulator->dirty(0, 0, properties().getWidth(), properties().getHeight()); |
| 124 | } else { |
| 125 | // Hope this is big enough? |
| 126 | // TODO: Get this from the display list ops or something |
| 127 | info.damageAccumulator->dirty(INT_MIN, INT_MIN, INT_MAX, INT_MAX); |
| 128 | } |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 129 | } |
| 130 | } |
| 131 | |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 132 | void RenderNode::prepareLayer(TreeInfo& info) { |
| 133 | LayerType layerType = properties().layerProperties().type(); |
| 134 | if (CC_UNLIKELY(layerType == kLayerTypeRenderLayer)) { |
| 135 | // We push a null transform here as we don't care what the existing dirty |
| 136 | // area is, only what our display list dirty is as well as our children's |
| 137 | // dirty area |
| 138 | info.damageAccumulator->pushNullTransform(); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | void RenderNode::pushLayerUpdate(TreeInfo& info) { |
| 143 | LayerType layerType = properties().layerProperties().type(); |
| 144 | // If we are not a layer OR we cannot be rendered (eg, view was detached) |
| 145 | // we need to destroy any Layers we may have had previously |
| 146 | if (CC_LIKELY(layerType != kLayerTypeRenderLayer) || CC_UNLIKELY(!isRenderable())) { |
| 147 | if (layerType == kLayerTypeRenderLayer) { |
| 148 | info.damageAccumulator->popTransform(); |
| 149 | } |
| 150 | if (CC_UNLIKELY(mLayer)) { |
| 151 | LayerRenderer::destroyLayer(mLayer); |
| 152 | mLayer = NULL; |
| 153 | } |
| 154 | return; |
| 155 | } |
| 156 | |
| 157 | if (!mLayer) { |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 158 | mLayer = LayerRenderer::createRenderLayer(info.renderState, getWidth(), getHeight()); |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 159 | applyLayerPropertiesToLayer(info); |
| 160 | damageSelf(info); |
| 161 | } else if (mLayer->layer.getWidth() != getWidth() || mLayer->layer.getHeight() != getHeight()) { |
John Reck | c25e506 | 2014-06-18 14:21:29 -0700 | [diff] [blame] | 162 | if (!LayerRenderer::resizeLayer(mLayer, getWidth(), getHeight())) { |
| 163 | LayerRenderer::destroyLayer(mLayer); |
| 164 | mLayer = 0; |
| 165 | } |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 166 | damageSelf(info); |
| 167 | } |
| 168 | |
| 169 | SkRect dirty; |
| 170 | info.damageAccumulator->peekAtDirty(&dirty); |
| 171 | info.damageAccumulator->popTransform(); |
| 172 | |
John Reck | c25e506 | 2014-06-18 14:21:29 -0700 | [diff] [blame] | 173 | if (!mLayer) { |
| 174 | if (info.errorHandler) { |
| 175 | std::string msg = "Unable to create layer for "; |
| 176 | msg += getName(); |
| 177 | info.errorHandler->onError(msg); |
| 178 | } |
| 179 | return; |
| 180 | } |
| 181 | |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 182 | if (!dirty.isEmpty()) { |
| 183 | mLayer->updateDeferred(this, dirty.fLeft, dirty.fTop, dirty.fRight, dirty.fBottom); |
| 184 | } |
| 185 | // This is not inside the above if because we may have called |
| 186 | // updateDeferred on a previous prepare pass that didn't have a renderer |
| 187 | if (info.renderer && mLayer->deferredUpdateScheduled) { |
| 188 | info.renderer->pushLayerUpdate(mLayer); |
| 189 | } |
| 190 | } |
| 191 | |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 192 | void RenderNode::prepareTreeImpl(TreeInfo& info) { |
John Reck | a447d29 | 2014-06-11 18:39:44 -0700 | [diff] [blame] | 193 | info.damageAccumulator->pushTransform(this); |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 194 | if (info.mode == TreeInfo::MODE_FULL) { |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 195 | pushStagingPropertiesChanges(info); |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 196 | evaluateAnimations(info); |
| 197 | } else if (info.mode == TreeInfo::MODE_MAYBE_DETACHING) { |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 198 | pushStagingPropertiesChanges(info); |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 199 | } else if (info.mode == TreeInfo::MODE_RT_ONLY) { |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 200 | evaluateAnimations(info); |
| 201 | } |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 202 | |
| 203 | prepareLayer(info); |
| 204 | if (info.mode == TreeInfo::MODE_FULL) { |
| 205 | pushStagingDisplayListChanges(info); |
| 206 | } |
John Reck | f4198b7 | 2014-04-09 17:00:04 -0700 | [diff] [blame] | 207 | prepareSubTree(info, mDisplayListData); |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 208 | pushLayerUpdate(info); |
| 209 | |
John Reck | a447d29 | 2014-06-11 18:39:44 -0700 | [diff] [blame] | 210 | info.damageAccumulator->popTransform(); |
John Reck | f4198b7 | 2014-04-09 17:00:04 -0700 | [diff] [blame] | 211 | } |
| 212 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 213 | class PushAnimatorsFunctor { |
| 214 | public: |
| 215 | PushAnimatorsFunctor(RenderNode* target, TreeInfo& info) |
| 216 | : mTarget(target), mInfo(info) {} |
| 217 | |
| 218 | bool operator() (const sp<BaseRenderNodeAnimator>& animator) { |
| 219 | animator->setupStartValueIfNecessary(mTarget, mInfo); |
| 220 | return animator->isFinished(); |
| 221 | } |
| 222 | private: |
| 223 | RenderNode* mTarget; |
| 224 | TreeInfo& mInfo; |
| 225 | }; |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 226 | |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 227 | void RenderNode::pushStagingPropertiesChanges(TreeInfo& info) { |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 228 | // Push the animators first so that setupStartValueIfNecessary() is called |
| 229 | // before properties() is trampled by stagingProperties(), as they are |
| 230 | // required by some animators. |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 231 | if (mNeedsAnimatorsSync) { |
John Reck | 5262266 | 2014-04-30 14:19:56 -0700 | [diff] [blame] | 232 | mAnimators.resize(mStagingAnimators.size()); |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 233 | std::vector< sp<BaseRenderNodeAnimator> >::iterator it; |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 234 | PushAnimatorsFunctor functor(this, info); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 235 | // hint: this means copy_if_not() |
| 236 | it = std::remove_copy_if(mStagingAnimators.begin(), mStagingAnimators.end(), |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 237 | mAnimators.begin(), functor); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 238 | mAnimators.resize(std::distance(mAnimators.begin(), it)); |
| 239 | } |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 240 | if (mDirtyPropertyFields) { |
| 241 | mDirtyPropertyFields = 0; |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 242 | damageSelf(info); |
John Reck | a447d29 | 2014-06-11 18:39:44 -0700 | [diff] [blame] | 243 | info.damageAccumulator->popTransform(); |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 244 | mProperties = mStagingProperties; |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 245 | applyLayerPropertiesToLayer(info); |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 246 | // We could try to be clever and only re-damage if the matrix changed. |
| 247 | // However, we don't need to worry about that. The cost of over-damaging |
| 248 | // here is only going to be a single additional map rect of this node |
| 249 | // plus a rect join(). The parent's transform (and up) will only be |
| 250 | // performed once. |
John Reck | a447d29 | 2014-06-11 18:39:44 -0700 | [diff] [blame] | 251 | info.damageAccumulator->pushTransform(this); |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 252 | damageSelf(info); |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 253 | } |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | void RenderNode::applyLayerPropertiesToLayer(TreeInfo& info) { |
| 257 | if (CC_LIKELY(!mLayer)) return; |
| 258 | |
| 259 | const LayerProperties& props = properties().layerProperties(); |
| 260 | mLayer->setAlpha(props.alpha(), props.xferMode()); |
| 261 | mLayer->setColorFilter(props.colorFilter()); |
| 262 | mLayer->setBlend(props.needsBlending()); |
| 263 | } |
| 264 | |
| 265 | void RenderNode::pushStagingDisplayListChanges(TreeInfo& info) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 266 | if (mNeedsDisplayListDataSync) { |
| 267 | mNeedsDisplayListDataSync = false; |
| 268 | // Do a push pass on the old tree to handle freeing DisplayListData |
| 269 | // that are no longer used |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 270 | TreeInfo oldTreeInfo(TreeInfo::MODE_MAYBE_DETACHING, info.renderState); |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 271 | oldTreeInfo.damageAccumulator = info.damageAccumulator; |
John Reck | f4198b7 | 2014-04-09 17:00:04 -0700 | [diff] [blame] | 272 | prepareSubTree(oldTreeInfo, mDisplayListData); |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 273 | delete mDisplayListData; |
| 274 | mDisplayListData = mStagingDisplayListData; |
| 275 | mStagingDisplayListData = 0; |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 276 | damageSelf(info); |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 277 | } |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 278 | } |
| 279 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 280 | class AnimateFunctor { |
| 281 | public: |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 282 | AnimateFunctor(RenderNode* target, TreeInfo& info) |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 283 | : mTarget(target), mInfo(info) {} |
| 284 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 285 | bool operator() (const sp<BaseRenderNodeAnimator>& animator) { |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 286 | return animator->animate(mTarget, mInfo); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 287 | } |
| 288 | private: |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 289 | RenderNode* mTarget; |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 290 | TreeInfo& mInfo; |
| 291 | }; |
| 292 | |
| 293 | void RenderNode::evaluateAnimations(TreeInfo& info) { |
| 294 | if (!mAnimators.size()) return; |
| 295 | |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 296 | // TODO: Can we target this better? For now treat it like any other staging |
| 297 | // property push and just damage self before and after animators are run |
| 298 | |
| 299 | damageSelf(info); |
John Reck | a447d29 | 2014-06-11 18:39:44 -0700 | [diff] [blame] | 300 | info.damageAccumulator->popTransform(); |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 301 | |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 302 | AnimateFunctor functor(this, info); |
| 303 | std::vector< sp<BaseRenderNodeAnimator> >::iterator newEnd; |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 304 | newEnd = std::remove_if(mAnimators.begin(), mAnimators.end(), functor); |
| 305 | mAnimators.erase(newEnd, mAnimators.end()); |
| 306 | mProperties.updateMatrix(); |
John Reck | f9be779 | 2014-05-02 18:21:16 -0700 | [diff] [blame] | 307 | info.out.hasAnimations |= mAnimators.size(); |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 308 | |
John Reck | a447d29 | 2014-06-11 18:39:44 -0700 | [diff] [blame] | 309 | info.damageAccumulator->pushTransform(this); |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 310 | damageSelf(info); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 311 | } |
| 312 | |
John Reck | f4198b7 | 2014-04-09 17:00:04 -0700 | [diff] [blame] | 313 | void RenderNode::prepareSubTree(TreeInfo& info, DisplayListData* subtree) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 314 | if (subtree) { |
John Reck | 860d155 | 2014-04-11 19:15:05 -0700 | [diff] [blame] | 315 | TextureCache& cache = Caches::getInstance().textureCache; |
John Reck | f9be779 | 2014-05-02 18:21:16 -0700 | [diff] [blame] | 316 | info.out.hasFunctors |= subtree->functorCount; |
John Reck | 860d155 | 2014-04-11 19:15:05 -0700 | [diff] [blame] | 317 | // TODO: Fix ownedBitmapResources to not require disabling prepareTextures |
| 318 | // and thus falling out of async drawing path. |
| 319 | if (subtree->ownedBitmapResources.size()) { |
| 320 | info.prepareTextures = false; |
| 321 | } |
| 322 | for (size_t i = 0; info.prepareTextures && i < subtree->bitmapResources.size(); i++) { |
| 323 | info.prepareTextures = cache.prefetchAndMarkInUse(subtree->bitmapResources[i]); |
John Reck | f4198b7 | 2014-04-09 17:00:04 -0700 | [diff] [blame] | 324 | } |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 325 | for (size_t i = 0; i < subtree->children().size(); i++) { |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 326 | DrawRenderNodeOp* op = subtree->children()[i]; |
| 327 | RenderNode* childNode = op->mRenderNode; |
John Reck | a447d29 | 2014-06-11 18:39:44 -0700 | [diff] [blame] | 328 | info.damageAccumulator->pushTransform(&op->mTransformFromParent); |
John Reck | f4198b7 | 2014-04-09 17:00:04 -0700 | [diff] [blame] | 329 | childNode->prepareTreeImpl(info); |
John Reck | a447d29 | 2014-06-11 18:39:44 -0700 | [diff] [blame] | 330 | info.damageAccumulator->popTransform(); |
John Reck | 5bf11bb | 2014-03-25 10:22:09 -0700 | [diff] [blame] | 331 | } |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 332 | } |
| 333 | } |
| 334 | |
| 335 | /* |
| 336 | * For property operations, we pass a savecount of 0, since the operations aren't part of the |
| 337 | * displaylist, and thus don't have to compensate for the record-time/playback-time discrepancy in |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 338 | * base saveCount (i.e., how RestoreToCount uses saveCount + properties().getCount()) |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 339 | */ |
| 340 | #define PROPERTY_SAVECOUNT 0 |
| 341 | |
| 342 | template <class T> |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 343 | void RenderNode::setViewProperties(OpenGLRenderer& renderer, T& handler) { |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 344 | #if DEBUG_DISPLAY_LIST |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 345 | properties().debugOutputProperties(handler.level() + 1); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 346 | #endif |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 347 | if (properties().getLeft() != 0 || properties().getTop() != 0) { |
| 348 | renderer.translate(properties().getLeft(), properties().getTop()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 349 | } |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 350 | if (properties().getStaticMatrix()) { |
Derek Sollenberger | 1390882 | 2013-12-10 12:28:58 -0500 | [diff] [blame] | 351 | renderer.concatMatrix(*properties().getStaticMatrix()); |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 352 | } else if (properties().getAnimationMatrix()) { |
Derek Sollenberger | 1390882 | 2013-12-10 12:28:58 -0500 | [diff] [blame] | 353 | renderer.concatMatrix(*properties().getAnimationMatrix()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 354 | } |
John Reck | f7483e3 | 2014-04-11 08:54:47 -0700 | [diff] [blame] | 355 | if (properties().hasTransformMatrix()) { |
| 356 | if (properties().isTransformTranslateOnly()) { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 357 | renderer.translate(properties().getTranslationX(), properties().getTranslationY()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 358 | } else { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 359 | renderer.concatMatrix(*properties().getTransformMatrix()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 360 | } |
| 361 | } |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 362 | const bool isLayer = properties().layerProperties().type() != kLayerTypeNone; |
| 363 | bool clipToBoundsNeeded = isLayer ? false : properties().getClipToBounds(); |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 364 | if (properties().getAlpha() < 1) { |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 365 | if (isLayer) { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 366 | renderer.setOverrideLayerAlpha(properties().getAlpha()); |
| 367 | } else if (!properties().getHasOverlappingRendering()) { |
| 368 | renderer.scaleAlpha(properties().getAlpha()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 369 | } else { |
| 370 | // TODO: should be able to store the size of a DL at record time and not |
| 371 | // have to pass it into this call. In fact, this information might be in the |
| 372 | // location/size info that we store with the new native transform data. |
| 373 | int saveFlags = SkCanvas::kHasAlphaLayer_SaveFlag; |
| 374 | if (clipToBoundsNeeded) { |
| 375 | saveFlags |= SkCanvas::kClipToLayer_SaveFlag; |
| 376 | clipToBoundsNeeded = false; // clipping done by saveLayer |
| 377 | } |
| 378 | |
| 379 | SaveLayerOp* op = new (handler.allocator()) SaveLayerOp( |
Chris Craik | 8c271ca | 2014-03-25 10:33:01 -0700 | [diff] [blame] | 380 | 0, 0, properties().getWidth(), properties().getHeight(), |
| 381 | properties().getAlpha() * 255, saveFlags); |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 382 | handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 383 | } |
| 384 | } |
| 385 | if (clipToBoundsNeeded) { |
Chris Craik | 8c271ca | 2014-03-25 10:33:01 -0700 | [diff] [blame] | 386 | ClipRectOp* op = new (handler.allocator()) ClipRectOp( |
| 387 | 0, 0, properties().getWidth(), properties().getHeight(), SkRegion::kIntersect_Op); |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 388 | handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 389 | } |
Chris Craik | 8c271ca | 2014-03-25 10:33:01 -0700 | [diff] [blame] | 390 | |
| 391 | if (CC_UNLIKELY(properties().hasClippingPath())) { |
Chris Craik | 2bcad17 | 2014-05-14 18:11:23 -0700 | [diff] [blame] | 392 | ClipPathOp* op = new (handler.allocator()) ClipPathOp( |
| 393 | properties().getClippingPath(), properties().getClippingPathOp()); |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 394 | handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 395 | } |
| 396 | } |
| 397 | |
| 398 | /** |
| 399 | * Apply property-based transformations to input matrix |
| 400 | * |
| 401 | * If true3dTransform is set to true, the transform applied to the input matrix will use true 4x4 |
| 402 | * matrix computation instead of the Skia 3x3 matrix + camera hackery. |
| 403 | */ |
| 404 | void RenderNode::applyViewPropertyTransforms(mat4& matrix, bool true3dTransform) { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 405 | if (properties().getLeft() != 0 || properties().getTop() != 0) { |
| 406 | matrix.translate(properties().getLeft(), properties().getTop()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 407 | } |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 408 | if (properties().getStaticMatrix()) { |
| 409 | mat4 stat(*properties().getStaticMatrix()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 410 | matrix.multiply(stat); |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 411 | } else if (properties().getAnimationMatrix()) { |
| 412 | mat4 anim(*properties().getAnimationMatrix()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 413 | matrix.multiply(anim); |
| 414 | } |
Chris Craik | e0bb87d | 2014-04-22 17:55:41 -0700 | [diff] [blame] | 415 | |
Chris Craik | cc39e16 | 2014-04-25 18:34:11 -0700 | [diff] [blame] | 416 | bool applyTranslationZ = true3dTransform && !MathUtils::isZero(properties().getZ()); |
Chris Craik | e0bb87d | 2014-04-22 17:55:41 -0700 | [diff] [blame] | 417 | if (properties().hasTransformMatrix() || applyTranslationZ) { |
John Reck | f7483e3 | 2014-04-11 08:54:47 -0700 | [diff] [blame] | 418 | if (properties().isTransformTranslateOnly()) { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 419 | matrix.translate(properties().getTranslationX(), properties().getTranslationY(), |
Chris Craik | cc39e16 | 2014-04-25 18:34:11 -0700 | [diff] [blame] | 420 | true3dTransform ? properties().getZ() : 0.0f); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 421 | } else { |
| 422 | if (!true3dTransform) { |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 423 | matrix.multiply(*properties().getTransformMatrix()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 424 | } else { |
| 425 | mat4 true3dMat; |
| 426 | true3dMat.loadTranslate( |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 427 | properties().getPivotX() + properties().getTranslationX(), |
| 428 | properties().getPivotY() + properties().getTranslationY(), |
Chris Craik | cc39e16 | 2014-04-25 18:34:11 -0700 | [diff] [blame] | 429 | properties().getZ()); |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 430 | true3dMat.rotate(properties().getRotationX(), 1, 0, 0); |
| 431 | true3dMat.rotate(properties().getRotationY(), 0, 1, 0); |
| 432 | true3dMat.rotate(properties().getRotation(), 0, 0, 1); |
| 433 | true3dMat.scale(properties().getScaleX(), properties().getScaleY(), 1); |
| 434 | true3dMat.translate(-properties().getPivotX(), -properties().getPivotY()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 435 | |
| 436 | matrix.multiply(true3dMat); |
| 437 | } |
| 438 | } |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | /** |
| 443 | * Organizes the DisplayList hierarchy to prepare for background projection reordering. |
| 444 | * |
| 445 | * This should be called before a call to defer() or drawDisplayList() |
| 446 | * |
| 447 | * Each DisplayList that serves as a 3d root builds its list of composited children, |
| 448 | * which are flagged to not draw in the standard draw loop. |
| 449 | */ |
| 450 | void RenderNode::computeOrdering() { |
| 451 | ATRACE_CALL(); |
| 452 | mProjectedNodes.clear(); |
| 453 | |
| 454 | // TODO: create temporary DDLOp and call computeOrderingImpl on top DisplayList so that |
| 455 | // transform properties are applied correctly to top level children |
| 456 | if (mDisplayListData == NULL) return; |
John Reck | 087bc0c | 2014-04-04 16:20:08 -0700 | [diff] [blame] | 457 | for (unsigned int i = 0; i < mDisplayListData->children().size(); i++) { |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 458 | DrawRenderNodeOp* childOp = mDisplayListData->children()[i]; |
| 459 | childOp->mRenderNode->computeOrderingImpl(childOp, |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 460 | properties().getOutline().getPath(), &mProjectedNodes, &mat4::identity()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 461 | } |
| 462 | } |
| 463 | |
| 464 | void RenderNode::computeOrderingImpl( |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 465 | DrawRenderNodeOp* opState, |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 466 | const SkPath* outlineOfProjectionSurface, |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 467 | Vector<DrawRenderNodeOp*>* compositedChildrenOfProjectionSurface, |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 468 | const mat4* transformFromProjectionSurface) { |
| 469 | mProjectedNodes.clear(); |
| 470 | if (mDisplayListData == NULL || mDisplayListData->isEmpty()) return; |
| 471 | |
| 472 | // TODO: should avoid this calculation in most cases |
| 473 | // TODO: just calculate single matrix, down to all leaf composited elements |
| 474 | Matrix4 localTransformFromProjectionSurface(*transformFromProjectionSurface); |
| 475 | localTransformFromProjectionSurface.multiply(opState->mTransformFromParent); |
| 476 | |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 477 | if (properties().getProjectBackwards()) { |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 478 | // composited projectee, flag for out of order draw, save matrix, and store in proj surface |
| 479 | opState->mSkipInOrderDraw = true; |
| 480 | opState->mTransformFromCompositingAncestor.load(localTransformFromProjectionSurface); |
| 481 | compositedChildrenOfProjectionSurface->add(opState); |
| 482 | } else { |
| 483 | // standard in order draw |
| 484 | opState->mSkipInOrderDraw = false; |
| 485 | } |
| 486 | |
John Reck | 087bc0c | 2014-04-04 16:20:08 -0700 | [diff] [blame] | 487 | if (mDisplayListData->children().size() > 0) { |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 488 | const bool isProjectionReceiver = mDisplayListData->projectionReceiveIndex >= 0; |
| 489 | bool haveAppliedPropertiesToProjection = false; |
John Reck | 087bc0c | 2014-04-04 16:20:08 -0700 | [diff] [blame] | 490 | for (unsigned int i = 0; i < mDisplayListData->children().size(); i++) { |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 491 | DrawRenderNodeOp* childOp = mDisplayListData->children()[i]; |
| 492 | RenderNode* child = childOp->mRenderNode; |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 493 | |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 494 | const SkPath* projectionOutline = NULL; |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 495 | Vector<DrawRenderNodeOp*>* projectionChildren = NULL; |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 496 | const mat4* projectionTransform = NULL; |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 497 | if (isProjectionReceiver && !child->properties().getProjectBackwards()) { |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 498 | // if receiving projections, collect projecting descendent |
| 499 | |
| 500 | // Note that if a direct descendent is projecting backwards, we pass it's |
| 501 | // grandparent projection collection, since it shouldn't project onto it's |
| 502 | // parent, where it will already be drawing. |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 503 | projectionOutline = properties().getOutline().getPath(); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 504 | projectionChildren = &mProjectedNodes; |
| 505 | projectionTransform = &mat4::identity(); |
| 506 | } else { |
| 507 | if (!haveAppliedPropertiesToProjection) { |
| 508 | applyViewPropertyTransforms(localTransformFromProjectionSurface); |
| 509 | haveAppliedPropertiesToProjection = true; |
| 510 | } |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 511 | projectionOutline = outlineOfProjectionSurface; |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 512 | projectionChildren = compositedChildrenOfProjectionSurface; |
| 513 | projectionTransform = &localTransformFromProjectionSurface; |
| 514 | } |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 515 | child->computeOrderingImpl(childOp, |
| 516 | projectionOutline, projectionChildren, projectionTransform); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 517 | } |
| 518 | } |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | class DeferOperationHandler { |
| 522 | public: |
| 523 | DeferOperationHandler(DeferStateStruct& deferStruct, int level) |
| 524 | : mDeferStruct(deferStruct), mLevel(level) {} |
| 525 | inline void operator()(DisplayListOp* operation, int saveCount, bool clipToBounds) { |
| 526 | operation->defer(mDeferStruct, saveCount, mLevel, clipToBounds); |
| 527 | } |
| 528 | inline LinearAllocator& allocator() { return *(mDeferStruct.mAllocator); } |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 529 | inline void startMark(const char* name) {} // do nothing |
| 530 | inline void endMark() {} |
| 531 | inline int level() { return mLevel; } |
| 532 | inline int replayFlags() { return mDeferStruct.mReplayFlags; } |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 533 | |
| 534 | private: |
| 535 | DeferStateStruct& mDeferStruct; |
| 536 | const int mLevel; |
| 537 | }; |
| 538 | |
Chris Craik | 80d4902 | 2014-06-20 15:03:43 -0700 | [diff] [blame] | 539 | void RenderNode::defer(DeferStateStruct& deferStruct, const int level) { |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 540 | DeferOperationHandler handler(deferStruct, level); |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 541 | issueOperations<DeferOperationHandler>(deferStruct.mRenderer, handler); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | class ReplayOperationHandler { |
| 545 | public: |
| 546 | ReplayOperationHandler(ReplayStateStruct& replayStruct, int level) |
| 547 | : mReplayStruct(replayStruct), mLevel(level) {} |
| 548 | inline void operator()(DisplayListOp* operation, int saveCount, bool clipToBounds) { |
| 549 | #if DEBUG_DISPLAY_LIST_OPS_AS_EVENTS |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 550 | mReplayStruct.mRenderer.eventMark(operation->name()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 551 | #endif |
| 552 | operation->replay(mReplayStruct, saveCount, mLevel, clipToBounds); |
| 553 | } |
| 554 | inline LinearAllocator& allocator() { return *(mReplayStruct.mAllocator); } |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 555 | inline void startMark(const char* name) { |
| 556 | mReplayStruct.mRenderer.startMark(name); |
| 557 | } |
| 558 | inline void endMark() { |
| 559 | mReplayStruct.mRenderer.endMark(); |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 560 | } |
| 561 | inline int level() { return mLevel; } |
| 562 | inline int replayFlags() { return mReplayStruct.mReplayFlags; } |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 563 | |
| 564 | private: |
| 565 | ReplayStateStruct& mReplayStruct; |
| 566 | const int mLevel; |
| 567 | }; |
| 568 | |
Chris Craik | 80d4902 | 2014-06-20 15:03:43 -0700 | [diff] [blame] | 569 | void RenderNode::replay(ReplayStateStruct& replayStruct, const int level) { |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 570 | ReplayOperationHandler handler(replayStruct, level); |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 571 | issueOperations<ReplayOperationHandler>(replayStruct.mRenderer, handler); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 572 | } |
| 573 | |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 574 | void RenderNode::buildZSortedChildList(Vector<ZDrawRenderNodeOpPair>& zTranslatedNodes) { |
John Reck | 087bc0c | 2014-04-04 16:20:08 -0700 | [diff] [blame] | 575 | if (mDisplayListData == NULL || mDisplayListData->children().size() == 0) return; |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 576 | |
John Reck | 087bc0c | 2014-04-04 16:20:08 -0700 | [diff] [blame] | 577 | for (unsigned int i = 0; i < mDisplayListData->children().size(); i++) { |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 578 | DrawRenderNodeOp* childOp = mDisplayListData->children()[i]; |
| 579 | RenderNode* child = childOp->mRenderNode; |
Chris Craik | cc39e16 | 2014-04-25 18:34:11 -0700 | [diff] [blame] | 580 | float childZ = child->properties().getZ(); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 581 | |
Chris Craik | e0bb87d | 2014-04-22 17:55:41 -0700 | [diff] [blame] | 582 | if (!MathUtils::isZero(childZ)) { |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 583 | zTranslatedNodes.add(ZDrawRenderNodeOpPair(childZ, childOp)); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 584 | childOp->mSkipInOrderDraw = true; |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 585 | } else if (!child->properties().getProjectBackwards()) { |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 586 | // regular, in order drawing DisplayList |
| 587 | childOp->mSkipInOrderDraw = false; |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | // Z sort 3d children (stable-ness makes z compare fall back to standard drawing order) |
| 592 | std::stable_sort(zTranslatedNodes.begin(), zTranslatedNodes.end()); |
| 593 | } |
| 594 | |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 595 | template <class T> |
| 596 | void RenderNode::issueDrawShadowOperation(const Matrix4& transformFromParent, T& handler) { |
Chris Craik | 6131732 | 2014-05-21 13:03:52 -0700 | [diff] [blame] | 597 | if (properties().getAlpha() <= 0.0f || properties().getOutline().isEmpty()) return; |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 598 | |
| 599 | mat4 shadowMatrixXY(transformFromParent); |
| 600 | applyViewPropertyTransforms(shadowMatrixXY); |
| 601 | |
| 602 | // Z matrix needs actual 3d transformation, so mapped z values will be correct |
| 603 | mat4 shadowMatrixZ(transformFromParent); |
| 604 | applyViewPropertyTransforms(shadowMatrixZ, true); |
| 605 | |
| 606 | const SkPath* outlinePath = properties().getOutline().getPath(); |
| 607 | const RevealClip& revealClip = properties().getRevealClip(); |
| 608 | const SkPath* revealClipPath = revealClip.hasConvexClip() |
| 609 | ? revealClip.getPath() : NULL; // only pass the reveal clip's path if it's convex |
| 610 | |
Chris Craik | 6131732 | 2014-05-21 13:03:52 -0700 | [diff] [blame] | 611 | if (revealClipPath && revealClipPath->isEmpty()) return; |
| 612 | |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 613 | /** |
| 614 | * The drawing area of the caster is always the same as the its perimeter (which |
| 615 | * the shadow system uses) *except* in the inverse clip case. Inform the shadow |
| 616 | * system that the caster's drawing area (as opposed to its perimeter) has been |
| 617 | * clipped, so that it knows the caster can't be opaque. |
| 618 | */ |
| 619 | bool casterUnclipped = !revealClip.willClip() || revealClip.hasConvexClip(); |
| 620 | |
| 621 | DisplayListOp* shadowOp = new (handler.allocator()) DrawShadowOp( |
| 622 | shadowMatrixXY, shadowMatrixZ, |
| 623 | properties().getAlpha(), casterUnclipped, |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 624 | outlinePath, revealClipPath); |
| 625 | handler(shadowOp, PROPERTY_SAVECOUNT, properties().getClipToBounds()); |
| 626 | } |
| 627 | |
Chris Craik | 80d4902 | 2014-06-20 15:03:43 -0700 | [diff] [blame] | 628 | template <class T> |
| 629 | int RenderNode::issueOperationsOfNegZChildren( |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 630 | const Vector<ZDrawRenderNodeOpPair>& zTranslatedNodes, |
Chris Craik | 80d4902 | 2014-06-20 15:03:43 -0700 | [diff] [blame] | 631 | OpenGLRenderer& renderer, T& handler) { |
| 632 | if (zTranslatedNodes.isEmpty()) return -1; |
| 633 | |
| 634 | // create a save around the body of the ViewGroup's draw method, so that |
| 635 | // matrix/clip methods don't affect composited children |
| 636 | int shadowSaveCount = renderer.getSaveCount(); |
| 637 | handler(new (handler.allocator()) SaveOp(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag), |
| 638 | PROPERTY_SAVECOUNT, properties().getClipToBounds()); |
| 639 | |
| 640 | issueOperationsOf3dChildren(zTranslatedNodes, kNegativeZChildren, renderer, handler); |
| 641 | return shadowSaveCount; |
| 642 | } |
| 643 | |
| 644 | template <class T> |
| 645 | void RenderNode::issueOperationsOfPosZChildren(int shadowRestoreTo, |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 646 | const Vector<ZDrawRenderNodeOpPair>& zTranslatedNodes, |
Chris Craik | 80d4902 | 2014-06-20 15:03:43 -0700 | [diff] [blame] | 647 | OpenGLRenderer& renderer, T& handler) { |
| 648 | if (zTranslatedNodes.isEmpty()) return; |
| 649 | |
| 650 | LOG_ALWAYS_FATAL_IF(shadowRestoreTo < 0, "invalid save to restore to"); |
| 651 | handler(new (handler.allocator()) RestoreToCountOp(shadowRestoreTo), |
| 652 | PROPERTY_SAVECOUNT, properties().getClipToBounds()); |
| 653 | renderer.setOverrideLayerAlpha(1.0f); |
| 654 | |
| 655 | issueOperationsOf3dChildren(zTranslatedNodes, kPositiveZChildren, renderer, handler); |
| 656 | } |
| 657 | |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 658 | #define SHADOW_DELTA 0.1f |
| 659 | |
| 660 | template <class T> |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 661 | void RenderNode::issueOperationsOf3dChildren(const Vector<ZDrawRenderNodeOpPair>& zTranslatedNodes, |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 662 | ChildrenSelectMode mode, OpenGLRenderer& renderer, T& handler) { |
| 663 | const int size = zTranslatedNodes.size(); |
| 664 | if (size == 0 |
| 665 | || (mode == kNegativeZChildren && zTranslatedNodes[0].key > 0.0f) |
| 666 | || (mode == kPositiveZChildren && zTranslatedNodes[size - 1].key < 0.0f)) { |
| 667 | // no 3d children to draw |
| 668 | return; |
| 669 | } |
| 670 | |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 671 | /** |
| 672 | * Draw shadows and (potential) casters mostly in order, but allow the shadows of casters |
| 673 | * with very similar Z heights to draw together. |
| 674 | * |
| 675 | * This way, if Views A & B have the same Z height and are both casting shadows, the shadows are |
| 676 | * underneath both, and neither's shadow is drawn on top of the other. |
| 677 | */ |
| 678 | const size_t nonNegativeIndex = findNonNegativeIndex(zTranslatedNodes); |
| 679 | size_t drawIndex, shadowIndex, endIndex; |
| 680 | if (mode == kNegativeZChildren) { |
| 681 | drawIndex = 0; |
| 682 | endIndex = nonNegativeIndex; |
| 683 | shadowIndex = endIndex; // draw no shadows |
| 684 | } else { |
| 685 | drawIndex = nonNegativeIndex; |
| 686 | endIndex = size; |
| 687 | shadowIndex = drawIndex; // potentially draw shadow for each pos Z child |
| 688 | } |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 689 | |
| 690 | DISPLAY_LIST_LOGD("%*s%d %s 3d children:", (handler.level() + 1) * 2, "", |
| 691 | endIndex - drawIndex, mode == kNegativeZChildren ? "negative" : "positive"); |
| 692 | |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 693 | float lastCasterZ = 0.0f; |
| 694 | while (shadowIndex < endIndex || drawIndex < endIndex) { |
| 695 | if (shadowIndex < endIndex) { |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 696 | DrawRenderNodeOp* casterOp = zTranslatedNodes[shadowIndex].value; |
| 697 | RenderNode* caster = casterOp->mRenderNode; |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 698 | const float casterZ = zTranslatedNodes[shadowIndex].key; |
| 699 | // attempt to render the shadow if the caster about to be drawn is its caster, |
| 700 | // OR if its caster's Z value is similar to the previous potential caster |
| 701 | if (shadowIndex == drawIndex || casterZ - lastCasterZ < SHADOW_DELTA) { |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 702 | caster->issueDrawShadowOperation(casterOp->mTransformFromParent, handler); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 703 | |
| 704 | lastCasterZ = casterZ; // must do this even if current caster not casting a shadow |
| 705 | shadowIndex++; |
| 706 | continue; |
| 707 | } |
| 708 | } |
| 709 | |
| 710 | // only the actual child DL draw needs to be in save/restore, |
| 711 | // since it modifies the renderer's matrix |
| 712 | int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag); |
| 713 | |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 714 | DrawRenderNodeOp* childOp = zTranslatedNodes[drawIndex].value; |
| 715 | RenderNode* child = childOp->mRenderNode; |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 716 | |
| 717 | renderer.concatMatrix(childOp->mTransformFromParent); |
| 718 | childOp->mSkipInOrderDraw = false; // this is horrible, I'm so sorry everyone |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 719 | handler(childOp, renderer.getSaveCount() - 1, properties().getClipToBounds()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 720 | childOp->mSkipInOrderDraw = true; |
| 721 | |
| 722 | renderer.restoreToCount(restoreTo); |
| 723 | drawIndex++; |
| 724 | } |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | template <class T> |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 728 | void RenderNode::issueOperationsOfProjectedChildren(OpenGLRenderer& renderer, T& handler) { |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 729 | DISPLAY_LIST_LOGD("%*s%d projected children:", (handler.level() + 1) * 2, "", mProjectedNodes.size()); |
| 730 | const SkPath* projectionReceiverOutline = properties().getOutline().getPath(); |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 731 | int restoreTo = renderer.getSaveCount(); |
| 732 | |
| 733 | // If the projection reciever has an outline, we mask each of the projected rendernodes to it |
| 734 | // Either with clipRect, or special saveLayer masking |
| 735 | LinearAllocator& alloc = handler.allocator(); |
| 736 | if (projectionReceiverOutline != NULL) { |
| 737 | const SkRect& outlineBounds = projectionReceiverOutline->getBounds(); |
| 738 | if (projectionReceiverOutline->isRect(NULL)) { |
| 739 | // mask to the rect outline simply with clipRect |
| 740 | handler(new (alloc) SaveOp(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag), |
| 741 | PROPERTY_SAVECOUNT, properties().getClipToBounds()); |
| 742 | ClipRectOp* clipOp = new (alloc) ClipRectOp( |
| 743 | outlineBounds.left(), outlineBounds.top(), |
| 744 | outlineBounds.right(), outlineBounds.bottom(), SkRegion::kIntersect_Op); |
| 745 | handler(clipOp, PROPERTY_SAVECOUNT, properties().getClipToBounds()); |
| 746 | } else { |
| 747 | // wrap the projected RenderNodes with a SaveLayer that will mask to the outline |
| 748 | SaveLayerOp* op = new (alloc) SaveLayerOp( |
| 749 | outlineBounds.left(), outlineBounds.top(), |
| 750 | outlineBounds.right(), outlineBounds.bottom(), |
Chris Craik | 80d4902 | 2014-06-20 15:03:43 -0700 | [diff] [blame] | 751 | 255, SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag | SkCanvas::kARGB_ClipLayer_SaveFlag); |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 752 | op->setMask(projectionReceiverOutline); |
| 753 | handler(op, PROPERTY_SAVECOUNT, properties().getClipToBounds()); |
| 754 | |
| 755 | /* TODO: add optimizations here to take advantage of placement/size of projected |
| 756 | * children (which may shrink saveLayer area significantly). This is dependent on |
| 757 | * passing actual drawing/dirtying bounds of projected content down to native. |
| 758 | */ |
| 759 | } |
| 760 | } |
| 761 | |
| 762 | // draw projected nodes |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 763 | for (size_t i = 0; i < mProjectedNodes.size(); i++) { |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 764 | DrawRenderNodeOp* childOp = mProjectedNodes[i]; |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 765 | |
| 766 | // matrix save, concat, and restore can be done safely without allocating operations |
| 767 | int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag); |
| 768 | renderer.concatMatrix(childOp->mTransformFromCompositingAncestor); |
| 769 | childOp->mSkipInOrderDraw = false; // this is horrible, I'm so sorry everyone |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 770 | handler(childOp, renderer.getSaveCount() - 1, properties().getClipToBounds()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 771 | childOp->mSkipInOrderDraw = true; |
| 772 | renderer.restoreToCount(restoreTo); |
| 773 | } |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 774 | |
| 775 | if (projectionReceiverOutline != NULL) { |
| 776 | handler(new (alloc) RestoreToCountOp(restoreTo), |
| 777 | PROPERTY_SAVECOUNT, properties().getClipToBounds()); |
| 778 | } |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 779 | } |
| 780 | |
| 781 | /** |
| 782 | * This function serves both defer and replay modes, and will organize the displayList's component |
| 783 | * operations for a single frame: |
| 784 | * |
| 785 | * Every 'simple' state operation that affects just the matrix and alpha (or other factors of |
| 786 | * DeferredDisplayState) may be issued directly to the renderer, but complex operations (with custom |
| 787 | * defer logic) and operations in displayListOps are issued through the 'handler' which handles the |
| 788 | * defer vs replay logic, per operation |
| 789 | */ |
| 790 | template <class T> |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 791 | void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) { |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 792 | const bool drawLayer = (mLayer && (&renderer != mLayer->renderer)); |
| 793 | // If we are updating the contents of mLayer, we don't want to apply any of |
| 794 | // the RenderNode's properties to this issueOperations pass. Those will all |
| 795 | // be applied when the layer is drawn, aka when this is true. |
| 796 | const bool useViewProperties = (!mLayer || drawLayer); |
| 797 | |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 798 | const int level = handler.level(); |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 799 | if (mDisplayListData->isEmpty() || (useViewProperties && properties().getAlpha() <= 0)) { |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 800 | DISPLAY_LIST_LOGD("%*sEmpty display list (%p, %s)", level * 2, "", this, getName()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 801 | return; |
| 802 | } |
| 803 | |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 804 | handler.startMark(getName()); |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 805 | |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 806 | #if DEBUG_DISPLAY_LIST |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 807 | const Rect& clipRect = renderer.getLocalClipBounds(); |
| 808 | DISPLAY_LIST_LOGD("%*sStart display list (%p, %s), localClipBounds: %.0f, %.0f, %.0f, %.0f", |
| 809 | level * 2, "", this, getName(), |
| 810 | clipRect.left, clipRect.top, clipRect.right, clipRect.bottom); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 811 | #endif |
| 812 | |
| 813 | LinearAllocator& alloc = handler.allocator(); |
| 814 | int restoreTo = renderer.getSaveCount(); |
| 815 | handler(new (alloc) SaveOp(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag), |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 816 | PROPERTY_SAVECOUNT, properties().getClipToBounds()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 817 | |
| 818 | DISPLAY_LIST_LOGD("%*sSave %d %d", (level + 1) * 2, "", |
| 819 | SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag, restoreTo); |
| 820 | |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 821 | if (useViewProperties) { |
| 822 | setViewProperties<T>(renderer, handler); |
| 823 | } |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 824 | |
Chris Craik | 8c271ca | 2014-03-25 10:33:01 -0700 | [diff] [blame] | 825 | bool quickRejected = properties().getClipToBounds() |
| 826 | && renderer.quickRejectConservative(0, 0, properties().getWidth(), properties().getHeight()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 827 | if (!quickRejected) { |
Chris Craik | deeda3d | 2014-05-05 19:09:33 -0700 | [diff] [blame] | 828 | if (mProperties.getOutline().willClip()) { |
| 829 | renderer.setClippingOutline(alloc, &(mProperties.getOutline())); |
| 830 | } |
| 831 | |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 832 | if (drawLayer) { |
| 833 | handler(new (alloc) DrawLayerOp(mLayer, 0, 0), |
| 834 | renderer.getSaveCount() - 1, properties().getClipToBounds()); |
| 835 | } else { |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 836 | Vector<ZDrawRenderNodeOpPair> zTranslatedNodes; |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 837 | buildZSortedChildList(zTranslatedNodes); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 838 | |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 839 | // for 3d root, draw children with negative z values |
Chris Craik | 80d4902 | 2014-06-20 15:03:43 -0700 | [diff] [blame] | 840 | int shadowRestoreTo = issueOperationsOfNegZChildren(zTranslatedNodes, renderer, handler); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 841 | |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 842 | DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance(); |
| 843 | const int saveCountOffset = renderer.getSaveCount() - 1; |
| 844 | const int projectionReceiveIndex = mDisplayListData->projectionReceiveIndex; |
| 845 | for (unsigned int i = 0; i < mDisplayListData->displayListOps.size(); i++) { |
| 846 | DisplayListOp *op = mDisplayListData->displayListOps[i]; |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 847 | |
Chris Craik | 80d4902 | 2014-06-20 15:03:43 -0700 | [diff] [blame] | 848 | #if DEBUG_DISPLAY_LIST |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 849 | op->output(level + 1); |
Chris Craik | 80d4902 | 2014-06-20 15:03:43 -0700 | [diff] [blame] | 850 | #endif |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 851 | logBuffer.writeCommand(level, op->name()); |
| 852 | handler(op, saveCountOffset, properties().getClipToBounds()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 853 | |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 854 | if (CC_UNLIKELY(i == projectionReceiveIndex && mProjectedNodes.size() > 0)) { |
| 855 | issueOperationsOfProjectedChildren(renderer, handler); |
| 856 | } |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 857 | } |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 858 | |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 859 | // for 3d root, draw children with positive z values |
Chris Craik | 80d4902 | 2014-06-20 15:03:43 -0700 | [diff] [blame] | 860 | issueOperationsOfPosZChildren(shadowRestoreTo, zTranslatedNodes, renderer, handler); |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 861 | } |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 862 | } |
| 863 | |
| 864 | DISPLAY_LIST_LOGD("%*sRestoreToCount %d", (level + 1) * 2, "", restoreTo); |
| 865 | handler(new (alloc) RestoreToCountOp(restoreTo), |
John Reck | d0a0b2a | 2014-03-20 16:28:56 -0700 | [diff] [blame] | 866 | PROPERTY_SAVECOUNT, properties().getClipToBounds()); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 867 | renderer.setOverrideLayerAlpha(1.0f); |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 868 | |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 869 | DISPLAY_LIST_LOGD("%*sDone (%p, %s)", level * 2, "", this, getName()); |
Chris Craik | b265e2c | 2014-03-27 15:50:09 -0700 | [diff] [blame] | 870 | handler.endMark(); |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 871 | } |
| 872 | |
| 873 | } /* namespace uirenderer */ |
| 874 | } /* namespace android */ |