blob: c4c655b75d22a15321702e1c08e1fea92a513403 [file] [log] [blame]
Chris Craikb565df12015-10-05 13:00:52 -07001/*
Chris Craik5ea17242016-01-11 14:07:59 -08002 * Copyright (C) 2016 The Android Open Source Project
Chris Craikb565df12015-10-05 13:00:52 -07003 *
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
Chris Craikf158b492016-01-12 14:45:08 -080017#include "FrameBuilder.h"
Chris Craikb565df12015-10-05 13:00:52 -070018
Chris Craik0b7e8242015-10-28 16:50:44 -070019#include "LayerUpdateQueue.h"
Chris Craik161f54b2015-11-05 11:08:52 -080020#include "RenderNode.h"
Chris Craik98787e62015-11-13 10:55:30 -080021#include "renderstate/OffscreenBufferPool.h"
Chris Craik161f54b2015-11-05 11:08:52 -080022#include "utils/FatVector.h"
23#include "utils/PaintUtils.h"
Chris Craik8ecf41c2015-11-16 10:27:59 -080024#include "utils/TraceUtils.h"
Chris Craikb565df12015-10-05 13:00:52 -070025
Chris Craik161f54b2015-11-05 11:08:52 -080026#include <SkCanvas.h>
Chris Craikd3daa312015-11-06 10:59:56 -080027#include <SkPathOps.h>
Chris Craik161f54b2015-11-05 11:08:52 -080028#include <utils/TypeHelpers.h>
Chris Craikb565df12015-10-05 13:00:52 -070029
30namespace android {
31namespace uirenderer {
32
Chris Craikf158b492016-01-12 14:45:08 -080033FrameBuilder::FrameBuilder(const LayerUpdateQueue& layers, const SkRect& clip,
Chris Craik0b7e8242015-10-28 16:50:44 -070034 uint32_t viewportWidth, uint32_t viewportHeight,
Chris Craik98787e62015-11-13 10:55:30 -080035 const std::vector< sp<RenderNode> >& nodes, const Vector3& lightCenter)
Chris Craik6fe991e52015-10-20 09:39:42 -070036 : mCanvasState(*this) {
Chris Craik818c9fb2015-10-23 14:33:42 -070037 ATRACE_NAME("prepare drawing commands");
Chris Craikb565df12015-10-05 13:00:52 -070038
Chris Craikf158b492016-01-12 14:45:08 -080039 mLayerBuilders.reserve(layers.entries().size());
Chris Craik98787e62015-11-13 10:55:30 -080040 mLayerStack.reserve(layers.entries().size());
41
42 // Prepare to defer Fbo0
Chris Craikf158b492016-01-12 14:45:08 -080043 auto fbo0 = mAllocator.create<LayerBuilder>(viewportWidth, viewportHeight, Rect(clip));
44 mLayerBuilders.push_back(fbo0);
Chris Craik98787e62015-11-13 10:55:30 -080045 mLayerStack.push_back(0);
Chris Craikb565df12015-10-05 13:00:52 -070046 mCanvasState.initializeSaveStack(viewportWidth, viewportHeight,
Chris Craikddf22152015-10-14 17:42:47 -070047 clip.fLeft, clip.fTop, clip.fRight, clip.fBottom,
Chris Craik98787e62015-11-13 10:55:30 -080048 lightCenter);
Chris Craik0b7e8242015-10-28 16:50:44 -070049
50 // Render all layers to be updated, in order. Defer in reverse order, so that they'll be
Chris Craikf158b492016-01-12 14:45:08 -080051 // updated in the order they're passed in (mLayerBuilders are issued to Renderer in reverse)
Chris Craik0b7e8242015-10-28 16:50:44 -070052 for (int i = layers.entries().size() - 1; i >= 0; i--) {
53 RenderNode* layerNode = layers.entries()[i].renderNode;
Chris Craike9c5fd82016-01-12 18:59:38 -080054 // only schedule repaint if node still on layer - possible it may have been
55 // removed during a dropped frame, but layers may still remain scheduled so
56 // as not to lose info on what portion is damaged
57 if (CC_LIKELY(layerNode->getLayer() != nullptr)) {
58 const Rect& layerDamage = layers.entries()[i].damage;
59 layerNode->computeOrdering();
Chris Craik0b7e8242015-10-28 16:50:44 -070060
Chris Craike9c5fd82016-01-12 18:59:38 -080061 // map current light center into RenderNode's coordinate space
62 Vector3 lightCenter = mCanvasState.currentSnapshot()->getRelativeLightCenter();
63 layerNode->getLayer()->inverseTransformInWindow.mapPoint3d(lightCenter);
Chris Craik8ecf41c2015-11-16 10:27:59 -080064
Chris Craike9c5fd82016-01-12 18:59:38 -080065 saveForLayer(layerNode->getWidth(), layerNode->getHeight(), 0, 0,
66 layerDamage, lightCenter, nullptr, layerNode);
Chris Craik0b7e8242015-10-28 16:50:44 -070067
Chris Craike9c5fd82016-01-12 18:59:38 -080068 if (layerNode->getDisplayList()) {
69 deferNodeOps(*layerNode);
70 }
71 restoreForLayer();
Chris Craik0b7e8242015-10-28 16:50:44 -070072 }
Chris Craik0b7e8242015-10-28 16:50:44 -070073 }
74
75 // Defer Fbo0
Chris Craikb565df12015-10-05 13:00:52 -070076 for (const sp<RenderNode>& node : nodes) {
77 if (node->nothingToDraw()) continue;
Chris Craik8d1f2122015-11-24 16:40:09 -080078 node->computeOrdering();
Chris Craikb565df12015-10-05 13:00:52 -070079
Chris Craik0b7e8242015-10-28 16:50:44 -070080 int count = mCanvasState.save(SkCanvas::kClip_SaveFlag | SkCanvas::kMatrix_SaveFlag);
81 deferNodePropsAndOps(*node);
82 mCanvasState.restoreToCount(count);
Chris Craikb565df12015-10-05 13:00:52 -070083 }
84}
85
Chris Craikf158b492016-01-12 14:45:08 -080086void FrameBuilder::onViewportInitialized() {}
Chris Craik818c9fb2015-10-23 14:33:42 -070087
Chris Craikf158b492016-01-12 14:45:08 -080088void FrameBuilder::onSnapshotRestored(const Snapshot& removed, const Snapshot& restored) {}
Chris Craik818c9fb2015-10-23 14:33:42 -070089
Chris Craikf158b492016-01-12 14:45:08 -080090void FrameBuilder::deferNodePropsAndOps(RenderNode& node) {
Chris Craik8ecf41c2015-11-16 10:27:59 -080091 const RenderProperties& properties = node.properties();
92 const Outline& outline = properties.getOutline();
93 if (properties.getAlpha() <= 0
94 || (outline.getShouldClip() && outline.isEmpty())
95 || properties.getScaleX() == 0
96 || properties.getScaleY() == 0) {
97 return; // rejected
98 }
99
100 if (properties.getLeft() != 0 || properties.getTop() != 0) {
101 mCanvasState.translate(properties.getLeft(), properties.getTop());
102 }
103 if (properties.getStaticMatrix()) {
104 mCanvasState.concatMatrix(*properties.getStaticMatrix());
105 } else if (properties.getAnimationMatrix()) {
106 mCanvasState.concatMatrix(*properties.getAnimationMatrix());
107 }
108 if (properties.hasTransformMatrix()) {
109 if (properties.isTransformTranslateOnly()) {
110 mCanvasState.translate(properties.getTranslationX(), properties.getTranslationY());
111 } else {
112 mCanvasState.concatMatrix(*properties.getTransformMatrix());
113 }
114 }
115
116 const int width = properties.getWidth();
117 const int height = properties.getHeight();
118
119 Rect saveLayerBounds; // will be set to non-empty if saveLayer needed
120 const bool isLayer = properties.effectiveLayerType() != LayerType::None;
121 int clipFlags = properties.getClippingFlags();
122 if (properties.getAlpha() < 1) {
123 if (isLayer) {
124 clipFlags &= ~CLIP_TO_BOUNDS; // bounds clipping done by layer
125 }
126 if (CC_LIKELY(isLayer || !properties.getHasOverlappingRendering())) {
127 // simply scale rendering content's alpha
128 mCanvasState.scaleAlpha(properties.getAlpha());
129 } else {
130 // schedule saveLayer by initializing saveLayerBounds
131 saveLayerBounds.set(0, 0, width, height);
132 if (clipFlags) {
133 properties.getClippingRectForFlags(clipFlags, &saveLayerBounds);
134 clipFlags = 0; // all clipping done by savelayer
135 }
136 }
137
138 if (CC_UNLIKELY(ATRACE_ENABLED() && properties.promotedToLayer())) {
139 // pretend alpha always causes savelayer to warn about
140 // performance problem affecting old versions
141 ATRACE_FORMAT("%s alpha caused saveLayer %dx%d", node.getName(), width, height);
142 }
143 }
144 if (clipFlags) {
145 Rect clipRect;
146 properties.getClippingRectForFlags(clipFlags, &clipRect);
147 mCanvasState.clipRect(clipRect.left, clipRect.top, clipRect.right, clipRect.bottom,
148 SkRegion::kIntersect_Op);
149 }
150
151 if (properties.getRevealClip().willClip()) {
152 Rect bounds;
153 properties.getRevealClip().getBounds(&bounds);
154 mCanvasState.setClippingRoundRect(mAllocator,
155 bounds, properties.getRevealClip().getRadius());
156 } else if (properties.getOutline().willClip()) {
157 mCanvasState.setClippingOutline(mAllocator, &(properties.getOutline()));
158 }
159
160 if (!mCanvasState.quickRejectConservative(0, 0, width, height)) {
161 // not rejected, so defer render as either Layer, or direct (possibly wrapped in saveLayer)
Chris Craik0b7e8242015-10-28 16:50:44 -0700162 if (node.getLayer()) {
163 // HW layer
164 LayerOp* drawLayerOp = new (mAllocator) LayerOp(node);
165 BakedOpState* bakedOpState = tryBakeOpState(*drawLayerOp);
166 if (bakedOpState) {
Chris Craik8ecf41c2015-11-16 10:27:59 -0800167 // Node's layer already deferred, schedule it to render into parent layer
Chris Craik0b7e8242015-10-28 16:50:44 -0700168 currentLayer().deferUnmergeableOp(mAllocator, bakedOpState, OpBatchType::Bitmap);
169 }
Chris Craik8ecf41c2015-11-16 10:27:59 -0800170 } else if (CC_UNLIKELY(!saveLayerBounds.isEmpty())) {
171 // draw DisplayList contents within temporary, since persisted layer could not be used.
172 // (temp layers are clipped to viewport, since they don't persist offscreen content)
173 SkPaint saveLayerPaint;
174 saveLayerPaint.setAlpha(properties.getAlpha());
Chris Craik268a9c02015-12-09 18:05:12 -0800175 deferBeginLayerOp(*new (mAllocator) BeginLayerOp(
Chris Craik8ecf41c2015-11-16 10:27:59 -0800176 saveLayerBounds,
177 Matrix4::identity(),
Chris Craike4db79d2015-12-22 16:32:23 -0800178 nullptr, // no record-time clip - need only respect defer-time one
Chris Craik8ecf41c2015-11-16 10:27:59 -0800179 &saveLayerPaint));
Chris Craik8d1f2122015-11-24 16:40:09 -0800180 deferNodeOps(node);
Chris Craik268a9c02015-12-09 18:05:12 -0800181 deferEndLayerOp(*new (mAllocator) EndLayerOp());
Chris Craik0b7e8242015-10-28 16:50:44 -0700182 } else {
Chris Craik8d1f2122015-11-24 16:40:09 -0800183 deferNodeOps(node);
Chris Craik0b7e8242015-10-28 16:50:44 -0700184 }
185 }
186}
187
Chris Craik161f54b2015-11-05 11:08:52 -0800188typedef key_value_pair_t<float, const RenderNodeOp*> ZRenderNodeOpPair;
189
190template <typename V>
191static void buildZSortedChildList(V* zTranslatedNodes,
192 const DisplayList& displayList, const DisplayList::Chunk& chunk) {
193 if (chunk.beginChildIndex == chunk.endChildIndex) return;
194
195 for (size_t i = chunk.beginChildIndex; i < chunk.endChildIndex; i++) {
196 RenderNodeOp* childOp = displayList.getChildren()[i];
197 RenderNode* child = childOp->renderNode;
198 float childZ = child->properties().getZ();
199
200 if (!MathUtils::isZero(childZ) && chunk.reorderChildren) {
201 zTranslatedNodes->push_back(ZRenderNodeOpPair(childZ, childOp));
202 childOp->skipInOrderDraw = true;
203 } else if (!child->properties().getProjectBackwards()) {
204 // regular, in order drawing DisplayList
205 childOp->skipInOrderDraw = false;
206 }
207 }
208
209 // Z sort any 3d children (stable-ness makes z compare fall back to standard drawing order)
210 std::stable_sort(zTranslatedNodes->begin(), zTranslatedNodes->end());
211}
212
213template <typename V>
214static size_t findNonNegativeIndex(const V& zTranslatedNodes) {
215 for (size_t i = 0; i < zTranslatedNodes.size(); i++) {
216 if (zTranslatedNodes[i].key >= 0.0f) return i;
217 }
218 return zTranslatedNodes.size();
219}
220
221template <typename V>
Chris Craikf158b492016-01-12 14:45:08 -0800222void FrameBuilder::defer3dChildren(ChildrenSelectMode mode, const V& zTranslatedNodes) {
Chris Craik161f54b2015-11-05 11:08:52 -0800223 const int size = zTranslatedNodes.size();
224 if (size == 0
225 || (mode == ChildrenSelectMode::Negative&& zTranslatedNodes[0].key > 0.0f)
226 || (mode == ChildrenSelectMode::Positive && zTranslatedNodes[size - 1].key < 0.0f)) {
227 // no 3d children to draw
228 return;
229 }
230
231 /**
232 * Draw shadows and (potential) casters mostly in order, but allow the shadows of casters
233 * with very similar Z heights to draw together.
234 *
235 * This way, if Views A & B have the same Z height and are both casting shadows, the shadows are
236 * underneath both, and neither's shadow is drawn on top of the other.
237 */
238 const size_t nonNegativeIndex = findNonNegativeIndex(zTranslatedNodes);
239 size_t drawIndex, shadowIndex, endIndex;
240 if (mode == ChildrenSelectMode::Negative) {
241 drawIndex = 0;
242 endIndex = nonNegativeIndex;
243 shadowIndex = endIndex; // draw no shadows
244 } else {
245 drawIndex = nonNegativeIndex;
246 endIndex = size;
247 shadowIndex = drawIndex; // potentially draw shadow for each pos Z child
248 }
249
250 float lastCasterZ = 0.0f;
251 while (shadowIndex < endIndex || drawIndex < endIndex) {
252 if (shadowIndex < endIndex) {
253 const RenderNodeOp* casterNodeOp = zTranslatedNodes[shadowIndex].value;
254 const float casterZ = zTranslatedNodes[shadowIndex].key;
255 // attempt to render the shadow if the caster about to be drawn is its caster,
256 // OR if its caster's Z value is similar to the previous potential caster
257 if (shadowIndex == drawIndex || casterZ - lastCasterZ < 0.1f) {
258 deferShadow(*casterNodeOp);
259
260 lastCasterZ = casterZ; // must do this even if current caster not casting a shadow
261 shadowIndex++;
262 continue;
263 }
264 }
265
266 const RenderNodeOp* childOp = zTranslatedNodes[drawIndex].value;
Chris Craik268a9c02015-12-09 18:05:12 -0800267 deferRenderNodeOpImpl(*childOp);
Chris Craik161f54b2015-11-05 11:08:52 -0800268 drawIndex++;
269 }
270}
271
Chris Craikf158b492016-01-12 14:45:08 -0800272void FrameBuilder::deferShadow(const RenderNodeOp& casterNodeOp) {
Chris Craikd3daa312015-11-06 10:59:56 -0800273 auto& node = *casterNodeOp.renderNode;
274 auto& properties = node.properties();
275
276 if (properties.getAlpha() <= 0.0f
277 || properties.getOutline().getAlpha() <= 0.0f
278 || !properties.getOutline().getPath()
279 || properties.getScaleX() == 0
280 || properties.getScaleY() == 0) {
281 // no shadow to draw
282 return;
283 }
284
285 const SkPath* casterOutlinePath = properties.getOutline().getPath();
286 const SkPath* revealClipPath = properties.getRevealClip().getPath();
287 if (revealClipPath && revealClipPath->isEmpty()) return;
288
289 float casterAlpha = properties.getAlpha() * properties.getOutline().getAlpha();
290
291 // holds temporary SkPath to store the result of intersections
292 SkPath* frameAllocatedPath = nullptr;
293 const SkPath* casterPath = casterOutlinePath;
294
295 // intersect the shadow-casting path with the reveal, if present
296 if (revealClipPath) {
297 frameAllocatedPath = createFrameAllocatedPath();
298
299 Op(*casterPath, *revealClipPath, kIntersect_SkPathOp, frameAllocatedPath);
300 casterPath = frameAllocatedPath;
301 }
302
303 // intersect the shadow-casting path with the clipBounds, if present
304 if (properties.getClippingFlags() & CLIP_TO_CLIP_BOUNDS) {
305 if (!frameAllocatedPath) {
306 frameAllocatedPath = createFrameAllocatedPath();
307 }
308 Rect clipBounds;
309 properties.getClippingRectForFlags(CLIP_TO_CLIP_BOUNDS, &clipBounds);
310 SkPath clipBoundsPath;
311 clipBoundsPath.addRect(clipBounds.left, clipBounds.top,
312 clipBounds.right, clipBounds.bottom);
313
314 Op(*casterPath, clipBoundsPath, kIntersect_SkPathOp, frameAllocatedPath);
315 casterPath = frameAllocatedPath;
316 }
317
318 ShadowOp* shadowOp = new (mAllocator) ShadowOp(casterNodeOp, casterAlpha, casterPath,
Chris Craik98787e62015-11-13 10:55:30 -0800319 mCanvasState.getLocalClipBounds(),
320 mCanvasState.currentSnapshot()->getRelativeLightCenter());
Chris Craikd3daa312015-11-06 10:59:56 -0800321 BakedOpState* bakedOpState = BakedOpState::tryShadowOpConstruct(
Chris Craike4db79d2015-12-22 16:32:23 -0800322 mAllocator, *mCanvasState.writableSnapshot(), shadowOp);
Chris Craikd3daa312015-11-06 10:59:56 -0800323 if (CC_LIKELY(bakedOpState)) {
324 currentLayer().deferUnmergeableOp(mAllocator, bakedOpState, OpBatchType::Shadow);
325 }
Chris Craik161f54b2015-11-05 11:08:52 -0800326}
Chris Craikd3daa312015-11-06 10:59:56 -0800327
Chris Craikf158b492016-01-12 14:45:08 -0800328void FrameBuilder::deferProjectedChildren(const RenderNode& renderNode) {
Chris Craik8d1f2122015-11-24 16:40:09 -0800329 const SkPath* projectionReceiverOutline = renderNode.properties().getOutline().getPath();
330 int count = mCanvasState.save(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
331
332 // can't be null, since DL=null node rejection happens before deferNodePropsAndOps
333 const DisplayList& displayList = *(renderNode.getDisplayList());
334
335 const RecordedOp* op = (displayList.getOps()[displayList.projectionReceiveIndex]);
336 const RenderNodeOp* backgroundOp = static_cast<const RenderNodeOp*>(op);
337 const RenderProperties& backgroundProps = backgroundOp->renderNode->properties();
338
339 // Transform renderer to match background we're projecting onto
340 // (by offsetting canvas by translationX/Y of background rendernode, since only those are set)
341 mCanvasState.translate(backgroundProps.getTranslationX(), backgroundProps.getTranslationY());
342
343 // If the projection receiver has an outline, we mask projected content to it
344 // (which we know, apriori, are all tessellated paths)
345 mCanvasState.setProjectionPathMask(mAllocator, projectionReceiverOutline);
346
347 // draw projected nodes
348 for (size_t i = 0; i < renderNode.mProjectedNodes.size(); i++) {
349 RenderNodeOp* childOp = renderNode.mProjectedNodes[i];
350
351 int restoreTo = mCanvasState.save(SkCanvas::kMatrix_SaveFlag);
352 mCanvasState.concatMatrix(childOp->transformFromCompositingAncestor);
Chris Craik268a9c02015-12-09 18:05:12 -0800353 deferRenderNodeOpImpl(*childOp);
Chris Craik8d1f2122015-11-24 16:40:09 -0800354 mCanvasState.restoreToCount(restoreTo);
355 }
356
357 mCanvasState.restoreToCount(count);
358}
359
Chris Craikb565df12015-10-05 13:00:52 -0700360/**
Chris Craikf158b492016-01-12 14:45:08 -0800361 * Used to define a list of lambdas referencing private FrameBuilder::onXX::defer() methods.
Chris Craikb565df12015-10-05 13:00:52 -0700362 *
Chris Craik8d1f2122015-11-24 16:40:09 -0800363 * This allows opIds embedded in the RecordedOps to be used for dispatching to these lambdas.
Chris Craikf158b492016-01-12 14:45:08 -0800364 * E.g. a BitmapOp op then would be dispatched to FrameBuilder::onBitmapOp(const BitmapOp&)
Chris Craikb565df12015-10-05 13:00:52 -0700365 */
Chris Craik6fe991e52015-10-20 09:39:42 -0700366#define OP_RECEIVER(Type) \
Chris Craikf158b492016-01-12 14:45:08 -0800367 [](FrameBuilder& frameBuilder, const RecordedOp& op) { frameBuilder.defer##Type(static_cast<const Type&>(op)); },
368void FrameBuilder::deferNodeOps(const RenderNode& renderNode) {
369 typedef void (*OpDispatcher) (FrameBuilder& frameBuilder, const RecordedOp& op);
Chris Craik7cbf63d2016-01-06 13:46:52 -0800370 static OpDispatcher receivers[] = BUILD_DEFERRABLE_OP_LUT(OP_RECEIVER);
Chris Craik8d1f2122015-11-24 16:40:09 -0800371
372 // can't be null, since DL=null node rejection happens before deferNodePropsAndOps
373 const DisplayList& displayList = *(renderNode.getDisplayList());
Chris Craikb36af872015-10-16 14:23:12 -0700374 for (const DisplayList::Chunk& chunk : displayList.getChunks()) {
Chris Craik161f54b2015-11-05 11:08:52 -0800375 FatVector<ZRenderNodeOpPair, 16> zTranslatedNodes;
376 buildZSortedChildList(&zTranslatedNodes, displayList, chunk);
377
378 defer3dChildren(ChildrenSelectMode::Negative, zTranslatedNodes);
Chris Craikb565df12015-10-05 13:00:52 -0700379 for (size_t opIndex = chunk.beginOpIndex; opIndex < chunk.endOpIndex; opIndex++) {
Chris Craikb36af872015-10-16 14:23:12 -0700380 const RecordedOp* op = displayList.getOps()[opIndex];
Chris Craikb565df12015-10-05 13:00:52 -0700381 receivers[op->opId](*this, *op);
Chris Craik8d1f2122015-11-24 16:40:09 -0800382
383 if (CC_UNLIKELY(!renderNode.mProjectedNodes.empty()
384 && displayList.projectionReceiveIndex >= 0
385 && static_cast<int>(opIndex) == displayList.projectionReceiveIndex)) {
386 deferProjectedChildren(renderNode);
387 }
Chris Craikb565df12015-10-05 13:00:52 -0700388 }
Chris Craik161f54b2015-11-05 11:08:52 -0800389 defer3dChildren(ChildrenSelectMode::Positive, zTranslatedNodes);
Chris Craikb565df12015-10-05 13:00:52 -0700390 }
391}
392
Chris Craikf158b492016-01-12 14:45:08 -0800393void FrameBuilder::deferRenderNodeOpImpl(const RenderNodeOp& op) {
Chris Craik161f54b2015-11-05 11:08:52 -0800394 if (op.renderNode->nothingToDraw()) return;
Chris Craik6fe991e52015-10-20 09:39:42 -0700395 int count = mCanvasState.save(SkCanvas::kClip_SaveFlag | SkCanvas::kMatrix_SaveFlag);
Chris Craikb565df12015-10-05 13:00:52 -0700396
Chris Craike4db79d2015-12-22 16:32:23 -0800397 // apply state from RecordedOp (clip first, since op's clip is transformed by current matrix)
398 mCanvasState.writableSnapshot()->mutateClipArea().applyClip(op.localClip,
399 *mCanvasState.currentSnapshot()->transform);
Chris Craikb565df12015-10-05 13:00:52 -0700400 mCanvasState.concatMatrix(op.localMatrix);
Chris Craikb565df12015-10-05 13:00:52 -0700401
Chris Craik0b7e8242015-10-28 16:50:44 -0700402 // then apply state from node properties, and defer ops
403 deferNodePropsAndOps(*op.renderNode);
404
Chris Craik6fe991e52015-10-20 09:39:42 -0700405 mCanvasState.restoreToCount(count);
Chris Craikb565df12015-10-05 13:00:52 -0700406}
407
Chris Craikf158b492016-01-12 14:45:08 -0800408void FrameBuilder::deferRenderNodeOp(const RenderNodeOp& op) {
Chris Craik161f54b2015-11-05 11:08:52 -0800409 if (!op.skipInOrderDraw) {
Chris Craik268a9c02015-12-09 18:05:12 -0800410 deferRenderNodeOpImpl(op);
Chris Craik161f54b2015-11-05 11:08:52 -0800411 }
412}
413
Chris Craik386aa032015-12-07 17:08:25 -0800414/**
415 * Defers an unmergeable, strokeable op, accounting correctly
416 * for paint's style on the bounds being computed.
417 */
Chris Craikf158b492016-01-12 14:45:08 -0800418void FrameBuilder::deferStrokeableOp(const RecordedOp& op, batchid_t batchId,
Chris Craik386aa032015-12-07 17:08:25 -0800419 BakedOpState::StrokeBehavior strokeBehavior) {
420 // Note: here we account for stroke when baking the op
421 BakedOpState* bakedState = BakedOpState::tryStrokeableOpConstruct(
Chris Craike4db79d2015-12-22 16:32:23 -0800422 mAllocator, *mCanvasState.writableSnapshot(), op, strokeBehavior);
Chris Craik386aa032015-12-07 17:08:25 -0800423 if (!bakedState) return; // quick rejected
424 currentLayer().deferUnmergeableOp(mAllocator, bakedState, batchId);
425}
426
427/**
428 * Returns batch id for tessellatable shapes, based on paint. Checks to see if path effect/AA will
429 * be used, since they trigger significantly different rendering paths.
430 *
431 * Note: not used for lines/points, since they don't currently support path effects.
432 */
433static batchid_t tessBatchId(const RecordedOp& op) {
434 const SkPaint& paint = *(op.paint);
Chris Craikb565df12015-10-05 13:00:52 -0700435 return paint.getPathEffect()
436 ? OpBatchType::AlphaMaskTexture
437 : (paint.isAntiAlias() ? OpBatchType::AlphaVertices : OpBatchType::Vertices);
438}
439
Chris Craikf158b492016-01-12 14:45:08 -0800440void FrameBuilder::deferArcOp(const ArcOp& op) {
Chris Craik268a9c02015-12-09 18:05:12 -0800441 deferStrokeableOp(op, tessBatchId(op));
Chris Craik386aa032015-12-07 17:08:25 -0800442}
443
Chris Craikb87eadd2016-01-06 09:16:05 -0800444static bool hasMergeableClip(const BakedOpState& state) {
445 return state.computedState.clipState
446 || state.computedState.clipState->mode == ClipMode::Rectangle;
447}
448
Chris Craikf158b492016-01-12 14:45:08 -0800449void FrameBuilder::deferBitmapOp(const BitmapOp& op) {
Chris Craik15c3f192015-12-03 12:16:56 -0800450 BakedOpState* bakedState = tryBakeOpState(op);
451 if (!bakedState) return; // quick rejected
Chris Craikb565df12015-10-05 13:00:52 -0700452
Chris Craik15c3f192015-12-03 12:16:56 -0800453 // Don't merge non-simply transformed or neg scale ops, SET_TEXTURE doesn't handle rotation
454 // Don't merge A8 bitmaps - the paint's color isn't compared by mergeId, or in
455 // MergingDrawBatch::canMergeWith()
456 if (bakedState->computedState.transform.isSimple()
457 && bakedState->computedState.transform.positiveScale()
458 && PaintUtils::getXfermodeDirect(op.paint) == SkXfermode::kSrcOver_Mode
Chris Craikb87eadd2016-01-06 09:16:05 -0800459 && op.bitmap->colorType() != kAlpha_8_SkColorType
460 && hasMergeableClip(*bakedState)) {
Chris Craikb250a832016-01-11 19:28:17 -0800461 mergeid_t mergeId = reinterpret_cast<mergeid_t>(op.bitmap->getGenerationID());
Chris Craik15c3f192015-12-03 12:16:56 -0800462 // TODO: AssetAtlas in mergeId
463 currentLayer().deferMergeableOp(mAllocator, bakedState, OpBatchType::Bitmap, mergeId);
464 } else {
465 currentLayer().deferUnmergeableOp(mAllocator, bakedState, OpBatchType::Bitmap);
466 }
Chris Craikb565df12015-10-05 13:00:52 -0700467}
468
Chris Craikf158b492016-01-12 14:45:08 -0800469void FrameBuilder::deferBitmapMeshOp(const BitmapMeshOp& op) {
Chris Craikf09ff5a2015-12-08 17:21:58 -0800470 BakedOpState* bakedState = tryBakeOpState(op);
471 if (!bakedState) return; // quick rejected
472 currentLayer().deferUnmergeableOp(mAllocator, bakedState, OpBatchType::Bitmap);
473}
474
Chris Craikf158b492016-01-12 14:45:08 -0800475void FrameBuilder::deferBitmapRectOp(const BitmapRectOp& op) {
Chris Craikf09ff5a2015-12-08 17:21:58 -0800476 BakedOpState* bakedState = tryBakeOpState(op);
477 if (!bakedState) return; // quick rejected
478 currentLayer().deferUnmergeableOp(mAllocator, bakedState, OpBatchType::Bitmap);
479}
480
Chris Craikf158b492016-01-12 14:45:08 -0800481void FrameBuilder::deferCirclePropsOp(const CirclePropsOp& op) {
Chris Craik268a9c02015-12-09 18:05:12 -0800482 // allocate a temporary oval op (with mAllocator, so it persists until render), so the
483 // renderer doesn't have to handle the RoundRectPropsOp type, and so state baking is simple.
484 float x = *(op.x);
485 float y = *(op.y);
486 float radius = *(op.radius);
487 Rect unmappedBounds(x - radius, y - radius, x + radius, y + radius);
488 const OvalOp* resolvedOp = new (mAllocator) OvalOp(
489 unmappedBounds,
490 op.localMatrix,
Chris Craike4db79d2015-12-22 16:32:23 -0800491 op.localClip,
Chris Craik268a9c02015-12-09 18:05:12 -0800492 op.paint);
493 deferOvalOp(*resolvedOp);
494}
495
Chris Craikf158b492016-01-12 14:45:08 -0800496void FrameBuilder::deferFunctorOp(const FunctorOp& op) {
Chris Craike29ce6f2015-12-10 16:25:13 -0800497 BakedOpState* bakedState = tryBakeOpState(op);
498 if (!bakedState) return; // quick rejected
Chris Craikd2dfd8f2015-12-16 14:27:20 -0800499 currentLayer().deferUnmergeableOp(mAllocator, bakedState, OpBatchType::Functor);
Chris Craike29ce6f2015-12-10 16:25:13 -0800500}
501
Chris Craikf158b492016-01-12 14:45:08 -0800502void FrameBuilder::deferLinesOp(const LinesOp& op) {
Chris Craik386aa032015-12-07 17:08:25 -0800503 batchid_t batch = op.paint->isAntiAlias() ? OpBatchType::AlphaVertices : OpBatchType::Vertices;
Chris Craik268a9c02015-12-09 18:05:12 -0800504 deferStrokeableOp(op, batch, BakedOpState::StrokeBehavior::Forced);
Chris Craik386aa032015-12-07 17:08:25 -0800505}
506
Chris Craikf158b492016-01-12 14:45:08 -0800507void FrameBuilder::deferOvalOp(const OvalOp& op) {
Chris Craik268a9c02015-12-09 18:05:12 -0800508 deferStrokeableOp(op, tessBatchId(op));
Chris Craik386aa032015-12-07 17:08:25 -0800509}
510
Chris Craikf158b492016-01-12 14:45:08 -0800511void FrameBuilder::deferPatchOp(const PatchOp& op) {
Chris Craikf09ff5a2015-12-08 17:21:58 -0800512 BakedOpState* bakedState = tryBakeOpState(op);
513 if (!bakedState) return; // quick rejected
514
515 if (bakedState->computedState.transform.isPureTranslate()
Chris Craikb87eadd2016-01-06 09:16:05 -0800516 && PaintUtils::getXfermodeDirect(op.paint) == SkXfermode::kSrcOver_Mode
517 && hasMergeableClip(*bakedState)) {
Chris Craikb250a832016-01-11 19:28:17 -0800518 mergeid_t mergeId = reinterpret_cast<mergeid_t>(op.bitmap->getGenerationID());
Chris Craikf09ff5a2015-12-08 17:21:58 -0800519 // TODO: AssetAtlas in mergeId
520
521 // Only use the MergedPatch batchId when merged, so Bitmap+Patch don't try to merge together
522 currentLayer().deferMergeableOp(mAllocator, bakedState, OpBatchType::MergedPatch, mergeId);
523 } else {
524 // Use Bitmap batchId since Bitmap+Patch use same shader
525 currentLayer().deferUnmergeableOp(mAllocator, bakedState, OpBatchType::Bitmap);
526 }
527}
528
Chris Craikf158b492016-01-12 14:45:08 -0800529void FrameBuilder::deferPathOp(const PathOp& op) {
Chris Craik268a9c02015-12-09 18:05:12 -0800530 deferStrokeableOp(op, OpBatchType::Bitmap);
Chris Craik386aa032015-12-07 17:08:25 -0800531}
532
Chris Craikf158b492016-01-12 14:45:08 -0800533void FrameBuilder::deferPointsOp(const PointsOp& op) {
Chris Craik386aa032015-12-07 17:08:25 -0800534 batchid_t batch = op.paint->isAntiAlias() ? OpBatchType::AlphaVertices : OpBatchType::Vertices;
Chris Craik268a9c02015-12-09 18:05:12 -0800535 deferStrokeableOp(op, batch, BakedOpState::StrokeBehavior::Forced);
Chris Craika1717272015-11-19 13:02:43 -0800536}
537
Chris Craikf158b492016-01-12 14:45:08 -0800538void FrameBuilder::deferRectOp(const RectOp& op) {
Chris Craik268a9c02015-12-09 18:05:12 -0800539 deferStrokeableOp(op, tessBatchId(op));
Chris Craik386aa032015-12-07 17:08:25 -0800540}
541
Chris Craikf158b492016-01-12 14:45:08 -0800542void FrameBuilder::deferRoundRectOp(const RoundRectOp& op) {
Chris Craik268a9c02015-12-09 18:05:12 -0800543 deferStrokeableOp(op, tessBatchId(op));
Chris Craikb565df12015-10-05 13:00:52 -0700544}
545
Chris Craikf158b492016-01-12 14:45:08 -0800546void FrameBuilder::deferRoundRectPropsOp(const RoundRectPropsOp& op) {
Chris Craik268a9c02015-12-09 18:05:12 -0800547 // allocate a temporary round rect op (with mAllocator, so it persists until render), so the
548 // renderer doesn't have to handle the RoundRectPropsOp type, and so state baking is simple.
549 const RoundRectOp* resolvedOp = new (mAllocator) RoundRectOp(
550 Rect(*(op.left), *(op.top), *(op.right), *(op.bottom)),
551 op.localMatrix,
Chris Craike4db79d2015-12-22 16:32:23 -0800552 op.localClip,
Chris Craik268a9c02015-12-09 18:05:12 -0800553 op.paint, *op.rx, *op.ry);
554 deferRoundRectOp(*resolvedOp);
555}
556
Chris Craikf158b492016-01-12 14:45:08 -0800557void FrameBuilder::deferSimpleRectsOp(const SimpleRectsOp& op) {
Chris Craik15c3f192015-12-03 12:16:56 -0800558 BakedOpState* bakedState = tryBakeOpState(op);
559 if (!bakedState) return; // quick rejected
560 currentLayer().deferUnmergeableOp(mAllocator, bakedState, OpBatchType::Vertices);
Chris Craikb565df12015-10-05 13:00:52 -0700561}
562
Chris Craikd7448e62015-12-15 10:34:36 -0800563static batchid_t textBatchId(const SkPaint& paint) {
564 // TODO: better handling of shader (since we won't care about color then)
565 return paint.getColor() == SK_ColorBLACK ? OpBatchType::Text : OpBatchType::ColorText;
566}
567
Chris Craikf158b492016-01-12 14:45:08 -0800568void FrameBuilder::deferTextOp(const TextOp& op) {
Chris Craik15c3f192015-12-03 12:16:56 -0800569 BakedOpState* bakedState = tryBakeOpState(op);
570 if (!bakedState) return; // quick rejected
Chris Craika1717272015-11-19 13:02:43 -0800571
Chris Craikd7448e62015-12-15 10:34:36 -0800572 batchid_t batchId = textBatchId(*(op.paint));
Chris Craik15c3f192015-12-03 12:16:56 -0800573 if (bakedState->computedState.transform.isPureTranslate()
Chris Craikb87eadd2016-01-06 09:16:05 -0800574 && PaintUtils::getXfermodeDirect(op.paint) == SkXfermode::kSrcOver_Mode
575 && hasMergeableClip(*bakedState)) {
Chris Craik15c3f192015-12-03 12:16:56 -0800576 mergeid_t mergeId = reinterpret_cast<mergeid_t>(op.paint->getColor());
577 currentLayer().deferMergeableOp(mAllocator, bakedState, batchId, mergeId);
578 } else {
579 currentLayer().deferUnmergeableOp(mAllocator, bakedState, batchId);
580 }
Chris Craika1717272015-11-19 13:02:43 -0800581}
582
Chris Craikf158b492016-01-12 14:45:08 -0800583void FrameBuilder::deferTextOnPathOp(const TextOnPathOp& op) {
Chris Craikd7448e62015-12-15 10:34:36 -0800584 BakedOpState* bakedState = tryBakeOpState(op);
585 if (!bakedState) return; // quick rejected
586 currentLayer().deferUnmergeableOp(mAllocator, bakedState, textBatchId(*(op.paint)));
587}
588
Chris Craikf158b492016-01-12 14:45:08 -0800589void FrameBuilder::deferTextureLayerOp(const TextureLayerOp& op) {
Chris Craikd2dfd8f2015-12-16 14:27:20 -0800590 BakedOpState* bakedState = tryBakeOpState(op);
591 if (!bakedState) return; // quick rejected
592 currentLayer().deferUnmergeableOp(mAllocator, bakedState, OpBatchType::TextureLayer);
593}
594
Chris Craikf158b492016-01-12 14:45:08 -0800595void FrameBuilder::saveForLayer(uint32_t layerWidth, uint32_t layerHeight,
Chris Craik8ecf41c2015-11-16 10:27:59 -0800596 float contentTranslateX, float contentTranslateY,
597 const Rect& repaintRect,
598 const Vector3& lightCenter,
Chris Craik0b7e8242015-10-28 16:50:44 -0700599 const BeginLayerOp* beginLayerOp, RenderNode* renderNode) {
Chris Craik6fe991e52015-10-20 09:39:42 -0700600 mCanvasState.save(SkCanvas::kClip_SaveFlag | SkCanvas::kMatrix_SaveFlag);
Chris Craik818c9fb2015-10-23 14:33:42 -0700601 mCanvasState.writableSnapshot()->initializeViewport(layerWidth, layerHeight);
Chris Craik6fe991e52015-10-20 09:39:42 -0700602 mCanvasState.writableSnapshot()->roundRectClipState = nullptr;
Chris Craik98787e62015-11-13 10:55:30 -0800603 mCanvasState.writableSnapshot()->setRelativeLightCenter(lightCenter);
Chris Craik8ecf41c2015-11-16 10:27:59 -0800604 mCanvasState.writableSnapshot()->transform->loadTranslate(
605 contentTranslateX, contentTranslateY, 0);
606 mCanvasState.writableSnapshot()->setClip(
607 repaintRect.left, repaintRect.top, repaintRect.right, repaintRect.bottom);
Chris Craik98787e62015-11-13 10:55:30 -0800608
Chris Craik8ecf41c2015-11-16 10:27:59 -0800609 // create a new layer repaint, and push its index on the stack
Chris Craikf158b492016-01-12 14:45:08 -0800610 mLayerStack.push_back(mLayerBuilders.size());
611 auto newFbo = mAllocator.create<LayerBuilder>(layerWidth, layerHeight,
Chris Craik84ad6142016-01-12 12:09:19 -0800612 repaintRect, beginLayerOp, renderNode);
Chris Craikf158b492016-01-12 14:45:08 -0800613 mLayerBuilders.push_back(newFbo);
Chris Craik0b7e8242015-10-28 16:50:44 -0700614}
615
Chris Craikf158b492016-01-12 14:45:08 -0800616void FrameBuilder::restoreForLayer() {
Chris Craik0b7e8242015-10-28 16:50:44 -0700617 // restore canvas, and pop finished layer off of the stack
618 mCanvasState.restore();
619 mLayerStack.pop_back();
620}
621
Chris Craikb87eadd2016-01-06 09:16:05 -0800622// TODO: defer time rejection (when bounds become empty) + tests
623// Option - just skip layers with no bounds at playback + defer?
Chris Craikf158b492016-01-12 14:45:08 -0800624void FrameBuilder::deferBeginLayerOp(const BeginLayerOp& op) {
Chris Craik8ecf41c2015-11-16 10:27:59 -0800625 uint32_t layerWidth = (uint32_t) op.unmappedBounds.getWidth();
626 uint32_t layerHeight = (uint32_t) op.unmappedBounds.getHeight();
627
628 auto previous = mCanvasState.currentSnapshot();
629 Vector3 lightCenter = previous->getRelativeLightCenter();
630
631 // Combine all transforms used to present saveLayer content:
632 // parent content transform * canvas transform * bounds offset
Chris Craikb87eadd2016-01-06 09:16:05 -0800633 Matrix4 contentTransform(*(previous->transform));
Chris Craik8ecf41c2015-11-16 10:27:59 -0800634 contentTransform.multiply(op.localMatrix);
635 contentTransform.translate(op.unmappedBounds.left, op.unmappedBounds.top);
636
637 Matrix4 inverseContentTransform;
638 inverseContentTransform.loadInverse(contentTransform);
639
640 // map the light center into layer-relative space
641 inverseContentTransform.mapPoint3d(lightCenter);
642
643 // Clip bounds of temporary layer to parent's clip rect, so:
644 Rect saveLayerBounds(layerWidth, layerHeight);
645 // 1) transform Rect(width, height) into parent's space
646 // note: left/top offsets put in contentTransform above
647 contentTransform.mapRect(saveLayerBounds);
648 // 2) intersect with parent's clip
649 saveLayerBounds.doIntersect(previous->getRenderTargetClip());
650 // 3) and transform back
651 inverseContentTransform.mapRect(saveLayerBounds);
652 saveLayerBounds.doIntersect(Rect(layerWidth, layerHeight));
653 saveLayerBounds.roundOut();
654
655 // if bounds are reduced, will clip the layer's area by reducing required bounds...
656 layerWidth = saveLayerBounds.getWidth();
657 layerHeight = saveLayerBounds.getHeight();
658 // ...and shifting drawing content to account for left/top side clipping
659 float contentTranslateX = -saveLayerBounds.left;
660 float contentTranslateY = -saveLayerBounds.top;
661
662 saveForLayer(layerWidth, layerHeight,
663 contentTranslateX, contentTranslateY,
664 Rect(layerWidth, layerHeight),
665 lightCenter,
666 &op, nullptr);
Chris Craik6fe991e52015-10-20 09:39:42 -0700667}
Chris Craikb565df12015-10-05 13:00:52 -0700668
Chris Craikf158b492016-01-12 14:45:08 -0800669void FrameBuilder::deferEndLayerOp(const EndLayerOp& /* ignored */) {
Chris Craik6fe991e52015-10-20 09:39:42 -0700670 const BeginLayerOp& beginLayerOp = *currentLayer().beginLayerOp;
Chris Craik6fe991e52015-10-20 09:39:42 -0700671 int finishedLayerIndex = mLayerStack.back();
Chris Craik0b7e8242015-10-28 16:50:44 -0700672
673 restoreForLayer();
Chris Craik6fe991e52015-10-20 09:39:42 -0700674
675 // record the draw operation into the previous layer's list of draw commands
676 // uses state from the associated beginLayerOp, since it has all the state needed for drawing
677 LayerOp* drawLayerOp = new (mAllocator) LayerOp(
678 beginLayerOp.unmappedBounds,
679 beginLayerOp.localMatrix,
Chris Craike4db79d2015-12-22 16:32:23 -0800680 beginLayerOp.localClip,
Chris Craik818c9fb2015-10-23 14:33:42 -0700681 beginLayerOp.paint,
Chris Craikf158b492016-01-12 14:45:08 -0800682 &(mLayerBuilders[finishedLayerIndex]->offscreenBuffer));
Chris Craik6fe991e52015-10-20 09:39:42 -0700683 BakedOpState* bakedOpState = tryBakeOpState(*drawLayerOp);
684
685 if (bakedOpState) {
686 // Layer will be drawn into parent layer (which is now current, since we popped mLayerStack)
687 currentLayer().deferUnmergeableOp(mAllocator, bakedOpState, OpBatchType::Bitmap);
688 } else {
689 // Layer won't be drawn - delete its drawing batches to prevent it from doing any work
Chris Craikb87eadd2016-01-06 09:16:05 -0800690 // TODO: need to prevent any render work from being done
691 // - create layerop earlier for reject purposes?
Chris Craikf158b492016-01-12 14:45:08 -0800692 mLayerBuilders[finishedLayerIndex]->clear();
Chris Craik6fe991e52015-10-20 09:39:42 -0700693 return;
Chris Craikb565df12015-10-05 13:00:52 -0700694 }
695}
696
Chris Craikf158b492016-01-12 14:45:08 -0800697void FrameBuilder::deferBeginUnclippedLayerOp(const BeginUnclippedLayerOp& op) {
Chris Craikb87eadd2016-01-06 09:16:05 -0800698 Matrix4 boundsTransform(*(mCanvasState.currentSnapshot()->transform));
699 boundsTransform.multiply(op.localMatrix);
700
701 Rect dstRect(op.unmappedBounds);
702 boundsTransform.mapRect(dstRect);
703 dstRect.doIntersect(mCanvasState.currentSnapshot()->getRenderTargetClip());
704
705 // Allocate a holding position for the layer object (copyTo will produce, copyFrom will consume)
Chris Craik7435eb12016-01-07 17:41:40 -0800706 OffscreenBuffer** layerHandle = mAllocator.create<OffscreenBuffer*>(nullptr);
Chris Craikb87eadd2016-01-06 09:16:05 -0800707
708 /**
709 * First, defer an operation to copy out the content from the rendertarget into a layer.
710 */
711 auto copyToOp = new (mAllocator) CopyToLayerOp(op, layerHandle);
Chris Craik7435eb12016-01-07 17:41:40 -0800712 BakedOpState* bakedState = BakedOpState::directConstruct(mAllocator,
713 &(currentLayer().viewportClip), dstRect, *copyToOp);
Chris Craikb87eadd2016-01-06 09:16:05 -0800714 currentLayer().deferUnmergeableOp(mAllocator, bakedState, OpBatchType::CopyToLayer);
715
716 /**
717 * Defer a clear rect, so that clears from multiple unclipped layers can be drawn
718 * both 1) simultaneously, and 2) as long after the copyToLayer executes as possible
719 */
720 currentLayer().deferLayerClear(dstRect);
721
722 /**
723 * And stash an operation to copy that layer back under the rendertarget until
724 * a balanced EndUnclippedLayerOp is seen
725 */
726 auto copyFromOp = new (mAllocator) CopyFromLayerOp(op, layerHandle);
Chris Craik7435eb12016-01-07 17:41:40 -0800727 bakedState = BakedOpState::directConstruct(mAllocator,
728 &(currentLayer().viewportClip), dstRect, *copyFromOp);
Chris Craikb87eadd2016-01-06 09:16:05 -0800729 currentLayer().activeUnclippedSaveLayers.push_back(bakedState);
730}
731
Chris Craikf158b492016-01-12 14:45:08 -0800732void FrameBuilder::deferEndUnclippedLayerOp(const EndUnclippedLayerOp& /* ignored */) {
Chris Craikb87eadd2016-01-06 09:16:05 -0800733 LOG_ALWAYS_FATAL_IF(currentLayer().activeUnclippedSaveLayers.empty(), "no layer to end!");
734
735 BakedOpState* copyFromLayerOp = currentLayer().activeUnclippedSaveLayers.back();
736 currentLayer().deferUnmergeableOp(mAllocator, copyFromLayerOp, OpBatchType::CopyFromLayer);
737 currentLayer().activeUnclippedSaveLayers.pop_back();
738}
739
Chris Craikb565df12015-10-05 13:00:52 -0700740} // namespace uirenderer
741} // namespace android