コード例 #1
0
ファイル: VectorImage.cpp プロジェクト: AtulKumar2/gecko-dev
/* readonly attribute int32_t height; */
NS_IMETHODIMP
VectorImage::GetHeight(int32_t* aHeight)
{
  if (mError || !mIsFullyLoaded) {
    *aHeight = -1;
  } else {
    SVGSVGElement* rootElem = mSVGDocumentWrapper->GetRootSVGElem();
    MOZ_ASSERT(rootElem, "Should have a root SVG elem, since we finished "
                         "loading without errors");
    *aHeight = rootElem->GetIntrinsicHeight();
  }
  return *aHeight >= 0 ? NS_OK : NS_ERROR_FAILURE;
}
コード例 #2
0
ファイル: VectorImage.cpp プロジェクト: AtulKumar2/gecko-dev
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
0
ファイル: VectorImage.cpp プロジェクト: MekliCZ/positron
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
0
ファイル: VectorImage.cpp プロジェクト: MekliCZ/positron
//******************************************************************************
NS_IMETHODIMP
VectorImage::GetHeight(int32_t* aHeight)
{
  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.
    *aHeight = 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 rootElemHeight = rootElem->GetIntrinsicHeight();
  if (rootElemHeight < 0) {
    *aHeight = 0;
    return NS_ERROR_FAILURE;
  }
  *aHeight = rootElemHeight;
  return NS_OK;
}