本文整理汇总了C++中SkIRect::right方法的典型用法代码示例。如果您正苦于以下问题:C++ SkIRect::right方法的具体用法?C++ SkIRect::right怎么用?C++ SkIRect::right使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkIRect
的用法示例。
在下文中一共展示了SkIRect::right方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onFilterImage
bool SkMatrixConvolutionImageFilter::onFilterImage(Proxy* proxy,
const SkBitmap& source,
const Context& ctx,
SkBitmap* result,
SkIPoint* offset) const {
SkBitmap src = source;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
if (!this->filterInput(0, proxy, source, ctx, &src, &srcOffset)) {
return false;
}
if (src.colorType() != kN32_SkColorType) {
return false;
}
SkIRect bounds;
if (!this->applyCropRect(ctx, proxy, src, &srcOffset, &bounds, &src)) {
return false;
}
if (!fConvolveAlpha && !src.isOpaque()) {
src = unpremultiplyBitmap(proxy, src);
}
SkAutoLockPixels alp(src);
if (!src.getPixels()) {
return false;
}
SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds.height()));
if (!device) {
return false;
}
*result = device->accessBitmap(false);
SkAutoLockPixels alp_result(*result);
offset->fX = bounds.fLeft;
offset->fY = bounds.fTop;
bounds.offset(-srcOffset);
SkIRect interior = SkIRect::MakeXYWH(bounds.left() + fKernelOffset.fX,
bounds.top() + fKernelOffset.fY,
bounds.width() - fKernelSize.fWidth + 1,
bounds.height() - fKernelSize.fHeight + 1);
SkIRect top = SkIRect::MakeLTRB(bounds.left(), bounds.top(), bounds.right(), interior.top());
SkIRect bottom = SkIRect::MakeLTRB(bounds.left(), interior.bottom(),
bounds.right(), bounds.bottom());
SkIRect left = SkIRect::MakeLTRB(bounds.left(), interior.top(),
interior.left(), interior.bottom());
SkIRect right = SkIRect::MakeLTRB(interior.right(), interior.top(),
bounds.right(), interior.bottom());
filterBorderPixels(src, result, top, bounds);
filterBorderPixels(src, result, left, bounds);
filterInteriorPixels(src, result, interior, bounds);
filterBorderPixels(src, result, right, bounds);
filterBorderPixels(src, result, bottom, bounds);
return true;
}
示例2: computeDisplacement
void computeDisplacement(Extractor ex, const SkVector& scale, SkBitmap* dst,
const SkBitmap& displ, const SkIPoint& offset,
const SkBitmap& src,
const SkIRect& bounds) {
static const SkScalar Inv8bit = SkScalarInvert(255);
const int srcW = src.width();
const int srcH = src.height();
const SkVector scaleForColor = SkVector::Make(scale.fX * Inv8bit, scale.fY * Inv8bit);
const SkVector scaleAdj = SkVector::Make(SK_ScalarHalf - scale.fX * SK_ScalarHalf,
SK_ScalarHalf - scale.fY * SK_ScalarHalf);
SkPMColor* dstPtr = dst->getAddr32(0, 0);
for (int y = bounds.top(); y < bounds.bottom(); ++y) {
const SkPMColor* displPtr = displ.getAddr32(bounds.left() + offset.fX, y + offset.fY);
for (int x = bounds.left(); x < bounds.right(); ++x, ++displPtr) {
SkPMColor c = unpremul_pm(*displPtr);
SkScalar displX = scaleForColor.fX * ex.getX(c) + scaleAdj.fX;
SkScalar displY = scaleForColor.fY * ex.getY(c) + scaleAdj.fY;
// Truncate the displacement values
const int32_t srcX = Sk32_sat_add(x, SkScalarTruncToInt(displX));
const int32_t srcY = Sk32_sat_add(y, SkScalarTruncToInt(displY));
*dstPtr++ = ((srcX < 0) || (srcX >= srcW) || (srcY < 0) || (srcY >= srcH)) ?
0 : *(src.getAddr32(srcX, srcY));
}
}
}
示例3: validateBounds
void validateBounds(SkCanvas* canvas) {
#ifdef SK_DEBUG
SkIRect bounds = canvas->getDeviceClipBounds();
SkASSERT(bounds.right()-bounds.left() >= W);
SkASSERT(bounds.bottom()-bounds.top() >= H);
#endif
}
示例4: insert
void SkTileGrid::insert(void* data, const SkRect& fbounds, bool) {
SkASSERT(!fbounds.isEmpty());
SkIRect dilatedBounds;
if (fbounds.isLargest()) {
// Dilating the largest SkIRect will overflow. Other nearly-largest rects may overflow too,
// but we don't make active use of them like we do the largest.
dilatedBounds.setLargest();
} else {
fbounds.roundOut(&dilatedBounds);
dilatedBounds.outset(fInfo.fMargin.width(), fInfo.fMargin.height());
dilatedBounds.offset(fInfo.fOffset);
}
const SkIRect gridBounds =
{ 0, 0, fInfo.fTileInterval.width() * fXTiles, fInfo.fTileInterval.height() * fYTiles };
if (!SkIRect::Intersects(dilatedBounds, gridBounds)) {
return;
}
// Note: SkIRects are non-inclusive of the right() column and bottom() row,
// hence the "-1"s in the computations of maxX and maxY.
int minX = SkMax32(0, SkMin32(dilatedBounds.left() / fInfo.fTileInterval.width(), fXTiles - 1));
int minY = SkMax32(0, SkMin32(dilatedBounds.top() / fInfo.fTileInterval.height(), fYTiles - 1));
int maxX = SkMax32(0, SkMin32((dilatedBounds.right() - 1) / fInfo.fTileInterval.width(),
fXTiles - 1));
int maxY = SkMax32(0, SkMin32((dilatedBounds.bottom() - 1) / fInfo.fTileInterval.height(),
fYTiles - 1));
Entry entry = { fCount++, data };
for (int y = minY; y <= maxY; y++) {
for (int x = minX; x <= maxX; x++) {
fTiles[y * fXTiles + x].push(entry);
}
}
}
示例5: onHandleInval
void SkExampleWindow::onHandleInval(const SkIRect& rect) {
RECT winRect;
winRect.top = rect.top();
winRect.bottom = rect.bottom();
winRect.right = rect.right();
winRect.left = rect.left();
InvalidateRect((HWND)this->getHWND(), &winRect, false);
}
示例6: MakeIRect
Json::Value SkJSONCanvas::MakeIRect(const SkIRect& rect) {
Json::Value result(Json::arrayValue);
result.append(Json::Value(rect.left()));
result.append(Json::Value(rect.top()));
result.append(Json::Value(rect.right()));
result.append(Json::Value(rect.bottom()));
return result;
}
示例7: apply_morphology_pass
static void apply_morphology_pass(GrRenderTargetContext* renderTargetContext,
const GrClip& clip,
sk_sp<GrTextureProxy> textureProxy,
const SkIRect& srcRect,
const SkIRect& dstRect,
int radius,
GrMorphologyEffect::Type morphType,
GrMorphologyEffect::Direction direction) {
float bounds[2] = { 0.0f, 1.0f };
SkIRect lowerSrcRect = srcRect, lowerDstRect = dstRect;
SkIRect middleSrcRect = srcRect, middleDstRect = dstRect;
SkIRect upperSrcRect = srcRect, upperDstRect = dstRect;
if (direction == GrMorphologyEffect::Direction::kX) {
bounds[0] = SkIntToScalar(srcRect.left()) + 0.5f;
bounds[1] = SkIntToScalar(srcRect.right()) - 0.5f;
lowerSrcRect.fRight = srcRect.left() + radius;
lowerDstRect.fRight = dstRect.left() + radius;
upperSrcRect.fLeft = srcRect.right() - radius;
upperDstRect.fLeft = dstRect.right() - radius;
middleSrcRect.inset(radius, 0);
middleDstRect.inset(radius, 0);
} else {
bounds[0] = SkIntToScalar(srcRect.top()) + 0.5f;
bounds[1] = SkIntToScalar(srcRect.bottom()) - 0.5f;
lowerSrcRect.fBottom = srcRect.top() + radius;
lowerDstRect.fBottom = dstRect.top() + radius;
upperSrcRect.fTop = srcRect.bottom() - radius;
upperDstRect.fTop = dstRect.bottom() - radius;
middleSrcRect.inset(0, radius);
middleDstRect.inset(0, radius);
}
if (middleSrcRect.width() <= 0) {
// radius covers srcRect; use bounds over entire draw
apply_morphology_rect(renderTargetContext, clip, std::move(textureProxy),
srcRect, dstRect, radius, morphType, bounds, direction);
} else {
// Draw upper and lower margins with bounds; middle without.
apply_morphology_rect(renderTargetContext, clip, textureProxy,
lowerSrcRect, lowerDstRect, radius, morphType, bounds, direction);
apply_morphology_rect(renderTargetContext, clip, textureProxy,
upperSrcRect, upperDstRect, radius, morphType, bounds, direction);
apply_morphology_rect_no_bounds(renderTargetContext, clip, std::move(textureProxy),
middleSrcRect, middleDstRect, radius, morphType, direction);
}
}
示例8: apply_morphology_pass
static void apply_morphology_pass(GrDrawContext* drawContext,
const GrClip& clip,
GrTexture* texture,
const SkIRect& srcRect,
const SkIRect& dstRect,
int radius,
GrMorphologyEffect::MorphologyType morphType,
Gr1DKernelEffect::Direction direction) {
float bounds[2] = { 0.0f, 1.0f };
SkIRect lowerSrcRect = srcRect, lowerDstRect = dstRect;
SkIRect middleSrcRect = srcRect, middleDstRect = dstRect;
SkIRect upperSrcRect = srcRect, upperDstRect = dstRect;
if (direction == Gr1DKernelEffect::kX_Direction) {
bounds[0] = (SkIntToScalar(srcRect.left()) + 0.5f) / texture->width();
bounds[1] = (SkIntToScalar(srcRect.right()) - 0.5f) / texture->width();
lowerSrcRect.fRight = srcRect.left() + radius;
lowerDstRect.fRight = dstRect.left() + radius;
upperSrcRect.fLeft = srcRect.right() - radius;
upperDstRect.fLeft = dstRect.right() - radius;
middleSrcRect.inset(radius, 0);
middleDstRect.inset(radius, 0);
} else {
bounds[0] = (SkIntToScalar(srcRect.top()) + 0.5f) / texture->height();
bounds[1] = (SkIntToScalar(srcRect.bottom()) - 0.5f) / texture->height();
lowerSrcRect.fBottom = srcRect.top() + radius;
lowerDstRect.fBottom = dstRect.top() + radius;
upperSrcRect.fTop = srcRect.bottom() - radius;
upperDstRect.fTop = dstRect.bottom() - radius;
middleSrcRect.inset(0, radius);
middleDstRect.inset(0, radius);
}
if (middleSrcRect.fLeft - middleSrcRect.fRight >= 0) {
// radius covers srcRect; use bounds over entire draw
apply_morphology_rect(drawContext, clip, texture, srcRect, dstRect, radius,
morphType, bounds, direction);
} else {
// Draw upper and lower margins with bounds; middle without.
apply_morphology_rect(drawContext, clip, texture, lowerSrcRect, lowerDstRect, radius,
morphType, bounds, direction);
apply_morphology_rect(drawContext, clip, texture, upperSrcRect, upperDstRect, radius,
morphType, bounds, direction);
apply_morphology_rect_no_bounds(drawContext, clip, texture, middleSrcRect, middleDstRect,
radius, morphType, direction);
}
}
示例9:
PassRefPtr<JSONObject> LoggingCanvas::objectForSkIRect(const SkIRect& rect)
{
RefPtr<JSONObject> rectItem = JSONObject::create();
rectItem->setNumber("left", rect.left());
rectItem->setNumber("top", rect.top());
rectItem->setNumber("right", rect.right());
rectItem->setNumber("bottom", rect.bottom());
return rectItem.release();
}
示例10: reset
void SkRecorder::reset(SkRecord* record, const SkRect& bounds,
DrawPictureMode dpm, SkMiniRecorder* mr) {
this->forgetRecord();
fDrawPictureMode = dpm;
fRecord = record;
SkIRect rounded = bounds.roundOut();
this->resetCanvas(rounded.right(), rounded.bottom());
fMiniRecorder = mr;
}
示例11: draw
void draw(SkCanvas* canvas) {
SkIRect rect = { 30, 50, 40, 60 };
SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} };
for (auto contained : tests) {
SkDebugf("rect: (%d, %d, %d, %d) %s (%d, %d, %d, %d)\n",
rect.left(), rect.top(), rect.right(), rect.bottom(),
rect.contains(contained) ? "contains" : "does not contain",
contained.left(), contained.top(), contained.right(), contained.bottom());
}
}
示例12: areBoundariesIntegerAligned
// Return true if the rectangle is aligned to integer boundaries.
// See comments for computeBitmapDrawRects() for how this is used.
static bool areBoundariesIntegerAligned(const SkRect& rect)
{
// Value is 1.19209e-007. This is the tolerance threshold.
const float epsilon = std::numeric_limits<float>::epsilon();
SkIRect roundedRect = roundedIntRect(rect);
return fabs(rect.x() - roundedRect.x()) < epsilon
&& fabs(rect.y() - roundedRect.y()) < epsilon
&& fabs(rect.right() - roundedRect.right()) < epsilon
&& fabs(rect.bottom() - roundedRect.bottom()) < epsilon;
}
示例13: search
void SkTileGrid::search(const SkIRect& query, SkTDArray<void*>* results) {
SkIRect adjustedQuery = query;
// The inset is to counteract the outset that was applied in 'insert'
// The outset/inset is to optimize for lookups of size
// 'tileInterval + 2 * margin' that are aligned with the tile grid.
adjustedQuery.inset(fInfo.fMargin.width(), fInfo.fMargin.height());
adjustedQuery.offset(fInfo.fOffset);
adjustedQuery.sort(); // in case the inset inverted the rectangle
// Convert the query rectangle from device coordinates to tile coordinates
// by rounding outwards to the nearest tile boundary so that the resulting tile
// region includes the query rectangle. (using truncating division to "floor")
int tileStartX = adjustedQuery.left() / fInfo.fTileInterval.width();
int tileEndX = (adjustedQuery.right() + fInfo.fTileInterval.width() - 1) /
fInfo.fTileInterval.width();
int tileStartY = adjustedQuery.top() / fInfo.fTileInterval.height();
int tileEndY = (adjustedQuery.bottom() + fInfo.fTileInterval.height() - 1) /
fInfo.fTileInterval.height();
tileStartX = SkPin32(tileStartX, 0, fXTileCount - 1);
tileEndX = SkPin32(tileEndX, tileStartX+1, fXTileCount);
tileStartY = SkPin32(tileStartY, 0, fYTileCount - 1);
tileEndY = SkPin32(tileEndY, tileStartY+1, fYTileCount);
int queryTileCount = (tileEndX - tileStartX) * (tileEndY - tileStartY);
SkASSERT(queryTileCount);
if (queryTileCount == 1) {
*results = this->tile(tileStartX, tileStartY);
} else {
results->reset();
SkTDArray<int> curPositions;
curPositions.setCount(queryTileCount);
// Note: Reserving space for 1024 tile pointers on the stack. If the
// malloc becomes a bottleneck, we may consider increasing that number.
// Typical large web page, say 2k x 16k, would require 512 tiles of
// size 256 x 256 pixels.
SkAutoSTArray<1024, SkTDArray<void *>*> storage(queryTileCount);
SkTDArray<void *>** tileRange = storage.get();
int tile = 0;
for (int x = tileStartX; x < tileEndX; ++x) {
for (int y = tileStartY; y < tileEndY; ++y) {
tileRange[tile] = &this->tile(x, y);
curPositions[tile] = tileRange[tile]->count() ? 0 : kTileFinished;
++tile;
}
}
void *nextElement;
while(NULL != (nextElement = fNextDatumFunction(tileRange, curPositions))) {
results->push(nextElement);
}
}
}
示例14: SkASSERT
/*
* Class: org_skia_canvasproof_GaneshPictureRenderer
* Method: GetCullRect
* Signature: (Landroid/graphics/Rect;J)V
*/
JNIEXPORT void JNICALL Java_org_skia_canvasproof_GaneshPictureRenderer_GetCullRect
(JNIEnv *env, jclass, jobject androidGraphicsRect, jlong picturePtr) {
SkASSERT(androidGraphicsRect);
const SkPicture* picture = reinterpret_cast<SkPicture*>(picturePtr);
SkRect rect = SkRect::MakeEmpty();
if (picture) {
rect = picture->cullRect();
}
SkIRect iRect;
rect.roundOut(&iRect);
static AndroidRectHelper help;
help.config(env);
env->SetIntField(androidGraphicsRect, help.fLeft, (jint)(iRect.left()));
env->SetIntField(androidGraphicsRect, help.fTop, (jint)(iRect.top()));
env->SetIntField(androidGraphicsRect, help.fRight, (jint)(iRect.right()));
env->SetIntField(androidGraphicsRect, help.fBottom, (jint)(iRect.bottom()));
}
示例15: onFilterImage
bool SkMatrixConvolutionImageFilter::onFilterImage(Proxy* proxy,
const SkBitmap& source,
const SkMatrix& matrix,
SkBitmap* result,
SkIPoint* loc) {
SkBitmap src = source;
if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, loc)) {
return false;
}
if (src.config() != SkBitmap::kARGB_8888_Config) {
return false;
}
if (!fConvolveAlpha && !src.isOpaque()) {
src = unpremultiplyBitmap(src);
}
SkAutoLockPixels alp(src);
if (!src.getPixels()) {
return false;
}
result->setConfig(src.config(), src.width(), src.height());
result->allocPixels();
SkIRect interior = SkIRect::MakeXYWH(fTarget.fX, fTarget.fY,
src.width() - fKernelSize.fWidth + 1,
src.height() - fKernelSize.fHeight + 1);
SkIRect top = SkIRect::MakeWH(src.width(), fTarget.fY);
SkIRect bottom = SkIRect::MakeLTRB(0, interior.bottom(),
src.width(), src.height());
SkIRect left = SkIRect::MakeXYWH(0, interior.top(),
fTarget.fX, interior.height());
SkIRect right = SkIRect::MakeLTRB(interior.right(), interior.top(),
src.width(), interior.bottom());
filterBorderPixels(src, result, top);
filterBorderPixels(src, result, left);
filterInteriorPixels(src, result, interior);
filterBorderPixels(src, result, right);
filterBorderPixels(src, result, bottom);
return true;
}