::testing::AssertionResult blink::FloatBoxTest::AssertContains(const char* m_expr, const char* n_expr, const FloatBox& m, const FloatBox& n)
{
    FloatBox newM = m;
    newM.expandTo(n);
    if (!ApproximatelyEqual(m, newM)) {
        return ::testing::AssertionFailure() << "        Value of:" << n_expr << std::endl
               << "          Actual:" << testing::PrintToString(n) << std::endl
               << "Not Contained in:" << m_expr << std::endl
               << "        Which is:" << ::testing::PrintToString(m);
    }
    return ::testing::AssertionSuccess();
}
예제 #2
0
TEST(FloatBoxTest, UnionTest)
{
    FloatBox box;
    EXPECT_TRUE(box.isEmpty());
    FloatBox unionedBox(3, 5, 6, 5, 3, 9);
    box.unionBounds(unionedBox);
    EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, unionedBox, box);

    box.unionBounds(FloatBox());
    EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, unionedBox, box);

    box.unionBounds(FloatBox(0, 0, 0, 1, 1, 1));
    EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, FloatBox(0, 0, 0, 8, 8, 15), box);
}
bool CompositorAnimations::getAnimatedBoundingBox(FloatBox& box, const AnimationEffect& effect, double minValue, double maxValue) const
{
    const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(effect);

    PropertySet properties = keyframeEffect.properties();

    if (properties.isEmpty())
        return true;

    minValue = std::min(minValue, 0.0);
    maxValue = std::max(maxValue, 1.0);

    for (const auto& property : properties) {
        // TODO: Add the ability to get expanded bounds for filters as well.
        if (property != CSSPropertyTransform && property != CSSPropertyWebkitTransform)
            continue;

        const PropertySpecificKeyframeVector& frames = keyframeEffect.getPropertySpecificKeyframes(property);
        if (frames.isEmpty() || frames.size() < 2)
            continue;

        FloatBox originalBox(box);

        for (size_t j = 0; j < frames.size() - 1; ++j) {
            const AnimatableTransform* startTransform = toAnimatableTransform(frames[j]->getAnimatableValue().get());
            const AnimatableTransform* endTransform = toAnimatableTransform(frames[j+1]->getAnimatableValue().get());
            if (!startTransform || !endTransform)
                return false;

            // TODO: Add support for inflating modes other than Replace.
            if (frames[j]->composite() != AnimationEffect::CompositeReplace)
                return false;

            const TimingFunction& timing = frames[j]->easing();
            double min = 0;
            double max = 1;
            if (j == 0) {
                float frameLength = frames[j+1]->offset();
                if (frameLength > 0) {
                    min = minValue / frameLength;
                }
            }

            if (j == frames.size() - 2) {
                float frameLength = frames[j+1]->offset() - frames[j]->offset();
                if (frameLength > 0) {
                    max = 1 + (maxValue - 1) / frameLength;
                }
            }

            FloatBox bounds;
            timing.range(&min, &max);
            if (!endTransform->transformOperations().blendedBoundsForBox(originalBox, startTransform->transformOperations(), min, max, &bounds))
                return false;
            box.expandTo(bounds);
        }
    }
    return true;
}
예제 #4
0
TEST(FloatBoxTest, EmptyBoxTest)
{
    FloatBox box;
    EXPECT_TRUE(box.isEmpty());
    box.expandTo(FloatPoint3D(1, 0, 0));
    EXPECT_TRUE(box.isEmpty());
    box.expandTo(FloatPoint3D(0, 1, 0));
    EXPECT_FALSE(box.isEmpty());
}
void blink::PrintTo(const FloatBox& box, ::std::ostream* os)
{
    *os << "FloatBox("
        << box.x() << ", "
        << box.y() << ", "
        << box.z() << ", "
        << box.width() << ", "
        << box.height() << ", "
        << box.depth() << ")";
}
void PrintTo(const FloatBox& box, std::ostream* os)
{
    ScopedFloatFlags scope(*os);
    *os << "FloatBox("
        << box.x() << ", "
        << box.y() << ", "
        << box.z() << ", "
        << box.width() << ", "
        << box.height() << ", "
        << box.depth() << ")";
}
예제 #7
0
bool AnimationStack::getAnimatedBoundingBox(FloatBox& box, CSSPropertyID property) const
{
    FloatBox originalBox(box);
    for (const auto& sampledEffect : m_effects) {
        if (sampledEffect->effect() && sampledEffect->effect()->affects(PropertyHandle(property))) {
            KeyframeEffect* effect = sampledEffect->effect();
            const Timing& timing = effect->specifiedTiming();
            double startRange = 0;
            double endRange = 1;
            timing.timingFunction->range(&startRange, &endRange);
            FloatBox expandingBox(originalBox);
            if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expandingBox, *effect->model(), startRange, endRange))
                return false;
            box.expandTo(expandingBox);
        }
    }
    return true;
}
예제 #8
0
TEST(FloatBoxTest, ExpandTests)
{
    FloatBox box;
    box.expandTo(FloatPoint3D(10, -3, 2));
    EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, FloatBox(0, -3, 0, 10, 3, 2), box);

    box.expandTo(FloatPoint3D(-15, 6, 8));
    EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, FloatBox(-15, -3, 0, 25, 9, 8), box);

    box = FloatBox();
    box.expandTo(FloatPoint3D(-3, 6, 9), FloatPoint3D(-2, 10, 11));
    EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, FloatBox(-3, 0, 0, 3, 10, 11), box);

    box = FloatBox();
    box.expandTo(FloatBox(-10, -10, -10, 3, 30, 40));
    box.expandTo(FloatBox(-11, 3, 50, 10, 15, 1));
    EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, FloatBox(-11, -10, -10, 11, 30, 61), box);
}
bool blink::FloatBoxTest::ApproximatelyEqual(const FloatBox& a, const FloatBox& b)
{
    if (!ApproximatelyEqual(a.x(), b.x())
            || !ApproximatelyEqual(a.y(), b.y())
            || !ApproximatelyEqual(a.z(), b.z())
            || !ApproximatelyEqual(a.width(), b.width())
            || !ApproximatelyEqual(a.height(), b.height())
            || !ApproximatelyEqual(a.depth(), b.depth())) {
        return false;
    }
    return true;
}
예제 #10
0
void PrintTo(const FloatBox& box, std::ostream* os) {
  *os << box.toString();
}