TEST_F(DisplayItemPropertyTreeBuilderTest, Nested2DTranslation) { FloatSize offset1(10, -40); TransformationMatrix translation1; translation1.translate(offset1.width(), offset1.height()); FloatSize offset2(80, 80); TransformationMatrix translation2; translation2.translate(offset2.width(), offset2.height()); // These drawings should share a transform node but have different range // record offsets. processDummyDisplayItem(); auto transform1 = processBeginTransform3D(translation1); processDummyDisplayItem(); auto transform2 = processBeginTransform3D(translation2); processDummyDisplayItem(); processEndTransform3D(transform2); processEndTransform3D(transform1); finishPropertyTrees(); // There should only be a root transform node. ASSERT_EQ(1u, transformTree().nodeCount()); EXPECT_TRUE(transformTree().nodeAt(0).isRoot()); // Check that the range records have the right offsets. EXPECT_THAT(rangeRecordsAsStdVector(), ElementsAre( AllOf(hasRange(0, 1), hasTransformNode(0), hasOffset(FloatSize())), AllOf(hasRange(2, 3), hasTransformNode(0), hasOffset(offset1)), AllOf(hasRange(4, 5), hasTransformNode(0), hasOffset(offset1 + offset2)))); }
size_t AlignFragment::size() const { assert(hasOffset() && "AlignFragment::size() should not be called before layout."); uint64_t size = llvm::OffsetToAlignment(getOffset(), m_Alignment); if (size > m_MaxBytesToEmit) return 0; return size; }
TEST_F(DisplayItemPropertyTreeBuilderTest, ScrollDisplayItemIs2DTranslation) { processDummyDisplayItem(); auto scrollClient = processBeginScroll(-90, 400); processDummyDisplayItem(); processEndScroll(scrollClient); processDummyDisplayItem(); finishPropertyTrees(); // There should be only one transform node. ASSERT_EQ(1u, transformTree().nodeCount()); EXPECT_TRUE(transformTree().nodeAt(0).isRoot()); // There should be three range records, the middle one affected by the // scroll. Note that the translation due to scroll is the negative of the // scroll offset. EXPECT_THAT(rangeRecordsAsStdVector(), ElementsAre( AllOf(hasRange(0, 1), hasTransformNode(0), hasOffset(FloatSize(0, 0))), AllOf(hasRange(2, 3), hasTransformNode(0), hasOffset(FloatSize(90, -400))), AllOf(hasRange(4, 5), hasTransformNode(0), hasOffset(FloatSize(0, 0))))); }
TEST_F(DisplayItemPropertyTreeBuilderTest, TransformDisplayItemOnly2DTranslation) { // In this case no transform node should be created for the 2D translation. AffineTransform translation = AffineTransform::translation(10, -40); processDummyDisplayItem(); auto transformClient = processBeginTransform(translation); processDummyDisplayItem(); processEndTransform(transformClient); processDummyDisplayItem(); finishPropertyTrees(); // There should be only one transform node. ASSERT_EQ(1u, transformTree().nodeCount()); EXPECT_TRUE(transformTree().nodeAt(0).isRoot()); // There should be three range records, the middle one affected by the // translation. EXPECT_THAT(rangeRecordsAsStdVector(), ElementsAre( AllOf(hasRange(0, 1), hasTransformNode(0), hasOffset(FloatSize(0, 0))), AllOf(hasRange(2, 3), hasTransformNode(0), hasOffset(FloatSize(10, -40))), AllOf(hasRange(4, 5), hasTransformNode(0), hasOffset(FloatSize(0, 0))))); }
bool ZStTransform::isIdentity() const { return !hasOffset() && !hasScale(); }