Loading libs/hwui/BakedOpDispatcher.cpp +1 −7 Original line number Diff line number Diff line Loading @@ -663,13 +663,7 @@ static void renderShadow(BakedOpRenderer& renderer, const BakedOpState& state, f } void BakedOpDispatcher::onShadowOp(BakedOpRenderer& renderer, const ShadowOp& op, const BakedOpState& state) { TessellationCache::vertexBuffer_pair_t buffers; renderer.caches().tessellationCache.getShadowBuffers(&state.computedState.transform, op.localClipRect, op.casterAlpha >= 1.0f, op.casterPath, &op.shadowMatrixXY, &op.shadowMatrixZ, op.lightCenter, renderer.getLightInfo().lightRadius, buffers); TessellationCache::vertexBuffer_pair_t buffers = *(op.shadowTask->getResult()); renderShadow(renderer, state, op.casterAlpha, buffers.first, buffers.second); } Loading libs/hwui/BakedOpRenderer.h +3 −5 Original line number Diff line number Diff line Loading @@ -45,13 +45,11 @@ public: * Position agnostic shadow lighting info. Used with all shadow ops in scene. */ struct LightInfo { LightInfo() : LightInfo(0, 0, 0) {} LightInfo(float lightRadius, uint8_t ambientShadowAlpha, LightInfo() : LightInfo(0, 0) {} LightInfo(uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha) : lightRadius(lightRadius) , ambientShadowAlpha(ambientShadowAlpha) : ambientShadowAlpha(ambientShadowAlpha) , spotShadowAlpha(spotShadowAlpha) {} float lightRadius; uint8_t ambientShadowAlpha; uint8_t spotShadowAlpha; }; Loading libs/hwui/BakedOpState.cpp +5 −10 Original line number Diff line number Diff line Loading @@ -63,16 +63,11 @@ ResolvedRenderState::ResolvedRenderState(LinearAllocator& allocator, Snapshot& s } } ResolvedRenderState::ResolvedRenderState(LinearAllocator& allocator, Snapshot& snapshot) { transform = *snapshot.transform; // Since the op doesn't have known bounds, we conservatively set the mapped bounds // to the current clipRect, and clipSideFlags to Full. clipState = snapshot.mutateClipArea().serializeClip(allocator); LOG_ALWAYS_FATAL_IF(!clipState, "clipState required"); clippedBounds = clipState->rect; clipSideFlags = OpClipSideFlags::Full; } ResolvedRenderState::ResolvedRenderState(LinearAllocator& allocator, Snapshot& snapshot) : transform(*snapshot.transform) , clipState(snapshot.mutateClipArea().serializeClip(allocator)) , clippedBounds(clipState->rect) , clipSideFlags(OpClipSideFlags::Full) {} ResolvedRenderState::ResolvedRenderState(const ClipRect* viewportRect, const Rect& dstRect) : transform(Matrix4::identity()) Loading libs/hwui/FrameBuilder.cpp +28 −19 Original line number Diff line number Diff line Loading @@ -33,17 +33,11 @@ namespace uirenderer { FrameBuilder::FrameBuilder(const LayerUpdateQueue& layers, const SkRect& clip, uint32_t viewportWidth, uint32_t viewportHeight, const std::vector< sp<RenderNode> >& nodes, const Vector3& lightCenter) : FrameBuilder(layers, clip, viewportWidth, viewportHeight, nodes, lightCenter, Rect(0, 0, 0, 0)) { } FrameBuilder::FrameBuilder(const LayerUpdateQueue& layers, const SkRect& clip, uint32_t viewportWidth, uint32_t viewportHeight, const std::vector< sp<RenderNode> >& nodes, const Vector3& lightCenter, const Rect &contentDrawBounds) : mCanvasState(*this) { const std::vector< sp<RenderNode> >& nodes, const LightGeometry& lightGeometry, const Rect &contentDrawBounds, Caches* caches) : mCanvasState(*this) , mCaches(caches) , mLightRadius(lightGeometry.radius) { ATRACE_NAME("prepare drawing commands"); mLayerBuilders.reserve(layers.entries().size()); Loading @@ -55,7 +49,7 @@ FrameBuilder::FrameBuilder(const LayerUpdateQueue& layers, const SkRect& clip, mLayerStack.push_back(0); mCanvasState.initializeSaveStack(viewportWidth, viewportHeight, clip.fLeft, clip.fTop, clip.fRight, clip.fBottom, lightCenter); lightGeometry.center); // Render all layers to be updated, in order. Defer in reverse order, so that they'll be // updated in the order they're passed in (mLayerBuilders are issued to Renderer in reverse) Loading Loading @@ -367,15 +361,30 @@ void FrameBuilder::deferShadow(const RenderNodeOp& casterNodeOp) { casterPath = frameAllocatedPath; } ShadowOp* shadowOp = new (mAllocator) ShadowOp(casterNodeOp, casterAlpha, casterPath, if (CC_LIKELY(!mCanvasState.getRenderTargetClipBounds().isEmpty())) { Matrix4 shadowMatrixXY(casterNodeOp.localMatrix); Matrix4 shadowMatrixZ(casterNodeOp.localMatrix); node.applyViewPropertyTransforms(shadowMatrixXY, false); node.applyViewPropertyTransforms(shadowMatrixZ, true); LOG_ALWAYS_FATAL_IF(!mCaches, "Caches needed for shadows"); sp<TessellationCache::ShadowTask> task = mCaches->tessellationCache.getShadowTask( mCanvasState.currentTransform(), mCanvasState.getLocalClipBounds(), mCanvasState.currentSnapshot()->getRelativeLightCenter()); casterAlpha >= 1.0f, casterPath, &shadowMatrixXY, &shadowMatrixZ, mCanvasState.currentSnapshot()->getRelativeLightCenter(), mLightRadius); ShadowOp* shadowOp = mAllocator.create<ShadowOp>(task, casterAlpha); BakedOpState* bakedOpState = BakedOpState::tryShadowOpConstruct( mAllocator, *mCanvasState.writableSnapshot(), shadowOp); if (CC_LIKELY(bakedOpState)) { currentLayer().deferUnmergeableOp(mAllocator, bakedOpState, OpBatchType::Shadow); } } } void FrameBuilder::deferProjectedChildren(const RenderNode& renderNode) { const SkPath* projectionReceiverOutline = renderNode.properties().getOutline().getPath(); Loading libs/hwui/FrameBuilder.h +18 −4 Original line number Diff line number Diff line Loading @@ -55,14 +55,24 @@ class Rect; */ class FrameBuilder : public CanvasStateClient { public: struct LightGeometry { Vector3 center; float radius; }; // TODO: remove FrameBuilder(const LayerUpdateQueue& layers, const SkRect& clip, uint32_t viewportWidth, uint32_t viewportHeight, const std::vector< sp<RenderNode> >& nodes, const Vector3& lightCenter); const std::vector< sp<RenderNode> >& nodes, const LightGeometry& lightGeometry, Caches* caches) : FrameBuilder(layers, clip, viewportWidth, viewportHeight, nodes, lightGeometry, Rect(), caches) {} FrameBuilder(const LayerUpdateQueue& layers, const SkRect& clip, uint32_t viewportWidth, uint32_t viewportHeight, const std::vector< sp<RenderNode> >& nodes, const Vector3& lightCenter, const Rect &contentDrawBounds); const std::vector< sp<RenderNode> >& nodes, const LightGeometry& lightGeometry, const Rect &contentDrawBounds, Caches* caches); virtual ~FrameBuilder() {} Loading Loading @@ -216,7 +226,11 @@ private: CanvasState mCanvasState; // contains ResolvedOps and Batches Caches* mCaches = nullptr; float mLightRadius; // contains single-frame objects, such as BakedOpStates, LayerBuilders, Batches LinearAllocator mAllocator; }; Loading Loading
libs/hwui/BakedOpDispatcher.cpp +1 −7 Original line number Diff line number Diff line Loading @@ -663,13 +663,7 @@ static void renderShadow(BakedOpRenderer& renderer, const BakedOpState& state, f } void BakedOpDispatcher::onShadowOp(BakedOpRenderer& renderer, const ShadowOp& op, const BakedOpState& state) { TessellationCache::vertexBuffer_pair_t buffers; renderer.caches().tessellationCache.getShadowBuffers(&state.computedState.transform, op.localClipRect, op.casterAlpha >= 1.0f, op.casterPath, &op.shadowMatrixXY, &op.shadowMatrixZ, op.lightCenter, renderer.getLightInfo().lightRadius, buffers); TessellationCache::vertexBuffer_pair_t buffers = *(op.shadowTask->getResult()); renderShadow(renderer, state, op.casterAlpha, buffers.first, buffers.second); } Loading
libs/hwui/BakedOpRenderer.h +3 −5 Original line number Diff line number Diff line Loading @@ -45,13 +45,11 @@ public: * Position agnostic shadow lighting info. Used with all shadow ops in scene. */ struct LightInfo { LightInfo() : LightInfo(0, 0, 0) {} LightInfo(float lightRadius, uint8_t ambientShadowAlpha, LightInfo() : LightInfo(0, 0) {} LightInfo(uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha) : lightRadius(lightRadius) , ambientShadowAlpha(ambientShadowAlpha) : ambientShadowAlpha(ambientShadowAlpha) , spotShadowAlpha(spotShadowAlpha) {} float lightRadius; uint8_t ambientShadowAlpha; uint8_t spotShadowAlpha; }; Loading
libs/hwui/BakedOpState.cpp +5 −10 Original line number Diff line number Diff line Loading @@ -63,16 +63,11 @@ ResolvedRenderState::ResolvedRenderState(LinearAllocator& allocator, Snapshot& s } } ResolvedRenderState::ResolvedRenderState(LinearAllocator& allocator, Snapshot& snapshot) { transform = *snapshot.transform; // Since the op doesn't have known bounds, we conservatively set the mapped bounds // to the current clipRect, and clipSideFlags to Full. clipState = snapshot.mutateClipArea().serializeClip(allocator); LOG_ALWAYS_FATAL_IF(!clipState, "clipState required"); clippedBounds = clipState->rect; clipSideFlags = OpClipSideFlags::Full; } ResolvedRenderState::ResolvedRenderState(LinearAllocator& allocator, Snapshot& snapshot) : transform(*snapshot.transform) , clipState(snapshot.mutateClipArea().serializeClip(allocator)) , clippedBounds(clipState->rect) , clipSideFlags(OpClipSideFlags::Full) {} ResolvedRenderState::ResolvedRenderState(const ClipRect* viewportRect, const Rect& dstRect) : transform(Matrix4::identity()) Loading
libs/hwui/FrameBuilder.cpp +28 −19 Original line number Diff line number Diff line Loading @@ -33,17 +33,11 @@ namespace uirenderer { FrameBuilder::FrameBuilder(const LayerUpdateQueue& layers, const SkRect& clip, uint32_t viewportWidth, uint32_t viewportHeight, const std::vector< sp<RenderNode> >& nodes, const Vector3& lightCenter) : FrameBuilder(layers, clip, viewportWidth, viewportHeight, nodes, lightCenter, Rect(0, 0, 0, 0)) { } FrameBuilder::FrameBuilder(const LayerUpdateQueue& layers, const SkRect& clip, uint32_t viewportWidth, uint32_t viewportHeight, const std::vector< sp<RenderNode> >& nodes, const Vector3& lightCenter, const Rect &contentDrawBounds) : mCanvasState(*this) { const std::vector< sp<RenderNode> >& nodes, const LightGeometry& lightGeometry, const Rect &contentDrawBounds, Caches* caches) : mCanvasState(*this) , mCaches(caches) , mLightRadius(lightGeometry.radius) { ATRACE_NAME("prepare drawing commands"); mLayerBuilders.reserve(layers.entries().size()); Loading @@ -55,7 +49,7 @@ FrameBuilder::FrameBuilder(const LayerUpdateQueue& layers, const SkRect& clip, mLayerStack.push_back(0); mCanvasState.initializeSaveStack(viewportWidth, viewportHeight, clip.fLeft, clip.fTop, clip.fRight, clip.fBottom, lightCenter); lightGeometry.center); // Render all layers to be updated, in order. Defer in reverse order, so that they'll be // updated in the order they're passed in (mLayerBuilders are issued to Renderer in reverse) Loading Loading @@ -367,15 +361,30 @@ void FrameBuilder::deferShadow(const RenderNodeOp& casterNodeOp) { casterPath = frameAllocatedPath; } ShadowOp* shadowOp = new (mAllocator) ShadowOp(casterNodeOp, casterAlpha, casterPath, if (CC_LIKELY(!mCanvasState.getRenderTargetClipBounds().isEmpty())) { Matrix4 shadowMatrixXY(casterNodeOp.localMatrix); Matrix4 shadowMatrixZ(casterNodeOp.localMatrix); node.applyViewPropertyTransforms(shadowMatrixXY, false); node.applyViewPropertyTransforms(shadowMatrixZ, true); LOG_ALWAYS_FATAL_IF(!mCaches, "Caches needed for shadows"); sp<TessellationCache::ShadowTask> task = mCaches->tessellationCache.getShadowTask( mCanvasState.currentTransform(), mCanvasState.getLocalClipBounds(), mCanvasState.currentSnapshot()->getRelativeLightCenter()); casterAlpha >= 1.0f, casterPath, &shadowMatrixXY, &shadowMatrixZ, mCanvasState.currentSnapshot()->getRelativeLightCenter(), mLightRadius); ShadowOp* shadowOp = mAllocator.create<ShadowOp>(task, casterAlpha); BakedOpState* bakedOpState = BakedOpState::tryShadowOpConstruct( mAllocator, *mCanvasState.writableSnapshot(), shadowOp); if (CC_LIKELY(bakedOpState)) { currentLayer().deferUnmergeableOp(mAllocator, bakedOpState, OpBatchType::Shadow); } } } void FrameBuilder::deferProjectedChildren(const RenderNode& renderNode) { const SkPath* projectionReceiverOutline = renderNode.properties().getOutline().getPath(); Loading
libs/hwui/FrameBuilder.h +18 −4 Original line number Diff line number Diff line Loading @@ -55,14 +55,24 @@ class Rect; */ class FrameBuilder : public CanvasStateClient { public: struct LightGeometry { Vector3 center; float radius; }; // TODO: remove FrameBuilder(const LayerUpdateQueue& layers, const SkRect& clip, uint32_t viewportWidth, uint32_t viewportHeight, const std::vector< sp<RenderNode> >& nodes, const Vector3& lightCenter); const std::vector< sp<RenderNode> >& nodes, const LightGeometry& lightGeometry, Caches* caches) : FrameBuilder(layers, clip, viewportWidth, viewportHeight, nodes, lightGeometry, Rect(), caches) {} FrameBuilder(const LayerUpdateQueue& layers, const SkRect& clip, uint32_t viewportWidth, uint32_t viewportHeight, const std::vector< sp<RenderNode> >& nodes, const Vector3& lightCenter, const Rect &contentDrawBounds); const std::vector< sp<RenderNode> >& nodes, const LightGeometry& lightGeometry, const Rect &contentDrawBounds, Caches* caches); virtual ~FrameBuilder() {} Loading Loading @@ -216,7 +226,11 @@ private: CanvasState mCanvasState; // contains ResolvedOps and Batches Caches* mCaches = nullptr; float mLightRadius; // contains single-frame objects, such as BakedOpStates, LayerBuilders, Batches LinearAllocator mAllocator; }; Loading