本文整理汇总了C++中SkIRect::left方法的典型用法代码示例。如果您正苦于以下问题:C++ SkIRect::left方法的具体用法?C++ SkIRect::left怎么用?C++ SkIRect::left使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkIRect
的用法示例。
在下文中一共展示了SkIRect::left方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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));
}
}
}
示例2: 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;
}
示例3: filterImageGPU
bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
SkBitmap* result, SkIPoint* offset) const {
#if SK_SUPPORT_GPU
SkBitmap input = src;
SkASSERT(fInputCount == 1);
SkIPoint srcOffset = SkIPoint::Make(0, 0);
if (!this->filterInputGPU(0, proxy, src, ctx, &input, &srcOffset)) {
return false;
}
GrTexture* srcTexture = input.getTexture();
SkIRect bounds;
if (!this->applyCropRect(ctx, proxy, input, &srcOffset, &bounds, &input)) {
return false;
}
SkRect srcRect = SkRect::Make(bounds);
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
GrContext* context = srcTexture->getContext();
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag,
desc.fWidth = bounds.width();
desc.fHeight = bounds.height();
desc.fConfig = kRGBA_8888_GrPixelConfig;
SkAutoTUnref<GrTexture> dst(context->textureProvider()->createTexture(desc,
GrTextureProvider::FromImageFilter(ctx.sizeConstraint())));
if (!dst) {
return false;
}
// setup new clip
GrClip clip(dstRect);
GrFragmentProcessor* fp;
offset->fX = bounds.left();
offset->fY = bounds.top();
bounds.offset(-srcOffset);
SkMatrix matrix(ctx.ctm());
matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
GrPaint paint;
if (this->asFragmentProcessor(&fp, srcTexture, matrix, bounds)) {
SkASSERT(fp);
paint.addColorFragmentProcessor(fp)->unref();
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(dst->asRenderTarget()));
if (drawContext) {
drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
WrapTexture(dst, bounds.width(), bounds.height(), result);
return true;
}
}
#endif
return false;
}
示例4: onFilterImage
bool SkMergeImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
const Context& ctx,
SkBitmap* result, SkIPoint* offset) const {
if (countInputs() < 1) {
return false;
}
SkIRect bounds;
if (!this->applyCropRect(ctx, src, SkIPoint::Make(0, 0), &bounds)) {
return false;
}
const int x0 = bounds.left();
const int y0 = bounds.top();
SkAutoTUnref<SkBaseDevice> dst(proxy->createDevice(bounds.width(), bounds.height()));
if (nullptr == dst) {
return false;
}
SkCanvas canvas(dst);
SkPaint paint;
bool didProduceResult = false;
int inputCount = countInputs();
for (int i = 0; i < inputCount; ++i) {
SkBitmap tmp;
const SkBitmap* srcPtr;
SkIPoint pos = SkIPoint::Make(0, 0);
SkImageFilter* filter = getInput(i);
if (filter) {
if (!filter->filterImage(proxy, src, ctx, &tmp, &pos)) {
continue;
}
srcPtr = &tmp;
} else {
srcPtr = &src;
}
if (fModes) {
paint.setXfermodeMode((SkXfermode::Mode)fModes[i]);
} else {
paint.setXfermode(nullptr);
}
canvas.drawSprite(*srcPtr, pos.x() - x0, pos.y() - y0, &paint);
didProduceResult = true;
}
if (!didProduceResult)
return false;
offset->fX = bounds.left();
offset->fY = bounds.top();
*result = dst->accessBitmap(false);
return true;
}
示例5: fetch
static inline SkPMColor fetch(const SkBitmap& src, int x, int y, const SkIRect& bounds) {
x = (x - bounds.left()) % bounds.width() + bounds.left();
y = (y - bounds.top()) % bounds.height() + bounds.top();
if (x < bounds.left()) {
x += bounds.width();
}
if (y < bounds.top()) {
y += bounds.height();
}
return *src.getAddr32(x, y);
}
示例6: onFilterImage
bool SkMergeImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
const SkMatrix& ctm,
SkBitmap* result, SkIPoint* loc) {
if (countInputs() < 1) {
return false;
}
const SkIRect srcBounds = SkIRect::MakeXYWH(loc->x(), loc->y(),
src.width(), src.height());
SkIRect bounds;
if (!this->filterBounds(srcBounds, ctm, &bounds)) {
return false;
}
const int x0 = bounds.left();
const int y0 = bounds.top();
SkAutoTUnref<SkDevice> dst(proxy->createDevice(bounds.width(), bounds.height()));
if (NULL == dst) {
return false;
}
SkCanvas canvas(dst);
SkPaint paint;
int inputCount = countInputs();
for (int i = 0; i < inputCount; ++i) {
SkBitmap tmp;
const SkBitmap* srcPtr;
SkIPoint pos = *loc;
SkImageFilter* filter = getInput(i);
if (filter) {
if (!filter->filterImage(proxy, src, ctm, &tmp, &pos)) {
return false;
}
srcPtr = &tmp;
} else {
srcPtr = &src;
}
if (fModes) {
paint.setXfermodeMode((SkXfermode::Mode)fModes[i]);
} else {
paint.setXfermode(NULL);
}
canvas.drawSprite(*srcPtr, pos.x() - x0, pos.y() - y0, &paint);
}
loc->set(bounds.left(), bounds.top());
*result = dst->accessBitmap(false);
return true;
}
示例7: filterImageGPU
bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) {
#if SK_SUPPORT_GPU
SkBitmap input;
SkASSERT(fInputCount == 1);
if (!SkImageFilterUtils::GetInputResultGPU(this->getInput(0), proxy, src, ctm, &input, offset)) {
return false;
}
GrTexture* srcTexture = input.getTexture();
SkIRect bounds;
src.getBounds(&bounds);
if (!this->applyCropRect(&bounds, ctm)) {
return false;
}
SkRect srcRect = SkRect::Make(bounds);
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
GrContext* context = srcTexture->getContext();
GrTextureDesc desc;
desc.fFlags = kRenderTarget_GrTextureFlagBit,
desc.fWidth = bounds.width();
desc.fHeight = bounds.height();
desc.fConfig = kRGBA_8888_GrPixelConfig;
GrAutoScratchTexture dst(context, desc);
GrContext::AutoMatrix am;
am.setIdentity(context);
GrContext::AutoRenderTarget art(context, dst.texture()->asRenderTarget());
GrContext::AutoClip acs(context, dstRect);
GrEffectRef* effect;
SkMatrix matrix(ctm);
matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
this->asNewEffect(&effect, srcTexture, matrix, bounds);
SkASSERT(effect);
SkAutoUnref effectRef(effect);
GrPaint paint;
paint.addColorEffect(effect);
context->drawRectToRect(paint, dstRect, srcRect);
SkAutoTUnref<GrTexture> resultTex(dst.detach());
SkImageFilterUtils::WrapTexture(resultTex, bounds.width(), bounds.height(), result);
offset->fX += bounds.left();
offset->fY += bounds.top();
return true;
#else
return false;
#endif
}
示例8: 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);
}
}
}
示例9: onFilterImage
bool SkPaintImageFilter::onFilterImage(Proxy* proxy,
const SkBitmap& source,
const Context& ctx,
SkBitmap* result,
SkIPoint* offset) const {
SkIRect bounds;
if (!this->applyCropRect(ctx, source, SkIPoint::Make(0, 0), &bounds)) {
return false;
}
SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(),
bounds.height()));
if (nullptr == device.get()) {
return false;
}
SkCanvas canvas(device.get());
SkMatrix matrix(ctx.ctm());
matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bounds.height()));
SkMatrix inverse;
if (matrix.invert(&inverse)) {
inverse.mapRect(&rect);
}
canvas.setMatrix(matrix);
canvas.drawRect(rect, fPaint);
*result = device.get()->accessBitmap(false);
offset->fX = bounds.fLeft;
offset->fY = bounds.fTop;
return true;
}
示例10: onFilterImage
bool SkRectShaderImageFilter::onFilterImage(Proxy* proxy,
const SkBitmap& source,
const Context& ctx,
SkBitmap* result,
SkIPoint* offset) const {
SkIRect bounds;
if (!this->applyCropRect(ctx, source, SkIPoint::Make(0, 0), &bounds)) {
return false;
}
SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(),
bounds.height()));
if (NULL == device.get()) {
return false;
}
SkCanvas canvas(device.get());
SkPaint paint;
SkMatrix matrix(ctx.ctm());
matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
SkSafeUnref(paint.setShader(SkShader::CreateLocalMatrixShader(fShader, matrix)));
SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bounds.height()));
canvas.drawRect(rect, paint);
*result = device.get()->accessBitmap(false);
offset->fX = bounds.fLeft;
offset->fY = bounds.fTop;
return true;
}
示例11: INHERITED
TiledPipeController::TiledPipeController(const SkBitmap& bitmap,
SkPicture::InstallPixelRefProc proc,
const SkMatrix* initial)
: INHERITED(NULL, proc) {
int32_t top = 0;
int32_t bottom;
int32_t height = bitmap.height() / NumberOfTiles;
SkIRect rect;
for (int i = 0; i < NumberOfTiles; i++) {
bottom = i + 1 == NumberOfTiles ? bitmap.height() : top + height;
rect.setLTRB(0, top, bitmap.width(), bottom);
top = bottom;
SkDEBUGCODE(bool extracted = )bitmap.extractSubset(&fBitmaps[i], rect);
SkASSERT(extracted);
SkBaseDevice* device = new SkBitmapDevice(fBitmaps[i]);
SkCanvas* canvas = new SkCanvas(device);
device->unref();
if (initial != NULL) {
canvas->setMatrix(*initial);
}
canvas->translate(SkIntToScalar(-rect.left()),
SkIntToScalar(-rect.top()));
if (0 == i) {
fReader.setCanvas(canvas);
} else {
fReaders[i - 1].setCanvas(canvas);
fReaders[i - 1].setBitmapDecoder(proc);
}
canvas->unref();
}
}
示例12: 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
}
示例13: call_proc_X
static void call_proc_X(SkMorphologyImageFilter::Proc procX,
const SkBitmap& src, SkBitmap* dst,
int radiusX, const SkIRect& bounds) {
procX(src.getAddr32(bounds.left(), bounds.top()), dst->getAddr32(0, 0),
radiusX, bounds.width(), bounds.height(),
src.rowBytesAsPixels(), dst->rowBytesAsPixels());
}
示例14: blitMask
void SkRasterPipelineBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {
if (mask.fFormat == SkMask::kBW_Format) {
// TODO: native BW masks?
return INHERITED::blitMask(mask, clip);
}
int x = clip.left();
for (int y = clip.top(); y < clip.bottom(); y++) {
auto dst = fDst.writable_addr(0,y);
SkRasterPipeline p;
p.extend(fShader);
p.extend(fColorFilter);
this->append_load_d(&p, dst);
p.extend(fXfermode);
switch (mask.fFormat) {
case SkMask::kA8_Format:
p.append<lerp_a8, lerp_a8_1>(mask.getAddr8(x,y)-x);
break;
case SkMask::kLCD16_Format:
p.append<lerp_lcd16, lerp_lcd16_1>(mask.getAddrLCD16(x,y)-x);
break;
default: break;
}
this->append_store(&p, dst);
p.run(x, clip.width());
}
}
示例15: 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;
}