本文整理汇总了C++中SVGSVGElement::GetIntrinsicWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGSVGElement::GetIntrinsicWidth方法的具体用法?C++ SVGSVGElement::GetIntrinsicWidth怎么用?C++ SVGSVGElement::GetIntrinsicWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGSVGElement
的用法示例。
在下文中一共展示了SVGSVGElement::GetIntrinsicWidth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/* readonly attribute int32_t width; */
NS_IMETHODIMP
VectorImage::GetWidth(int32_t* aWidth)
{
if (mError || !mIsFullyLoaded) {
*aWidth = -1;
} else {
SVGSVGElement* rootElem = mSVGDocumentWrapper->GetRootSVGElem();
MOZ_ASSERT(rootElem, "Should have a root SVG elem, since we finished "
"loading without errors");
*aWidth = rootElem->GetIntrinsicWidth();
}
return *aWidth >= 0 ? NS_OK : NS_ERROR_FAILURE;
}
示例2: imageIntSize
VectorImage::GetFrame(uint32_t aWhichFrame,
uint32_t aFlags)
{
MOZ_ASSERT(aWhichFrame <= FRAME_MAX_VALUE);
if (aWhichFrame > FRAME_MAX_VALUE) {
return nullptr;
}
if (mError || !mIsFullyLoaded) {
return nullptr;
}
// Look up height & width
// ----------------------
SVGSVGElement* svgElem = mSVGDocumentWrapper->GetRootSVGElem();
MOZ_ASSERT(svgElem, "Should have a root SVG elem, since we finished "
"loading without errors");
nsIntSize imageIntSize(svgElem->GetIntrinsicWidth(),
svgElem->GetIntrinsicHeight());
if (imageIntSize.IsEmpty()) {
// We'll get here if our SVG doc has a percent-valued or negative width or
// height.
return nullptr;
}
// Make our surface the size of what will ultimately be drawn to it.
// (either the full image size, or the restricted region)
RefPtr<DrawTarget> dt = gfxPlatform::GetPlatform()->
CreateOffscreenContentDrawTarget(IntSize(imageIntSize.width,
imageIntSize.height),
SurfaceFormat::B8G8R8A8);
if (!dt) {
NS_ERROR("Could not create a DrawTarget");
return nullptr;
}
nsRefPtr<gfxContext> context = new gfxContext(dt);
auto result = Draw(context, imageIntSize,
ImageRegion::Create(imageIntSize),
aWhichFrame, GraphicsFilter::FILTER_NEAREST,
Nothing(), aFlags);
return result == DrawResult::SUCCESS ? dt->Snapshot() : nullptr;
}
示例3: imageIntSize
VectorImage::GetFrame(uint32_t aWhichFrame, uint32_t aFlags)
{
// Look up height & width
// ----------------------
SVGSVGElement* svgElem = mSVGDocumentWrapper->GetRootSVGElem();
MOZ_ASSERT(svgElem, "Should have a root SVG elem, since we finished "
"loading without errors");
nsIntSize imageIntSize(svgElem->GetIntrinsicWidth(),
svgElem->GetIntrinsicHeight());
if (imageIntSize.IsEmpty()) {
// We'll get here if our SVG doc has a percent-valued or negative width or
// height.
return nullptr;
}
return GetFrameAtSize(imageIntSize, aWhichFrame, aFlags);
}
示例4:
//******************************************************************************
NS_IMETHODIMP
VectorImage::GetWidth(int32_t* aWidth)
{
if (mError || !mIsFullyLoaded) {
// XXXdholbert Technically we should leave outparam untouched when we
// fail. But since many callers don't check for failure, we set it to 0 on
// failure, for sane/predictable results.
*aWidth = 0;
return NS_ERROR_FAILURE;
}
SVGSVGElement* rootElem = mSVGDocumentWrapper->GetRootSVGElem();
MOZ_ASSERT(rootElem, "Should have a root SVG elem, since we finished "
"loading without errors");
int32_t rootElemWidth = rootElem->GetIntrinsicWidth();
if (rootElemWidth < 0) {
*aWidth = 0;
return NS_ERROR_FAILURE;
}
*aWidth = rootElemWidth;
return NS_OK;
}