summaryrefslogtreecommitdiffstats
path: root/libs/hwui/RenderNode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/RenderNode.cpp')
-rw-r--r--libs/hwui/RenderNode.cpp93
1 files changed, 32 insertions, 61 deletions
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp
index c993556..e009451 100644
--- a/libs/hwui/RenderNode.cpp
+++ b/libs/hwui/RenderNode.cpp
@@ -29,9 +29,9 @@
#include "DamageAccumulator.h"
#include "Debug.h"
#include "DisplayListOp.h"
-#include "DisplayListLogBuffer.h"
#include "LayerRenderer.h"
#include "OpenGLRenderer.h"
+#include "TreeInfo.h"
#include "utils/MathUtils.h"
#include "utils/TraceUtils.h"
#include "renderthread/CanvasContext.h"
@@ -39,28 +39,6 @@
namespace android {
namespace uirenderer {
-void RenderNode::outputLogBuffer(int fd) {
- DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
- if (logBuffer.isEmpty()) {
- return;
- }
-
- FILE *file = fdopen(fd, "a");
-
- fprintf(file, "\nRecent DisplayList operations\n");
- logBuffer.outputCommands(file);
-
- if (Caches::hasInstance()) {
- String8 cachesLog;
- Caches::getInstance().dumpMemoryUsage(cachesLog);
- fprintf(file, "\nCaches:\n%s\n", cachesLog.string());
- } else {
- fprintf(file, "\nNo caches instance.\n");
- }
-
- fflush(file);
-}
-
void RenderNode::debugDumpLayers(const char* prefix) {
if (mLayer) {
ALOGD("%sNode %p (%s) has layer %p (fbo = %u, wasBuildLayered = %s)",
@@ -77,10 +55,10 @@ void RenderNode::debugDumpLayers(const char* prefix) {
RenderNode::RenderNode()
: mDirtyPropertyFields(0)
, mNeedsDisplayListDataSync(false)
- , mDisplayListData(0)
- , mStagingDisplayListData(0)
+ , mDisplayListData(nullptr)
+ , mStagingDisplayListData(nullptr)
, mAnimatorManager(*this)
- , mLayer(0)
+ , mLayer(nullptr)
, mParentCount(0) {
}
@@ -90,7 +68,7 @@ RenderNode::~RenderNode() {
if (mLayer) {
ALOGW("Memory Warning: Layer %p missed its detachment, held on to for far too long!", mLayer);
mLayer->postDecStrong();
- mLayer = 0;
+ mLayer = nullptr;
}
}
@@ -109,7 +87,7 @@ void RenderNode::output(uint32_t level) {
getName(),
(properties().hasShadow() ? ", casting shadow" : ""),
(isRenderable() ? "" : ", empty"),
- (mLayer != NULL ? ", on HW Layer" : ""));
+ (mLayer != nullptr ? ", on HW Layer" : ""));
ALOGD("%*s%s %d", level * 2, "", "Save",
SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
@@ -161,7 +139,7 @@ void RenderNode::damageSelf(TreeInfo& info) {
void RenderNode::prepareLayer(TreeInfo& info, uint32_t dirtyMask) {
LayerType layerType = properties().layerProperties().type();
- if (CC_UNLIKELY(layerType == kLayerTypeRenderLayer)) {
+ if (CC_UNLIKELY(layerType == LayerType::RenderLayer)) {
// Damage applied so far needs to affect our parent, but does not require
// the layer to be updated. So we pop/push here to clear out the current
// damage and get a clean state for display list or children updates to
@@ -178,10 +156,10 @@ void RenderNode::pushLayerUpdate(TreeInfo& info) {
LayerType layerType = properties().layerProperties().type();
// If we are not a layer OR we cannot be rendered (eg, view was detached)
// we need to destroy any Layers we may have had previously
- if (CC_LIKELY(layerType != kLayerTypeRenderLayer) || CC_UNLIKELY(!isRenderable())) {
+ if (CC_LIKELY(layerType != LayerType::RenderLayer) || CC_UNLIKELY(!isRenderable())) {
if (CC_UNLIKELY(mLayer)) {
LayerRenderer::destroyLayer(mLayer);
- mLayer = NULL;
+ mLayer = nullptr;
}
return;
}
@@ -195,7 +173,7 @@ void RenderNode::pushLayerUpdate(TreeInfo& info) {
} else if (mLayer->layer.getWidth() != getWidth() || mLayer->layer.getHeight() != getHeight()) {
if (!LayerRenderer::resizeLayer(mLayer, getWidth(), getHeight())) {
LayerRenderer::destroyLayer(mLayer);
- mLayer = 0;
+ mLayer = nullptr;
}
damageSelf(info);
transformUpdateNeeded = true;
@@ -222,7 +200,7 @@ void RenderNode::pushLayerUpdate(TreeInfo& info) {
}
if (dirty.intersect(0, 0, getWidth(), getHeight())) {
- dirty.roundOut();
+ dirty.roundOut(&dirty);
mLayer->updateDeferred(this, dirty.fLeft, dirty.fTop, dirty.fRight, dirty.fBottom);
}
// This is not inside the above if because we may have called
@@ -310,10 +288,10 @@ void RenderNode::pushStagingDisplayListChanges(TreeInfo& info) {
Caches::getInstance().registerFunctors(mStagingDisplayListData->functors.size());
}
mDisplayListData = mStagingDisplayListData;
- mStagingDisplayListData = NULL;
+ mStagingDisplayListData = nullptr;
if (mDisplayListData) {
for (size_t i = 0; i < mDisplayListData->functors.size(); i++) {
- (*mDisplayListData->functors[i])(DrawGlInfo::kModeSync, NULL);
+ (*mDisplayListData->functors[i])(DrawGlInfo::kModeSync, nullptr);
}
}
damageSelf(info);
@@ -330,18 +308,13 @@ void RenderNode::deleteDisplayListData() {
}
}
delete mDisplayListData;
- mDisplayListData = NULL;
+ mDisplayListData = nullptr;
}
void RenderNode::prepareSubTree(TreeInfo& info, DisplayListData* subtree) {
if (subtree) {
TextureCache& cache = Caches::getInstance().textureCache;
info.out.hasFunctors |= subtree->functors.size();
- // TODO: Fix ownedBitmapResources to not require disabling prepareTextures
- // and thus falling out of async drawing path.
- if (subtree->ownedBitmapResources.size()) {
- info.prepareTextures = false;
- }
for (size_t i = 0; info.prepareTextures && i < subtree->bitmapResources.size(); i++) {
info.prepareTextures = cache.prefetchAndMarkInUse(subtree->bitmapResources[i]);
}
@@ -358,7 +331,7 @@ void RenderNode::prepareSubTree(TreeInfo& info, DisplayListData* subtree) {
void RenderNode::destroyHardwareResources() {
if (mLayer) {
LayerRenderer::destroyLayer(mLayer);
- mLayer = NULL;
+ mLayer = nullptr;
}
if (mDisplayListData) {
for (size_t i = 0; i < mDisplayListData->children().size(); i++) {
@@ -411,7 +384,7 @@ void RenderNode::setViewProperties(OpenGLRenderer& renderer, T& handler) {
renderer.concatMatrix(*properties().getTransformMatrix());
}
}
- const bool isLayer = properties().layerProperties().type() != kLayerTypeNone;
+ const bool isLayer = properties().layerProperties().type() != LayerType::None;
int clipFlags = properties().getClippingFlags();
if (properties().getAlpha() < 1) {
if (isLayer) {
@@ -429,9 +402,10 @@ void RenderNode::setViewProperties(OpenGLRenderer& renderer, T& handler) {
clipFlags = 0; // all clipping done by saveLayer
}
- ATRACE_FORMAT("%s alpha caused %ssaveLayer %dx%d",
- getName(), clipFlags ? "" : "unclipped ",
- (int)layerBounds.getWidth(), (int)layerBounds.getHeight());
+ ATRACE_FORMAT("%s alpha caused %ssaveLayer %dx%d", getName(),
+ (saveFlags & SkCanvas::kClipToLayer_SaveFlag) ? "" : "unclipped ",
+ static_cast<int>(layerBounds.getWidth()),
+ static_cast<int>(layerBounds.getHeight()));
SaveLayerOp* op = new (handler.allocator()) SaveLayerOp(
layerBounds.left, layerBounds.top, layerBounds.right, layerBounds.bottom,
@@ -516,7 +490,7 @@ void RenderNode::computeOrdering() {
// TODO: create temporary DDLOp and call computeOrderingImpl on top DisplayList so that
// transform properties are applied correctly to top level children
- if (mDisplayListData == NULL) return;
+ if (mDisplayListData == nullptr) return;
for (unsigned int i = 0; i < mDisplayListData->children().size(); i++) {
DrawRenderNodeOp* childOp = mDisplayListData->children()[i];
childOp->mRenderNode->computeOrderingImpl(childOp,
@@ -530,7 +504,7 @@ void RenderNode::computeOrderingImpl(
Vector<DrawRenderNodeOp*>* compositedChildrenOfProjectionSurface,
const mat4* transformFromProjectionSurface) {
mProjectedNodes.clear();
- if (mDisplayListData == NULL || mDisplayListData->isEmpty()) return;
+ if (mDisplayListData == nullptr || mDisplayListData->isEmpty()) return;
// TODO: should avoid this calculation in most cases
// TODO: just calculate single matrix, down to all leaf composited elements
@@ -554,9 +528,9 @@ void RenderNode::computeOrderingImpl(
DrawRenderNodeOp* childOp = mDisplayListData->children()[i];
RenderNode* child = childOp->mRenderNode;
- const SkPath* projectionOutline = NULL;
- Vector<DrawRenderNodeOp*>* projectionChildren = NULL;
- const mat4* projectionTransform = NULL;
+ const SkPath* projectionOutline = nullptr;
+ Vector<DrawRenderNodeOp*>* projectionChildren = nullptr;
+ const mat4* projectionTransform = nullptr;
if (isProjectionReceiver && !child->properties().getProjectBackwards()) {
// if receiving projections, collect projecting descendent
@@ -682,7 +656,7 @@ void RenderNode::issueDrawShadowOperation(const Matrix4& transformFromParent, T&
// holds temporary SkPath to store the result of intersections
- SkPath* frameAllocatedPath = NULL;
+ SkPath* frameAllocatedPath = nullptr;
const SkPath* outlinePath = casterOutlinePath;
// intersect the outline with the reveal clip, if present
@@ -809,9 +783,9 @@ void RenderNode::issueOperationsOfProjectedChildren(OpenGLRenderer& renderer, T&
// If the projection reciever has an outline, we mask each of the projected rendernodes to it
// Either with clipRect, or special saveLayer masking
- if (projectionReceiverOutline != NULL) {
+ if (projectionReceiverOutline != nullptr) {
const SkRect& outlineBounds = projectionReceiverOutline->getBounds();
- if (projectionReceiverOutline->isRect(NULL)) {
+ if (projectionReceiverOutline->isRect(nullptr)) {
// mask to the rect outline simply with clipRect
ClipRectOp* clipOp = new (alloc) ClipRectOp(
outlineBounds.left(), outlineBounds.top(),
@@ -846,7 +820,7 @@ void RenderNode::issueOperationsOfProjectedChildren(OpenGLRenderer& renderer, T&
renderer.restoreToCount(restoreTo);
}
- if (projectionReceiverOutline != NULL) {
+ if (projectionReceiverOutline != nullptr) {
handler(new (alloc) RestoreToCountOp(restoreTo),
PROPERTY_SAVECOUNT, properties().getClipToBounds());
}
@@ -863,13 +837,12 @@ void RenderNode::issueOperationsOfProjectedChildren(OpenGLRenderer& renderer, T&
*/
template <class T>
void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) {
- const int level = handler.level();
if (mDisplayListData->isEmpty()) {
DISPLAY_LIST_LOGD("%*sEmpty display list (%p, %s)", level * 2, "", this, getName());
return;
}
- const bool drawLayer = (mLayer && (&renderer != mLayer->renderer));
+ const bool drawLayer = (mLayer && (&renderer != mLayer->renderer.get()));
// If we are updating the contents of mLayer, we don't want to apply any of
// the RenderNode's properties to this issueOperations pass. Those will all
// be applied when the layer is drawn, aka when this is true.
@@ -887,7 +860,7 @@ void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) {
#if DEBUG_DISPLAY_LIST
const Rect& clipRect = renderer.getLocalClipBounds();
DISPLAY_LIST_LOGD("%*sStart display list (%p, %s), localClipBounds: %.0f, %.0f, %.0f, %.0f",
- level * 2, "", this, getName(),
+ handler.level() * 2, "", this, getName(),
clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
#endif
@@ -914,7 +887,6 @@ void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) {
} else {
const int saveCountOffset = renderer.getSaveCount() - 1;
const int projectionReceiveIndex = mDisplayListData->projectionReceiveIndex;
- DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
for (size_t chunkIndex = 0; chunkIndex < mDisplayListData->getChunks().size(); chunkIndex++) {
const DisplayListData::Chunk& chunk = mDisplayListData->getChunks()[chunkIndex];
@@ -928,9 +900,8 @@ void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) {
for (size_t opIndex = chunk.beginOpIndex; opIndex < chunk.endOpIndex; opIndex++) {
DisplayListOp *op = mDisplayListData->displayListOps[opIndex];
#if DEBUG_DISPLAY_LIST
- op->output(level + 1);
+ op->output(handler.level() + 1);
#endif
- logBuffer.writeCommand(level, op->name());
handler(op, saveCountOffset, properties().getClipToBounds());
if (CC_UNLIKELY(!mProjectedNodes.isEmpty() && projectionReceiveIndex >= 0 &&