当前位置: 首页>>代码示例>>C++>>正文


C++ gfxRect类代码示例

本文整理汇总了C++中gfxRect的典型用法代码示例。如果您正苦于以下问题:C++ gfxRect类的具体用法?C++ gfxRect怎么用?C++ gfxRect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了gfxRect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: NS_NewSVGRect

nsresult
NS_NewSVGRect(mozilla::dom::SVGRect** result, const gfxRect& rect)
{
  return NS_NewSVGRect(result,
                       rect.X(), rect.Y(),
                       rect.Width(), rect.Height());
}
开发者ID:JSilver99,项目名称:mozilla-central,代码行数:7,代码来源:SVGRect.cpp

示例2: ProjectPoint

gfxRect gfx3DMatrix::ProjectRectBounds(const gfxRect& aRect) const
{
  gfxPoint points[4];

  points[0] = ProjectPoint(aRect.TopLeft());
  points[1] = ProjectPoint(gfxPoint(aRect.X() + aRect.Width(), aRect.Y()));
  points[2] = ProjectPoint(gfxPoint(aRect.X(), aRect.Y() + aRect.Height()));
  points[3] = ProjectPoint(gfxPoint(aRect.X() + aRect.Width(),
                                    aRect.Y() + aRect.Height()));

  gfxFloat min_x, max_x;
  gfxFloat min_y, max_y;

  min_x = max_x = points[0].x;
  min_y = max_y = points[0].y;

  for (int i=1; i<4; i++) {
    min_x = min(points[i].x, min_x);
    max_x = max(points[i].x, max_x);
    min_y = min(points[i].y, min_y);
    max_y = max(points[i].y, max_y);
  }

  return gfxRect(min_x, min_y, max_x - min_x, max_y - min_y);
}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:25,代码来源:gfx3DMatrix.cpp

示例3: NS_NewSVGRect

nsresult
NS_NewSVGRect(nsIDOMSVGRect** result, const gfxRect& rect)
{
  return NS_NewSVGRect(result,
                       rect.X(), rect.Y(),
                       rect.Width(), rect.Height());
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:7,代码来源:nsSVGRect.cpp

示例4:

// clipping
void
gfxContext::Clip(const gfxRect& rect)
{
    cairo_new_path(mCairo);
    cairo_rectangle(mCairo, rect.X(), rect.Y(), rect.Width(), rect.Height());
    cairo_clip(mCairo);
}
开发者ID:typ4rk,项目名称:mozilla-history,代码行数:8,代码来源:gfxContext.cpp

示例5: gfxRGBA

void
gfxFontMissingGlyphs::DrawMissingGlyph(gfxContext *aContext, const gfxRect& aRect,
                                       uint32_t aChar)
{
    aContext->Save();

    gfxRGBA currentColor;
    if (!aContext->GetDeviceColor(currentColor)) {
        // We're currently drawing with some kind of pattern... Just draw
        // the missing-glyph data in black.
        currentColor = gfxRGBA(0,0,0,1);
    }

    // Stroke a rectangle so that the stroke's left edge is inset one pixel
    // from the left edge of the glyph box and the stroke's right edge
    // is inset one pixel from the right edge of the glyph box.
    gfxFloat halfBorderWidth = BOX_BORDER_WIDTH/2.0;
    gfxFloat borderLeft = aRect.X() + BOX_HORIZONTAL_INSET + halfBorderWidth;
    gfxFloat borderRight = aRect.XMost() - BOX_HORIZONTAL_INSET - halfBorderWidth;
    gfxRect borderStrokeRect(borderLeft, aRect.Y() + halfBorderWidth,
                             borderRight - borderLeft, aRect.Height() - 2*halfBorderWidth);
    if (!borderStrokeRect.IsEmpty()) {
        aContext->SetLineWidth(BOX_BORDER_WIDTH);
        aContext->SetDash(gfxContext::gfxLineSolid);
        aContext->SetLineCap(gfxContext::LINE_CAP_SQUARE);
        aContext->SetLineJoin(gfxContext::LINE_JOIN_MITER);
        gfxRGBA color = currentColor;
        color.a *= BOX_BORDER_OPACITY;
        aContext->SetDeviceColor(color);
        aContext->NewPath();
        aContext->Rectangle(borderStrokeRect);

#ifdef MOZ_GFX_OPTIMIZE_MOBILE
        aContext->Fill();
#else
        aContext->Stroke();
#endif
    }

#ifndef MOZ_GFX_OPTIMIZE_MOBILE
    gfxPoint center(aRect.X() + aRect.Width()/2,
                    aRect.Y() + aRect.Height()/2);
    gfxFloat halfGap = HEX_CHAR_GAP/2.0;
    gfxFloat top = -(MINIFONT_HEIGHT + halfGap);
    if (aChar < 0x10000) {
        if (aRect.Width() >= 2*MINIFONT_WIDTH + HEX_CHAR_GAP &&
            aRect.Height() >= 2*MINIFONT_HEIGHT + HEX_CHAR_GAP) {
            // Draw 4 digits for BMP
            aContext->SetDeviceColor(currentColor);
            gfxFloat left = -(MINIFONT_WIDTH + halfGap);
            DrawHexChar(aContext,
                        center + gfxPoint(left, top), (aChar >> 12) & 0xF);
            DrawHexChar(aContext,
                        center + gfxPoint(halfGap, top), (aChar >> 8) & 0xF);
            DrawHexChar(aContext,
                        center + gfxPoint(left, halfGap), (aChar >> 4) & 0xF);
            DrawHexChar(aContext,
                        center + gfxPoint(halfGap, halfGap), aChar & 0xF);
        }
    } else {
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:60,代码来源:gfxFontMissingGlyphs.cpp

示例6:

void
gfxASurface::MarkDirty(const gfxRect& r)
{
    cairo_surface_mark_dirty_rectangle(mSurface,
                                       (int) r.X(), (int) r.Y(),
                                       (int) r.Width(), (int) r.Height());
}
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:7,代码来源:gfxASurface.cpp

示例7:

void
gfxASurface::MarkDirty(const gfxRect& r)
{
    if (!mSurfaceValid)
        return;
    cairo_surface_mark_dirty_rectangle(mSurface,
                                       (int) r.X(), (int) r.Y(),
                                       (int) r.Width(), (int) r.Height());
    gfxPlatform::ClearSourceSurfaceForSurface(this);
}
开发者ID:MrKeiKun,项目名称:mozilla-central,代码行数:10,代码来源:gfxASurface.cpp

示例8: PR_MIN

gfxRect
gfxRect::Union(const gfxRect& aRect) const
{
    if (IsEmpty())
        return aRect;
    if (aRect.IsEmpty())
        return *this;

    gfxFloat x = PR_MIN(aRect.X(), X());
    gfxFloat xmost = PR_MAX(aRect.XMost(), XMost());
    gfxFloat y = PR_MIN(aRect.Y(), Y());
    gfxFloat ymost = PR_MAX(aRect.YMost(), YMost());
    return gfxRect(x, y, xmost - x, ymost - y);
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:14,代码来源:gfxRect.cpp

示例9:

gfx3DMatrix
Layer::SnapTransform(const gfx3DMatrix& aTransform,
                     const gfxRect& aSnapRect,
                     gfxMatrix* aResidualTransform)
{
  if (aResidualTransform) {
    *aResidualTransform = gfxMatrix();
  }

  gfxMatrix matrix2D;
  gfx3DMatrix result;
  if (mManager->IsSnappingEffectiveTransforms() &&
      aTransform.Is2D(&matrix2D) &&
      matrix2D.HasNonIntegerTranslation() &&
      !matrix2D.IsSingular() &&
      !matrix2D.HasNonAxisAlignedTransform()) {
    gfxMatrix snappedMatrix;
    gfxPoint topLeft = matrix2D.Transform(aSnapRect.TopLeft());
    topLeft.Round();
    // first compute scale factors that scale aSnapRect to the snapped rect
    if (aSnapRect.IsEmpty()) {
      snappedMatrix.xx = matrix2D.xx;
      snappedMatrix.yy = matrix2D.yy;
    } else {
      gfxPoint bottomRight = matrix2D.Transform(aSnapRect.BottomRight());
      bottomRight.Round();
      snappedMatrix.xx = (bottomRight.x - topLeft.x)/aSnapRect.Width();
      snappedMatrix.yy = (bottomRight.y - topLeft.y)/aSnapRect.Height();
    }
    // compute translation factors that will move aSnapRect to the snapped rect
    // given those scale factors
    snappedMatrix.x0 = topLeft.x - aSnapRect.pos.x*snappedMatrix.xx;
    snappedMatrix.y0 = topLeft.y - aSnapRect.pos.y*snappedMatrix.yy;
    result = gfx3DMatrix::From2D(snappedMatrix);
    if (aResidualTransform && !snappedMatrix.IsSingular()) {
      // set aResidualTransform so that aResidual * snappedMatrix == matrix2D.
      // (i.e., appying snappedMatrix after aResidualTransform gives the
      // ideal transform.
      gfxMatrix snappedMatrixInverse = snappedMatrix;
      snappedMatrixInverse.Invert();
      *aResidualTransform = matrix2D * snappedMatrixInverse;
    }
  } else {
    result = aTransform;
  }
  return result;
}
开发者ID:sahlberg,项目名称:timberwolf,代码行数:47,代码来源:Layers.cpp

示例10: gfxQuad

gfxQuad 
gfx3DMatrix::TransformRect(const gfxRect& aRect) const
{
  gfxPoint points[4];

  points[0] = Transform(aRect.TopLeft());
  points[1] = Transform(gfxPoint(aRect.X() + aRect.Width(), aRect.Y()));
  points[2] = Transform(gfxPoint(aRect.X() + aRect.Width(),
                                 aRect.Y() + aRect.Height()));
  points[3] = Transform(gfxPoint(aRect.X(), aRect.Y() + aRect.Height()));
  
  // Could this ever result in lines that intersect? I don't think so.
  return gfxQuad(points[0], points[1], points[2], points[3]);
}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:14,代码来源:gfx3DMatrix.cpp

示例11: result

gfxRect
gfxRect::Intersect(const gfxRect& aRect) const
{
    gfxRect result(0,0,0,0);

    gfxFloat x = PR_MAX(aRect.X(), X());
    gfxFloat xmost = PR_MIN(aRect.XMost(), XMost());
    if (x >= xmost)
        return result;

    gfxFloat y = PR_MAX(aRect.Y(), Y());
    gfxFloat ymost = PR_MIN(aRect.YMost(), YMost());
    if (y >= ymost)
        return result;

    result = gfxRect(x, y, xmost - x, ymost - y);
    return result;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:18,代码来源:gfxRect.cpp

示例12: snappedRect

// XXX snapToPixels is only valid when snapping for filled
// rectangles and for even-width stroked rectangles.
// For odd-width stroked rectangles, we need to offset x/y by
// 0.5...
void
gfxContext::Rectangle(const gfxRect& rect, bool snapToPixels)
{
    if (snapToPixels) {
        gfxRect snappedRect(rect);

        if (UserToDevicePixelSnapped(snappedRect, PR_TRUE))
        {
            cairo_matrix_t mat;
            cairo_get_matrix(mCairo, &mat);
            cairo_identity_matrix(mCairo);
            Rectangle(snappedRect);
            cairo_set_matrix(mCairo, &mat);

            return;
        }
    }

    cairo_rectangle(mCairo, rect.X(), rect.Y(), rect.Width(), rect.Height());
}
开发者ID:typ4rk,项目名称:mozilla-history,代码行数:24,代码来源:gfxContext.cpp

示例13: if

void
gfxASurface::SetOpaqueRect(const gfxRect& aRect)
{
    if (aRect.IsEmpty()) {
        mOpaqueRect = nullptr;
    } else if (!!mOpaqueRect) {
        *mOpaqueRect = aRect;
    } else {
        mOpaqueRect = MakeUnique<gfxRect>(aRect);
    }
}
开发者ID:ppbao,项目名称:mozilla-os2,代码行数:11,代码来源:gfxASurface.cpp

示例14: PROFILER_LABEL

bool imgFrame::Draw(gfxContext *aContext, GraphicsFilter aFilter,
                    const gfxMatrix &aUserSpaceToImageSpace, const gfxRect& aFill,
                    const nsIntMargin &aPadding, const nsIntRect &aSubimage,
                    uint32_t aImageFlags)
{
  PROFILER_LABEL("image", "imgFrame::Draw");
  NS_ASSERTION(!aFill.IsEmpty(), "zero dest size --- fix caller");
  NS_ASSERTION(!aSubimage.IsEmpty(), "zero source size --- fix caller");
  NS_ASSERTION(!mPalettedImageData, "Directly drawing a paletted image!");

  bool doPadding = aPadding != nsIntMargin(0,0,0,0);
  bool doPartialDecode = !ImageComplete();

  if (mSinglePixel && !doPadding && !doPartialDecode) {
    DoSingleColorFastPath(aContext, mSinglePixelColor, aFill);
    return true;
  }

  gfxMatrix userSpaceToImageSpace = aUserSpaceToImageSpace;
  gfxRect sourceRect = userSpaceToImageSpace.TransformBounds(aFill);
  gfxRect imageRect(0, 0, mSize.width + aPadding.LeftRight(),
                    mSize.height + aPadding.TopBottom());
  gfxRect subimage(aSubimage.x, aSubimage.y, aSubimage.width, aSubimage.height);
  gfxRect fill = aFill;

  NS_ASSERTION(!sourceRect.Intersect(subimage).IsEmpty(),
               "We must be allowed to sample *some* source pixels!");

  nsRefPtr<gfxASurface> surf;
  if (!mSinglePixel) {
    surf = ThebesSurface();
    if (!surf)
      return false;
  }

  bool doTile = !imageRect.Contains(sourceRect) &&
                !(aImageFlags & imgIContainer::FLAG_CLAMP);
  SurfaceWithFormat surfaceResult =
    SurfaceForDrawing(doPadding, doPartialDecode, doTile, aPadding,
                      userSpaceToImageSpace, fill, subimage, sourceRect,
                      imageRect, surf);

  if (surfaceResult.IsValid()) {
    gfxUtils::DrawPixelSnapped(aContext, surfaceResult.mDrawable,
                               userSpaceToImageSpace,
                               subimage, sourceRect, imageRect, fill,
                               surfaceResult.mFormat, aFilter, aImageFlags);
  }
  return true;
}
开发者ID:PatMart,项目名称:gecko-dev,代码行数:50,代码来源:imgFrame.cpp

示例15: GetPatternMatrix

// Given the matrix for the pattern element's own transform, this returns a
// combined matrix including the transforms applicable to its target.
static Matrix
GetPatternMatrix(uint16_t aPatternUnits,
                 const Matrix &patternTransform,
                 const gfxRect &bbox,
                 const gfxRect &callerBBox,
                 const Matrix &callerCTM)
{
  // We really want the pattern matrix to handle translations
  gfxFloat minx = bbox.X();
  gfxFloat miny = bbox.Y();

  if (aPatternUnits == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
    minx += callerBBox.X();
    miny += callerBBox.Y();
  }

  float scale = 1.0f / MaxExpansion(callerCTM);
  Matrix patternMatrix = patternTransform;
  patternMatrix.PreScale(scale, scale);
  patternMatrix.PreTranslate(minx, miny);

  return patternMatrix;
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:25,代码来源:nsSVGPatternFrame.cpp


注:本文中的gfxRect类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。