本文整理汇总了C++中SkVector::y方法的典型用法代码示例。如果您正苦于以下问题:C++ SkVector::y方法的具体用法?C++ SkVector::y怎么用?C++ SkVector::y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkVector
的用法示例。
在下文中一共展示了SkVector::y方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: filterImageGPUDeprecated
bool SkBlurImageFilter::filterImageGPUDeprecated(Proxy* proxy, const SkBitmap& src,
const Context& ctx,
SkBitmap* result, SkIPoint* offset) const {
#if SK_SUPPORT_GPU
SkBitmap input = src;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
if (!this->filterInputGPUDeprecated(0, proxy, src, ctx, &input, &srcOffset)) {
return false;
}
SkIRect srcBounds = input.bounds();
srcBounds.offset(srcOffset);
SkIRect dstBounds;
if (!this->applyCropRect(this->mapContext(ctx), srcBounds, &dstBounds)) {
return false;
}
if (!srcBounds.intersect(dstBounds)) {
return false;
}
SkVector sigma = map_sigma(fSigma, ctx.ctm());
if (sigma.x() == 0 && sigma.y() == 0) {
input.extractSubset(result, srcBounds);
offset->fX = srcBounds.x();
offset->fY = srcBounds.y();
return true;
}
offset->fX = dstBounds.fLeft;
offset->fY = dstBounds.fTop;
srcBounds.offset(-srcOffset);
dstBounds.offset(-srcOffset);
SkRect srcBoundsF(SkRect::Make(srcBounds));
GrTexture* inputTexture = input.getTexture();
SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(inputTexture->getContext(),
inputTexture,
false,
SkRect::Make(dstBounds),
&srcBoundsF,
sigma.x(),
sigma.y()));
if (!tex) {
return false;
}
GrWrapTextureInBitmap(tex, dstBounds.width(), dstBounds.height(), false, result);
return true;
#else
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
#endif
}
示例2: filterImageGPU
bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
SkBitmap* result, SkIPoint* offset) const {
#if SK_SUPPORT_GPU
SkBitmap input = src;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
return false;
}
SkIRect rect;
if (!this->applyCropRect(ctx, proxy, input, &srcOffset, &rect, &input)) {
return false;
}
GrTexture* source = input.getTexture();
SkVector sigma = SkVector::Make(fSigma.width(), fSigma.height());
ctx.ctm().mapVectors(&sigma, 1);
sigma.fX = SkMinScalar(sigma.fX, MAX_SIGMA);
sigma.fY = SkMinScalar(sigma.fY, MAX_SIGMA);
offset->fX = rect.fLeft;
offset->fY = rect.fTop;
rect.offset(-srcOffset);
SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(source->getContext(),
source,
false,
SkRect::Make(rect),
true,
sigma.x(),
sigma.y()));
WrapTexture(tex, rect.width(), rect.height(), result);
return true;
#else
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
#endif
}
示例3: onFilterNodeBounds
SkIRect SkMorphologyImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
MapDirection) const {
SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()),
SkIntToScalar(this->radius().height()));
ctm.mapVectors(&radius, 1);
return src.makeOutset(SkScalarCeilToInt(radius.x()), SkScalarCeilToInt(radius.y()));
}
示例4: onFilterNodeBounds
void SkBlurImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
SkIRect* dst, MapDirection) const {
*dst = src;
SkVector sigma = mapSigma(fSigma, ctm);
dst->outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))),
SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3))));
}
示例5:
PassRefPtr<JSONObject> LoggingCanvas::objectForRadius(const SkRRect& rrect, SkRRect::Corner corner)
{
RefPtr<JSONObject> radiusItem = JSONObject::create();
SkVector radius = rrect.radii(corner);
radiusItem->setNumber("xRadius", radius.x());
radiusItem->setNumber("yRadius", radius.y());
return radiusItem.release();
}
示例6: onFilterNodeBounds
void SkDropShadowImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
SkIRect* dst, MapDirection direction) const {
*dst = src;
SkVector offsetVec = SkVector::Make(fDx, fDy);
if (kReverse_MapDirection == direction) {
offsetVec.negate();
}
ctm.mapVectors(&offsetVec, 1);
dst->offset(SkScalarCeilToInt(offsetVec.x()),
SkScalarCeilToInt(offsetVec.y()));
SkVector sigma = SkVector::Make(fSigmaX, fSigmaY);
ctm.mapVectors(&sigma, 1);
dst->outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))),
SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3))));
if (fShadowMode == kDrawShadowAndForeground_ShadowMode) {
dst->join(src);
}
}
示例7: onFilterBounds
bool SkDropShadowImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
SkIRect* dst) const {
SkIRect bounds = src;
if (getInput(0) && !getInput(0)->filterBounds(src, ctm, &bounds)) {
return false;
}
SkVector offsetVec = SkVector::Make(fDx, fDy);
ctm.mapVectors(&offsetVec, 1);
bounds.offset(-SkScalarCeilToInt(offsetVec.x()),
-SkScalarCeilToInt(offsetVec.y()));
SkVector sigma = SkVector::Make(fSigmaX, fSigmaY);
ctm.mapVectors(&sigma, 1);
bounds.outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))),
SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3))));
bounds.join(src);
*dst = bounds;
return true;
}
示例8: onFilterNodeBounds
SkIRect SkDropShadowImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
MapDirection direction) const {
SkVector offsetVec = SkVector::Make(fDx, fDy);
if (kReverse_MapDirection == direction) {
offsetVec.negate();
}
ctm.mapVectors(&offsetVec, 1);
SkIRect dst = src.makeOffset(SkScalarCeilToInt(offsetVec.x()),
SkScalarCeilToInt(offsetVec.y()));
SkVector sigma = SkVector::Make(fSigmaX, fSigmaY);
ctm.mapVectors(&sigma, 1);
dst.outset(
SkScalarCeilToInt(SkScalarAbs(sigma.x() * 3)),
SkScalarCeilToInt(SkScalarAbs(sigma.y() * 3)));
if (fShadowMode == kDrawShadowAndForeground_ShadowMode) {
dst.join(src);
}
return dst;
}
示例9: MakeImage
static sk_sp<SkImage> MakeImage(const SkVector& vec, SkColor color) {
const SkPoint start = SkPoint::Make(vec.y() * kSegLen / 2, vec.x() * kSegLen / 2);
const SkPoint end = SkPoint::Make(start.x() + vec.x() * (kSegLen - 1),
start.y() + vec.y() * (kSegLen - 1));
SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(kSegLen, kSegLen));
surface->getCanvas()->clear(SK_ColorTRANSPARENT);
SkPaint paint;
paint.setAntiAlias(true);
const SkRect border = SkRect::MakeIWH(kSegLen, kSegLen).makeInset(.5f, .5f);
paint.setColor(SK_ColorBLUE);
paint.setStyle(SkPaint::kStroke_Style);
surface->getCanvas()->drawRect(border, paint);
paint.setColor(SK_ColorBLACK);
surface->getCanvas()->drawLine(start.x(), start.y(), end.x(), end.y(), paint);
surface->getCanvas()->drawPoint(start.x(), start.y(), color);
surface->getCanvas()->drawPoint(end.x(), end.y(), color);
return surface->makeImageSnapshot();
}
示例10: onFilterBounds
bool SkBlurImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
SkIRect* dst) const {
SkIRect bounds = src;
if (getInput(0) && !getInput(0)->filterBounds(src, ctm, &bounds)) {
return false;
}
SkVector sigma = SkVector::Make(fSigma.width(), fSigma.height());
ctm.mapVectors(&sigma, 1);
bounds.outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))),
SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3))));
*dst = bounds;
return true;
}
示例11: onFilterBounds
bool SkMorphologyImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
SkIRect* dst) const {
SkIRect bounds = src;
SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()),
SkIntToScalar(this->radius().height()));
ctm.mapVectors(&radius, 1);
bounds.outset(SkScalarCeilToInt(radius.x()), SkScalarCeilToInt(radius.y()));
if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) {
return false;
}
*dst = bounds;
return true;
}
示例12: onFilterImage
SkSpecialImage* SkOffsetImageFilter::onFilterImage(SkSpecialImage* source,
const Context& ctx,
SkIPoint* offset) const {
SkIPoint srcOffset = SkIPoint::Make(0, 0);
SkAutoTUnref<SkSpecialImage> input(this->filterInput(0, source, ctx, &srcOffset));
if (!input) {
return nullptr;
}
SkVector vec;
ctx.ctm().mapVectors(&vec, &fOffset, 1);
if (!this->cropRectIsSet()) {
offset->fX = srcOffset.fX + SkScalarRoundToInt(vec.fX);
offset->fY = srcOffset.fY + SkScalarRoundToInt(vec.fY);
return input.release();
} else {
SkIRect bounds;
SkIRect srcBounds = SkIRect::MakeWH(input->width(), input->height());
srcBounds.offset(srcOffset);
if (!this->applyCropRect(ctx, srcBounds, &bounds)) {
return nullptr;
}
SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(),
kPremul_SkAlphaType);
sk_sp<SkSpecialSurface> surf(source->makeSurface(info));
if (!surf) {
return nullptr;
}
SkCanvas* canvas = surf->getCanvas();
SkASSERT(canvas);
// TODO: it seems like this clear shouldn't be necessary (see skbug.com/5075)
canvas->clear(0x0);
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
canvas->translate(SkIntToScalar(srcOffset.fX - bounds.fLeft),
SkIntToScalar(srcOffset.fY - bounds.fTop));
input->draw(canvas, vec.x(), vec.y(), &paint);
offset->fX = bounds.fLeft;
offset->fY = bounds.fTop;
return surf->makeImageSnapshot().release();
}
}
示例13: onFilterImage
bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source,
const Context& ctx,
SkBitmap* result,
SkIPoint* offset) const {
SkBitmap src = source;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
if (!cropRectIsSet()) {
if (!this->filterInput(0, proxy, source, ctx, &src, &srcOffset)) {
return false;
}
SkVector vec;
ctx.ctm().mapVectors(&vec, &fOffset, 1);
offset->fX = srcOffset.fX + SkScalarRoundToInt(vec.fX);
offset->fY = srcOffset.fY + SkScalarRoundToInt(vec.fY);
*result = src;
} else {
if (!this->filterInput(0, proxy, source, ctx, &src, &srcOffset)) {
return false;
}
SkIRect bounds;
if (!this->applyCropRect(ctx, src, srcOffset, &bounds)) {
return false;
}
SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds.height()));
if (nullptr == device.get()) {
return false;
}
SkCanvas canvas(device);
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
canvas.translate(SkIntToScalar(srcOffset.fX - bounds.fLeft),
SkIntToScalar(srcOffset.fY - bounds.fTop));
SkVector vec;
ctx.ctm().mapVectors(&vec, &fOffset, 1);
canvas.drawBitmap(src, vec.x(), vec.y(), &paint);
*result = device->accessBitmap(false);
offset->fX = bounds.fLeft;
offset->fY = bounds.fTop;
}
return true;
}
示例14: filterImageGPU
bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
SkBitmap* result, SkIPoint* offset) const {
#if SK_SUPPORT_GPU
SkBitmap input = src;
SkIPoint srcOffset = SkIPoint::Make(0, 0);
if (!this->filterInputGPU(0, proxy, src, ctx, &input, &srcOffset)) {
return false;
}
SkIRect srcBounds, dstBounds;
if (!this->applyCropRect(this->mapContext(ctx), input, srcOffset, &dstBounds, &srcBounds)) {
return false;
}
if (!srcBounds.intersect(dstBounds)) {
return false;
}
GrTexture* source = input.getTexture();
SkVector sigma = mapSigma(fSigma, ctx.ctm());
offset->fX = dstBounds.fLeft;
offset->fY = dstBounds.fTop;
srcBounds.offset(-srcOffset);
dstBounds.offset(-srcOffset);
SkRect srcBoundsF(SkRect::Make(srcBounds));
auto constraint = GrTextureProvider::FromImageFilter(ctx.sizeConstraint());
SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(source->getContext(),
source,
false,
SkRect::Make(dstBounds),
&srcBoundsF,
sigma.x(),
sigma.y(),
constraint));
if (!tex) {
return false;
}
WrapTexture(tex, dstBounds.width(), dstBounds.height(), result);
return true;
#else
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
#endif
}
示例15: inputBoundsF
sk_sp<SkSpecialImage> SkBlurImageFilter::onFilterImage(SkSpecialImage* source,
const Context& ctx,
SkIPoint* offset) const {
SkIPoint inputOffset = SkIPoint::Make(0, 0);
sk_sp<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset));
if (!input) {
return nullptr;
}
SkIRect inputBounds = SkIRect::MakeXYWH(inputOffset.fX, inputOffset.fY,
input->width(), input->height());
SkIRect dstBounds;
if (!this->applyCropRect(this->mapContext(ctx), inputBounds, &dstBounds)) {
return nullptr;
}
if (!inputBounds.intersect(dstBounds)) {
return nullptr;
}
const SkVector sigma = map_sigma(fSigma, ctx.ctm());
#if SK_SUPPORT_GPU
if (input->peekTexture() && input->peekTexture()->getContext()) {
if (0 == sigma.x() && 0 == sigma.y()) {
offset->fX = inputBounds.x();
offset->fY = inputBounds.y();
return input->makeSubset(inputBounds.makeOffset(-inputOffset.x(),
-inputOffset.y()));
}
GrTexture* inputTexture = input->peekTexture();
offset->fX = dstBounds.fLeft;
offset->fY = dstBounds.fTop;
inputBounds.offset(-inputOffset);
dstBounds.offset(-inputOffset);
SkRect inputBoundsF(SkRect::Make(inputBounds));
SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(inputTexture->getContext(),
inputTexture,
false,
source->props().allowSRGBInputs(),
SkRect::Make(dstBounds),
&inputBoundsF,
sigma.x(),
sigma.y()));
if (!tex) {
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(),
//.........这里部分代码省略.........