本文整理汇总了C++中SkIRect::bottom方法的典型用法代码示例。如果您正苦于以下问题:C++ SkIRect::bottom方法的具体用法?C++ SkIRect::bottom怎么用?C++ SkIRect::bottom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkIRect
的用法示例。
在下文中一共展示了SkIRect::bottom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: 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);
}
}
示例4: 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);
}
}
示例5:
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();
}
示例6: 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;
}
示例7: 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());
}
}
示例8: 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;
}
示例9: 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);
}
if (mask.fFormat == SkMask::kA8_Format && !fBlitMaskA8) {
SkRasterPipeline p(fAlloc);
p.extend(fColorPipeline);
if (fBlend == SkBlendMode::kSrcOver) {
p.append(SkRasterPipeline::scale_u8, &fMaskPtr);
this->append_load_d(&p);
this->append_blend(&p);
} else {
this->append_load_d(&p);
this->append_blend(&p);
p.append(SkRasterPipeline::lerp_u8, &fMaskPtr);
}
this->maybe_clamp(&p);
this->append_store(&p);
fBlitMaskA8 = p.compile();
}
if (mask.fFormat == SkMask::kLCD16_Format && !fBlitMaskLCD16) {
SkRasterPipeline p(fAlloc);
p.extend(fColorPipeline);
this->append_load_d(&p);
this->append_blend(&p);
p.append(SkRasterPipeline::lerp_565, &fMaskPtr);
this->maybe_clamp(&p);
this->append_store(&p);
fBlitMaskLCD16 = p.compile();
}
int x = clip.left();
for (int y = clip.top(); y < clip.bottom(); y++) {
fDstPtr = fDst.writable_addr(0,y);
this->maybe_shade(x,y,clip.width());
switch (mask.fFormat) {
case SkMask::kA8_Format:
fMaskPtr = mask.getAddr8(x,y)-x;
fBlitMaskA8(x,y,clip.width());
break;
case SkMask::kLCD16_Format:
fMaskPtr = mask.getAddrLCD16(x,y)-x;
fBlitMaskLCD16(x,y,clip.width());
break;
default:
// TODO
break;
}
}
}
示例10: 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;
}
示例11: 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);
}
}
}
示例12: 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()));
}
示例13: SkMemoryStream
static void add_type3_font_info(SkPDFCanon* canon,
SkPDFDict* font,
SkTypeface* typeface,
const SkBitSet& subset,
SkGlyphID firstGlyphID,
SkGlyphID lastGlyphID) {
const SkAdvancedTypefaceMetrics* metrics = SkPDFFont::GetMetrics(typeface, canon);
SkASSERT(lastGlyphID >= firstGlyphID);
// Remove unused glyphs at the end of the range.
// Keep the lastGlyphID >= firstGlyphID invariant true.
while (lastGlyphID > firstGlyphID && !subset.has(lastGlyphID)) {
--lastGlyphID;
}
int unitsPerEm;
auto cache = SkPDFFont::MakeVectorCache(typeface, &unitsPerEm);
SkASSERT(cache);
SkScalar emSize = (SkScalar)unitsPerEm;
font->insertName("Subtype", "Type3");
// Flip about the x-axis and scale by 1/emSize.
SkMatrix fontMatrix;
fontMatrix.setScale(SkScalarInvert(emSize), -SkScalarInvert(emSize));
font->insertObject("FontMatrix", SkPDFUtils::MatrixToArray(fontMatrix));
auto charProcs = sk_make_sp<SkPDFDict>();
auto encoding = sk_make_sp<SkPDFDict>("Encoding");
auto encDiffs = sk_make_sp<SkPDFArray>();
// length(firstGlyphID .. lastGlyphID) == lastGlyphID - firstGlyphID + 1
// plus 1 for glyph 0;
SkASSERT(firstGlyphID > 0);
SkASSERT(lastGlyphID >= firstGlyphID);
int glyphCount = lastGlyphID - firstGlyphID + 2;
// one other entry for the index of first glyph.
encDiffs->reserve(glyphCount + 1);
encDiffs->appendInt(0); // index of first glyph
auto widthArray = sk_make_sp<SkPDFArray>();
widthArray->reserve(glyphCount);
SkIRect bbox = SkIRect::MakeEmpty();
sk_sp<SkPDFStream> emptyStream;
for (SkGlyphID gID : SingleByteGlyphIdIterator(firstGlyphID, lastGlyphID)) {
bool skipGlyph = gID != 0 && !subset.has(gID);
SkString characterName;
SkScalar advance = 0.0f;
SkIRect glyphBBox;
if (skipGlyph) {
characterName.set("g0");
} else {
characterName.printf("g%X", gID);
const SkGlyph& glyph = cache->getGlyphIDMetrics(gID);
advance = SkFloatToScalar(glyph.fAdvanceX);
glyphBBox = SkIRect::MakeXYWH(glyph.fLeft, glyph.fTop,
glyph.fWidth, glyph.fHeight);
bbox.join(glyphBBox);
const SkPath* path = cache->findPath(glyph);
if (path && !path->isEmpty()) {
SkDynamicMemoryWStream content;
setGlyphWidthAndBoundingBox(SkFloatToScalar(glyph.fAdvanceX), glyphBBox,
&content);
SkPDFUtils::EmitPath(*path, SkPaint::kFill_Style, &content);
SkPDFUtils::PaintPath(SkPaint::kFill_Style, path->getFillType(),
&content);
charProcs->insertObjRef(
characterName, sk_make_sp<SkPDFStream>(
std::unique_ptr<SkStreamAsset>(content.detachAsStream())));
} else {
if (!emptyStream) {
emptyStream = sk_make_sp<SkPDFStream>(
std::unique_ptr<SkStreamAsset>(
new SkMemoryStream((size_t)0)));
}
charProcs->insertObjRef(characterName, emptyStream);
}
}
encDiffs->appendName(characterName.c_str());
widthArray->appendScalar(advance);
}
encoding->insertObject("Differences", std::move(encDiffs));
font->insertInt("FirstChar", 0);
font->insertInt("LastChar", lastGlyphID - firstGlyphID + 1);
/* FontBBox: "A rectangle expressed in the glyph coordinate
system, specifying the font bounding box. This is the smallest
rectangle enclosing the shape that would result if all of the
glyphs of the font were placed with their origins coincident and
then filled." */
auto fontBBox = sk_make_sp<SkPDFArray>();
fontBBox->reserve(4);
fontBBox->appendInt(bbox.left());
fontBBox->appendInt(bbox.bottom());
fontBBox->appendInt(bbox.right());
fontBBox->appendInt(bbox.top());
font->insertObject("FontBBox", std::move(fontBBox));
font->insertName("CIDToGIDMap", "Identity");
if (metrics && metrics->fGlyphToUnicode.count() > 0) {
font->insertObjRef("ToUnicode",
SkPDFMakeToUnicodeCmap(metrics->fGlyphToUnicode,
&subset,
//.........这里部分代码省略.........
示例14: draw_nine_clipped
static void draw_nine_clipped(const SkMask& mask, const SkIRect& outerR,
const SkIPoint& center, bool fillCenter,
const SkIRect& clipR, SkBlitter* blitter) {
int cx = center.x();
int cy = center.y();
SkMask m;
// top-left
m.fBounds = mask.fBounds;
m.fBounds.fRight = cx;
m.fBounds.fBottom = cy;
if (m.fBounds.width() > 0 && m.fBounds.height() > 0) {
extractMaskSubset(mask, &m);
m.fBounds.offsetTo(outerR.left(), outerR.top());
blitClippedMask(blitter, m, m.fBounds, clipR);
}
// top-right
m.fBounds = mask.fBounds;
m.fBounds.fLeft = cx + 1;
m.fBounds.fBottom = cy;
if (m.fBounds.width() > 0 && m.fBounds.height() > 0) {
extractMaskSubset(mask, &m);
m.fBounds.offsetTo(outerR.right() - m.fBounds.width(), outerR.top());
blitClippedMask(blitter, m, m.fBounds, clipR);
}
// bottom-left
m.fBounds = mask.fBounds;
m.fBounds.fRight = cx;
m.fBounds.fTop = cy + 1;
if (m.fBounds.width() > 0 && m.fBounds.height() > 0) {
extractMaskSubset(mask, &m);
m.fBounds.offsetTo(outerR.left(), outerR.bottom() - m.fBounds.height());
blitClippedMask(blitter, m, m.fBounds, clipR);
}
// bottom-right
m.fBounds = mask.fBounds;
m.fBounds.fLeft = cx + 1;
m.fBounds.fTop = cy + 1;
if (m.fBounds.width() > 0 && m.fBounds.height() > 0) {
extractMaskSubset(mask, &m);
m.fBounds.offsetTo(outerR.right() - m.fBounds.width(),
outerR.bottom() - m.fBounds.height());
blitClippedMask(blitter, m, m.fBounds, clipR);
}
SkIRect innerR;
innerR.set(outerR.left() + cx - mask.fBounds.left(),
outerR.top() + cy - mask.fBounds.top(),
outerR.right() + (cx + 1 - mask.fBounds.right()),
outerR.bottom() + (cy + 1 - mask.fBounds.bottom()));
if (fillCenter) {
blitClippedRect(blitter, innerR, clipR);
}
const int innerW = innerR.width();
size_t storageSize = (innerW + 1) * (sizeof(int16_t) + sizeof(uint8_t));
SkAutoSMalloc<4*1024> storage(storageSize);
int16_t* runs = (int16_t*)storage.get();
uint8_t* alpha = (uint8_t*)(runs + innerW + 1);
SkIRect r;
// top
r.set(innerR.left(), outerR.top(), innerR.right(), innerR.top());
if (r.intersect(clipR)) {
int startY = SkMax32(0, r.top() - outerR.top());
int stopY = startY + r.height();
int width = r.width();
for (int y = startY; y < stopY; ++y) {
runs[0] = width;
runs[width] = 0;
alpha[0] = *mask.getAddr8(cx, mask.fBounds.top() + y);
blitter->blitAntiH(r.left(), outerR.top() + y, alpha, runs);
}
}
// bottom
r.set(innerR.left(), innerR.bottom(), innerR.right(), outerR.bottom());
if (r.intersect(clipR)) {
int startY = outerR.bottom() - r.bottom();
int stopY = startY + r.height();
int width = r.width();
for (int y = startY; y < stopY; ++y) {
runs[0] = width;
runs[width] = 0;
alpha[0] = *mask.getAddr8(cx, mask.fBounds.bottom() - y - 1);
blitter->blitAntiH(r.left(), outerR.bottom() - y - 1, alpha, runs);
}
}
// left
r.set(outerR.left(), innerR.top(), innerR.left(), innerR.bottom());
if (r.intersect(clipR)) {
int startX = r.left() - outerR.left();
int stopX = startX + r.width();
int height = r.height();
for (int x = startX; x < stopX; ++x) {
blitter->blitV(outerR.left() + x, r.top(), height,
*mask.getAddr8(mask.fBounds.left() + x, mask.fBounds.top() + cy));
}
//.........这里部分代码省略.........
示例15: inputBoundsF
//.........这里部分代码省略.........
return nullptr;
}
return SkSpecialImage::MakeFromGpu(source->internal_getProxy(),
SkIRect::MakeWH(dstBounds.width(), dstBounds.height()),
kNeedNewImageUniqueID_SpecialImage,
tex, &source->props());
}
#endif
int kernelSizeX, kernelSizeX3, lowOffsetX, highOffsetX;
int kernelSizeY, kernelSizeY3, lowOffsetY, highOffsetY;
get_box3_params(sigma.x(), &kernelSizeX, &kernelSizeX3, &lowOffsetX, &highOffsetX);
get_box3_params(sigma.y(), &kernelSizeY, &kernelSizeY3, &lowOffsetY, &highOffsetY);
if (kernelSizeX < 0 || kernelSizeY < 0) {
return nullptr;
}
if (kernelSizeX == 0 && kernelSizeY == 0) {
offset->fX = inputBounds.x();
offset->fY = inputBounds.y();
return input->makeSubset(inputBounds.makeOffset(-inputOffset.x(),
-inputOffset.y()));
}
SkPixmap inputPixmap;
if (!input->peekPixels(&inputPixmap)) {
return nullptr;
}
if (inputPixmap.colorType() != kN32_SkColorType) {
return nullptr;
}
SkImageInfo info = SkImageInfo::Make(dstBounds.width(), dstBounds.height(),
inputPixmap.colorType(), inputPixmap.alphaType());
SkBitmap tmp, dst;
if (!tmp.tryAllocPixels(info) || !dst.tryAllocPixels(info)) {
return nullptr;
}
SkAutoLockPixels tmpLock(tmp), dstLock(dst);
offset->fX = dstBounds.fLeft;
offset->fY = dstBounds.fTop;
SkPMColor* t = tmp.getAddr32(0, 0);
SkPMColor* d = dst.getAddr32(0, 0);
int w = dstBounds.width(), h = dstBounds.height();
const SkPMColor* s = inputPixmap.addr32(inputBounds.x() - inputOffset.x(),
inputBounds.y() - inputOffset.y());
inputBounds.offset(-dstBounds.x(), -dstBounds.y());
dstBounds.offset(-dstBounds.x(), -dstBounds.y());
SkIRect inputBoundsT = SkIRect::MakeLTRB(inputBounds.top(), inputBounds.left(),
inputBounds.bottom(), inputBounds.right());
SkIRect dstBoundsT = SkIRect::MakeWH(dstBounds.height(), dstBounds.width());
int sw = int(inputPixmap.rowBytes() >> 2);
/**
*
* In order to make memory accesses cache-friendly, we reorder the passes to
* use contiguous memory reads wherever possible.
*
* For example, the 6 passes of the X-and-Y blur case are rewritten as
* follows. Instead of 3 passes in X and 3 passes in Y, we perform
* 2 passes in X, 1 pass in X transposed to Y on write, 2 passes in X,
* then 1 pass in X transposed to Y on write.
*
* +----+ +----+ +----+ +---+ +---+ +---+ +----+
* + AB + ----> | AB | ----> | AB | -----> | A | ----> | A | ----> | A | -----> | AB |
* +----+ blurX +----+ blurX +----+ blurXY | B | blurX | B | blurX | B | blurXY +----+
* +---+ +---+ +---+
*
* In this way, two of the y-blurs become x-blurs applied to transposed
* images, and all memory reads are contiguous.
*/
if (kernelSizeX > 0 && kernelSizeY > 0) {
SkOpts::box_blur_xx(s, sw, inputBounds, t, kernelSizeX, lowOffsetX, highOffsetX, w, h);
SkOpts::box_blur_xx(t, w, dstBounds, d, kernelSizeX, highOffsetX, lowOffsetX, w, h);
SkOpts::box_blur_xy(d, w, dstBounds, t, kernelSizeX3, highOffsetX, highOffsetX, w, h);
SkOpts::box_blur_xx(t, h, dstBoundsT, d, kernelSizeY, lowOffsetY, highOffsetY, h, w);
SkOpts::box_blur_xx(d, h, dstBoundsT, t, kernelSizeY, highOffsetY, lowOffsetY, h, w);
SkOpts::box_blur_xy(t, h, dstBoundsT, d, kernelSizeY3, highOffsetY, highOffsetY, h, w);
} else if (kernelSizeX > 0) {
SkOpts::box_blur_xx(s, sw, inputBounds, d, kernelSizeX, lowOffsetX, highOffsetX, w, h);
SkOpts::box_blur_xx(d, w, dstBounds, t, kernelSizeX, highOffsetX, lowOffsetX, w, h);
SkOpts::box_blur_xx(t, w, dstBounds, d, kernelSizeX3, highOffsetX, highOffsetX, w, h);
} else if (kernelSizeY > 0) {
SkOpts::box_blur_yx(s, sw, inputBoundsT, d, kernelSizeY, lowOffsetY, highOffsetY, h, w);
SkOpts::box_blur_xx(d, h, dstBoundsT, t, kernelSizeY, highOffsetY, lowOffsetY, h, w);
SkOpts::box_blur_xy(t, h, dstBoundsT, d, kernelSizeY3, highOffsetY, highOffsetY, h, w);
}
return SkSpecialImage::MakeFromRaster(source->internal_getProxy(),
SkIRect::MakeWH(dstBounds.width(),
dstBounds.height()),
dst, &source->props());
}