本文整理汇总了C++中gfx3DMatrix类的典型用法代码示例。如果您正苦于以下问题:C++ gfx3DMatrix类的具体用法?C++ gfx3DMatrix怎么用?C++ gfx3DMatrix使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了gfx3DMatrix类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: metricsScrollOffset
bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSampleTime,
const FrameMetrics& aFrame,
const gfx3DMatrix& aCurrentTransform,
gfx3DMatrix* aNewTransform) {
// The eventual return value of this function. The compositor needs to know
// whether or not to advance by a frame as soon as it can. For example, if a
// fling is happening, it has to keep compositing so that the animation is
// smooth. If an animation frame is requested, it is the compositor's
// responsibility to schedule a composite.
bool requestAnimationFrame = false;
// Scales on the root layer, on what's currently painted.
float rootScaleX = aCurrentTransform.GetXScale(),
rootScaleY = aCurrentTransform.GetYScale();
nsIntPoint metricsScrollOffset(0, 0);
nsIntPoint scrollOffset;
float localScaleX, localScaleY;
{
MonitorAutoLock mon(mMonitor);
// If a fling is currently happening, apply it now. We can pull the updated
// metrics afterwards.
requestAnimationFrame = requestAnimationFrame || DoFling(aSampleTime - mLastSampleTime);
// Current local transform; this is not what's painted but rather what PZC has
// transformed due to touches like panning or pinching. Eventually, the root
// layer transform will become this during runtime, but we must wait for Gecko
// to repaint.
localScaleX = mFrameMetrics.mResolution.width;
localScaleY = mFrameMetrics.mResolution.height;
if (aFrame.IsScrollable()) {
metricsScrollOffset = aFrame.mViewportScrollOffset;
}
scrollOffset = mFrameMetrics.mViewportScrollOffset;
}
nsIntPoint scrollCompensation(
(scrollOffset.x / rootScaleX - metricsScrollOffset.x) * localScaleX,
(scrollOffset.y / rootScaleY - metricsScrollOffset.y) * localScaleY);
ViewTransform treeTransform(-scrollCompensation, localScaleX, localScaleY);
*aNewTransform = gfx3DMatrix(treeTransform) * aCurrentTransform;
mLastSampleTime = aSampleTime;
return requestAnimationFrame;
}
示例2: RecoverZDepth
/**
* Recover the z component from a 2d transformed point by finding the intersection
* of a line through the point in the z direction and the transformed plane.
*
* We want to solve:
*
* point = normal . (p0 - l0) / normal . l
*/
static gfxFloat RecoverZDepth(const gfx3DMatrix& aTransform, const gfxPoint& aPoint)
{
const gfxPoint3D l(0, 0, 1);
gfxPoint3D l0 = gfxPoint3D(aPoint.x, aPoint.y, 0);
gfxPoint3D p0 = aTransform.Transform3D(gfxPoint3D(0, 0, 0));
gfxPoint3D normal = aTransform.GetNormalVector();
gfxFloat n = normal.DotProduct(p0 - l0);
gfxFloat d = normal.DotProduct(l);
if (!d) {
return 0;
}
return n/d;
}
示例3: ApplyScreenToLayoutTransform
static LayoutDeviceRect
ApplyScreenToLayoutTransform(const gfx3DMatrix& aTransform, const ScreenRect& aScreenRect)
{
gfxRect input(aScreenRect.x, aScreenRect.y, aScreenRect.width, aScreenRect.height);
gfxRect output = aTransform.TransformBounds(input);
return LayoutDeviceRect(output.x, output.y, output.width, output.height);
}
示例4: ProcessMatrix
/* Helper function to process a matrix entry. */
static void
ProcessMatrix(gfx3DMatrix& aMatrix,
const nsCSSValue::Array* aData,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree,
nsRect& aBounds)
{
NS_PRECONDITION(aData->Count() == 7, "Invalid array!");
gfxMatrix result;
/* Take the first four elements out of the array as floats and store
* them.
*/
result._11 = aData->Item(1).GetFloatValue();
result._12 = aData->Item(2).GetFloatValue();
result._21 = aData->Item(3).GetFloatValue();
result._22 = aData->Item(4).GetFloatValue();
/* The last two elements have their length parts stored in aDelta
* and their percent parts stored in aX[0] and aY[1].
*/
result._31 = ProcessTranslatePart(aData->Item(5),
aContext, aPresContext, aCanStoreInRuleTree,
aBounds.Width());
result._32 = ProcessTranslatePart(aData->Item(6),
aContext, aPresContext, aCanStoreInRuleTree,
aBounds.Height());
aMatrix.PreMultiply(result);
}
示例5: ProcessRotateY
static void
ProcessRotateY(gfx3DMatrix& aMatrix, const nsCSSValue::Array* aData)
{
NS_PRECONDITION(aData->Count() == 2, "Invalid array!");
double theta = aData->Item(1).GetAngleValueInRadians();
aMatrix.RotateY(theta);
}
示例6: ProcessTranslate3D
static void
ProcessTranslate3D(gfx3DMatrix& aMatrix,
const nsCSSValue::Array* aData,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree,
nsRect& aBounds)
{
NS_PRECONDITION(aData->Count() == 4, "Invalid array!");
Point3D temp;
temp.x = ProcessTranslatePart(aData->Item(1),
aContext, aPresContext, aCanStoreInRuleTree,
aBounds.Width());
temp.y = ProcessTranslatePart(aData->Item(2),
aContext, aPresContext, aCanStoreInRuleTree,
aBounds.Height());
temp.z = ProcessTranslatePart(aData->Item(3),
aContext, aPresContext, aCanStoreInRuleTree,
0);
aMatrix.Translate(temp);
}
示例7: Multiply2D
gfx3DMatrix
gfx3DMatrix::operator*(const gfx3DMatrix &aMatrix) const
{
if (Is2D() && aMatrix.Is2D()) {
return Multiply2D(aMatrix);
}
gfx3DMatrix matrix;
matrix._11 = _11 * aMatrix._11 + _12 * aMatrix._21 + _13 * aMatrix._31 + _14 * aMatrix._41;
matrix._21 = _21 * aMatrix._11 + _22 * aMatrix._21 + _23 * aMatrix._31 + _24 * aMatrix._41;
matrix._31 = _31 * aMatrix._11 + _32 * aMatrix._21 + _33 * aMatrix._31 + _34 * aMatrix._41;
matrix._41 = _41 * aMatrix._11 + _42 * aMatrix._21 + _43 * aMatrix._31 + _44 * aMatrix._41;
matrix._12 = _11 * aMatrix._12 + _12 * aMatrix._22 + _13 * aMatrix._32 + _14 * aMatrix._42;
matrix._22 = _21 * aMatrix._12 + _22 * aMatrix._22 + _23 * aMatrix._32 + _24 * aMatrix._42;
matrix._32 = _31 * aMatrix._12 + _32 * aMatrix._22 + _33 * aMatrix._32 + _34 * aMatrix._42;
matrix._42 = _41 * aMatrix._12 + _42 * aMatrix._22 + _43 * aMatrix._32 + _44 * aMatrix._42;
matrix._13 = _11 * aMatrix._13 + _12 * aMatrix._23 + _13 * aMatrix._33 + _14 * aMatrix._43;
matrix._23 = _21 * aMatrix._13 + _22 * aMatrix._23 + _23 * aMatrix._33 + _24 * aMatrix._43;
matrix._33 = _31 * aMatrix._13 + _32 * aMatrix._23 + _33 * aMatrix._33 + _34 * aMatrix._43;
matrix._43 = _41 * aMatrix._13 + _42 * aMatrix._23 + _43 * aMatrix._33 + _44 * aMatrix._43;
matrix._14 = _11 * aMatrix._14 + _12 * aMatrix._24 + _13 * aMatrix._34 + _14 * aMatrix._44;
matrix._24 = _21 * aMatrix._14 + _22 * aMatrix._24 + _23 * aMatrix._34 + _24 * aMatrix._44;
matrix._34 = _31 * aMatrix._14 + _32 * aMatrix._24 + _33 * aMatrix._34 + _34 * aMatrix._44;
matrix._44 = _41 * aMatrix._14 + _42 * aMatrix._24 + _43 * aMatrix._34 + _44 * aMatrix._44;
return matrix;
}
示例8: ProcessScaleHelper
/* Helper function to set up a scale matrix. */
static void
ProcessScaleHelper(gfx3DMatrix& aMatrix,
float aXScale,
float aYScale,
float aZScale)
{
aMatrix.Scale(aXScale, aYScale, aZScale);
}
示例9: ProcessPerspective
static void
ProcessPerspective(gfx3DMatrix& aMatrix,
const nsCSSValue::Array* aData,
nsStyleContext *aContext,
nsPresContext *aPresContext,
bool &aCanStoreInRuleTree)
{
NS_PRECONDITION(aData->Count() == 2, "Invalid array!");
float depth = ProcessTranslatePart(aData->Item(1), aContext,
aPresContext, aCanStoreInRuleTree,
0);
aMatrix.Perspective(depth);
}
示例10: ProcessTranslateZ
static void
ProcessTranslateZ(gfx3DMatrix& aMatrix,
const nsCSSValue::Array* aData,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree)
{
NS_PRECONDITION(aData->Count() == 2, "Invalid array!");
Point3D temp;
temp.z = ProcessTranslatePart(aData->Item(1), aContext,
aPresContext, aCanStoreInRuleTree, 0);
aMatrix.Translate(temp);
}
示例11: TransformRect
static nsIntRect
TransformRect(const nsIntRect& aRect, const gfx3DMatrix& aTransform)
{
if (aRect.IsEmpty()) {
return nsIntRect();
}
gfxRect rect(aRect.x, aRect.y, aRect.width, aRect.height);
rect = aTransform.TransformBounds(rect);
rect.RoundOut();
nsIntRect intRect;
if (!gfxUtils::GfxRectToIntRect(rect, &intRect)) {
return nsIntRect();
}
return intRect;
}
示例12: SubtractTransformedRegion
static void
SubtractTransformedRegion(nsIntRegion& aRegion,
const nsIntRegion& aRegionToSubtract,
const gfx3DMatrix& aTransform)
{
if (aRegionToSubtract.IsEmpty()) {
return;
}
// For each rect in the region, find out its bounds in screen space and
// subtract it from the screen region.
nsIntRegionRectIterator it(aRegionToSubtract);
while (const nsIntRect* rect = it.Next()) {
gfxRect incompleteRect = aTransform.TransformBounds(gfxRect(*rect));
aRegion.Sub(aRegion, nsIntRect(incompleteRect.x,
incompleteRect.y,
incompleteRect.width,
incompleteRect.height));
}
}
示例13: Transform
static void
Transform(DataSourceSurface* aDest,
DataSourceSurface* aSource,
const gfx3DMatrix& aTransform,
const Point& aDestOffset)
{
if (aTransform.IsSingular()) {
return;
}
IntSize destSize = aDest->GetSize();
SkImageInfo destInfo = SkImageInfo::Make(destSize.width,
destSize.height,
kBGRA_8888_SkColorType,
kPremul_SkAlphaType);
SkBitmap destBitmap;
destBitmap.setInfo(destInfo, aDest->Stride());
destBitmap.setPixels((uint32_t*)aDest->GetData());
SkCanvas destCanvas(destBitmap);
IntSize srcSize = aSource->GetSize();
SkImageInfo srcInfo = SkImageInfo::Make(srcSize.width,
srcSize.height,
kBGRA_8888_SkColorType,
kPremul_SkAlphaType);
SkBitmap src;
src.setInfo(srcInfo, aSource->Stride());
src.setPixels((uint32_t*)aSource->GetData());
gfx3DMatrix transform = aTransform;
transform.TranslatePost(Point3D(-aDestOffset.x, -aDestOffset.y, 0));
destCanvas.setMatrix(Matrix3DToSkia(transform));
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
paint.setAntiAlias(true);
paint.setFilterLevel(SkPaint::kLow_FilterLevel);
SkRect destRect = SkRect::MakeXYWH(0, 0, srcSize.width, srcSize.height);
destCanvas.drawBitmapRectToRect(src, nullptr, destRect, &paint);
}
示例14: ProcessMatrix3D
static void
ProcessMatrix3D(gfx3DMatrix& aMatrix,
const nsCSSValue::Array* aData,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree,
nsRect& aBounds)
{
NS_PRECONDITION(aData->Count() == 17, "Invalid array!");
gfx3DMatrix temp;
temp._11 = aData->Item(1).GetFloatValue();
temp._12 = aData->Item(2).GetFloatValue();
temp._13 = aData->Item(3).GetFloatValue();
temp._14 = aData->Item(4).GetFloatValue();
temp._21 = aData->Item(5).GetFloatValue();
temp._22 = aData->Item(6).GetFloatValue();
temp._23 = aData->Item(7).GetFloatValue();
temp._24 = aData->Item(8).GetFloatValue();
temp._31 = aData->Item(9).GetFloatValue();
temp._32 = aData->Item(10).GetFloatValue();
temp._33 = aData->Item(11).GetFloatValue();
temp._34 = aData->Item(12).GetFloatValue();
temp._44 = aData->Item(16).GetFloatValue();
temp._41 = ProcessTranslatePart(aData->Item(13),
aContext, aPresContext, aCanStoreInRuleTree,
aBounds.Width());
temp._42 = ProcessTranslatePart(aData->Item(14),
aContext, aPresContext, aCanStoreInRuleTree,
aBounds.Height());
temp._43 = ProcessTranslatePart(aData->Item(15),
aContext, aPresContext, aCanStoreInRuleTree,
aBounds.Height());
aMatrix.PreMultiply(temp);
}
示例15: TransformCompositionBounds
static LayoutDeviceRect
TransformCompositionBounds(const ParentLayerRect& aCompositionBounds,
const CSSToParentLayerScale& aZoom,
const ScreenPoint& aScrollOffset,
const CSSToScreenScale& aResolution,
const gfx3DMatrix& aTransformScreenToLayout)
{
// Transform the current composition bounds into transformed layout device
// space by compensating for the difference in resolution and subtracting the
// old composition bounds origin.
ScreenRect offsetViewportRect = (aCompositionBounds / aZoom) * aResolution;
offsetViewportRect.MoveBy(-aScrollOffset);
gfxRect transformedViewport =
aTransformScreenToLayout.TransformBounds(
gfxRect(offsetViewportRect.x, offsetViewportRect.y,
offsetViewportRect.width, offsetViewportRect.height));
return LayoutDeviceRect(transformedViewport.x,
transformedViewport.y,
transformedViewport.width,
transformedViewport.height);
}