本文整理汇总了C++中SkBitmap::getBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ SkBitmap::getBounds方法的具体用法?C++ SkBitmap::getBounds怎么用?C++ SkBitmap::getBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkBitmap
的用法示例。
在下文中一共展示了SkBitmap::getBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onFilterImage
bool SkColorFilterImageFilter::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;
}
SkIRect bounds;
src.getBounds(&bounds);
if (!this->applyCropRect(&bounds, matrix)) {
return false;
}
SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds.height()));
if (NULL == device.get()) {
return false;
}
SkCanvas canvas(device.get());
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
paint.setColorFilter(fColorFilter);
canvas.drawSprite(src, -bounds.fLeft, -bounds.fTop, &paint);
*result = device.get()->accessBitmap(false);
loc->fX += bounds.fLeft;
loc->fY += bounds.fTop;
return true;
}
示例2: filterImageGPU
bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) {
#if SK_SUPPORT_GPU
SkBitmap input;
if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, ctm, &input, offset)) {
return false;
}
GrTexture* source = input.getTexture();
SkIRect rect;
src.getBounds(&rect);
if (!this->applyCropRect(&rect, ctm)) {
return false;
}
SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(source->getContext(),
source,
false,
SkRect::Make(rect),
true,
fSigma.width(),
fSigma.height()));
offset->fX += rect.fLeft;
offset->fY += rect.fTop;
return SkImageFilterUtils::WrapTexture(tex, rect.width(), rect.height(), result);
#else
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
#endif
}
示例3: filterImageGPU
bool SkBicubicImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) {
SkBitmap srcBM;
if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, ctm, &srcBM, offset)) {
return false;
}
GrTexture* srcTexture = srcBM.getTexture();
GrContext* context = srcTexture->getContext();
SkRect dstRect = SkRect::MakeWH(srcBM.width() * fScale.fWidth,
srcBM.height() * fScale.fHeight);
GrTextureDesc desc;
desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
desc.fWidth = SkScalarCeilToInt(dstRect.width());
desc.fHeight = SkScalarCeilToInt(dstRect.height());
desc.fConfig = kSkia8888_GrPixelConfig;
GrAutoScratchTexture ast(context, desc);
SkAutoTUnref<GrTexture> dst(ast.detach());
if (!dst) {
return false;
}
GrContext::AutoRenderTarget art(context, dst->asRenderTarget());
GrPaint paint;
paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->unref();
SkRect srcRect;
srcBM.getBounds(&srcRect);
context->drawRectToRect(paint, dstRect, srcRect);
return SkImageFilterUtils::WrapTexture(dst, desc.fWidth, desc.fHeight, result);
}
示例4: just_trans_clamp
/**
* For the purposes of drawing bitmaps, if a matrix is "almost" translate
* go ahead and treat it as if it were, so that subsequent code can go fast.
*/
static bool just_trans_clamp(const SkMatrix& matrix, const SkBitmap& bitmap) {
SkASSERT(matrix_only_scale_translate(matrix));
if (matrix.getType() & SkMatrix::kScale_Mask) {
SkRect src, dst;
bitmap.getBounds(&src);
// Can't call mapRect(), since that will fix up inverted rectangles,
// e.g. when scale is negative, and we don't want to return true for
// those.
matrix.mapPoints(SkTCast<SkPoint*>(&dst),
SkTCast<const SkPoint*>(&src),
2);
// Now round all 4 edges to device space, and then compare the device
// width/height to the original. Note: we must map all 4 and subtract
// rather than map the "width" and compare, since we care about the
// phase (in pixel space) that any translate in the matrix might impart.
SkIRect idst;
dst.round(&idst);
return idst.width() == bitmap.width() && idst.height() == bitmap.height();
}
// if we got here, we're either kTranslate_Mask or identity
return true;
}
示例5: applyCropRect
bool SkImageFilter::applyCropRect(const Context& ctx, Proxy* proxy, const SkBitmap& src,
SkIPoint* srcOffset, SkIRect* bounds, SkBitmap* dst) const {
SkIRect srcBounds;
src.getBounds(&srcBounds);
srcBounds.offset(*srcOffset);
SkIRect dstBounds;
this->onFilterNodeBounds(srcBounds, ctx.ctm(), &dstBounds, kForward_MapDirection);
fCropRect.applyTo(dstBounds, ctx.ctm(), bounds);
if (!bounds->intersect(ctx.clipBounds())) {
return false;
}
if (srcBounds.contains(*bounds)) {
*dst = src;
return true;
} else {
SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds->width(), bounds->height()));
if (!device) {
return false;
}
SkCanvas canvas(device);
canvas.clear(0x00000000);
canvas.drawBitmap(src, srcOffset->x() - bounds->x(), srcOffset->y() - bounds->y());
*srcOffset = SkIPoint::Make(bounds->x(), bounds->y());
*dst = device->accessBitmap(false);
return true;
}
}
示例6: filterImageGPU
bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
const SkBitmap& src,
const Context& ctx,
SkBitmap* result,
SkIPoint* offset) const {
SkBitmap background = src;
SkIPoint backgroundOffset = SkIPoint::Make(0, 0);
if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &background,
&backgroundOffset)) {
return onFilterImage(proxy, src, ctx, result, offset);
}
GrTexture* backgroundTex = background.getTexture();
SkBitmap foreground = src;
SkIPoint foregroundOffset = SkIPoint::Make(0, 0);
if (getInput(1) && !getInput(1)->getInputResultGPU(proxy, src, ctx, &foreground,
&foregroundOffset)) {
return onFilterImage(proxy, src, ctx, result, offset);
}
GrTexture* foregroundTex = foreground.getTexture();
GrContext* context = foregroundTex->getContext();
GrFragmentProcessor* xferProcessor = NULL;
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurfaceFlag;
desc.fWidth = src.width();
desc.fHeight = src.height();
desc.fConfig = kSkia8888_GrPixelConfig;
SkAutoTUnref<GrTexture> dst(
context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch));
if (!dst) {
return false;
}
GrContext::AutoRenderTarget art(context, dst->asRenderTarget());
if (!fMode || !fMode->asFragmentProcessor(&xferProcessor, backgroundTex)) {
// canFilterImageGPU() should've taken care of this
SkASSERT(false);
return false;
}
SkMatrix foregroundMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(foregroundTex);
foregroundMatrix.preTranslate(SkIntToScalar(backgroundOffset.fX-foregroundOffset.fX),
SkIntToScalar(backgroundOffset.fY-foregroundOffset.fY));
SkRect srcRect;
src.getBounds(&srcRect);
GrPaint paint;
paint.addColorTextureProcessor(foregroundTex, foregroundMatrix);
paint.addColorProcessor(xferProcessor)->unref();
context->drawRect(paint, srcRect);
offset->fX = backgroundOffset.fX;
offset->fY = backgroundOffset.fY;
WrapTexture(dst, src.width(), src.height(), result);
return true;
}
示例7: onFilterImage
bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
const Context& ctx,
SkBitmap* dst, SkIPoint* offset) const {
SkBitmap source = src;
SkImageFilter* input = getInput(0);
SkIPoint srcOffset = SkIPoint::Make(0, 0);
if (input && !input->filterImage(proxy, src, ctx, &source, &srcOffset)) {
return false;
}
SkRect dstRect;
ctx.ctm().mapRect(&dstRect, fDstRect);
const SkIRect dstIRect = dstRect.roundOut();
int w = dstIRect.width();
int h = dstIRect.height();
if (!fSrcRect.width() || !fSrcRect.height() || !w || !h) {
return false;
}
SkRect srcRect;
ctx.ctm().mapRect(&srcRect, fSrcRect);
SkIRect srcIRect;
srcRect.roundOut(&srcIRect);
srcIRect.offset(-srcOffset);
SkBitmap subset;
SkIRect bounds;
source.getBounds(&bounds);
if (!srcIRect.intersect(bounds)) {
offset->fX = offset->fY = 0;
return true;
} else if (!source.extractSubset(&subset, srcIRect)) {
return false;
}
SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(w, h));
if (NULL == device.get()) {
return false;
}
SkCanvas canvas(device);
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
SkMatrix shaderMatrix;
shaderMatrix.setTranslate(SkIntToScalar(srcOffset.fX),
SkIntToScalar(srcOffset.fY));
SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(subset,
SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode,
&shaderMatrix));
paint.setShader(shader);
canvas.translate(-dstRect.fLeft, -dstRect.fTop);
canvas.drawRect(dstRect, paint);
*dst = device->accessBitmap(false);
offset->fX = dstIRect.fLeft;
offset->fY = dstIRect.fTop;
return true;
}
示例8: applyCropRect
bool SkImageFilter::applyCropRect(const Context& ctx, const SkBitmap& src,
const SkIPoint& srcOffset, SkIRect* dstBounds,
SkIRect* srcBounds) const {
SkIRect storage;
if (!srcBounds) {
srcBounds = &storage;
}
src.getBounds(srcBounds);
srcBounds->offset(srcOffset);
return fCropRect.applyTo(*srcBounds, ctx, dstBounds) && srcBounds->intersect(*dstBounds);
}
示例9: drawBitmapRect
bool SkMiniRecorder::drawBitmapRect(const SkBitmap& bm, const SkRect* src, const SkRect& dst,
const SkPaint* p, SkCanvas::SrcRectConstraint constraint) {
SkRect bounds;
if (!src) {
bm.getBounds(&bounds);
src = &bounds;
}
SkTLazy<SkPaint> defaultPaint;
if (!p) {
p = defaultPaint.init();
}
TRY_TO_STORE(DrawBitmapRectFixedSize, *p, bm, *src, dst, constraint);
}
示例10: onFilterImage
bool SkXfermodeImageFilter::onFilterImage(Proxy* proxy,
const SkBitmap& src,
const SkMatrix& ctm,
SkBitmap* dst,
SkIPoint* offset) {
SkBitmap background = src, foreground = src;
SkImageFilter* backgroundInput = getInput(0);
SkImageFilter* foregroundInput = getInput(1);
SkIPoint backgroundOffset = SkIPoint::Make(0, 0);
if (backgroundInput &&
!backgroundInput->filterImage(proxy, src, ctm, &background, &backgroundOffset)) {
return false;
}
SkIPoint foregroundOffset = SkIPoint::Make(0, 0);
if (foregroundInput &&
!foregroundInput->filterImage(proxy, src, ctm, &foreground, &foregroundOffset)) {
return false;
}
SkIRect bounds, foregroundBounds;
background.getBounds(&bounds);
bounds.offset(backgroundOffset);
foreground.getBounds(&foregroundBounds);
foregroundBounds.offset(foregroundOffset);
bounds.join(foregroundBounds);
if (!applyCropRect(&bounds, ctm)) {
return false;
}
SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds.height()));
if (NULL == device.get()) {
return false;
}
SkCanvas canvas(device);
canvas.translate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
canvas.drawBitmap(background, SkIntToScalar(backgroundOffset.fX),
SkIntToScalar(backgroundOffset.fY), &paint);
paint.setXfermode(fMode);
canvas.drawBitmap(foreground, SkIntToScalar(foregroundOffset.fX),
SkIntToScalar(foregroundOffset.fY), &paint);
canvas.clipRect(SkRect::Make(foregroundBounds), SkRegion::kDifference_Op);
paint.setColor(SK_ColorTRANSPARENT);
canvas.drawPaint(paint);
*dst = device->accessBitmap(false);
offset->fX += bounds.left();
offset->fY += bounds.top();
return true;
}
示例11: 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
}
示例12: applyCropRect
bool SkImageFilter::applyCropRect(const Context& ctx, const SkBitmap& src,
const SkIPoint& srcOffset, SkIRect* dstBounds,
SkIRect* srcBounds) const {
SkIRect storage;
if (!srcBounds) {
srcBounds = &storage;
}
src.getBounds(srcBounds);
srcBounds->offset(srcOffset);
#ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
return fCropRect.applyTo(*srcBounds, ctx, dstBounds);
#else
this->onFilterNodeBounds(*srcBounds, ctx.ctm(), dstBounds, kForward_MapDirection);
return fCropRect.applyTo(*dstBounds, ctx, dstBounds);
#endif
}
示例13: onFilterImage
bool SkMatrixImageFilter::onFilterImage(Proxy* proxy,
const SkBitmap& source,
const Context& ctx,
SkBitmap* result,
SkIPoint* offset) const {
SkBitmap src = source;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
return false;
}
SkRect dstRect;
SkIRect srcBounds, dstBounds;
src.getBounds(&srcBounds);
srcBounds.offset(srcOffset);
SkRect srcRect = SkRect::Make(srcBounds);
SkMatrix matrix;
if (!ctx.ctm().invert(&matrix)) {
return false;
}
matrix.postConcat(fTransform);
matrix.postConcat(ctx.ctm());
matrix.mapRect(&dstRect, srcRect);
dstRect.roundOut(&dstBounds);
SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(dstBounds.width(), dstBounds.height()));
if (NULL == device.get()) {
return false;
}
SkCanvas canvas(device.get());
canvas.translate(-SkIntToScalar(dstBounds.x()), -SkIntToScalar(dstBounds.y()));
canvas.concat(matrix);
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
paint.setFilterLevel(fFilterLevel);
canvas.drawBitmap(src, srcRect.x(), srcRect.y(), &paint);
*result = device.get()->accessBitmap(false);
offset->fX = dstBounds.fLeft;
offset->fY = dstBounds.fTop;
return true;
}
开发者ID:xin3liang,项目名称:platform_external_chromium_org_third_party_skia,代码行数:44,代码来源:SkMatrixImageFilter.cpp
示例14: filterImageGPU
bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result) {
#if SK_SUPPORT_GPU
SkBitmap input;
SkASSERT(fInputCount == 1);
if (!SkImageFilterUtils::GetInputResultGPU(this->getInput(0), proxy, src, &input)) {
return false;
}
GrTexture* srcTexture = (GrTexture*) input.getTexture();
SkRect rect;
src.getBounds(&rect);
GrContext* context = srcTexture->getContext();
GrTextureDesc desc;
desc.fFlags = kRenderTarget_GrTextureFlagBit,
desc.fWidth = input.width();
desc.fHeight = input.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, rect);
GrEffectRef* effect;
this->asNewEffect(&effect, srcTexture);
SkASSERT(effect);
SkAutoUnref effectRef(effect);
GrPaint paint;
paint.colorStage(0)->setEffect(effect);
context->drawRect(paint, rect);
SkAutoTUnref<GrTexture> resultTex(dst.detach());
SkImageFilterUtils::WrapTexture(resultTex, input.width(), input.height(), result);
return true;
#else
return false;
#endif
}
示例15: onFilterImageDeprecated
bool SkTileImageFilter::onFilterImageDeprecated(Proxy* proxy, const SkBitmap& src,
const Context& ctx,
SkBitmap* dst, SkIPoint* offset) const {
SkBitmap source = src;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
if (!this->filterInputDeprecated(0, proxy, src, ctx, &source, &srcOffset)) {
return false;
}
SkRect dstRect;
ctx.ctm().mapRect(&dstRect, fDstRect);
if (!dstRect.intersect(SkRect::Make(ctx.clipBounds()))) {
offset->fX = offset->fY = 0;
return true;
}
const SkIRect dstIRect = dstRect.roundOut();
int w = dstIRect.width();
int h = dstIRect.height();
if (!fSrcRect.width() || !fSrcRect.height() || !w || !h) {
return false;
}
SkRect srcRect;
ctx.ctm().mapRect(&srcRect, fSrcRect);
SkIRect srcIRect;
srcRect.roundOut(&srcIRect);
srcIRect.offset(-srcOffset);
SkBitmap subset;
SkIRect srcBounds;
source.getBounds(&srcBounds);
if (!SkIRect::Intersects(srcIRect, srcBounds)) {
offset->fX = offset->fY = 0;
return true;
}
if (srcBounds.contains(srcIRect)) {
if (!source.extractSubset(&subset, srcIRect)) {
return false;
}
} else {
SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(srcIRect.width(),
srcIRect.height(),
kPossible_TileUsage));
if (!device) {
return false;
}
SkCanvas canvas(device);
canvas.drawBitmap(src, SkIntToScalar(srcOffset.x()),
SkIntToScalar(srcOffset.y()));
subset = device->accessBitmap(false);
}
SkASSERT(subset.width() == srcIRect.width());
SkASSERT(subset.height() == srcIRect.height());
SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(w, h));
if (nullptr == device.get()) {
return false;
}
SkCanvas canvas(device);
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
paint.setShader(SkShader::MakeBitmapShader(subset, SkShader::kRepeat_TileMode,
SkShader::kRepeat_TileMode));
canvas.translate(-dstRect.fLeft, -dstRect.fTop);
canvas.drawRect(dstRect, paint);
*dst = device->accessBitmap(false);
offset->fX = dstIRect.fLeft;
offset->fY = dstIRect.fTop;
return true;
}