2014-03-18 09:22:59 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 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.
|
|
|
|
*/
|
2016-07-06 16:10:09 -07:00
|
|
|
|
|
|
|
#pragma once
|
2014-03-18 09:22:59 -07:00
|
|
|
|
|
|
|
#include <SkCamera.h>
|
|
|
|
#include <SkMatrix.h>
|
|
|
|
|
|
|
|
#include <utils/LinearAllocator.h>
|
|
|
|
#include <utils/RefBase.h>
|
|
|
|
#include <utils/String8.h>
|
|
|
|
|
|
|
|
#include <cutils/compiler.h>
|
|
|
|
|
|
|
|
#include <androidfw/ResourceTypes.h>
|
|
|
|
|
2014-06-24 15:34:58 -07:00
|
|
|
#include "AnimatorManager.h"
|
2018-07-02 18:33:32 -07:00
|
|
|
#include "CanvasTransform.h"
|
2014-03-18 09:22:59 -07:00
|
|
|
#include "Debug.h"
|
|
|
|
#include "DisplayList.h"
|
2015-10-05 13:00:52 -07:00
|
|
|
#include "Matrix.h"
|
2014-03-18 09:22:59 -07:00
|
|
|
#include "RenderProperties.h"
|
2016-10-17 16:26:15 -04:00
|
|
|
#include "pipeline/skia/SkiaDisplayList.h"
|
2016-10-26 10:30:09 -04:00
|
|
|
#include "pipeline/skia/SkiaLayer.h"
|
2017-01-25 10:58:30 -08:00
|
|
|
#include "utils/FatVector.h"
|
2014-03-18 09:22:59 -07:00
|
|
|
|
2015-07-29 16:48:58 -07:00
|
|
|
#include <vector>
|
|
|
|
|
2014-03-18 09:22:59 -07:00
|
|
|
class SkBitmap;
|
|
|
|
class SkPaint;
|
|
|
|
class SkPath;
|
|
|
|
class SkRegion;
|
2016-09-27 16:04:42 -04:00
|
|
|
class SkSurface;
|
2014-03-18 09:22:59 -07:00
|
|
|
|
|
|
|
namespace android {
|
|
|
|
namespace uirenderer {
|
|
|
|
|
2015-10-05 13:00:52 -07:00
|
|
|
class CanvasState;
|
2016-07-06 16:10:09 -07:00
|
|
|
class Rect;
|
|
|
|
class SkiaShader;
|
2015-11-24 16:40:09 -08:00
|
|
|
struct RenderNodeOp;
|
2016-07-06 16:10:09 -07:00
|
|
|
|
2014-10-15 15:46:42 -04:00
|
|
|
class TreeInfo;
|
2016-03-25 14:29:48 -07:00
|
|
|
class TreeObserver;
|
2014-03-18 09:22:59 -07:00
|
|
|
|
2015-08-05 13:53:53 -07:00
|
|
|
namespace proto {
|
|
|
|
class RenderNode;
|
|
|
|
}
|
|
|
|
|
2014-03-18 09:22:59 -07:00
|
|
|
/**
|
2017-11-03 10:12:19 -07:00
|
|
|
* Primary class for storing recorded canvas commands, as well as per-View/ViewGroup display
|
|
|
|
* properties.
|
2014-03-18 09:22:59 -07:00
|
|
|
*
|
|
|
|
* Recording of canvas commands is somewhat similar to SkPicture, except the canvas-recording
|
2016-07-06 16:10:09 -07:00
|
|
|
* functionality is split between RecordingCanvas (which manages the recording), DisplayList
|
|
|
|
* (which holds the actual data), and RenderNode (which holds properties used for render playback).
|
2014-03-18 09:22:59 -07:00
|
|
|
*
|
2015-10-16 10:24:55 -07:00
|
|
|
* Note that DisplayList is swapped out from beneath an individual RenderNode when a view's
|
|
|
|
* recorded stream of canvas operations is refreshed. The RenderNode (and its properties) stay
|
2014-03-18 09:22:59 -07:00
|
|
|
* attached.
|
|
|
|
*/
|
2014-04-04 16:20:08 -07:00
|
|
|
class RenderNode : public VirtualLightRefBase {
|
2017-11-03 10:12:19 -07:00
|
|
|
friend class TestUtils; // allow TestUtils to access syncDisplayList / syncProperties
|
|
|
|
|
2014-03-18 09:22:59 -07:00
|
|
|
public:
|
2014-05-14 16:34:14 -07:00
|
|
|
enum DirtyPropertyMask {
|
2017-11-03 10:12:19 -07:00
|
|
|
GENERIC = 1 << 1,
|
|
|
|
TRANSLATION_X = 1 << 2,
|
|
|
|
TRANSLATION_Y = 1 << 3,
|
|
|
|
TRANSLATION_Z = 1 << 4,
|
|
|
|
SCALE_X = 1 << 5,
|
|
|
|
SCALE_Y = 1 << 6,
|
|
|
|
ROTATION = 1 << 7,
|
|
|
|
ROTATION_X = 1 << 8,
|
|
|
|
ROTATION_Y = 1 << 9,
|
|
|
|
X = 1 << 10,
|
|
|
|
Y = 1 << 11,
|
|
|
|
Z = 1 << 12,
|
|
|
|
ALPHA = 1 << 13,
|
|
|
|
DISPLAY_LIST = 1 << 14,
|
2014-05-14 16:34:14 -07:00
|
|
|
};
|
|
|
|
|
2014-03-18 09:22:59 -07:00
|
|
|
ANDROID_API RenderNode();
|
2014-04-15 09:50:16 -07:00
|
|
|
ANDROID_API virtual ~RenderNode();
|
2014-03-18 09:22:59 -07:00
|
|
|
|
|
|
|
// See flags defined in DisplayList.java
|
2017-11-03 10:12:19 -07:00
|
|
|
enum ReplayFlag { kReplayFlag_ClipChildren = 0x1 };
|
2014-03-18 09:22:59 -07:00
|
|
|
|
2017-01-25 10:58:30 -08:00
|
|
|
ANDROID_API void setStagingDisplayList(DisplayList* newData);
|
2014-03-18 09:22:59 -07:00
|
|
|
|
2016-08-08 13:22:06 -07:00
|
|
|
ANDROID_API void output();
|
2014-05-23 17:42:28 -07:00
|
|
|
ANDROID_API int getDebugSize();
|
2014-03-18 09:22:59 -07:00
|
|
|
|
2017-11-03 10:12:19 -07:00
|
|
|
bool isRenderable() const { return mDisplayList && !mDisplayList->isEmpty(); }
|
2014-03-18 09:22:59 -07:00
|
|
|
|
2014-06-11 18:39:44 -07:00
|
|
|
bool hasProjectionReceiver() const {
|
2018-09-20 13:00:04 -07:00
|
|
|
return mDisplayList && mDisplayList->containsProjectionReceiver();
|
2014-06-11 18:39:44 -07:00
|
|
|
}
|
|
|
|
|
2017-11-03 10:12:19 -07:00
|
|
|
const char* getName() const { return mName.string(); }
|
2014-04-08 18:17:07 -07:00
|
|
|
|
2014-03-18 09:22:59 -07:00
|
|
|
void setName(const char* name) {
|
|
|
|
if (name) {
|
2016-03-24 12:03:42 -07:00
|
|
|
const char* lastPeriod = strrchr(name, '.');
|
2014-03-18 09:22:59 -07:00
|
|
|
if (lastPeriod) {
|
|
|
|
mName.setTo(lastPeriod + 1);
|
|
|
|
} else {
|
|
|
|
mName.setTo(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-03 10:12:19 -07:00
|
|
|
VirtualLightRefBase* getUserContext() const { return mUserContext.get(); }
|
2016-03-25 14:29:48 -07:00
|
|
|
|
2017-11-03 10:12:19 -07:00
|
|
|
void setUserContext(VirtualLightRefBase* context) { mUserContext = context; }
|
2016-03-25 14:29:48 -07:00
|
|
|
|
2014-05-14 16:34:14 -07:00
|
|
|
bool isPropertyFieldDirty(DirtyPropertyMask field) const {
|
|
|
|
return mDirtyPropertyFields & field;
|
|
|
|
}
|
|
|
|
|
2017-11-03 10:12:19 -07:00
|
|
|
void setPropertyFieldsDirty(uint32_t fields) { mDirtyPropertyFields |= fields; }
|
2014-05-14 16:34:14 -07:00
|
|
|
|
2017-11-03 10:12:19 -07:00
|
|
|
const RenderProperties& properties() const { return mProperties; }
|
2014-03-18 09:22:59 -07:00
|
|
|
|
2017-11-03 10:12:19 -07:00
|
|
|
RenderProperties& animatorProperties() { return mProperties; }
|
2014-05-01 21:27:37 -07:00
|
|
|
|
2017-11-03 10:12:19 -07:00
|
|
|
const RenderProperties& stagingProperties() { return mStagingProperties; }
|
2014-03-20 16:28:56 -07:00
|
|
|
|
2017-11-03 10:12:19 -07:00
|
|
|
RenderProperties& mutateStagingProperties() { return mStagingProperties; }
|
2014-03-20 16:28:56 -07:00
|
|
|
|
2017-11-03 10:12:19 -07:00
|
|
|
bool isValid() { return mValid; }
|
2017-01-25 10:58:30 -08:00
|
|
|
|
2017-11-03 10:12:19 -07:00
|
|
|
int getWidth() const { return properties().getWidth(); }
|
2014-03-18 09:22:59 -07:00
|
|
|
|
2017-11-03 10:12:19 -07:00
|
|
|
int getHeight() const { return properties().getHeight(); }
|
2014-03-18 09:22:59 -07:00
|
|
|
|
2014-04-15 09:50:16 -07:00
|
|
|
ANDROID_API virtual void prepareTree(TreeInfo& info);
|
2017-01-25 10:58:30 -08:00
|
|
|
void destroyHardwareResources(TreeInfo* info = nullptr);
|
|
|
|
void destroyLayers();
|
2014-04-15 09:50:16 -07:00
|
|
|
|
|
|
|
// UI thread only!
|
2014-06-24 15:34:58 -07:00
|
|
|
ANDROID_API void addAnimator(const sp<BaseRenderNodeAnimator>& animator);
|
2016-02-19 21:46:06 +00:00
|
|
|
void removeAnimator(const sp<BaseRenderNodeAnimator>& animator);
|
|
|
|
|
|
|
|
// This can only happen during pushStaging()
|
|
|
|
void onAnimatorTargetChanged(BaseRenderNodeAnimator* animator) {
|
|
|
|
mAnimatorManager.onAnimatorTargetChanged(animator);
|
|
|
|
}
|
2014-03-26 15:10:40 -07:00
|
|
|
|
2014-08-14 09:02:01 -07:00
|
|
|
AnimatorManager& animators() { return mAnimatorManager; }
|
|
|
|
|
2014-08-14 13:34:01 -07:00
|
|
|
void applyViewPropertyTransforms(mat4& matrix, bool true3dTransform = false) const;
|
|
|
|
|
2015-10-05 13:00:52 -07:00
|
|
|
bool nothingToDraw() const {
|
|
|
|
const Outline& outline = properties().getOutline();
|
2017-11-03 10:12:19 -07:00
|
|
|
return mDisplayList == nullptr || properties().getAlpha() <= 0 ||
|
|
|
|
(outline.getShouldClip() && outline.isEmpty()) || properties().getScaleX() == 0 ||
|
|
|
|
properties().getScaleY() == 0;
|
2015-10-05 13:00:52 -07:00
|
|
|
}
|
|
|
|
|
2017-11-03 10:12:19 -07:00
|
|
|
const DisplayList* getDisplayList() const { return mDisplayList; }
|
2015-10-05 13:00:52 -07:00
|
|
|
|
2016-06-16 15:36:13 -07:00
|
|
|
// Note: The position callbacks are relying on the listener using
|
|
|
|
// the frameNumber to appropriately batch/synchronize these transactions.
|
|
|
|
// There is no other filtering/batching to ensure that only the "final"
|
|
|
|
// state called once per frame.
|
2016-06-27 13:27:23 -07:00
|
|
|
class ANDROID_API PositionListener : public VirtualLightRefBase {
|
2016-02-02 15:18:23 -08:00
|
|
|
public:
|
|
|
|
virtual ~PositionListener() {}
|
2016-06-16 15:36:13 -07:00
|
|
|
// Called when the RenderNode's position changes
|
2016-02-02 15:18:23 -08:00
|
|
|
virtual void onPositionUpdated(RenderNode& node, const TreeInfo& info) = 0;
|
2016-06-16 15:36:13 -07:00
|
|
|
// Called when the RenderNode no longer has a position. As in, it's
|
|
|
|
// no longer being drawn.
|
|
|
|
// Note, tree info might be null
|
|
|
|
virtual void onPositionLost(RenderNode& node, const TreeInfo* info) = 0;
|
2016-02-02 15:18:23 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
// Note this is not thread safe, this needs to be called
|
|
|
|
// before the RenderNode is used for drawing.
|
|
|
|
// RenderNode takes ownership of the pointer
|
|
|
|
ANDROID_API void setPositionListener(PositionListener* listener) {
|
2016-06-27 13:27:23 -07:00
|
|
|
mPositionListener = listener;
|
2016-02-02 15:18:23 -08:00
|
|
|
}
|
|
|
|
|
2016-03-25 14:29:48 -07:00
|
|
|
// This is only modified in MODE_FULL, so it can be safely accessed
|
|
|
|
// on the UI thread.
|
2017-11-03 10:12:19 -07:00
|
|
|
ANDROID_API bool hasParents() { return mParentCount; }
|
2016-03-25 14:29:48 -07:00
|
|
|
|
2017-01-25 10:58:30 -08:00
|
|
|
void onRemovedFromTree(TreeInfo* info);
|
|
|
|
|
|
|
|
// Called by CanvasContext to promote a RenderNode to be a root node
|
2017-11-03 10:12:19 -07:00
|
|
|
void makeRoot() { incParentRefCount(); }
|
2017-01-25 10:58:30 -08:00
|
|
|
|
|
|
|
// Called by CanvasContext when it drops a RenderNode from being a root node
|
|
|
|
void clearRoot();
|
|
|
|
|
2017-02-09 16:59:27 -05:00
|
|
|
void output(std::ostream& output, uint32_t level);
|
|
|
|
|
2018-08-15 10:17:12 -07:00
|
|
|
void setUsageHint(UsageHint usageHint) { mUsageHint = usageHint; }
|
2018-07-02 18:33:32 -07:00
|
|
|
|
2018-08-15 10:17:12 -07:00
|
|
|
UsageHint usageHint() const { return mUsageHint; }
|
2018-07-02 18:33:32 -07:00
|
|
|
|
2018-11-29 09:44:10 -08:00
|
|
|
int64_t uniqueId() const { return mUniqueId; }
|
|
|
|
|
|
|
|
void markDrawStart(SkCanvas& canvas);
|
|
|
|
void markDrawEnd(SkCanvas& canvas);
|
|
|
|
|
2014-03-18 09:22:59 -07:00
|
|
|
private:
|
2016-07-06 16:10:09 -07:00
|
|
|
void computeOrderingImpl(RenderNodeOp* opState,
|
2017-11-03 10:12:19 -07:00
|
|
|
std::vector<RenderNodeOp*>* compositedChildrenOfProjectionSurface,
|
|
|
|
const mat4* transformFromProjectionSurface);
|
2014-03-18 09:22:59 -07:00
|
|
|
|
2015-10-05 13:00:52 -07:00
|
|
|
void syncProperties();
|
2017-01-25 10:58:30 -08:00
|
|
|
void syncDisplayList(TreeObserver& observer, TreeInfo* info);
|
2018-09-27 17:39:45 -07:00
|
|
|
void handleForceDark(TreeInfo* info);
|
2015-10-05 13:00:52 -07:00
|
|
|
|
2017-01-25 10:58:30 -08:00
|
|
|
void prepareTreeImpl(TreeObserver& observer, TreeInfo& info, bool functorsNeedLayer);
|
2014-06-12 13:46:45 -07:00
|
|
|
void pushStagingPropertiesChanges(TreeInfo& info);
|
2017-01-25 10:58:30 -08:00
|
|
|
void pushStagingDisplayListChanges(TreeObserver& observer, TreeInfo& info);
|
2014-08-08 13:21:00 -07:00
|
|
|
void prepareLayer(TreeInfo& info, uint32_t dirtyMask);
|
2014-06-12 13:46:45 -07:00
|
|
|
void pushLayerUpdate(TreeInfo& info);
|
2017-01-25 10:58:30 -08:00
|
|
|
void deleteDisplayList(TreeObserver& observer, TreeInfo* info = nullptr);
|
2014-07-16 13:29:45 -07:00
|
|
|
void damageSelf(TreeInfo& info);
|
2014-07-08 13:59:49 -07:00
|
|
|
|
|
|
|
void incParentRefCount() { mParentCount++; }
|
2017-01-25 10:58:30 -08:00
|
|
|
void decParentRefCount(TreeObserver& observer, TreeInfo* info = nullptr);
|
2014-04-09 15:23:38 -07:00
|
|
|
|
2018-11-29 09:44:10 -08:00
|
|
|
const int64_t mUniqueId;
|
2014-03-18 09:22:59 -07:00
|
|
|
String8 mName;
|
2016-03-25 14:29:48 -07:00
|
|
|
sp<VirtualLightRefBase> mUserContext;
|
2014-03-18 09:22:59 -07:00
|
|
|
|
2014-05-14 16:34:14 -07:00
|
|
|
uint32_t mDirtyPropertyFields;
|
2014-03-18 09:22:59 -07:00
|
|
|
RenderProperties mProperties;
|
2014-03-20 16:28:56 -07:00
|
|
|
RenderProperties mStagingProperties;
|
|
|
|
|
2017-01-25 10:58:30 -08:00
|
|
|
// Owned by UI. Set when DL is set, cleared when DL cleared or when node detached
|
|
|
|
// (likely by parent re-record/removal)
|
|
|
|
bool mValid = false;
|
|
|
|
|
2015-10-16 10:24:55 -07:00
|
|
|
bool mNeedsDisplayListSync;
|
|
|
|
// WARNING: Do not delete this directly, you must go through deleteDisplayList()!
|
|
|
|
DisplayList* mDisplayList;
|
|
|
|
DisplayList* mStagingDisplayList;
|
2014-03-18 09:22:59 -07:00
|
|
|
|
2014-06-24 15:34:58 -07:00
|
|
|
friend class AnimatorManager;
|
|
|
|
AnimatorManager mAnimatorManager;
|
2014-04-15 09:50:16 -07:00
|
|
|
|
2014-03-18 09:22:59 -07:00
|
|
|
/**
|
|
|
|
* Draw time state - these properties are only set and used during rendering
|
|
|
|
*/
|
|
|
|
|
|
|
|
// for projection surfaces, contains a list of all children items
|
2016-07-06 16:10:09 -07:00
|
|
|
std::vector<RenderNodeOp*> mProjectedNodes;
|
2014-07-08 13:59:49 -07:00
|
|
|
|
|
|
|
// How many references our parent(s) have to us. Typically this should alternate
|
|
|
|
// between 2 and 1 (when a staging push happens we inc first then dec)
|
|
|
|
// When this hits 0 we are no longer in the tree, so any hardware resources
|
|
|
|
// (specifically Layers) should be released.
|
|
|
|
// This is *NOT* thread-safe, and should therefore only be tracking
|
2015-10-16 10:24:55 -07:00
|
|
|
// mDisplayList, not mStagingDisplayList.
|
2014-07-08 13:59:49 -07:00
|
|
|
uint32_t mParentCount;
|
2016-02-02 15:18:23 -08:00
|
|
|
|
2016-06-27 13:27:23 -07:00
|
|
|
sp<PositionListener> mPositionListener;
|
2016-09-27 16:04:42 -04:00
|
|
|
|
2018-07-02 18:33:32 -07:00
|
|
|
UsageHint mUsageHint = UsageHint::Unknown;
|
|
|
|
|
2017-11-03 10:12:19 -07:00
|
|
|
// METHODS & FIELDS ONLY USED BY THE SKIA RENDERER
|
2016-09-27 16:04:42 -04:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Detach and transfer ownership of an already allocated displayList for use
|
|
|
|
* in recording updated content for this renderNode
|
|
|
|
*/
|
2016-10-17 16:26:15 -04:00
|
|
|
std::unique_ptr<skiapipeline::SkiaDisplayList> detachAvailableList() {
|
2016-09-27 16:04:42 -04:00
|
|
|
return std::move(mAvailableDisplayList);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attach unused displayList to this node for potential future reuse.
|
|
|
|
*/
|
2016-10-17 16:26:15 -04:00
|
|
|
void attachAvailableList(skiapipeline::SkiaDisplayList* skiaDisplayList) {
|
2016-09-27 16:04:42 -04:00
|
|
|
mAvailableDisplayList.reset(skiaDisplayList);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if an offscreen layer from any renderPipeline is attached
|
|
|
|
* to this node.
|
|
|
|
*/
|
2018-05-24 16:27:35 -07:00
|
|
|
bool hasLayer() const { return mSkiaLayer.get(); }
|
2016-09-27 16:04:42 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Used by the RenderPipeline to attach an offscreen surface to the RenderNode.
|
|
|
|
* The surface is then will be used to store the contents of a layer.
|
|
|
|
*/
|
2016-10-26 10:30:09 -04:00
|
|
|
void setLayerSurface(sk_sp<SkSurface> layer) {
|
|
|
|
if (layer.get()) {
|
|
|
|
if (!mSkiaLayer.get()) {
|
|
|
|
mSkiaLayer = std::make_unique<skiapipeline::SkiaLayer>();
|
|
|
|
}
|
|
|
|
mSkiaLayer->layerSurface = std::move(layer);
|
|
|
|
mSkiaLayer->inverseTransformInWindow.loadIdentity();
|
|
|
|
} else {
|
|
|
|
mSkiaLayer.reset();
|
|
|
|
}
|
|
|
|
}
|
2016-09-27 16:04:42 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If the RenderNode is of type LayerType::RenderLayer then this method will
|
|
|
|
* return the an offscreen rendering surface that is used to both render into
|
|
|
|
* the layer and composite the layer into its parent. If the type is not
|
|
|
|
* LayerType::RenderLayer then it will return a nullptr.
|
|
|
|
*
|
|
|
|
* NOTE: this function is only guaranteed to return accurate results after
|
|
|
|
* prepareTree has been run for this RenderNode
|
|
|
|
*/
|
2016-10-26 10:30:09 -04:00
|
|
|
SkSurface* getLayerSurface() const {
|
|
|
|
return mSkiaLayer.get() ? mSkiaLayer->layerSurface.get() : nullptr;
|
|
|
|
}
|
|
|
|
|
2017-11-03 10:12:19 -07:00
|
|
|
skiapipeline::SkiaLayer* getSkiaLayer() const { return mSkiaLayer.get(); }
|
2016-09-27 16:04:42 -04:00
|
|
|
|
2017-08-29 16:33:49 -04:00
|
|
|
/**
|
|
|
|
* Returns the path that represents the outline of RenderNode intersected with
|
|
|
|
* the provided rect. This call will internally cache the resulting path in
|
|
|
|
* order to potentially return that path for subsequent calls to this method.
|
|
|
|
* By reusing the same path we get better performance on the GPU backends since
|
|
|
|
* those resources are cached in the hardware based on the path's genID.
|
|
|
|
*
|
|
|
|
* The returned path is only guaranteed to be valid until this function is called
|
|
|
|
* again or the RenderNode's outline is mutated.
|
|
|
|
*/
|
|
|
|
const SkPath* getClippedOutline(const SkRect& clipRect) const;
|
2017-11-03 10:12:19 -07:00
|
|
|
|
2016-09-27 16:04:42 -04:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* If this RenderNode has been used in a previous frame then the SkiaDisplayList
|
|
|
|
* from that frame is cached here until one of the following conditions is met:
|
|
|
|
* 1) The RenderNode is deleted (causing this to be deleted)
|
|
|
|
* 2) It is replaced with the displayList from the next completed frame
|
|
|
|
* 3) It is detached and used to to record a new displayList for a later frame
|
|
|
|
*/
|
2016-10-17 16:26:15 -04:00
|
|
|
std::unique_ptr<skiapipeline::SkiaDisplayList> mAvailableDisplayList;
|
2016-09-27 16:04:42 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An offscreen rendering target used to contain the contents this RenderNode
|
|
|
|
* when it has been set to draw as a LayerType::RenderLayer.
|
|
|
|
*/
|
2016-10-26 10:30:09 -04:00
|
|
|
std::unique_ptr<skiapipeline::SkiaLayer> mSkiaLayer;
|
2017-08-29 16:33:49 -04:00
|
|
|
|
|
|
|
struct ClippedOutlineCache {
|
|
|
|
// keys
|
|
|
|
uint32_t outlineID = 0;
|
|
|
|
SkRect clipRect;
|
|
|
|
|
|
|
|
// value
|
|
|
|
SkPath clippedOutline;
|
|
|
|
};
|
|
|
|
mutable ClippedOutlineCache mClippedOutlineCache;
|
2017-11-03 10:12:19 -07:00
|
|
|
}; // class RenderNode
|
2014-03-18 09:22:59 -07:00
|
|
|
|
2017-01-25 10:58:30 -08:00
|
|
|
class MarkAndSweepRemoved : public TreeObserver {
|
2017-11-03 10:12:19 -07:00
|
|
|
PREVENT_COPY_AND_ASSIGN(MarkAndSweepRemoved);
|
2017-01-25 10:58:30 -08:00
|
|
|
|
|
|
|
public:
|
|
|
|
explicit MarkAndSweepRemoved(TreeInfo* info) : mTreeInfo(info) {}
|
|
|
|
|
2017-11-03 10:12:19 -07:00
|
|
|
void onMaybeRemovedFromTree(RenderNode* node) override { mMarked.emplace_back(node); }
|
2017-01-25 10:58:30 -08:00
|
|
|
|
|
|
|
~MarkAndSweepRemoved() {
|
|
|
|
for (auto& node : mMarked) {
|
|
|
|
if (!node->hasParents()) {
|
|
|
|
node->onRemovedFromTree(mTreeInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
FatVector<sp<RenderNode>, 10> mMarked;
|
|
|
|
TreeInfo* mTreeInfo;
|
|
|
|
};
|
|
|
|
|
2014-03-18 09:22:59 -07:00
|
|
|
} /* namespace uirenderer */
|
|
|
|
} /* namespace android */
|