本文整理汇总了C++中TransformOperations类的典型用法代码示例。如果您正苦于以下问题:C++ TransformOperations类的具体用法?C++ TransformOperations怎么用?C++ TransformOperations使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TransformOperations类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: concat
Vector<RefPtr<TransformOperation>> concat(const TransformOperations& a,
const TransformOperations& b) {
Vector<RefPtr<TransformOperation>> result;
result.reserveCapacity(a.size() + b.size());
result.appendVector(a.operations());
result.appendVector(b.operations());
return result;
}
开发者ID:ollie314,项目名称:chromium,代码行数:8,代码来源:CSSTransformInterpolationType.cpp
示例2: switch
void ArgumentCoder<TransformOperations>::encode(ArgumentEncoder& encoder, const TransformOperations& transformOperations)
{
encoder << static_cast<uint32_t>(transformOperations.size());
for (size_t i = 0; i < transformOperations.size(); ++i) {
const TransformOperation* operation = transformOperations.at(i);
encoder.encodeEnum(operation->getOperationType());
switch (operation->getOperationType()) {
case TransformOperation::SCALE_X:
case TransformOperation::SCALE_Y:
case TransformOperation::SCALE:
case TransformOperation::SCALE_Z:
case TransformOperation::SCALE_3D:
encoder << static_cast<const ScaleTransformOperation*>(operation)->x();
encoder << static_cast<const ScaleTransformOperation*>(operation)->y();
encoder << static_cast<const ScaleTransformOperation*>(operation)->z();
break;
case TransformOperation::TRANSLATE_X:
case TransformOperation::TRANSLATE_Y:
case TransformOperation::TRANSLATE:
case TransformOperation::TRANSLATE_Z:
case TransformOperation::TRANSLATE_3D:
ArgumentCoder<Length>::encode(encoder, static_cast<const TranslateTransformOperation*>(operation)->x());
ArgumentCoder<Length>::encode(encoder, static_cast<const TranslateTransformOperation*>(operation)->y());
ArgumentCoder<Length>::encode(encoder, static_cast<const TranslateTransformOperation*>(operation)->z());
break;
case TransformOperation::ROTATE:
case TransformOperation::ROTATE_X:
case TransformOperation::ROTATE_Y:
case TransformOperation::ROTATE_3D:
encoder << static_cast<const RotateTransformOperation*>(operation)->x();
encoder << static_cast<const RotateTransformOperation*>(operation)->y();
encoder << static_cast<const RotateTransformOperation*>(operation)->z();
encoder << static_cast<const RotateTransformOperation*>(operation)->angle();
break;
case TransformOperation::SKEW_X:
case TransformOperation::SKEW_Y:
case TransformOperation::SKEW:
encoder << static_cast<const SkewTransformOperation*>(operation)->angleX();
encoder << static_cast<const SkewTransformOperation*>(operation)->angleY();
break;
case TransformOperation::MATRIX:
ArgumentCoder<TransformationMatrix>::encode(encoder, static_cast<const MatrixTransformOperation*>(operation)->matrix());
break;
case TransformOperation::MATRIX_3D:
ArgumentCoder<TransformationMatrix>::encode(encoder, static_cast<const Matrix3DTransformOperation*>(operation)->matrix());
break;
case TransformOperation::PERSPECTIVE:
ArgumentCoder<Length>::encode(encoder, static_cast<const PerspectiveTransformOperation*>(operation)->perspective());
break;
case TransformOperation::IDENTITY:
break;
case TransformOperation::NONE:
ASSERT_NOT_REACHED();
break;
}
}
}
开发者ID:jiezh,项目名称:h5vcc,代码行数:58,代码来源:CoordinatedGraphicsArgumentCoders.cpp
示例3: blend
TransformOperations TransformOperations::blend(const TransformOperations& from, double progress, const LayoutSize& size) const
{
if (from == *this)
return *this;
if (from.size() && from.operationsMatch(*this))
return blendByMatchingOperations(from, progress);
return blendByUsingMatrixInterpolation(from, progress, size);
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:10,代码来源:TransformOperations.cpp
示例4: operationsMatch
bool TransformOperations::operationsMatch(const TransformOperations& other) const
{
size_t numOperations = operations().size();
// If the sizes of the function lists don't match, the lists don't match
if (numOperations != other.operations().size())
return false;
// If the types of each function are not the same, the lists don't match
for (size_t i = 0; i < numOperations; ++i) {
if (!operations()[i]->isSameType(*other.operations()[i]))
return false;
}
return true;
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:14,代码来源:TransformOperations.cpp
示例5: create
PassRefPtr<TransformOperation> InterpolatedTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)
{
if (from && !from->isSameType(*this))
return this;
TransformOperations thisOperations;
thisOperations.operations().append(this);
TransformOperations fromOperations;
if (blendToIdentity)
fromOperations.operations().append(IdentityTransformOperation::create());
else
fromOperations.operations().append(const_cast<TransformOperation*>(from));
return InterpolatedTransformOperation::create(thisOperations, fromOperations, progress);
}
开发者ID:Jamesducque,项目名称:mojo,代码行数:14,代码来源:InterpolatedTransformOperation.cpp
示例6: TEST
TEST(AnimationTranslationUtilTest, transformsWork)
{
TransformOperations ops;
WebTransformOperationsMock outOps;
EXPECT_CALL(outOps, appendTranslate(2, 0, 0));
EXPECT_CALL(outOps, appendRotate(0.1, 0.2, 0.3, 200000.4));
EXPECT_CALL(outOps, appendScale(50.2, 100, -4));
ops.operations().append(TranslateTransformOperation::create(Length(2, Fixed), Length(0, Fixed), TransformOperation::TranslateX));
ops.operations().append(RotateTransformOperation::create(0.1, 0.2, 0.3, 200000.4, TransformOperation::Rotate3D));
ops.operations().append(ScaleTransformOperation::create(50.2, 100, -4, TransformOperation::Scale3D));
toWebTransformOperations(ops, &outOps);
}
开发者ID:dstockwell,项目名称:blink,代码行数:14,代码来源:AnimationTranslationUtilTest.cpp
示例7: PrintTo
void PrintTo(const AnimatableTransform& animTransform, ::std::ostream* os)
{
TransformOperations ops = animTransform.transformOperations();
*os << "AnimatableTransform(";
// FIXME: TransformOperations should really have it's own pretty-printer
// then we could just call that.
// FIXME: Output useful names not just the raw matrixes.
for (unsigned i = 0; i < ops.size(); i++) {
const TransformOperation* op = ops.at(i);
TransformationMatrix matrix;
op->apply(matrix, FloatSize(1.0, 1.0));
*os << "[";
if (matrix.isAffine()) {
*os << matrix.a();
*os << " " << matrix.b();
*os << " " << matrix.c();
*os << " " << matrix.d();
*os << " " << matrix.e();
*os << " " << matrix.f();
} else {
*os << matrix.m11();
*os << " " << matrix.m12();
*os << " " << matrix.m13();
*os << " " << matrix.m14();
*os << " ";
*os << " " << matrix.m21();
*os << " " << matrix.m22();
*os << " " << matrix.m23();
*os << " " << matrix.m24();
*os << " ";
*os << " " << matrix.m31();
*os << " " << matrix.m32();
*os << " " << matrix.m33();
*os << " " << matrix.m34();
*os << " ";
*os << " " << matrix.m41();
*os << " " << matrix.m42();
*os << " " << matrix.m43();
*os << " " << matrix.m44();
}
*os << "]";
if (i < ops.size() - 1)
*os << ", ";
}
*os << ")";
}
开发者ID:jeremyroman,项目名称:blink,代码行数:49,代码来源:AnimatableValueTestHelper.cpp
示例8: blendByUsingMatrixInterpolation
TransformOperations TransformOperations::blendByUsingMatrixInterpolation(const TransformOperations& from, double progress, const LayoutSize& size) const
{
TransformOperations result;
// Convert the TransformOperations into matrices
TransformationMatrix fromTransform;
TransformationMatrix toTransform;
from.apply(size, fromTransform);
apply(size, toTransform);
toTransform.blend(fromTransform, progress);
// Append the result
result.operations().append(Matrix3DTransformOperation::create(toTransform));
return result;
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:17,代码来源:TransformOperations.cpp
示例9: TEST_F
TEST_F(AnimationCompositorAnimationsTest, isNotCandidateForCompositorAnimationTransformDependsOnBoxSize)
{
TransformOperations ops;
ops.operations().append(TranslateTransformOperation::create(Length(2, Fixed), Length(2, Fixed), TransformOperation::TranslateX));
RefPtr<AnimatableValueKeyframe> goodKeyframe = createReplaceOpKeyframe(CSSPropertyTransform, AnimatableTransform::create(ops).get());
EXPECT_TRUE(duplicateSingleKeyframeAndTestIsCandidateOnResult(goodKeyframe.get()));
ops.operations().append(TranslateTransformOperation::create(Length(50, Percent), Length(2, Fixed), TransformOperation::TranslateX));
RefPtr<AnimatableValueKeyframe> badKeyframe = createReplaceOpKeyframe(CSSPropertyTransform, AnimatableTransform::create(ops).get());
EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(badKeyframe.get()));
TransformOperations ops2;
Length calcLength = Length(100, Percent).blend(Length(100, Fixed), 0.5, ValueRangeAll);
ops2.operations().append(TranslateTransformOperation::create(calcLength, Length(0, Fixed), TransformOperation::TranslateX));
RefPtr<AnimatableValueKeyframe> badKeyframe2 = createReplaceOpKeyframe(CSSPropertyTransform, AnimatableTransform::create(ops2).get());
EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(badKeyframe2.get()));
}
开发者ID:domenic,项目名称:mojo,代码行数:17,代码来源:CompositorAnimationsTest.cpp
示例10: applyTransformAnimation
static TransformationMatrix applyTransformAnimation(const TransformOperations& from, const TransformOperations& to, double progress, const FloatSize& boxSize, bool listsMatch)
{
TransformationMatrix matrix;
// First frame of an animation.
if (!progress) {
from.apply(boxSize, matrix);
return matrix;
}
// Last frame of an animation.
if (progress == 1) {
to.apply(boxSize, matrix);
return matrix;
}
// If we have incompatible operation lists, we blend the resulting matrices.
if (!listsMatch) {
TransformationMatrix fromMatrix;
to.apply(boxSize, matrix);
from.apply(boxSize, fromMatrix);
matrix.blend(fromMatrix, progress);
return matrix;
}
// Animation to "-webkit-transform: none".
if (!to.size()) {
TransformOperations blended(from);
for (auto& operation : blended.operations())
operation->blend(nullptr, progress, true)->apply(matrix, boxSize);
return matrix;
}
// Animation from "-webkit-transform: none".
if (!from.size()) {
TransformOperations blended(to);
for (auto& operation : blended.operations())
operation->blend(nullptr, 1 - progress, true)->apply(matrix, boxSize);
return matrix;
}
// Normal animation with a matching operation list.
TransformOperations blended(to);
for (size_t i = 0; i < blended.operations().size(); ++i)
blended.operations()[i]->blend(from.at(i), progress, !from.at(i))->apply(matrix, boxSize);
return matrix;
}
开发者ID:edcwconan,项目名称:webkit,代码行数:47,代码来源:TextureMapperAnimation.cpp
示例11: setMatrixValue
void WebKitCSSMatrix::setMatrixValue(const String& string, ExceptionCode& ec)
{
if (string.isEmpty())
return;
RefPtr<StylePropertySet> styleDeclaration = StylePropertySet::create();
if (CSSParser::parseValue(styleDeclaration.get(), CSSPropertyWebkitTransform, string, true, CSSStrictMode, 0)) {
// Convert to TransformOperations. This can fail if a property
// requires style (i.e., param uses 'ems' or 'exs')
RefPtr<CSSValue> value = styleDeclaration->getPropertyCSSValue(CSSPropertyWebkitTransform);
// Check for a "none" or empty transform. In these cases we can use the default identity matrix.
if (!value || (value->isPrimitiveValue() && (static_cast<CSSPrimitiveValue*>(value.get()))->getIdent() == CSSValueNone))
return;
TransformOperations operations;
if (!StyleResolver::createTransformOperations(value.get(), 0, 0, operations)) {
ec = SYNTAX_ERR;
return;
}
// Convert transform operations to a TransformationMatrix. This can fail
// if a param has a percentage ('%')
TransformationMatrix t;
for (unsigned i = 0; i < operations.operations().size(); ++i) {
if (operations.operations()[i].get()->apply(t, IntSize(0, 0))) {
ec = SYNTAX_ERR;
return;
}
}
// set the matrix
m_matrix = t;
} else // There is something there but parsing failed.
ec = SYNTAX_ERR;
}
开发者ID:fmalita,项目名称:webkit,代码行数:36,代码来源:WebKitCSSMatrix.cpp
示例12: DEFINE_STATIC_REF
void CSSMatrix::setMatrixValue(const String& string, ExceptionState& exceptionState)
{
if (string.isEmpty())
return;
// FIXME: crbug.com/154722 - should this continue to use legacy style parsing?
RefPtrWillBeRawPtr<MutableStylePropertySet> styleDeclaration = MutableStylePropertySet::create();
if (BisonCSSParser::parseValue(styleDeclaration.get(), CSSPropertyWebkitTransform, string, true, HTMLStandardMode, 0)) {
// Convert to TransformOperations. This can fail if a property
// requires style (i.e., param uses 'ems' or 'exs')
RefPtrWillBeRawPtr<CSSValue> value = styleDeclaration->getPropertyCSSValue(CSSPropertyWebkitTransform);
// Check for a "none" or empty transform. In these cases we can use the default identity matrix.
if (!value || (value->isPrimitiveValue() && (toCSSPrimitiveValue(value.get()))->getValueID() == CSSValueNone))
return;
DEFINE_STATIC_REF(RenderStyle, defaultStyle, RenderStyle::createDefaultStyle());
TransformOperations operations;
if (!TransformBuilder::createTransformOperations(value.get(), CSSToLengthConversionData(defaultStyle, defaultStyle, 0, 0, 1.0f), operations)) {
exceptionState.throwDOMException(SyntaxError, "Failed to interpret '" + string + "' as a transformation operation.");
return;
}
// Convert transform operations to a TransformationMatrix. This can fail
// if a param has a percentage ('%')
if (operations.dependsOnBoxSize())
exceptionState.throwDOMException(SyntaxError, "The transformation depends on the box size, which is not supported.");
TransformationMatrix t;
operations.apply(FloatSize(0, 0), t);
// set the matrix
m_matrix = t;
} else { // There is something there but parsing failed.
exceptionState.throwDOMException(SyntaxError, "Failed to parse '" + string + "'.");
}
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:36,代码来源:CSSMatrix.cpp
示例13: DEFINE_STATIC_REF
void CSSMatrix::setMatrixValue(const String& string, ExceptionState& exceptionState)
{
if (string.isEmpty())
return;
if (RefPtrWillBeRawPtr<CSSValue> value = CSSParser::parseSingleValue(CSSPropertyTransform, string)) {
// Check for a "none" transform. In these cases we can use the default identity matrix.
if (value->isPrimitiveValue() && (toCSSPrimitiveValue(value.get()))->getValueID() == CSSValueNone)
return;
DEFINE_STATIC_REF(ComputedStyle, initialStyle, createInitialStyle());
TransformOperations operations;
TransformBuilder::createTransformOperations(*value, CSSToLengthConversionData(initialStyle, initialStyle, nullptr, 1.0f), operations);
// Convert transform operations to a TransformationMatrix. This can fail
// if a param has a percentage ('%')
if (operations.dependsOnBoxSize())
exceptionState.throwDOMException(SyntaxError, "The transformation depends on the box size, which is not supported.");
m_matrix = adoptPtr(new TransformationMatrix);
operations.apply(FloatSize(0, 0), *m_matrix);
} else { // There is something there but parsing failed.
exceptionState.throwDOMException(SyntaxError, "Failed to parse '" + string + "'.");
}
}
开发者ID:howardroark2018,项目名称:chromium,代码行数:24,代码来源:CSSMatrix.cpp
示例14: composite
PassRefPtr<CSSTransformNonInterpolableValue> composite(
const CSSTransformNonInterpolableValue& other,
double otherProgress) {
DCHECK(!isAdditive());
if (other.m_isSingle) {
DCHECK_EQ(otherProgress, 0);
DCHECK(other.isAdditive());
TransformOperations result;
result.operations() = concat(transform(), other.transform());
return create(std::move(result));
}
DCHECK(other.m_isStartAdditive || other.m_isEndAdditive);
TransformOperations start;
start.operations() = other.m_isStartAdditive
? concat(transform(), other.m_start)
: other.m_start.operations();
TransformOperations end;
end.operations() = other.m_isEndAdditive ? concat(transform(), other.m_end)
: other.m_end.operations();
return create(end.blend(start, otherProgress));
}
开发者ID:ollie314,项目名称:chromium,代码行数:22,代码来源:CSSTransformInterpolationType.cpp
示例15: blendByMatchingOperations
TransformOperations TransformOperations::blendByMatchingOperations(const TransformOperations& from, const double& progress) const
{
TransformOperations result;
unsigned fromSize = from.operations().size();
unsigned toSize = operations().size();
unsigned size = max(fromSize, toSize);
for (unsigned i = 0; i < size; i++) {
RefPtr<TransformOperation> fromOperation = (i < fromSize) ? from.operations()[i].get() : 0;
RefPtr<TransformOperation> toOperation = (i < toSize) ? operations()[i].get() : 0;
RefPtr<TransformOperation> blendedOperation = toOperation ? toOperation->blend(fromOperation.get(), progress) : (fromOperation ? fromOperation->blend(0, progress, true) : 0);
if (blendedOperation)
result.operations().append(blendedOperation);
else {
RefPtr<TransformOperation> identityOperation = IdentityTransformOperation::create();
if (progress > 0.5)
result.operations().append(toOperation ? toOperation : identityOperation);
else
result.operations().append(fromOperation ? fromOperation : identityOperation);
}
}
return result;
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:24,代码来源:TransformOperations.cpp
示例16: createTransformOperations
bool TransformBuilder::createTransformOperations(CSSValue* inValue, const CSSToLengthConversionData& conversionData, TransformOperations& outOperations)
{
if (!inValue || !inValue->isValueList()) {
outOperations.clear();
return false;
}
TransformOperations operations;
for (CSSValueListIterator i = inValue; i.hasMore(); i.advance()) {
CSSValue* currValue = i.value();
if (!currValue->isTransformValue())
continue;
CSSTransformValue* transformValue = toCSSTransformValue(i.value());
if (!transformValue->length())
continue;
bool haveNonPrimitiveValue = false;
for (unsigned j = 0; j < transformValue->length(); ++j) {
if (!transformValue->item(j)->isPrimitiveValue()) {
haveNonPrimitiveValue = true;
break;
}
}
if (haveNonPrimitiveValue)
continue;
CSSPrimitiveValue* firstValue = toCSSPrimitiveValue(transformValue->item(0));
switch (transformValue->operationType()) {
case CSSTransformValue::ScaleTransformOperation:
case CSSTransformValue::ScaleXTransformOperation:
case CSSTransformValue::ScaleYTransformOperation: {
double sx = 1.0;
double sy = 1.0;
if (transformValue->operationType() == CSSTransformValue::ScaleYTransformOperation)
sy = firstValue->getDoubleValue();
else {
sx = firstValue->getDoubleValue();
if (transformValue->operationType() != CSSTransformValue::ScaleXTransformOperation) {
if (transformValue->length() > 1) {
CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(transformValue->item(1));
sy = secondValue->getDoubleValue();
} else
sy = sx;
}
}
operations.operations().append(ScaleTransformOperation::create(sx, sy, 1.0, getTransformOperationType(transformValue->operationType())));
break;
}
case CSSTransformValue::ScaleZTransformOperation:
case CSSTransformValue::Scale3DTransformOperation: {
double sx = 1.0;
double sy = 1.0;
double sz = 1.0;
if (transformValue->operationType() == CSSTransformValue::ScaleZTransformOperation)
sz = firstValue->getDoubleValue();
else if (transformValue->operationType() == CSSTransformValue::ScaleYTransformOperation)
sy = firstValue->getDoubleValue();
else {
sx = firstValue->getDoubleValue();
if (transformValue->operationType() != CSSTransformValue::ScaleXTransformOperation) {
if (transformValue->length() > 2) {
CSSPrimitiveValue* thirdValue = toCSSPrimitiveValue(transformValue->item(2));
sz = thirdValue->getDoubleValue();
}
if (transformValue->length() > 1) {
CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(transformValue->item(1));
sy = secondValue->getDoubleValue();
} else
sy = sx;
}
}
operations.operations().append(ScaleTransformOperation::create(sx, sy, sz, getTransformOperationType(transformValue->operationType())));
break;
}
case CSSTransformValue::TranslateTransformOperation:
case CSSTransformValue::TranslateXTransformOperation:
case CSSTransformValue::TranslateYTransformOperation: {
Length tx = Length(0, Fixed);
Length ty = Length(0, Fixed);
if (transformValue->operationType() == CSSTransformValue::TranslateYTransformOperation)
ty = convertToFloatLength(firstValue, conversionData);
else {
tx = convertToFloatLength(firstValue, conversionData);
if (transformValue->operationType() != CSSTransformValue::TranslateXTransformOperation) {
if (transformValue->length() > 1) {
CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(transformValue->item(1));
ty = convertToFloatLength(secondValue, conversionData);
}
}
}
operations.operations().append(TranslateTransformOperation::create(tx, ty, 0, getTransformOperationType(transformValue->operationType())));
break;
}
case CSSTransformValue::TranslateZTransformOperation:
case CSSTransformValue::Translate3DTransformOperation: {
Length tx = Length(0, Fixed);
//.........这里部分代码省略.........
开发者ID:Jamesducque,项目名称:mojo,代码行数:101,代码来源:TransformBuilder.cpp
示例17: createFromTransformProperties
static PassRefPtr<AnimatableValue> createFromTransformProperties(PassRefPtr<TransformOperation> transform, double zoom, PassRefPtr<TransformOperation> initialTransform)
{
TransformOperations operation;
operation.operations().append(transform ? transform : initialTransform);
return AnimatableTransform::create(operation, transform ? zoom : 1);
}
开发者ID:astojilj,项目名称:chromium-crosswalk,代码行数:6,代码来源:CSSAnimatableValueFactory.cpp
示例18: createTransformOperations
bool TransformBuilder::createTransformOperations(CSSValue* inValue, RenderStyle* style, RenderStyle* rootStyle, TransformOperations& outOperations)
{
if (!inValue || !inValue->isValueList()) {
outOperations.clear();
return false;
}
float zoomFactor = style ? style->effectiveZoom() : 1;
TransformOperations operations;
for (CSSValueListIterator i = inValue; i.hasMore(); i.advance()) {
CSSValue* currValue = i.value();
if (!currValue->isCSSTransformValue())
continue;
CSSTransformValue* transformValue = static_cast<CSSTransformValue*>(i.value());
if (!transformValue->length())
continue;
bool haveNonPrimitiveValue = false;
for (unsigned j = 0; j < transformValue->length(); ++j) {
if (!transformValue->itemWithoutBoundsCheck(j)->isPrimitiveValue()) {
haveNonPrimitiveValue = true;
break;
}
}
if (haveNonPrimitiveValue)
continue;
CSSPrimitiveValue* firstValue = toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(0));
switch (transformValue->operationType()) {
case CSSTransformValue::ScaleTransformOperation:
case CSSTransformValue::ScaleXTransformOperation:
case CSSTransformValue::ScaleYTransformOperation: {
double sx = 1.0;
double sy = 1.0;
if (transformValue->operationType() == CSSTransformValue::ScaleYTransformOperation)
sy = firstValue->getDoubleValue();
else {
sx = firstValue->getDoubleValue();
if (transformValue->operationType() != CSSTransformValue::ScaleXTransformOperation) {
if (transformValue->length() > 1) {
CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(1));
sy = secondValue->getDoubleValue();
} else
sy = sx;
}
}
operations.operations().append(ScaleTransformOperation::create(sx, sy, 1.0, getTransformOperationType(transformValue->operationType())));
break;
}
case CSSTransformValue::ScaleZTransformOperation:
case CSSTransformValue::Scale3DTransformOperation: {
double sx = 1.0;
double sy = 1.0;
double sz = 1.0;
if (transformValue->operationType() == CSSTransformValue::ScaleZTransformOperation)
sz = firstValue->getDoubleValue();
else if (transformValue->operationType() == CSSTransformValue::ScaleYTransformOperation)
sy = firstValue->getDoubleValue();
else {
sx = firstValue->getDoubleValue();
if (transformValue->operationType() != CSSTransformValue::ScaleXTransformOperation) {
if (transformValue->length() > 2) {
CSSPrimitiveValue* thirdValue = toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(2));
sz = thirdValue->getDoubleValue();
}
if (transformValue->length() > 1) {
CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(1));
sy = secondValue->getDoubleValue();
} else
sy = sx;
}
}
operations.operations().append(ScaleTransformOperation::create(sx, sy, sz, getTransformOperationType(transformValue->operationType())));
break;
}
case CSSTransformValue::TranslateTransformOperation:
case CSSTransformValue::TranslateXTransformOperation:
case CSSTransformValue::TranslateYTransformOperation: {
Length tx = Length(0, Fixed);
Length ty = Length(0, Fixed);
if (transformValue->operationType() == CSSTransformValue::TranslateYTransformOperation)
ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
else {
tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
if (transformValue->operationType() != CSSTransformValue::TranslateXTransformOperation) {
if (transformValue->length() > 1) {
CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(1));
ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor);
}
}
}
if (tx.isUndefined() || ty.isUndefined())
return false;
operations.operations().append(TranslateTransformOperation::create(tx, ty, Length(0, Fixed), getTransformOperationType(transformValue->operationType())));
break;
//.........这里部分代码省略.........
开发者ID:windyuuy,项目名称:opera,代码行数:101,代码来源:TransformBuilder.cpp
示例19: switch
void ArgumentCoder<TransformOperations>::encode(ArgumentEncoder& encoder, const TransformOperations& transformOperations)
{
encoder << static_cast<uint32_t>(transformOperations.size());
for (const auto& operation : transformOperations.operations()) {
encoder.encodeEnum(operation->type());
switch (operation->type()) {
case TransformOperation::SCALE_X:
case TransformOperation::SCALE_Y:
case TransformOperation::SCALE:
case TransformOperation::SCALE_Z:
case TransformOperation::SCALE_3D: {
const auto& scaleOperation = downcast<ScaleTransformOperation>(*operation);
encoder << scaleOperation.x();
encoder << scaleOperation.y();
encoder << scaleOperation.z();
break;
}
case TransformOperation::TRANSLATE_X:
case TransformOperation::TRANSLATE_Y:
case TransformOperation::TRANSLATE:
case TransformOperation::TRANSLATE_Z:
case TransformOperation::TRANSLATE_3D: {
const auto& translateOperation = downcast<TranslateTransformOperation>(*operation);
ArgumentCoder<Length>::encode(encoder, translateOperation.x());
ArgumentCoder<Length>::encode(encoder, translateOperation.y());
ArgumentCoder<Length>::encode(encoder, translateOperation.z());
break;
}
case TransformOperation::ROTATE:
case TransformOperation::ROTATE_X:
case TransformOperation::ROTATE_Y:
case TransformOperation::ROTATE_3D: {
const auto& rotateOperation = downcast<RotateTransformOperation>(*operation);
encoder << rotateOperation.x();
encoder << rotateOperation.y();
encoder << rotateOperation.z();
encoder << rotateOperation.angle();
break;
}
case TransformOperation::SKEW_X:
case TransformOperation::SKEW_Y:
case TransformOperation::SKEW: {
const auto& skewOperation = downcast<SkewTransformOperation>(*operation);
encoder << skewOperation.angleX();
encoder << skewOperation.angleY();
break;
}
case TransformOperation::MATRIX:
ArgumentCoder<TransformationMatrix>::encode(encoder, downcast<MatrixTransformOperation>(*operation).matrix());
break;
case TransformOperation::MATRIX_3D:
ArgumentCoder<TransformationMatrix>::encode(encoder, downcast<Matrix3DTransformOperation>(*operation).matrix());
break;
case TransformOperation::PERSPECTIVE:
ArgumentCoder<Length>::encode(encoder, downcast<PerspectiveTransformOperation>(*operation).perspective());
break;
case TransformOperation::IDENTITY:
break;
case TransformOperation::NONE:
ASSERT_NOT_REACHED();
break;
}
}
}
开发者ID:AndriyKalashnykov,项目名称:webkit,代码行数:65,代码来源:CoordinatedGraphicsArgumentCoders.cpp
示例20: node
// FIXME: It's cleaner to only call updateFromElement when an attribute has changed. The body of
// this method should probably be moved to a private stretchHeightChanged or checkStretchHeight
// method. Probably at the same time, addChild/removeChild methods should be made to work for
// dynamic DOM changes.
void RenderMathMLOperator::updateFromElement()
{
RenderObject* savedRenderer = node()->renderer();
// Destroy our current children
children()->destroyLeftoverChildren();
// Since we share a node with our children, destroying our children may set our node's
// renderer to 0, so we need to restore it.
node()->setRenderer(savedRenderer);
int index = stretchyCharacterIndex();
bool isStretchy = index >= 0;
// We only stack glyphs if the stretch height is larger than a minimum size.
bool shouldStack = isStretchy && m_stretchHeight > style()->fontSize();
struct StretchyCharacter* partsData = 0;
float topGlyphHeight = 0;
float extensionGlyphHeight = 0;
float bottomGlyphHeight = 0;
float middleGlyphHeight = 0;
if (isStretchy) {
partsData = &stretchyCharacters[index];
FontCachePurgePreventer fontCachePurgePreventer;
topGlyphHeight = glyphHeightForCharacter(partsData->topGlyph);
extensionGlyphHeight = glyphHeightForCharacter(partsData->extensionGlyph) - 1;
bottomGlyphHeight = glyphHeightForCharacter(partsData->bottomGlyph);
if (partsData->middleGlyph)
middleGlyphHeight = glyphHeightForCharacter(partsData->middleGlyph) - 1;
shouldStack = m_stretchHeight >= topGlyphHeight + middleGlyphHeight + bottomGlyphHeight && extensionGlyphHeight > 0;
}
bool stretchDisabled = stretchDisabledByMarkup();
// Either stretch is disabled or we don't have a stretchable character over the minimum height
if (stretchDisabled || !shouldStack) {
RenderBlock* container = new (renderArena()) RenderMathMLBlock(toElement(node()));
toRenderMathMLBlock(container)->setIgnoreInAccessibilityTree(true);
RefPtr<RenderStyle> newStyle = RenderStyle::create();
newStyle->inheritFrom(style());
newStyle->setDisplay(FLEX);
newStyle->setJustifyContent(JustifyCenter);
UChar firstCharacter = firstTextCharacter();
m_isStretched = firstCharacter && isStretchy && m_stretchHeight > style()->fontMetrics().floatHeight();
if (m_isStretched)
newStyle->setHeight(Length(m_stretchHeight, Fixed));
container->setStyle(newStyle.release());
addChild(container);
if (m_isStretched) {
float scaleY = m_stretchHeight / glyphHeightForCharacter(firstCharacter);
TransformOperations transform;
transform.operations().append(ScaleTransformOperation::create(1.0, scaleY, ScaleTransformOperation::SCALE_X));
RefPtr<RenderStyle> innerStyle = RenderStyle::create();
innerStyle->inheritFrom(style());
innerStyle->setTransform(transform);
innerStyle->setTransformOriginY(Length(0, Fixed));
RenderBlock* innerContainer = new (renderArena()) RenderMathMLBlock(toElement(node()));
toRenderMathMLBlock(innerContainer)->setIgnoreInAccessibilityTree(true);
innerContainer->setStyle(innerStyle);
container->addChild(innerContainer);
container = innerContainer;
}
// Build the text of the operator.
RenderText* text = 0;
if (m_operator)
text = new (renderArena()) RenderText(node(), StringImpl::create(&m_operator, 1));
else if (node()->isElementNode())
if (Element* mo = static_cast<Element*>(node()))
text = new (renderArena()) RenderText(node(), mo->textContent().replace(hyphenMinus, minusSign).impl());
// If we can't figure out the text, leave i
|
请发表评论