Serializing display lists
This is a WIP prototype
Change-Id: Id4bfcf2b7bf905221c3734b7b6887c9b2efd37e6
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp
index 7d09c0b..ddc7ecd 100644
--- a/libs/hwui/RenderNode.cpp
+++ b/libs/hwui/RenderNode.cpp
@@ -33,6 +33,9 @@
#include "utils/TraceUtils.h"
#include "renderthread/CanvasContext.h"
+#include "protos/hwui.pb.h"
+#include "protos/ProtoHelpers.h"
+
namespace android {
namespace uirenderer {
@@ -102,6 +105,78 @@
ALOGD("%*sDone (%p, %s)", (level - 1) * 2, "", this, getName());
}
+void RenderNode::copyTo(proto::RenderNode *pnode) {
+ pnode->set_id(static_cast<uint64_t>(
+ reinterpret_cast<uintptr_t>(this)));
+ pnode->set_name(mName.string(), mName.length());
+
+ proto::RenderProperties* pprops = pnode->mutable_properties();
+ pprops->set_left(properties().getLeft());
+ pprops->set_top(properties().getTop());
+ pprops->set_right(properties().getRight());
+ pprops->set_bottom(properties().getBottom());
+ pprops->set_clip_flags(properties().getClippingFlags());
+ pprops->set_alpha(properties().getAlpha());
+ pprops->set_translation_x(properties().getTranslationX());
+ pprops->set_translation_y(properties().getTranslationY());
+ pprops->set_translation_z(properties().getTranslationZ());
+ pprops->set_elevation(properties().getElevation());
+ pprops->set_rotation(properties().getRotation());
+ pprops->set_rotation_x(properties().getRotationX());
+ pprops->set_rotation_y(properties().getRotationY());
+ pprops->set_scale_x(properties().getScaleX());
+ pprops->set_scale_y(properties().getScaleY());
+ pprops->set_pivot_x(properties().getPivotX());
+ pprops->set_pivot_y(properties().getPivotY());
+ pprops->set_has_overlapping_rendering(properties().getHasOverlappingRendering());
+ pprops->set_pivot_explicitly_set(properties().isPivotExplicitlySet());
+ pprops->set_project_backwards(properties().getProjectBackwards());
+ pprops->set_projection_receiver(properties().isProjectionReceiver());
+ set(pprops->mutable_clip_bounds(), properties().getClipBounds());
+
+ const Outline& outline = properties().getOutline();
+ if (outline.getType() != Outline::Type::None) {
+ proto::Outline* poutline = pprops->mutable_outline();
+ poutline->clear_path();
+ if (outline.getType() == Outline::Type::Empty) {
+ poutline->set_type(proto::Outline_Type_Empty);
+ } else if (outline.getType() == Outline::Type::ConvexPath) {
+ poutline->set_type(proto::Outline_Type_ConvexPath);
+ if (const SkPath* path = outline.getPath()) {
+ set(poutline->mutable_path(), *path);
+ }
+ } else if (outline.getType() == Outline::Type::RoundRect) {
+ poutline->set_type(proto::Outline_Type_RoundRect);
+ } else {
+ ALOGW("Uknown outline type! %d", static_cast<int>(outline.getType()));
+ poutline->set_type(proto::Outline_Type_None);
+ }
+ poutline->set_should_clip(outline.getShouldClip());
+ poutline->set_alpha(outline.getAlpha());
+ poutline->set_radius(outline.getRadius());
+ set(poutline->mutable_bounds(), outline.getBounds());
+ } else {
+ pprops->clear_outline();
+ }
+
+ const RevealClip& revealClip = properties().getRevealClip();
+ if (revealClip.willClip()) {
+ proto::RevealClip* prevealClip = pprops->mutable_reveal_clip();
+ prevealClip->set_x(revealClip.getX());
+ prevealClip->set_y(revealClip.getY());
+ prevealClip->set_radius(revealClip.getRadius());
+ } else {
+ pprops->clear_reveal_clip();
+ }
+
+ pnode->clear_children();
+ if (mDisplayListData) {
+ for (auto&& child : mDisplayListData->children()) {
+ child->mRenderNode->copyTo(pnode->add_children());
+ }
+ }
+}
+
int RenderNode::getDebugSize() {
int size = sizeof(RenderNode);
if (mStagingDisplayListData) {