本文整理汇总了C++中gfx::Rect类的典型用法代码示例。如果您正苦于以下问题:C++ Rect类的具体用法?C++ Rect怎么用?C++ Rect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Rect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rectgrid
static void rectgrid(ui::Graphics* g, const gfx::Rect& rc, const gfx::Size& tile)
{
if (tile.w < 1 || tile.h < 1)
return;
int x, y, u, v;
gfx::Color c1 = gfx::rgba(128, 128, 128);
gfx::Color c2 = gfx::rgba(192, 192, 192);
u = 0;
v = 0;
for (y=rc.y; y<rc.y2()-tile.h; y+=tile.h) {
for (x=rc.x; x<rc.x2()-tile.w; x+=tile.w)
g->fillRect(((u++)&1)? c1: c2, gfx::Rect(x, y, tile.w, tile.h));
if (x < rc.x2())
g->fillRect(((u++)&1)? c1: c2, gfx::Rect(x, y, rc.x2()-x, tile.h));
u = (++v);
}
if (y < rc.y2()) {
for (x=rc.x; x<rc.x2()-tile.w; x+=tile.w)
g->fillRect(((u++)&1)? c1: c2, gfx::Rect(x, y, tile.w, rc.y2()-y));
if (x < rc.x2())
g->fillRect(((u++)&1)? c1: c2, gfx::Rect(x, y, rc.x2()-x, rc.y2()-y));
}
}
示例2: DrawSurfaceWithTextureCoords
static void
DrawSurfaceWithTextureCoords(DrawTarget *aDest,
const gfx::Rect& aDestRect,
SourceSurface *aSource,
const gfx::Rect& aTextureCoords,
gfx::Filter aFilter,
float aOpacity,
SourceSurface *aMask,
const Matrix* aMaskTransform)
{
// Convert aTextureCoords into aSource's coordinate space
gfxRect sourceRect(aTextureCoords.x * aSource->GetSize().width,
aTextureCoords.y * aSource->GetSize().height,
aTextureCoords.width * aSource->GetSize().width,
aTextureCoords.height * aSource->GetSize().height);
// Floating point error can accumulate above and we know our visible region
// is integer-aligned, so round it out.
sourceRect.Round();
// Compute a transform that maps sourceRect to aDestRect.
Matrix matrix =
gfxUtils::TransformRectToRect(sourceRect,
gfx::IntPoint(aDestRect.x, aDestRect.y),
gfx::IntPoint(aDestRect.XMost(), aDestRect.y),
gfx::IntPoint(aDestRect.XMost(), aDestRect.YMost()));
// Only use REPEAT if aTextureCoords is outside (0, 0, 1, 1).
gfx::Rect unitRect(0, 0, 1, 1);
ExtendMode mode = unitRect.Contains(aTextureCoords) ? ExtendMode::CLAMP : ExtendMode::REPEAT;
FillRectWithMask(aDest, aDestRect, aSource, aFilter, DrawOptions(aOpacity),
mode, aMask, aMaskTransform, &matrix);
}
示例3: SetAbsoluteBounds
void BrowserBubble::SetAbsoluteBounds(const gfx::Rect& window_bounds)
{
// Convert screen coordinates to frame relative.
gfx::Point relative_origin = window_bounds.origin();
view::View::ConvertPointToView(NULL, frame_->GetRootView(),
&relative_origin);
SetBounds(relative_origin.x(), relative_origin.y(),
window_bounds.width(), window_bounds.height());
}
示例4: NonClientTopBorderHeight
gfx::Rect CustomFrameView::GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const
{
int top_height = NonClientTopBorderHeight();
int border_thickness = NonClientBorderThickness();
return gfx::Rect(std::max(0, client_bounds.x()-border_thickness),
std::max(0, client_bounds.y()-top_height),
client_bounds.width()+(2*border_thickness),
client_bounds.height()+top_height+border_thickness);
}
示例5: jniFrame
void
AndroidGeckoLayerClient::SetPageRect(const gfx::Rect& aCssPageRect)
{
NS_ASSERTION(!isNull(), "SetPageRect called on null layer client!");
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
if (!env)
return;
AutoLocalJNIFrame jniFrame(env, 0);
return env->CallVoidMethod(wrapped_obj, jSetPageRect,
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost());
}
示例6: device
void
CompositorD3D9::ClearRect(const gfx::Rect& aRect)
{
D3DRECT rect;
rect.x1 = aRect.X();
rect.y1 = aRect.Y();
rect.x2 = aRect.XMost();
rect.y2 = aRect.YMost();
device()->Clear(1, &rect, D3DCLEAR_TARGET,
0x00000000, 0, 0);
}
示例7: DrawQuad
void
Compositor::DrawGeometry(const gfx::Rect& aRect,
const gfx::IntRect& aClipRect,
const EffectChain& aEffectChain,
gfx::Float aOpacity,
const gfx::Matrix4x4& aTransform,
const gfx::Rect& aVisibleRect,
const Maybe<gfx::Polygon3D>& aGeometry)
{
if (!aGeometry) {
DrawQuad(aRect, aClipRect, aEffectChain,
aOpacity, aTransform, aVisibleRect);
return;
}
// Cull invisible polygons.
if (aRect.Intersect(aGeometry->BoundingBox()).IsEmpty()) {
return;
}
gfx::Polygon3D clipped = aGeometry->ClipPolygon(aRect);
nsTArray<gfx::Triangle> triangles = clipped.ToTriangles();
for (gfx::Triangle& geometry : triangles) {
const gfx::Rect intersection = aRect.Intersect(geometry.BoundingBox());
// Cull invisible triangles.
if (intersection.IsEmpty()) {
continue;
}
MOZ_ASSERT(aRect.width > 0.0f && aRect.height > 0.0f);
MOZ_ASSERT(intersection.width > 0.0f && intersection.height > 0.0f);
gfx::TexturedTriangle triangle(Move(geometry));
triangle.width = aRect.width;
triangle.height = aRect.height;
// Since the texture was created for non-split geometry, we need to
// update the texture coordinates to account for the split.
if (aEffectChain.mPrimaryEffect->mType == EffectTypes::RGB) {
TexturedEffect* texturedEffect =
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
UpdateTextureCoordinates(triangle, aRect, intersection,
texturedEffect->mTextureCoords);
}
DrawTriangle(triangle, aClipRect, aEffectChain,
aOpacity, aTransform, aVisibleRect);
}
}
示例8: SharesEdgeWith
bool Rect::SharesEdgeWith(const gfx::Rect& rect) const
{
return (y()==rect.y() && height()==rect.height() &&
(x()==rect.right() || right()==rect.x())) ||
(x()==rect.x() && width()==rect.width() &&
(y()==rect.bottom() || bottom()==rect.y()));
}
示例9: fill_rect
void fill_rect(Image* image, const gfx::Rect& rc, color_t c)
{
gfx::Rect clip = rc.createIntersect(image->bounds());
if (!clip.isEmpty())
image->fillRect(clip.x, clip.y,
clip.x+clip.w-1, clip.y+clip.h-1, c);
}
示例10: create
void ExtraCel::create(doc::Sprite* sprite,
const gfx::Rect& bounds,
doc::frame_t frame,
int opacity)
{
ASSERT(sprite);
if (!m_image ||
m_image->pixelFormat() != sprite->pixelFormat() ||
m_image->width() != bounds.w ||
m_image->height() != bounds.h) {
if (!m_imageBuffer)
m_imageBuffer.reset(new doc::ImageBuffer(1));
doc::Image* newImage = doc::Image::create(sprite->pixelFormat(),
bounds.w, bounds.h,
m_imageBuffer);
m_image.reset(newImage);
}
if (!m_cel) {
// Ignored fields for this cel (frame, and image index)
m_cel.reset(new doc::Cel(doc::frame_t(0), doc::ImageRef(nullptr)));
}
m_cel->setPosition(bounds.getOrigin());
m_cel->setOpacity(opacity);
m_cel->setFrame(frame);
}
示例11: WithImage
ClearRect::ClearRect(Cel* cel, const gfx::Rect& bounds)
{
app::Document* doc = static_cast<app::Document*>(cel->document());
Image* image = (cel ? cel->image(): NULL);
if (!image)
return;
m_offsetX = bounds.x - cel->x();
m_offsetY = bounds.y - cel->y();
gfx::Rect bounds2 =
image->bounds().createIntersection(
gfx::Rect(
m_offsetX, m_offsetY,
bounds.w, bounds.h));
if (bounds.isEmpty())
return;
m_dstImage.reset(new WithImage(image));
m_bgcolor = doc->bgColor(cel->layer());
m_copy.reset(crop_image(image,
bounds2.x, bounds2.y, bounds2.w, bounds2.h, m_bgcolor));
}
示例12: PaintText
void Label::PaintText(gfx::Canvas* canvas,
const std::wstring& text,
const gfx::Rect& text_bounds,
int flags)
{
canvas->DrawStringInt(text, font_, color_,
text_bounds.x(), text_bounds.y(),
text_bounds.width(), text_bounds.height(), flags);
if(HasFocus() || paint_as_focused_)
{
gfx::Rect focus_bounds = text_bounds;
focus_bounds.Inset(-kFocusBorderPadding, -kFocusBorderPadding);
canvas->DrawFocusRect(focus_bounds.x(), focus_bounds.y(),
focus_bounds.width(), focus_bounds.height());
}
}
示例13: DrawRegion
void Layer::DrawRegion(const ui::TextureDrawParams& params,
const gfx::Rect& region_to_draw)
{
if(!region_to_draw.IsEmpty())
{
texture_->Draw(params, region_to_draw);
}
}
示例14: fillAreaBetweenRects
void Graphics::fillAreaBetweenRects(gfx::Color color,
const gfx::Rect& outer, const gfx::Rect& inner)
{
if (!outer.intersects(inner))
fillRect(color, outer);
else {
gfx::Region rgn(outer);
rgn.createSubtraction(rgn, gfx::Region(inner));
fillRegion(color, rgn);
}
}
示例15: switch
Dirty::Dirty(Image* image, Image* image_diff, const gfx::Rect& bounds)
: m_format(image->getPixelFormat())
, m_x1(bounds.x), m_y1(bounds.y)
, m_x2(bounds.x2()-1), m_y2(bounds.y2()-1)
{
int y, x1, x2;
for (y=m_y1; y<=m_y2; y++) {
x1 = m_x1;
x2 = m_x2;
bool res;
switch (image->getPixelFormat()) {
case IMAGE_RGB:
res = shrink_row<RgbTraits>(image, image_diff, x1, y, x2);
break;
case IMAGE_GRAYSCALE:
res = shrink_row<GrayscaleTraits>(image, image_diff, x1, y, x2);
break;
case IMAGE_INDEXED:
res = shrink_row<IndexedTraits>(image, image_diff, x1, y, x2);
break;
default:
ASSERT(false && "Not implemented for bitmaps");
return;
}
if (!res)
continue;
Col* col = new Col(x1, x2-x1+1);
col->data.resize(getLineSize(col->w));
Row* row = new Row(y);
row->cols.push_back(col);
m_rows.push_back(row);
}
}