本文整理汇总了C++中SkIRect::set方法的典型用法代码示例。如果您正苦于以下问题:C++ SkIRect::set方法的具体用法?C++ SkIRect::set怎么用?C++ SkIRect::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkIRect
的用法示例。
在下文中一共展示了SkIRect::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void RenderSkinButton::Draw(SkCanvas* canvas, const IntRect& r, RenderSkinAndroid::State newState)
{
// If we failed to decode, do nothing. This way the browser still works,
// and webkit will still draw the label and layout space for us.
if (!gDecoded) {
return;
}
// Ensure that the state is within the valid range of our array.
SkASSERT(static_cast<unsigned>(newState) <
static_cast<unsigned>(RenderSkinAndroid::kNumStates));
// Set up the ninepatch information for drawing.
SkRect bounds(r);
const PatchData& pd = gFiles[newState];
int marginValue = pd.margin + pd.outset;
SkIRect margin;
margin.set(marginValue, marginValue, marginValue, marginValue);
if (gHighRes) {
/* FIXME: it shoudn't be necessary to offset the button here,
but gives the right results. */
bounds.offset(0, SK_Scalar1 * 2);
/* FIXME: This temporarily gets around the fact that the margin values and
positioning were created for a low res asset, which was used on
g1-like devices. A better fix would be to read the offset information
out of the png. */
margin.set(10, 9, 10, 14);
}
// Draw to the canvas.
SkNinePatch::DrawNine(canvas, bounds, gButton[newState], margin);
}
示例2: paintThumb
void ScrollbarThemeChromiumLinux::paintThumb(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect)
{
const bool hovered = scrollbar->hoveredPart() == ThumbPart;
const int midx = rect.x() + rect.width() / 2;
const int midy = rect.y() + rect.height() / 2;
const bool vertical = scrollbar->orientation() == VerticalScrollbar;
SkCanvas* const canvas = gc->platformContext()->canvas();
SkScalar thumb[3];
SkColorToHSV(hovered
? PlatformThemeChromiumGtk::thumbActiveColor()
: PlatformThemeChromiumGtk::thumbInactiveColor(),
thumb);
SkPaint paint;
paint.setColor(PlatformThemeChromiumGtk::saturateAndBrighten(thumb, 0, 0.02));
SkIRect skrect;
if (vertical)
skrect.set(rect.x(), rect.y(), midx + 1, rect.y() + rect.height());
else
skrect.set(rect.x(), rect.y(), rect.x() + rect.width(), midy + 1);
canvas->drawIRect(skrect, paint);
paint.setColor(PlatformThemeChromiumGtk::saturateAndBrighten(thumb, 0, -0.02));
if (vertical)
skrect.set(midx + 1, rect.y(), rect.x() + rect.width(), rect.y() + rect.height());
else
skrect.set(rect.x(), midy + 1, rect.x() + rect.width(), rect.y() + rect.height());
canvas->drawIRect(skrect, paint);
SkScalar track[3];
SkColorToHSV(PlatformThemeChromiumGtk::trackColor(), track);
paint.setColor(PlatformThemeChromiumGtk::outlineColor(track, thumb));
drawBox(canvas, rect, paint);
if (rect.height() > 10 && rect.width() > 10) {
const int grippyHalfWidth = 2;
const int interGrippyOffset = 3;
if (vertical) {
drawHorizLine(canvas, midx - grippyHalfWidth, midx + grippyHalfWidth, midy - interGrippyOffset, paint);
drawHorizLine(canvas, midx - grippyHalfWidth, midx + grippyHalfWidth, midy, paint);
drawHorizLine(canvas, midx - grippyHalfWidth, midx + grippyHalfWidth, midy + interGrippyOffset, paint);
} else {
drawVertLine(canvas, midx - interGrippyOffset, midy - grippyHalfWidth, midy + grippyHalfWidth, paint);
drawVertLine(canvas, midx, midy - grippyHalfWidth, midy + grippyHalfWidth, paint);
drawVertLine(canvas, midx + interGrippyOffset, midy - grippyHalfWidth, midy + grippyHalfWidth, paint);
}
}
}
示例3: show_bm
static void show_bm(SkCanvas* canvas, int width, int height, SkColor color) {
SkBitmap bm;
make_bm(&bm, width, height, color);
SkPaint paint;
SkRect r;
SkIRect ir;
paint.setStyle(SkPaint::kStroke_Style);
ir.set(0, 0, 128, 128);
r.set(ir);
canvas->save();
canvas->clipRect(r);
canvas->drawBitmap(bm, 0, 0, NULL);
canvas->restore();
canvas->drawRect(r, paint);
r.offset(SkIntToScalar(150), 0);
// exercises extract bitmap, but not shader
canvas->drawBitmapRect(bm, &ir, r, NULL);
canvas->drawRect(r, paint);
r.offset(SkIntToScalar(150), 0);
// exercises bitmapshader
canvas->drawBitmapRect(bm, NULL, r, NULL);
canvas->drawRect(r, paint);
}
示例4: webRectToSkIRect
static SkIRect webRectToSkIRect(const WebRect& webRect)
{
SkIRect irect;
irect.set(webRect.x, webRect.y,
webRect.x + webRect.width - 1, webRect.y + webRect.height - 1);
return irect;
}
示例5: onDraw
virtual void onDraw(SkCanvas* canvas) {
this->drawBG(canvas);
// canvas->scale(1.5f, 1.5f);
canvas->drawBitmap(fBM, 0, 0);
SkIRect margins;
SkRect dst;
int d = 25;
margins.set(d, d, d, d);
margins.fLeft = fBM.width()/2 - 1;
margins.fTop = fBM.height()/2 - 1;
margins.fRight = fBM.width() - margins.fLeft - 1;
margins.fBottom = fBM.height() - margins.fTop - 1;
// canvas->translate(fX/5, fY/5);
canvas->translate(0, 76);
dst.set(0, 0, SkIntToScalar(200), SkIntToScalar(200));
SkPaint paint;
paint.setAntiAlias(false);
paint.setDither(true);
paint.setFilterBitmap(false);
// SkNinePatch::DrawNine(canvas, dst, fBM, margins, &paint);
test_rects(canvas, fBM, &paint);
}
示例6: addCornerArc
void addCornerArc(SkPath* path, const SkRect& rect, const IntSize& size, int startAngle)
{
SkIRect ir;
int rx = SkMin32(SkScalarRound(rect.width()), size.width());
int ry = SkMin32(SkScalarRound(rect.height()), size.height());
ir.set(-rx, -ry, rx, ry);
switch (startAngle) {
case 0:
ir.offset(rect.fRight - ir.fRight, rect.fBottom - ir.fBottom);
break;
case 90:
ir.offset(rect.fLeft - ir.fLeft, rect.fBottom - ir.fBottom);
break;
case 180:
ir.offset(rect.fLeft - ir.fLeft, rect.fTop - ir.fTop);
break;
case 270:
ir.offset(rect.fRight - ir.fRight, rect.fTop - ir.fTop);
break;
default:
ASSERT(0);
}
SkRect r;
r.set(ir);
path->arcTo(r, SkIntToScalar(startAngle), SkIntToScalar(90), false);
}
示例7: clipRegionOp
bool Snapshot::clipRegionOp(float left, float top, float right, float bottom, SkRegion::Op op) {
SkIRect tmp;
tmp.set(left, top, right, bottom);
clipRegion->op(tmp, op);
copyClipRectFromRegion();
return true;
}
示例8: Draw
void RenderSkinButton::Draw(SkCanvas* canvas, const IntRect& r, RenderSkinAndroid::State newState)
{
// If we failed to decode, do nothing. This way the browser still works,
// and webkit will still draw the label and layout space for us.
if (!gDecoded) {
return;
}
// Ensure that the state is within the valid range of our array.
SkASSERT(static_cast<unsigned>(newState) <
static_cast<unsigned>(RenderSkinAndroid::kNumStates));
// Set up the ninepatch information for drawing.
SkRect bounds;
android_setrect(&bounds, r);
const PatchData& pd = gFiles[newState];
int marginValue = pd.margin + pd.outset;
SkIRect margin;
margin.set(marginValue, marginValue, marginValue, marginValue);
// Draw to the canvas.
SkNinePatch::DrawNine(canvas, bounds, gButton[newState], margin);
}
示例9: onDraw
virtual void onDraw(SkCanvas* canvas)
{
this->drawBG(canvas);
canvas->drawBitmap(fBitmap, 0, 0, NULL);
SkIRect subset;
const int SRC_WIDTH = 16;
const int SRC_HEIGHT = 16;
subset.set(0, 0, SRC_WIDTH, SRC_HEIGHT);
subset.offset(fCurrX, fCurrY);
SkDebugf("---- src x=%d y=%d\n", subset.fLeft, subset.fTop);
SkRect dst0, dst1;
SkScalar y = SkIntToScalar(fBitmap.height() + 16);
dst0.set(SkIntToScalar(50), y,
SkIntToScalar(50+SRC_WIDTH),
y + SkIntToScalar(SRC_HEIGHT));
dst1 = dst0;
dst1.offset(SkIntToScalar(200), 0);
dst1.fRight = dst1.fLeft + 8 * dst0.width();
dst1.fBottom = dst1.fTop + 8 * dst0.height();
canvas->drawBitmapRect(fBitmap, &subset, dst0, NULL);
canvas->drawBitmapRect(fBitmap, &subset, dst1, NULL);
SkPaint paint;
paint.setColor(0x88FF0000);
canvas->drawRect(dst0, paint);
paint.setColor(0x880000FF);
canvas->drawRect(dst1, paint);
}
示例10: nestedBoxes
void WebTestThemeControlWin::nestedBoxes(int indentLeft, int indentTop, int indentRight, int indentBottom, SkColor outerColor, SkColor innerColor)
{
SkIRect lirect;
box(m_irect, outerColor);
lirect.set(m_irect.fLeft + indentLeft, m_irect.fTop + indentTop, m_irect.fRight - indentRight, m_irect.fBottom - indentBottom);
box(lirect, innerColor);
}
示例11: inval
void SkPageFlipper::inval(const SkIRect& rect) {
SkIRect r;
r.set(0, 0, fWidth, fHeight);
if (r.intersect(rect)) {
fDirty1->op(r, SkRegion::kUnion_Op);
}
}
示例12: boolTojboolean
static jboolean Region_op0(JNIEnv* env, jobject, jlong dstHandle, jint left, jint top, jint right, jint bottom, jint op) {
SkRegion* dst = reinterpret_cast<SkRegion*>(dstHandle);
SkIRect ir;
ir.set(left, top, right, bottom);
bool result = dst->op(ir, (SkRegion::Op)op);
return boolTojboolean(result);
}
示例13: make_rgn
static void make_rgn(SkRegion* rgn, int left, int top, int right, int bottom,
size_t count, int32_t runs[]) {
SkIRect r;
r.set(left, top, right, bottom);
rgn->debugSetRuns(runs, count);
SkASSERT(rgn->getBounds() == r);
}
示例14: SkASSERT
// stolen from SkDraw.cpp - D1G_NoBounder_RectClip
static void SkGL_Draw1Glyph(const SkDraw1Glyph& state, const SkGlyph& glyph,
int x, int y) {
SkASSERT(glyph.fWidth > 0 && glyph.fHeight > 0);
SkGLDrawProcs* procs = (SkGLDrawProcs*)state.fDraw->fProcs;
x += glyph.fLeft;
y += glyph.fTop;
// check if we're clipped out (nothing to draw)
SkIRect bounds;
bounds.set(x, y, x + glyph.fWidth, y + glyph.fHeight);
if (!SkIRect::Intersects(state.fClip->getBounds(), bounds)) {
return;
}
// now dig up our texture cache
SkGlyphCache* gcache = state.fCache;
void* auxData;
SkGLTextCache* textCache = NULL;
if (gcache->getAuxProcData(SkGLDevice::GlyphCacheAuxProc, &auxData)) {
textCache = (SkGLTextCache*)auxData;
}
if (NULL == textCache) {
// need to create one
textCache = SkNEW(SkGLTextCache);
gcache->setAuxProc(SkGLDevice::GlyphCacheAuxProc, textCache);
}
int offset;
SkGLTextCache::Strike* strike = textCache->findGlyph(glyph, &offset);
if (NULL == strike) {
// make sure the glyph has an image
uint8_t* aa = (uint8_t*)glyph.fImage;
if (NULL == aa) {
aa = (uint8_t*)gcache->findImage(glyph);
if (NULL == aa) {
return; // can't rasterize glyph
}
}
strike = textCache->addGlyphAndBind(glyph, aa, &offset);
if (NULL == strike) {
// too big to cache, need to draw as is...
return;
}
}
const int shiftW = strike->widthShift();
const int shiftH = strike->heightShift();
SkFixed left = offset << (16 - shiftW);
SkFixed right = (offset + glyph.fWidth) << (16 - shiftW);
SkFixed bottom = glyph.fHeight << (16 - shiftH);
procs->addQuad(strike->texture(), x, y, glyph, left, right, bottom);
}
示例15: paintSliderThumb
bool RenderThemeChromiumSkia::paintSliderThumb(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
{
// Make a thumb similar to the scrollbar thumb.
const bool hovered = isHovered(o) || toRenderSlider(o->parent())->inDragMode();
const int midx = rect.x() + rect.width() / 2;
const int midy = rect.y() + rect.height() / 2;
const bool vertical = (o->style()->appearance() == SliderThumbVerticalPart);
SkCanvas* const canvas = i.context->platformContext()->canvas();
const SkColor thumbLightGrey = SkColorSetARGB(0xff, 0xf4, 0xf2, 0xef);
const SkColor thumbDarkGrey = SkColorSetARGB(0xff, 0xea, 0xe5, 0xe0);
SkPaint paint;
paint.setColor(hovered ? SK_ColorWHITE : thumbLightGrey);
SkIRect skrect;
if (vertical)
skrect.set(rect.x(), rect.y(), midx + 1, rect.bottom());
else
skrect.set(rect.x(), rect.y(), rect.right(), midy + 1);
canvas->drawIRect(skrect, paint);
paint.setColor(hovered ? thumbLightGrey : thumbDarkGrey);
if (vertical)
skrect.set(midx + 1, rect.y(), rect.right(), rect.bottom());
else
skrect.set(rect.x(), midy + 1, rect.right(), rect.bottom());
canvas->drawIRect(skrect, paint);
const SkColor borderDarkGrey = SkColorSetARGB(0xff, 0x9d, 0x96, 0x8e);
paint.setColor(borderDarkGrey);
drawBox(canvas, rect, paint);
if (rect.height() > 10 && rect.width() > 10) {
drawHorizLine(canvas, midx - 2, midx + 2, midy, paint);
drawHorizLine(canvas, midx - 2, midx + 2, midy - 3, paint);
drawHorizLine(canvas, midx - 2, midx + 2, midy + 3, paint);
}
return false;
}