本文整理汇总了C++中gfxMatrix类的典型用法代码示例。如果您正苦于以下问题:C++ gfxMatrix类的具体用法?C++ gfxMatrix怎么用?C++ gfxMatrix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了gfxMatrix类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
LayerManagerOGL::SetWorldTransform(const gfxMatrix& aMatrix)
{
NS_ASSERTION(aMatrix.PreservesAxisAlignedRectangles(),
"SetWorldTransform only accepts matrices that satisfy PreservesAxisAlignedRectangles");
NS_ASSERTION(!aMatrix.HasNonIntegerScale(),
"SetWorldTransform only accepts matrices with integer scale");
mWorldMatrix = aMatrix;
}
示例2: visibleRect
/* static */ bool
HwcUtils::PrepareLayerRects(nsIntRect aVisible, const gfxMatrix& aTransform,
nsIntRect aClip, nsIntRect aBufferRect,
hwc_rect_t* aSourceCrop, hwc_rect_t* aVisibleRegionScreen) {
gfxRect visibleRect(aVisible);
gfxRect clip(aClip);
gfxRect visibleRectScreen = aTransform.TransformBounds(visibleRect);
// |clip| is guaranteed to be integer
visibleRectScreen.IntersectRect(visibleRectScreen, clip);
if (visibleRectScreen.IsEmpty()) {
LOGD("Skip layer");
return false;
}
gfxMatrix inverse(aTransform);
inverse.Invert();
gfxRect crop = inverse.TransformBounds(visibleRectScreen);
//clip to buffer size
crop.IntersectRect(crop, aBufferRect);
crop.Round();
if (crop.IsEmpty()) {
LOGD("Skip layer");
return false;
}
//propagate buffer clipping back to visible rect
visibleRectScreen = aTransform.TransformBounds(crop);
visibleRectScreen.Round();
// Map from layer space to buffer space
crop -= aBufferRect.TopLeft();
aSourceCrop->left = crop.x;
aSourceCrop->top = crop.y;
aSourceCrop->right = crop.x + crop.width;
aSourceCrop->bottom = crop.y + crop.height;
aVisibleRegionScreen->left = visibleRectScreen.x;
aVisibleRegionScreen->top = visibleRectScreen.y;
aVisibleRegionScreen->right = visibleRectScreen.x + visibleRectScreen.width;
aVisibleRegionScreen->bottom = visibleRectScreen.y + visibleRectScreen.height;
return true;
}
示例3: LOGD
bool
HwcComposer2D::TryRender(Layer* aRoot,
const gfxMatrix& aGLWorldTransform)
{
if (!aGLWorldTransform.PreservesAxisAlignedRectangles()) {
LOGD("Render aborted. World transform has non-square angle rotation");
return false;
}
MOZ_ASSERT(Initialized());
if (mList) {
mList->numHwLayers = 0;
}
if (!PrepareLayerList(aRoot,
mScreenRect,
gfxMatrix(),
aGLWorldTransform))
{
LOGD("Render aborted. Nothing was drawn to the screen");
return false;
}
if (mHwc->set(mHwc, mDpy, mSur, mList)) {
LOGE("Hardware device failed to render");
return false;
}
LOGD("Frame rendered");
return true;
}
示例4: r
/* static */ bool
HwcUtils::CalculateClipRect(const gfxMatrix& aTransform,
const nsIntRect* aLayerClip,
nsIntRect aParentClip, nsIntRect* aRenderClip) {
*aRenderClip = aParentClip;
if (!aLayerClip) {
return true;
}
if (aLayerClip->IsEmpty()) {
return false;
}
nsIntRect clip = *aLayerClip;
gfxRect r(clip);
gfxRect trClip = aTransform.TransformBounds(r);
trClip.Round();
gfxUtils::GfxRectToIntRect(trClip, &clip);
aRenderClip->IntersectRect(*aRenderClip, clip);
return true;
}
示例5: rect
/* static */ bool
HwcUtils::PrepareVisibleRegion(const nsIntRegion& aVisible,
const gfxMatrix& aTransform,
nsIntRect aClip, nsIntRect aBufferRect,
RectVector* aVisibleRegionScreen) {
nsIntRegionRectIterator rect(aVisible);
bool isVisible = false;
while (const nsIntRect* visibleRect = rect.Next()) {
hwc_rect_t visibleRectScreen;
gfxRect screenRect;
screenRect.IntersectRect(gfxRect(*visibleRect), aBufferRect);
screenRect = aTransform.TransformBounds(screenRect);
screenRect.IntersectRect(screenRect, aClip);
screenRect.Round();
if (screenRect.IsEmpty()) {
continue;
}
visibleRectScreen.left = screenRect.x;
visibleRectScreen.top = screenRect.y;
visibleRectScreen.right = screenRect.XMost();
visibleRectScreen.bottom = screenRect.YMost();
aVisibleRegionScreen->push_back(visibleRectScreen);
isVisible = true;
}
return isVisible;
}
示例6: size
imgFrame::SurfaceWithFormat
imgFrame::SurfaceForDrawing(bool aDoPadding,
bool aDoPartialDecode,
bool aDoTile,
const nsIntMargin& aPadding,
gfxMatrix& aUserSpaceToImageSpace,
gfxRect& aFill,
gfxRect& aSubimage,
gfxRect& aSourceRect,
gfxRect& aImageRect)
{
gfxIntSize size(PRInt32(aImageRect.Width()), PRInt32(aImageRect.Height()));
if (!aDoPadding && !aDoPartialDecode) {
NS_ASSERTION(!mSinglePixel, "This should already have been handled");
return SurfaceWithFormat(new gfxSurfaceDrawable(ThebesSurface(), size), mFormat);
}
gfxRect available = gfxRect(mDecoded.x, mDecoded.y, mDecoded.width, mDecoded.height);
if (aDoTile || mSinglePixel) {
// Create a temporary surface.
// Give this surface an alpha channel because there are
// transparent pixels in the padding or undecoded area
gfxImageSurface::gfxImageFormat format = gfxASurface::ImageFormatARGB32;
nsRefPtr<gfxASurface> surface =
gfxPlatform::GetPlatform()->CreateOffscreenSurface(size, gfxImageSurface::ContentFromFormat(format));
if (!surface || surface->CairoStatus())
return SurfaceWithFormat();
// Fill 'available' with whatever we've got
gfxContext tmpCtx(surface);
tmpCtx.SetOperator(gfxContext::OPERATOR_SOURCE);
if (mSinglePixel) {
tmpCtx.SetDeviceColor(mSinglePixelColor);
} else {
tmpCtx.SetSource(ThebesSurface(), gfxPoint(aPadding.left, aPadding.top));
}
tmpCtx.Rectangle(available);
tmpCtx.Fill();
return SurfaceWithFormat(new gfxSurfaceDrawable(surface, size), format);
}
// Not tiling, and we have a surface, so we can account for
// padding and/or a partial decode just by twiddling parameters.
// First, update our user-space fill rect.
aSourceRect = aSourceRect.Intersect(available);
gfxMatrix imageSpaceToUserSpace = aUserSpaceToImageSpace;
imageSpaceToUserSpace.Invert();
aFill = imageSpaceToUserSpace.Transform(aSourceRect);
aSubimage = aSubimage.Intersect(available) - gfxPoint(aPadding.left, aPadding.top);
aUserSpaceToImageSpace.Multiply(gfxMatrix().Translate(-gfxPoint(aPadding.left, aPadding.top)));
aSourceRect = aSourceRect - gfxPoint(aPadding.left, aPadding.top);
aImageRect = gfxRect(0, 0, mSize.width, mSize.height);
gfxIntSize availableSize(mDecoded.width, mDecoded.height);
return SurfaceWithFormat(new gfxSurfaceDrawable(ThebesSurface(),
availableSize),
mFormat);
}
示例7: NS_ABORT_IF_FALSE
gfxMatrix
nsSVGGraphicElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
TransformTypes aWhich) const
{
NS_ABORT_IF_FALSE(aWhich != eChildToUserSpace || aMatrix.IsIdentity(),
"Skipping eUserSpaceToParent transforms makes no sense");
gfxMatrix result(aMatrix);
if (aWhich == eChildToUserSpace) {
// We don't have anything to prepend.
// eChildToUserSpace is not the common case, which is why we return
// 'result' to benefit from NRVO rather than returning aMatrix before
// creating 'result'.
return result;
}
NS_ABORT_IF_FALSE(aWhich == eAllTransforms || aWhich == eUserSpaceToParent,
"Unknown TransformTypes");
// animateMotion's resulting transform is supposed to apply *on top of*
// any transformations from the |transform| attribute. So since we're
// PRE-multiplying, we need to apply the animateMotion transform *first*.
if (mAnimateMotionTransform) {
result.PreMultiply(*mAnimateMotionTransform);
}
if (mTransforms) {
result.PreMultiply(mTransforms->GetAnimValue().GetConsolidationMatrix());
}
return result;
}
示例8: gfxPattern
bool
gfxSurfaceDrawable::Draw(gfxContext* aContext,
const gfxRect& aFillRect,
bool aRepeat,
const GraphicsFilter& aFilter,
const gfxMatrix& aTransform)
{
nsRefPtr<gfxPattern> pattern = new gfxPattern(mSurface);
if (aRepeat) {
pattern->SetExtend(gfxPattern::EXTEND_REPEAT);
pattern->SetFilter(aFilter);
} else {
GraphicsFilter filter = aFilter;
if (aContext->CurrentMatrix().HasOnlyIntegerTranslation() &&
aTransform.HasOnlyIntegerTranslation())
{
// If we only have integer translation, no special filtering needs to
// happen and we explicitly use FILTER_FAST. This is fast for some
// backends.
filter = GraphicsFilter::FILTER_FAST;
}
nsRefPtr<gfxASurface> currentTarget = aContext->CurrentSurface();
gfxMatrix deviceSpaceToImageSpace =
DeviceToImageTransform(aContext, aTransform);
PreparePatternForUntiledDrawing(pattern, deviceSpaceToImageSpace,
currentTarget, filter);
}
pattern->SetMatrix(gfxMatrix(aTransform).Multiply(mTransform));
aContext->NewPath();
aContext->SetPattern(pattern);
aContext->Rectangle(aFillRect);
aContext->Fill();
return true;
}
示例9: ToCanvasBounds
/**
* Returns the app unit canvas bounds of a userspace rect.
*
* @param aToCanvas Transform from userspace to canvas device space.
*/
static nsRect
ToCanvasBounds(const gfxRect &aUserspaceRect,
const gfxMatrix &aToCanvas,
const nsPresContext *presContext)
{
return nsLayoutUtils::RoundGfxRectToAppRect(
aToCanvas.TransformBounds(aUserspaceRect),
presContext->AppUnitsPerDevPixel());
}
示例10: imageSizeGfx
/* [noscript] void draw(in gfxContext aContext,
* in gfxGraphicsFilter aFilter,
* [const] in gfxMatrix aUserSpaceToImageSpace,
* [const] in gfxRect aFill,
* [const] in nsIntRect aSubimage,
* [const] in nsIntSize aViewportSize,
* in PRUint32 aFlags); */
NS_IMETHODIMP
VectorImage::Draw(gfxContext* aContext,
gfxPattern::GraphicsFilter aFilter,
const gfxMatrix& aUserSpaceToImageSpace,
const gfxRect& aFill,
const nsIntRect& aSubimage,
const nsIntSize& aViewportSize,
PRUint32 aFlags)
{
NS_ENSURE_ARG_POINTER(aContext);
if (mError || !mIsFullyLoaded)
return NS_ERROR_FAILURE;
if (mIsDrawing) {
NS_WARNING("Refusing to make re-entrant call to VectorImage::Draw");
return NS_ERROR_FAILURE;
}
mIsDrawing = true;
if (aViewportSize != mLastRenderedSize) {
mSVGDocumentWrapper->UpdateViewportBounds(aViewportSize);
mLastRenderedSize = aViewportSize;
}
mSVGDocumentWrapper->FlushImageTransformInvalidation();
nsIntSize imageSize = mHaveRestrictedRegion ?
mRestrictedRegion.Size() : aViewportSize;
// XXXdholbert Do we need to convert image size from
// CSS pixels to dev pixels here? (is gfxCallbackDrawable's 2nd arg in dev
// pixels?)
gfxIntSize imageSizeGfx(imageSize.width, imageSize.height);
// Based on imgFrame::Draw
gfxRect sourceRect = aUserSpaceToImageSpace.Transform(aFill);
gfxRect imageRect(0, 0, imageSize.width, imageSize.height);
gfxRect subimage(aSubimage.x, aSubimage.y, aSubimage.width, aSubimage.height);
nsRefPtr<gfxDrawingCallback> cb =
new SVGDrawingCallback(mSVGDocumentWrapper,
mHaveRestrictedRegion ?
mRestrictedRegion :
nsIntRect(nsIntPoint(0, 0), aViewportSize),
aFlags);
nsRefPtr<gfxDrawable> drawable = new gfxCallbackDrawable(cb, imageSizeGfx);
gfxUtils::DrawPixelSnapped(aContext, drawable,
aUserSpaceToImageSpace,
subimage, sourceRect, imageRect, aFill,
gfxASurface::ImageFormatARGB32, aFilter);
mIsDrawing = false;
return NS_OK;
}
示例11: CreateSamplingRestrictedDrawable
// EXTEND_PAD won't help us here; we have to create a temporary surface to hold
// the subimage of pixels we're allowed to sample.
static already_AddRefed<gfxDrawable>
CreateSamplingRestrictedDrawable(gfxDrawable* aDrawable,
gfxContext* aContext,
const gfxMatrix& aUserSpaceToImageSpace,
const gfxRect& aSourceRect,
const gfxRect& aSubimage,
const gfxImageFormat aFormat)
{
PROFILER_LABEL("gfxUtils", "CreateSamplingRestricedDrawable");
gfxRect userSpaceClipExtents = aContext->GetClipExtents();
// This isn't optimal --- if aContext has a rotation then GetClipExtents
// will have to do a bounding-box computation, and TransformBounds might
// too, so we could get a better result if we computed image space clip
// extents in one go --- but it doesn't really matter and this is easier
// to understand.
gfxRect imageSpaceClipExtents =
aUserSpaceToImageSpace.TransformBounds(userSpaceClipExtents);
// Inflate by one pixel because bilinear filtering will sample at most
// one pixel beyond the computed image pixel coordinate.
imageSpaceClipExtents.Inflate(1.0);
gfxRect needed = imageSpaceClipExtents.Intersect(aSourceRect);
needed = needed.Intersect(aSubimage);
needed.RoundOut();
// if 'needed' is empty, nothing will be drawn since aFill
// must be entirely outside the clip region, so it doesn't
// matter what we do here, but we should avoid trying to
// create a zero-size surface.
if (needed.IsEmpty())
return nullptr;
nsRefPtr<gfxDrawable> drawable;
gfxIntSize size(int32_t(needed.Width()), int32_t(needed.Height()));
nsRefPtr<gfxImageSurface> image = aDrawable->GetAsImageSurface();
if (image && gfxRect(0, 0, image->GetSize().width, image->GetSize().height).Contains(needed)) {
nsRefPtr<gfxASurface> temp = image->GetSubimage(needed);
drawable = new gfxSurfaceDrawable(temp, size, gfxMatrix().Translate(-needed.TopLeft()));
} else {
mozilla::RefPtr<mozilla::gfx::DrawTarget> target =
gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(ToIntSize(size),
ImageFormatToSurfaceFormat(aFormat));
if (!target) {
return nullptr;
}
nsRefPtr<gfxContext> tmpCtx = new gfxContext(target);
tmpCtx->SetOperator(OptimalFillOperator());
aDrawable->Draw(tmpCtx, needed - needed.TopLeft(), true,
GraphicsFilter::FILTER_FAST, gfxMatrix().Translate(needed.TopLeft()));
drawable = new gfxSurfaceDrawable(target, size, gfxMatrix().Translate(-needed.TopLeft()));
}
return drawable.forget();
}
示例12: SVGBBox
SVGBBox
nsSVGForeignObjectFrame::GetBBoxContribution(const gfxMatrix &aToBBoxUserspace,
PRUint32 aFlags)
{
nsSVGForeignObjectElement *content =
static_cast<nsSVGForeignObjectElement*>(mContent);
float x, y, w, h;
content->GetAnimatedLengthValues(&x, &y, &w, &h, nsnull);
if (w < 0.0f) w = 0.0f;
if (h < 0.0f) h = 0.0f;
if (aToBBoxUserspace.IsSingular()) {
// XXX ReportToConsole
return SVGBBox();
}
return aToBBoxUserspace.TransformBounds(gfxRect(0.0, 0.0, w, h));
}
示例13: gfxRect
gfxRect
nsSVGPathGeometryFrame::GetBBoxContribution(const gfxMatrix &aToBBoxUserspace)
{
if (aToBBoxUserspace.IsSingular()) {
// XXX ReportToConsole
return gfxRect(0.0, 0.0, 0.0, 0.0);
}
gfxContext context(nsSVGUtils::GetThebesComputationalSurface());
GeneratePath(&context, &aToBBoxUserspace);
context.IdentityMatrix();
return context.GetUserPathExtent();
}
示例14: gfxRect
gfxRect
nsSVGForeignObjectFrame::GetBBoxContribution(const gfxMatrix &aToBBoxUserspace)
{
NS_ASSERTION(!(GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD),
"Should not be calling this on a non-display child");
nsSVGForeignObjectElement *content =
static_cast<nsSVGForeignObjectElement*>(mContent);
float x, y, w, h;
content->GetAnimatedLengthValues(&x, &y, &w, &h, nsnull);
if (w < 0.0f) w = 0.0f;
if (h < 0.0f) h = 0.0f;
if (aToBBoxUserspace.IsSingular()) {
// XXX ReportToConsole
return gfxRect(0.0, 0.0, 0.0, 0.0);
}
return aToBBoxUserspace.TransformBounds(gfxRect(0.0, 0.0, w, h));
}
示例15: gfxPattern
bool
gfxSurfaceDrawable::Draw(gfxContext* aContext,
const gfxRect& aFillRect,
bool aRepeat,
const GraphicsFilter& aFilter,
const gfxMatrix& aTransform)
{
nsRefPtr<gfxPattern> pattern;
if (mDrawTarget) {
if (aContext->IsCairo()) {
nsRefPtr<gfxASurface> source =
gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mDrawTarget);
pattern = new gfxPattern(source);
} else {
RefPtr<SourceSurface> source = mDrawTarget->Snapshot();
pattern = new gfxPattern(source, Matrix());
}
} else if (mSourceSurface) {
pattern = new gfxPattern(mSourceSurface, Matrix());
} else {
pattern = new gfxPattern(mSurface);
}
if (aRepeat) {
pattern->SetExtend(gfxPattern::EXTEND_REPEAT);
pattern->SetFilter(aFilter);
} else {
GraphicsFilter filter = aFilter;
if (aContext->CurrentMatrix().HasOnlyIntegerTranslation() &&
aTransform.HasOnlyIntegerTranslation())
{
// If we only have integer translation, no special filtering needs to
// happen and we explicitly use FILTER_FAST. This is fast for some
// backends.
filter = GraphicsFilter::FILTER_FAST;
}
nsRefPtr<gfxASurface> currentTarget = aContext->CurrentSurface();
gfxMatrix deviceSpaceToImageSpace =
DeviceToImageTransform(aContext, aTransform);
PreparePatternForUntiledDrawing(pattern, deviceSpaceToImageSpace,
currentTarget, filter);
}
pattern->SetMatrix(gfxMatrix(aTransform).Multiply(mTransform));
aContext->NewPath();
aContext->SetPattern(pattern);
aContext->Rectangle(aFillRect);
aContext->Fill();
// clear the pattern so that the snapshot is released before the
// drawable is destroyed
aContext->SetDeviceColor(gfxRGBA(0.0, 0.0, 0.0, 0.0));
return true;
}