本文整理汇总了C++中TransformationMatrix类的典型用法代码示例。如果您正苦于以下问题:C++ TransformationMatrix类的具体用法?C++ TransformationMatrix怎么用?C++ TransformationMatrix使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TransformationMatrix类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertToTransformationMatrix
void GLUtils::convertToTransformationMatrix(const float* matrix, TransformationMatrix& transformMatrix)
{
transformMatrix.setMatrix(
matrix[0], matrix[1], matrix[2], matrix[3],
matrix[4], matrix[5], matrix[6], matrix[7],
matrix[8], matrix[9], matrix[10], matrix[11],
matrix[12], matrix[13], matrix[14], matrix[15]);
}
示例2: computeTransformedExtentViaMatrix
bool AnimationBase::computeTransformedExtentViaMatrix(const FloatRect& rendererBox, const RenderStyle& style, LayoutRect& bounds) const
{
TransformationMatrix transform;
style.applyTransform(transform, rendererBox, RenderStyle::IncludeTransformOrigin);
if (!transform.isAffine())
return false;
TransformationMatrix::Decomposed2Type fromDecomp;
transform.decompose2(fromDecomp);
// Any rotation prevents us from using a simple start/end rect union.
if (fromDecomp.angle)
return false;
bounds = LayoutRect(transform.mapRect(bounds));
return true;
}
示例3: x
FloatRect SVGSVGElement::viewport() const
{
double _x = 0.0;
double _y = 0.0;
if (!isOutermostSVG()) {
_x = x().value(this);
_y = y().value(this);
}
float w = width().value(this);
float h = height().value(this);
TransformationMatrix viewBox = viewBoxToViewTransform(w, h);
double wDouble = w;
double hDouble = h;
viewBox.map(_x, _y, _x, _y);
viewBox.map(w, h, wDouble, hDouble);
return FloatRect::narrowPrecision(_x, _y, wDouble, hDouble);
}
示例4: contentToScreenSpaceTransform
static inline TransformationMatrix contentToScreenSpaceTransform(const LayerType* layer)
{
ASSERT(layerTransformsToScreenKnown(layer));
IntSize boundsInLayerSpace = layer->bounds();
IntSize boundsInContentSpace = layer->contentBounds();
TransformationMatrix transform = layer->screenSpaceTransform();
if (boundsInContentSpace.isEmpty())
return transform;
// Scale from content space to layer space
transform.scaleNonUniform(boundsInLayerSpace.width() / static_cast<double>(boundsInContentSpace.width()),
boundsInLayerSpace.height() / static_cast<double>(boundsInContentSpace.height()));
return transform;
}
示例5: bindProgramTransformParameter
void CustomFilterRenderer::bindProgramTransformParameter(int uniformLocation, CustomFilterTransformParameter* transformParameter)
{
TransformationMatrix matrix;
if (m_contextSize.width() && m_contextSize.height()) {
// The viewport is a box with the size of 1 unit, so we are scaling up here to make sure that translations happen using real pixel
// units. At the end we scale back down in order to map it back to the original box. Note that transforms come in reverse order, because it is
// supposed to multiply to the left of the coordinates of the vertices.
// Note that the origin (0, 0) of the viewport is in the middle of the context, so there's no need to change the origin of the transform
// in order to rotate around the middle of mesh.
matrix.scale3d(1.0 / m_contextSize.width(), 1.0 / m_contextSize.height(), 1);
transformParameter->applyTransform(matrix, m_contextSize);
matrix.scale3d(m_contextSize.width(), m_contextSize.height(), 1);
}
float glMatrix[16];
matrix.toColumnMajorFloatArray(glMatrix);
m_context->uniformMatrix4fv(uniformLocation, 1, false, &glMatrix[0]);
}
示例6: blendWithOpacity
void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options)
{
if (!m_state.visible || !m_state.contentsVisible)
return;
// We apply the following transform to compensate for painting into a surface, and then apply the offset so that the painting fits in the target rect.
TransformationMatrix transform;
transform.translate(options.offset.width(), options.offset.height());
transform.multiply(options.transform);
transform.multiply(m_currentTransform.combined());
if (m_state.solidColor.isValid() && !m_state.contentsRect.isEmpty() && m_state.solidColor.alpha()) {
options.textureMapper->drawSolidColor(m_state.contentsRect, transform, blendWithOpacity(m_state.solidColor, options.opacity));
if (m_state.showDebugBorders)
options.textureMapper->drawBorder(m_state.debugBorderColor, m_state.debugBorderWidth, layerRect(), transform);
return;
}
options.textureMapper->setWrapMode(TextureMapper::StretchWrap);
options.textureMapper->setPatternTransform(TransformationMatrix());
if (m_backingStore) {
FloatRect targetRect = layerRect();
ASSERT(!targetRect.isEmpty());
m_backingStore->paintToTextureMapper(options.textureMapper, targetRect, transform, options.opacity);
if (m_state.showDebugBorders)
m_backingStore->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, targetRect, transform);
// Only draw repaint count for the main backing store.
if (m_state.showRepaintCounter)
m_backingStore->drawRepaintCounter(options.textureMapper, m_state.repaintCount, m_state.debugBorderColor, targetRect, transform);
}
if (!m_contentsLayer)
return;
if (!m_state.contentsTileSize.isEmpty()) {
computePatternTransformIfNeeded();
options.textureMapper->setWrapMode(TextureMapper::RepeatWrap);
options.textureMapper->setPatternTransform(m_patternTransform);
}
ASSERT(!layerRect().isEmpty());
m_contentsLayer->paintToTextureMapper(options.textureMapper, m_state.contentsRect, transform, options.opacity);
if (m_state.showDebugBorders)
m_contentsLayer->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, m_state.contentsRect, transform);
}
示例7: drawTransform
TransformationMatrix TiledLayerChromium::tilingTransform() const
{
TransformationMatrix transform = drawTransform();
if (contentBounds().isEmpty())
return transform;
transform.scaleNonUniform(bounds().width() / static_cast<double>(contentBounds().width()),
bounds().height() / static_cast<double>(contentBounds().height()));
// Tiler draws with a different origin from other layers.
transform.translate(-contentBounds().width() / 2.0, -contentBounds().height() / 2.0);
transform.translate(-scrollPosition().x(), -scrollPosition().y());
return transform;
}
示例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;
}
示例9: containsRotation
bool AnimationBase::computeTransformedExtentViaTransformList(const FloatRect& rendererBox, const RenderStyle& style, LayoutRect& bounds) const
{
FloatRect floatBounds = bounds;
FloatPoint transformOrigin;
bool applyTransformOrigin = containsRotation(style.transform().operations()) || style.transform().affectedByTransformOrigin();
if (applyTransformOrigin) {
float offsetX = style.transformOriginX().isPercent() ? rendererBox.x() : 0;
float offsetY = style.transformOriginY().isPercent() ? rendererBox.y() : 0;
transformOrigin.setX(floatValueForLength(style.transformOriginX(), rendererBox.width()) + offsetX);
transformOrigin.setY(floatValueForLength(style.transformOriginY(), rendererBox.height()) + offsetY);
// Ignore transformOriginZ because we'll bail if we encounter any 3D transforms.
floatBounds.moveBy(-transformOrigin);
}
for (const auto& operation : style.transform().operations()) {
if (operation->type() == TransformOperation::ROTATE) {
// For now, just treat this as a full rotation. This could take angle into account to reduce inflation.
floatBounds = boundsOfRotatingRect(floatBounds);
} else {
TransformationMatrix transform;
operation->apply(transform, rendererBox.size());
if (!transform.isAffine())
return false;
if (operation->type() == TransformOperation::MATRIX || operation->type() == TransformOperation::MATRIX_3D) {
TransformationMatrix::Decomposed2Type toDecomp;
transform.decompose2(toDecomp);
// Any rotation prevents us from using a simple start/end rect union.
if (toDecomp.angle)
return false;
}
floatBounds = transform.mapRect(floatBounds);
}
}
if (applyTransformOrigin)
floatBounds.moveBy(transformOrigin);
bounds = LayoutRect(floatBounds);
return true;
}
示例10: clipToTextMask
static inline TransformationMatrix clipToTextMask(GraphicsContext* context,
OwnPtr<ImageBuffer>& imageBuffer, const RenderObject* object,
const SVGPaintServerGradient* gradientServer)
{
FloatRect maskBBox = const_cast<RenderObject*>(findTextRootObject(object))->objectBoundingBox();
// Fixup transformations to be able to clip to mask
TransformationMatrix transform = object->absoluteTransform();
FloatRect textBoundary = transform.mapRect(maskBBox);
IntSize maskSize(lroundf(textBoundary.width()), lroundf(textBoundary.height()));
clampImageBufferSizeToViewport(object->view()->frameView(), maskSize);
textBoundary.setSize(textBoundary.size().shrunkTo(maskSize));
// Clip current context to mask image (gradient)
context->concatCTM(transform.inverse());
context->clipToImageBuffer(textBoundary, imageBuffer.get());
context->concatCTM(transform);
TransformationMatrix matrix;
if (gradientServer->boundingBoxMode()) {
matrix.translate(maskBBox.x(), maskBBox.y());
matrix.scaleNonUniform(maskBBox.width(), maskBBox.height());
}
matrix.multiply(gradientServer->gradientTransform());
return matrix;
}
示例11: ASSERT
void ContentLayerChromium::calculateClippedUpdateRect(IntRect& dirtyRect, IntRect& drawRect) const
{
// For the given layer size and content rect, calculate:
// 1) The minimal texture space rectangle to be uploaded, returned in dirtyRect.
// 2) The rectangle to draw this texture in relative to the target render surface, returned in drawRect.
ASSERT(m_targetRenderSurface);
const IntRect clipRect = m_targetRenderSurface->contentRect();
TransformationMatrix layerOriginTransform = drawTransform();
layerOriginTransform.translate3d(-0.5 * m_bounds.width(), -0.5 * m_bounds.height(), 0);
// For now we apply the large layer treatment only for layers that are either untransformed
// or are purely translated. Their matrix is expected to be invertible.
ASSERT(layerOriginTransform.isInvertible());
TransformationMatrix targetToLayerMatrix = layerOriginTransform.inverse();
IntRect clipRectInLayerCoords = targetToLayerMatrix.mapRect(clipRect);
clipRectInLayerCoords.intersect(IntRect(0, 0, m_bounds.width(), m_bounds.height()));
dirtyRect = clipRectInLayerCoords;
// Map back to the target surface coordinate system.
drawRect = layerOriginTransform.mapRect(dirtyRect);
}
示例12: ASSERT
void RenderGeometryMap::push(const RenderObject* renderer, const TransformationMatrix& t, bool accumulatingTransform, bool isNonUniform, bool isFixedPosition, bool hasTransform, LayoutSize offsetForFixedPosition)
{
ASSERT(m_insertionPosition != kNotFound);
ASSERT(!renderer->isRenderView() || !m_insertionPosition || m_mapCoordinatesFlags & TraverseDocumentBoundaries);
ASSERT(offsetForFixedPosition.isZero() || renderer->isRenderView());
m_mapping.insert(m_insertionPosition, RenderGeometryMapStep(renderer, accumulatingTransform, isNonUniform, isFixedPosition, hasTransform));
RenderGeometryMapStep& step = m_mapping[m_insertionPosition];
step.m_offsetForFixedPosition = offsetForFixedPosition;
if (!t.isIntegerTranslation())
step.m_transform = adoptPtr(new TransformationMatrix(t));
else
step.m_offset = LayoutSize(t.e(), t.f());
stepInserted(step);
}
示例13: setProjectionMatrix
void ShaderProgram::setProjectionMatrix(SkRect& geometry, GLint projectionMatrixHandle)
{
TransformationMatrix translate;
translate.translate3d(geometry.fLeft, geometry.fTop, 0.0);
TransformationMatrix scale;
scale.scale3d(geometry.width(), geometry.height(), 1.0);
TransformationMatrix total;
if (!m_alphaLayer)
total = m_projectionMatrix * m_repositionMatrix * m_webViewMatrix
* translate * scale;
else
total = m_projectionMatrix * translate * scale;
GLfloat projectionMatrix[16];
GLUtils::toGLMatrix(projectionMatrix, total);
glUniformMatrix4fv(projectionMatrixHandle, 1, GL_FALSE, projectionMatrix);
}
示例14: getMax
void BoundingBox::getMax(float &x, float &y, float &z) const {
// Maximum, relative to the origin
if (_absolute) {
x = _max[0]; y = _max[1]; z = _max[2];
return;
}
TransformationMatrix min = _origin;
min.translate(_min[0], _min[1], _min[2]);
TransformationMatrix max = _origin;
max.translate(_max[0], _max[1], _max[2]);
x = MAX(min.getX(), max.getX());
y = MAX(min.getY(), max.getY());
z = MAX(min.getZ(), max.getZ());
}
示例15: render
virtual void render(const RenderState& state)
{
TransformationMatrix renderMatrix;
if (pageNode()->devicePixelRatio() != 1.0) {
renderMatrix.scale(pageNode()->devicePixelRatio());
if (matrix())
renderMatrix.multiply(*matrix());
} else if (matrix())
renderMatrix = *matrix();
// When rendering to an intermediate surface, Qt will
// mirror the projection matrix to fit on the destination coordinate system.
const QMatrix4x4* projection = state.projectionMatrix;
bool mirrored = projection && (*projection)(0, 0) * (*projection)(1, 1) - (*projection)(0, 1) * (*projection)(1, 0) > 0;
// FIXME: Support non-rectangular clippings.
coordinatedGraphicsScene()->paintToCurrentGLContext(renderMatrix, inheritedOpacity(), clipRect(), mirrored ? TextureMapper::PaintingMirrored : 0);
}