Loading libs/hwui/Android.bp +0 −4 Original line number Diff line number Diff line Loading @@ -210,8 +210,6 @@ cc_defaults { "DamageAccumulator.cpp", "DeferredLayerUpdater.cpp", "DeviceInfo.cpp", "DisplayList.cpp", "FrameBuilder.cpp", "FrameInfo.cpp", "FrameInfoVisualizer.cpp", "GlLayer.cpp", Loading @@ -237,7 +235,6 @@ cc_defaults { "Properties.cpp", "PropertyValuesAnimatorSet.cpp", "PropertyValuesHolder.cpp", "RecordingCanvas.cpp", "RenderNode.cpp", "RenderProperties.cpp", "ResourceCache.cpp", Loading Loading @@ -399,7 +396,6 @@ cc_benchmark { srcs: [ "tests/microbench/main.cpp", "tests/microbench/DisplayListCanvasBench.cpp", "tests/microbench/FrameBuilderBench.cpp", "tests/microbench/LinearAllocatorBench.cpp", "tests/microbench/PathParserBench.cpp", "tests/microbench/RenderNodeBench.cpp", Loading libs/hwui/Animator.h +2 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ #ifndef ANIMATOR_H #define ANIMATOR_H #include "CanvasProperty.h" #include <cutils/compiler.h> #include <utils/RefBase.h> #include <utils/StrongPointer.h> Loading @@ -31,8 +33,6 @@ namespace uirenderer { class AnimationContext; class BaseRenderNodeAnimator; class CanvasPropertyPrimitive; class CanvasPropertyPaint; class Interpolator; class RenderNode; class RenderProperties; Loading libs/hwui/BakedOpRenderer.h +1 −10 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #pragma once #include "BakedOpState.h" #include "Lighting.h" #include "Matrix.h" #include "utils/Macros.h" Loading @@ -42,16 +43,6 @@ struct ClipBase; class BakedOpRenderer { public: typedef void (*GlopReceiver)(BakedOpRenderer&, const Rect*, const ClipBase*, const Glop&); /** * Position agnostic shadow lighting info. Used with all shadow ops in scene. */ struct LightInfo { LightInfo() : LightInfo(0, 0) {} LightInfo(uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha) : ambientShadowAlpha(ambientShadowAlpha), spotShadowAlpha(spotShadowAlpha) {} uint8_t ambientShadowAlpha; uint8_t spotShadowAlpha; }; BakedOpRenderer(Caches& caches, RenderState& renderState, bool opaque, bool wideColorGamut, const LightInfo& lightInfo) Loading libs/hwui/DisplayList.cppdeleted 100644 → 0 +0 −142 Original line number Diff line number Diff line /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <SkCanvas.h> #include <algorithm> #include <utils/Trace.h> #include "DamageAccumulator.h" #include "Debug.h" #include "DisplayList.h" #include "OpDumper.h" #include "RecordedOp.h" #include "RenderNode.h" #include "VectorDrawable.h" #include "renderthread/CanvasContext.h" namespace android { namespace uirenderer { DisplayList::DisplayList() : projectionReceiveIndex(-1) , stdAllocator(allocator) , chunks(stdAllocator) , ops(stdAllocator) , children(stdAllocator) , bitmapResources(stdAllocator) , pathResources(stdAllocator) , patchResources(stdAllocator) , paints(stdAllocator) , regions(stdAllocator) , referenceHolders(stdAllocator) , functors(stdAllocator) , vectorDrawables(stdAllocator) {} DisplayList::~DisplayList() { cleanupResources(); } void DisplayList::cleanupResources() { if (CC_UNLIKELY(patchResources.size())) { ResourceCache& resourceCache = ResourceCache::getInstance(); resourceCache.lock(); for (size_t i = 0; i < patchResources.size(); i++) { resourceCache.decrementRefcountLocked(patchResources[i]); } resourceCache.unlock(); } for (size_t i = 0; i < pathResources.size(); i++) { const SkPath* path = pathResources[i]; delete path; } for (auto& iter : functors) { if (iter.listener) { iter.listener->onGlFunctorReleased(iter.functor); } } patchResources.clear(); pathResources.clear(); paints.clear(); regions.clear(); } size_t DisplayList::addChild(NodeOpType* op) { referenceHolders.push_back(op->renderNode); size_t index = children.size(); children.push_back(op); return index; } void DisplayList::syncContents() { for (auto& iter : functors) { (*iter.functor)(DrawGlInfo::kModeSync, nullptr); } for (auto& vectorDrawable : vectorDrawables) { vectorDrawable->syncProperties(); } } void DisplayList::updateChildren(std::function<void(RenderNode*)> updateFn) { for (auto&& child : children) { updateFn(child->renderNode); } } bool DisplayList::prepareListAndChildren( TreeObserver& observer, TreeInfo& info, bool functorsNeedLayer, std::function<void(RenderNode*, TreeObserver&, TreeInfo&, bool)> childFn) { info.prepareTextures = info.canvasContext.pinImages(bitmapResources); for (auto&& op : children) { RenderNode* childNode = op->renderNode; info.damageAccumulator->pushTransform(&op->localMatrix); bool childFunctorsNeedLayer = functorsNeedLayer; // TODO! || op->mRecordedWithPotentialStencilClip; childFn(childNode, observer, info, childFunctorsNeedLayer); info.damageAccumulator->popTransform(); } bool isDirty = false; for (auto& vectorDrawable : vectorDrawables) { // If any vector drawable in the display list needs update, damage the node. if (vectorDrawable->isDirty()) { isDirty = true; } vectorDrawable->setPropertyChangeWillBeConsumed(true); } return isDirty; } void DisplayList::output(std::ostream& output, uint32_t level) { for (auto&& op : getOps()) { OpDumper::dump(*op, output, level + 1); if (op->opId == RecordedOpId::RenderNodeOp) { auto rnOp = reinterpret_cast<const RenderNodeOp*>(op); rnOp->renderNode->output(output, level + 1); } else { output << std::endl; } } } }; // namespace uirenderer }; // namespace android libs/hwui/DisplayList.h +2 −131 Original line number Diff line number Diff line Loading @@ -16,149 +16,20 @@ #pragma once #include <SkCamera.h> #include <SkDrawable.h> #include <SkMatrix.h> #include <private/hwui/DrawGlInfo.h> #include <utils/KeyedVector.h> #include <utils/LinearAllocator.h> #include <utils/RefBase.h> #include <utils/SortedVector.h> #include <utils/String8.h> #include <cutils/compiler.h> #include <androidfw/ResourceTypes.h> #include "CanvasProperty.h" #include "Debug.h" #include "GlFunctorLifecycleListener.h" #include "Matrix.h" #include "RenderProperties.h" #include "TreeInfo.h" #include "hwui/Bitmap.h" #include <vector> class SkBitmap; class SkPaint; class SkPath; class SkRegion; #include "pipeline/skia/SkiaDisplayList.h" namespace android { namespace uirenderer { struct ClipBase; class Rect; class Layer; struct RecordedOp; struct RenderNodeOp; typedef RecordedOp BaseOpType; typedef RenderNodeOp NodeOpType; namespace VectorDrawable { class Tree; }; typedef uirenderer::VectorDrawable::Tree VectorDrawableRoot; struct FunctorContainer { Functor* functor; GlFunctorLifecycleListener* listener; }; /** * Data structure that holds the list of commands used in display list stream */ class DisplayList { friend class RecordingCanvas; public: struct Chunk { // range of included ops in DisplayList::ops() size_t beginOpIndex; size_t endOpIndex; // range of included children in DisplayList::children() size_t beginChildIndex; size_t endChildIndex; // whether children with non-zero Z in the chunk should be reordered bool reorderChildren; // clip at the beginning of a reorder section, applied to reordered children const ClipBase* reorderClip; }; DisplayList(); virtual ~DisplayList(); // index of DisplayListOp restore, after which projected descendants should be drawn int projectionReceiveIndex; const LsaVector<Chunk>& getChunks() const { return chunks; } const LsaVector<BaseOpType*>& getOps() const { return ops; } const LsaVector<NodeOpType*>& getChildren() const { return children; } const LsaVector<sk_sp<Bitmap>>& getBitmapResources() const { return bitmapResources; } size_t addChild(NodeOpType* childOp); void ref(VirtualLightRefBase* prop) { referenceHolders.push_back(prop); } size_t getUsedSize() { return allocator.usedSize(); } virtual bool isEmpty() const { return ops.empty(); } virtual bool hasFunctor() const { return !functors.empty(); } virtual bool hasVectorDrawables() const { return !vectorDrawables.empty(); } virtual bool isSkiaDL() const { return false; } virtual bool reuseDisplayList(RenderNode* node, renderthread::CanvasContext* context) { return false; } virtual void syncContents(); virtual void updateChildren(std::function<void(RenderNode*)> updateFn); virtual bool prepareListAndChildren( TreeObserver& observer, TreeInfo& info, bool functorsNeedLayer, std::function<void(RenderNode*, TreeObserver&, TreeInfo&, bool)> childFn); virtual void output(std::ostream& output, uint32_t level); protected: // allocator into which all ops and LsaVector arrays allocated LinearAllocator allocator; LinearStdAllocator<void*> stdAllocator; private: LsaVector<Chunk> chunks; LsaVector<BaseOpType*> ops; // list of Ops referring to RenderNode children for quick, non-drawing traversal LsaVector<NodeOpType*> children; // Resources - Skia objects + 9 patches referred to by this DisplayList LsaVector<sk_sp<Bitmap>> bitmapResources; LsaVector<const SkPath*> pathResources; LsaVector<const Res_png_9patch*> patchResources; LsaVector<std::unique_ptr<const SkPaint>> paints; LsaVector<std::unique_ptr<const SkRegion>> regions; LsaVector<sp<VirtualLightRefBase>> referenceHolders; // List of functors LsaVector<FunctorContainer> functors; // List of VectorDrawables that need to be notified of pushStaging. Note that this list gets // nothing // but a callback during sync DisplayList, unlike the list of functors defined above, which // gets special treatment exclusive for webview. LsaVector<VectorDrawableRoot*> vectorDrawables; void cleanupResources(); }; using DisplayList = skiapipeline::SkiaDisplayList; }; // namespace uirenderer }; // namespace android Loading
libs/hwui/Android.bp +0 −4 Original line number Diff line number Diff line Loading @@ -210,8 +210,6 @@ cc_defaults { "DamageAccumulator.cpp", "DeferredLayerUpdater.cpp", "DeviceInfo.cpp", "DisplayList.cpp", "FrameBuilder.cpp", "FrameInfo.cpp", "FrameInfoVisualizer.cpp", "GlLayer.cpp", Loading @@ -237,7 +235,6 @@ cc_defaults { "Properties.cpp", "PropertyValuesAnimatorSet.cpp", "PropertyValuesHolder.cpp", "RecordingCanvas.cpp", "RenderNode.cpp", "RenderProperties.cpp", "ResourceCache.cpp", Loading Loading @@ -399,7 +396,6 @@ cc_benchmark { srcs: [ "tests/microbench/main.cpp", "tests/microbench/DisplayListCanvasBench.cpp", "tests/microbench/FrameBuilderBench.cpp", "tests/microbench/LinearAllocatorBench.cpp", "tests/microbench/PathParserBench.cpp", "tests/microbench/RenderNodeBench.cpp", Loading
libs/hwui/Animator.h +2 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ #ifndef ANIMATOR_H #define ANIMATOR_H #include "CanvasProperty.h" #include <cutils/compiler.h> #include <utils/RefBase.h> #include <utils/StrongPointer.h> Loading @@ -31,8 +33,6 @@ namespace uirenderer { class AnimationContext; class BaseRenderNodeAnimator; class CanvasPropertyPrimitive; class CanvasPropertyPaint; class Interpolator; class RenderNode; class RenderProperties; Loading
libs/hwui/BakedOpRenderer.h +1 −10 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #pragma once #include "BakedOpState.h" #include "Lighting.h" #include "Matrix.h" #include "utils/Macros.h" Loading @@ -42,16 +43,6 @@ struct ClipBase; class BakedOpRenderer { public: typedef void (*GlopReceiver)(BakedOpRenderer&, const Rect*, const ClipBase*, const Glop&); /** * Position agnostic shadow lighting info. Used with all shadow ops in scene. */ struct LightInfo { LightInfo() : LightInfo(0, 0) {} LightInfo(uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha) : ambientShadowAlpha(ambientShadowAlpha), spotShadowAlpha(spotShadowAlpha) {} uint8_t ambientShadowAlpha; uint8_t spotShadowAlpha; }; BakedOpRenderer(Caches& caches, RenderState& renderState, bool opaque, bool wideColorGamut, const LightInfo& lightInfo) Loading
libs/hwui/DisplayList.cppdeleted 100644 → 0 +0 −142 Original line number Diff line number Diff line /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <SkCanvas.h> #include <algorithm> #include <utils/Trace.h> #include "DamageAccumulator.h" #include "Debug.h" #include "DisplayList.h" #include "OpDumper.h" #include "RecordedOp.h" #include "RenderNode.h" #include "VectorDrawable.h" #include "renderthread/CanvasContext.h" namespace android { namespace uirenderer { DisplayList::DisplayList() : projectionReceiveIndex(-1) , stdAllocator(allocator) , chunks(stdAllocator) , ops(stdAllocator) , children(stdAllocator) , bitmapResources(stdAllocator) , pathResources(stdAllocator) , patchResources(stdAllocator) , paints(stdAllocator) , regions(stdAllocator) , referenceHolders(stdAllocator) , functors(stdAllocator) , vectorDrawables(stdAllocator) {} DisplayList::~DisplayList() { cleanupResources(); } void DisplayList::cleanupResources() { if (CC_UNLIKELY(patchResources.size())) { ResourceCache& resourceCache = ResourceCache::getInstance(); resourceCache.lock(); for (size_t i = 0; i < patchResources.size(); i++) { resourceCache.decrementRefcountLocked(patchResources[i]); } resourceCache.unlock(); } for (size_t i = 0; i < pathResources.size(); i++) { const SkPath* path = pathResources[i]; delete path; } for (auto& iter : functors) { if (iter.listener) { iter.listener->onGlFunctorReleased(iter.functor); } } patchResources.clear(); pathResources.clear(); paints.clear(); regions.clear(); } size_t DisplayList::addChild(NodeOpType* op) { referenceHolders.push_back(op->renderNode); size_t index = children.size(); children.push_back(op); return index; } void DisplayList::syncContents() { for (auto& iter : functors) { (*iter.functor)(DrawGlInfo::kModeSync, nullptr); } for (auto& vectorDrawable : vectorDrawables) { vectorDrawable->syncProperties(); } } void DisplayList::updateChildren(std::function<void(RenderNode*)> updateFn) { for (auto&& child : children) { updateFn(child->renderNode); } } bool DisplayList::prepareListAndChildren( TreeObserver& observer, TreeInfo& info, bool functorsNeedLayer, std::function<void(RenderNode*, TreeObserver&, TreeInfo&, bool)> childFn) { info.prepareTextures = info.canvasContext.pinImages(bitmapResources); for (auto&& op : children) { RenderNode* childNode = op->renderNode; info.damageAccumulator->pushTransform(&op->localMatrix); bool childFunctorsNeedLayer = functorsNeedLayer; // TODO! || op->mRecordedWithPotentialStencilClip; childFn(childNode, observer, info, childFunctorsNeedLayer); info.damageAccumulator->popTransform(); } bool isDirty = false; for (auto& vectorDrawable : vectorDrawables) { // If any vector drawable in the display list needs update, damage the node. if (vectorDrawable->isDirty()) { isDirty = true; } vectorDrawable->setPropertyChangeWillBeConsumed(true); } return isDirty; } void DisplayList::output(std::ostream& output, uint32_t level) { for (auto&& op : getOps()) { OpDumper::dump(*op, output, level + 1); if (op->opId == RecordedOpId::RenderNodeOp) { auto rnOp = reinterpret_cast<const RenderNodeOp*>(op); rnOp->renderNode->output(output, level + 1); } else { output << std::endl; } } } }; // namespace uirenderer }; // namespace android
libs/hwui/DisplayList.h +2 −131 Original line number Diff line number Diff line Loading @@ -16,149 +16,20 @@ #pragma once #include <SkCamera.h> #include <SkDrawable.h> #include <SkMatrix.h> #include <private/hwui/DrawGlInfo.h> #include <utils/KeyedVector.h> #include <utils/LinearAllocator.h> #include <utils/RefBase.h> #include <utils/SortedVector.h> #include <utils/String8.h> #include <cutils/compiler.h> #include <androidfw/ResourceTypes.h> #include "CanvasProperty.h" #include "Debug.h" #include "GlFunctorLifecycleListener.h" #include "Matrix.h" #include "RenderProperties.h" #include "TreeInfo.h" #include "hwui/Bitmap.h" #include <vector> class SkBitmap; class SkPaint; class SkPath; class SkRegion; #include "pipeline/skia/SkiaDisplayList.h" namespace android { namespace uirenderer { struct ClipBase; class Rect; class Layer; struct RecordedOp; struct RenderNodeOp; typedef RecordedOp BaseOpType; typedef RenderNodeOp NodeOpType; namespace VectorDrawable { class Tree; }; typedef uirenderer::VectorDrawable::Tree VectorDrawableRoot; struct FunctorContainer { Functor* functor; GlFunctorLifecycleListener* listener; }; /** * Data structure that holds the list of commands used in display list stream */ class DisplayList { friend class RecordingCanvas; public: struct Chunk { // range of included ops in DisplayList::ops() size_t beginOpIndex; size_t endOpIndex; // range of included children in DisplayList::children() size_t beginChildIndex; size_t endChildIndex; // whether children with non-zero Z in the chunk should be reordered bool reorderChildren; // clip at the beginning of a reorder section, applied to reordered children const ClipBase* reorderClip; }; DisplayList(); virtual ~DisplayList(); // index of DisplayListOp restore, after which projected descendants should be drawn int projectionReceiveIndex; const LsaVector<Chunk>& getChunks() const { return chunks; } const LsaVector<BaseOpType*>& getOps() const { return ops; } const LsaVector<NodeOpType*>& getChildren() const { return children; } const LsaVector<sk_sp<Bitmap>>& getBitmapResources() const { return bitmapResources; } size_t addChild(NodeOpType* childOp); void ref(VirtualLightRefBase* prop) { referenceHolders.push_back(prop); } size_t getUsedSize() { return allocator.usedSize(); } virtual bool isEmpty() const { return ops.empty(); } virtual bool hasFunctor() const { return !functors.empty(); } virtual bool hasVectorDrawables() const { return !vectorDrawables.empty(); } virtual bool isSkiaDL() const { return false; } virtual bool reuseDisplayList(RenderNode* node, renderthread::CanvasContext* context) { return false; } virtual void syncContents(); virtual void updateChildren(std::function<void(RenderNode*)> updateFn); virtual bool prepareListAndChildren( TreeObserver& observer, TreeInfo& info, bool functorsNeedLayer, std::function<void(RenderNode*, TreeObserver&, TreeInfo&, bool)> childFn); virtual void output(std::ostream& output, uint32_t level); protected: // allocator into which all ops and LsaVector arrays allocated LinearAllocator allocator; LinearStdAllocator<void*> stdAllocator; private: LsaVector<Chunk> chunks; LsaVector<BaseOpType*> ops; // list of Ops referring to RenderNode children for quick, non-drawing traversal LsaVector<NodeOpType*> children; // Resources - Skia objects + 9 patches referred to by this DisplayList LsaVector<sk_sp<Bitmap>> bitmapResources; LsaVector<const SkPath*> pathResources; LsaVector<const Res_png_9patch*> patchResources; LsaVector<std::unique_ptr<const SkPaint>> paints; LsaVector<std::unique_ptr<const SkRegion>> regions; LsaVector<sp<VirtualLightRefBase>> referenceHolders; // List of functors LsaVector<FunctorContainer> functors; // List of VectorDrawables that need to be notified of pushStaging. Note that this list gets // nothing // but a callback during sync DisplayList, unlike the list of functors defined above, which // gets special treatment exclusive for webview. LsaVector<VectorDrawableRoot*> vectorDrawables; void cleanupResources(); }; using DisplayList = skiapipeline::SkiaDisplayList; }; // namespace uirenderer }; // namespace android