本文整理汇总了C++中SkIPoint::x方法的典型用法代码示例。如果您正苦于以下问题:C++ SkIPoint::x方法的具体用法?C++ SkIPoint::x怎么用?C++ SkIPoint::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkIPoint
的用法示例。
在下文中一共展示了SkIPoint::x方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: conv
static void convolve_gaussian_2d(GrDrawContext* drawContext,
const GrClip& clip,
const SkIRect& dstRect,
const SkIPoint& srcOffset,
GrTexture* texture,
int radiusX,
int radiusY,
SkScalar sigmaX,
SkScalar sigmaY,
const SkIRect* srcBounds) {
SkMatrix localMatrix = SkMatrix::MakeTrans(-SkIntToScalar(srcOffset.x()),
-SkIntToScalar(srcOffset.y()));
SkISize size = SkISize::Make(2 * radiusX + 1, 2 * radiusY + 1);
SkIPoint kernelOffset = SkIPoint::Make(radiusX, radiusY);
GrPaint paint;
paint.setGammaCorrect(drawContext->isGammaCorrect());
SkIRect bounds = srcBounds ? *srcBounds : SkIRect::EmptyIRect();
sk_sp<GrFragmentProcessor> conv(GrMatrixConvolutionEffect::MakeGaussian(
texture, bounds, size, 1.0, 0.0, kernelOffset,
srcBounds ? GrTextureDomain::kDecal_Mode : GrTextureDomain::kIgnore_Mode,
true, sigmaX, sigmaY));
paint.addColorFragmentProcessor(std::move(conv));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
drawContext->fillRectWithLocalMatrix(clip, paint, SkMatrix::I(),
SkRect::Make(dstRect), localMatrix);
}
示例2: drawSpriteWithFilter
void SkBaseDevice::drawSpriteWithFilter(const SkDraw& draw, const SkBitmap& bitmap,
int x, int y,
const SkPaint& paint) {
SkImageFilter* filter = paint.getImageFilter();
SkASSERT(filter);
if (!this->canHandleImageFilter(filter)) {
SkImageFilter::DeviceProxy proxy(this);
SkIPoint offset = SkIPoint::Make(0, 0);
SkMatrix matrix = *draw.fMatrix;
matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
const SkIRect clipBounds = draw.fClip->getBounds().makeOffset(-x, -y);
SkAutoTUnref<SkImageFilter::Cache> cache(this->getImageFilterCache());
SkImageFilter::Context ctx(matrix, clipBounds, cache.get());
sk_sp<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(&proxy, bitmap,
&this->surfaceProps()));
if (!srcImg) {
return; // something disastrous happened
}
sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offset));
if (resultImg) {
SkPaint tmpUnfiltered(paint);
tmpUnfiltered.setImageFilter(nullptr);
SkBitmap resultBM;
if (resultImg->internal_getBM(&resultBM)) {
// TODO: add drawSprite(SkSpecialImage) to SkDevice? (see skbug.com/5073)
this->drawSprite(draw, resultBM, x + offset.x(), y + offset.y(), tmpUnfiltered);
}
}
} else {
this->drawSprite(draw, bitmap, x, y, paint);
}
}
示例3: INHERITED
GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(sk_sp<GrTextureProxy> proxy,
const SkIRect& bounds,
const SkISize& kernelSize,
const SkScalar* kernel,
SkScalar gain,
SkScalar bias,
const SkIPoint& kernelOffset,
GrTextureDomain::Mode tileMode,
bool convolveAlpha)
// To advertise either the modulation or opaqueness optimizations we'd have to examine the
// parameters.
: INHERITED(kGrMatrixConvolutionEffect_ClassID, kNone_OptimizationFlags)
, fCoordTransform(proxy.get())
, fDomain(proxy.get(), GrTextureDomain::MakeTexelDomainForMode(bounds, tileMode), tileMode)
, fTextureSampler(std::move(proxy))
, fKernelSize(kernelSize)
, fGain(SkScalarToFloat(gain))
, fBias(SkScalarToFloat(bias) / 255.0f)
, fConvolveAlpha(convolveAlpha) {
this->addCoordTransform(&fCoordTransform);
this->addTextureSampler(&fTextureSampler);
for (int i = 0; i < kernelSize.width() * kernelSize.height(); i++) {
fKernel[i] = SkScalarToFloat(kernel[i]);
}
fKernelOffset[0] = static_cast<float>(kernelOffset.x());
fKernelOffset[1] = static_cast<float>(kernelOffset.y());
}
示例4: drawSpecial
void SkBitmapDevice::drawSpecial(const SkDraw& draw, SkSpecialImage* srcImg, int x, int y,
const SkPaint& paint) {
SkASSERT(!srcImg->isTextureBacked());
SkBitmap resultBM;
SkImageFilter* filter = paint.getImageFilter();
if (filter) {
SkIPoint offset = SkIPoint::Make(0, 0);
SkMatrix matrix = *draw.fMatrix;
matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
const SkIRect clipBounds = draw.fRC->getBounds().makeOffset(-x, -y);
SkAutoTUnref<SkImageFilterCache> cache(this->getImageFilterCache());
SkImageFilter::OutputProperties outputProperties(fBitmap.colorSpace());
SkImageFilter::Context ctx(matrix, clipBounds, cache.get(), outputProperties);
sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg, ctx, &offset));
if (resultImg) {
SkPaint tmpUnfiltered(paint);
tmpUnfiltered.setImageFilter(nullptr);
if (resultImg->getROPixels(&resultBM)) {
this->drawSprite(draw, resultBM, x + offset.x(), y + offset.y(), tmpUnfiltered);
}
}
} else {
if (srcImg->getROPixels(&resultBM)) {
this->drawSprite(draw, resultBM, x, y, paint);
}
}
}
示例5:
sk_sp<GrTextureProxy> SkImageGenerator::generateTexture(GrContext* ctx, const SkImageInfo& info,
const SkIPoint& origin) {
SkIRect srcRect = SkIRect::MakeXYWH(origin.x(), origin.y(), info.width(), info.height());
if (!SkIRect::MakeWH(fInfo.width(), fInfo.height()).contains(srcRect)) {
return nullptr;
}
return this->onGenerateTexture(ctx, info, origin);
}
示例6: validator
sk_sp<SkImage> SkImage_Lazy::onMakeSubset(const SkIRect& subset) const {
SkASSERT(fInfo.bounds().contains(subset));
SkASSERT(fInfo.bounds() != subset);
const SkIRect generatorSubset = subset.makeOffset(fOrigin.x(), fOrigin.y());
Validator validator(fSharedGenerator, &generatorSubset, fInfo.refColorSpace());
return validator ? sk_sp<SkImage>(new SkImage_Lazy(&validator)) : nullptr;
}
示例7:
const SkGlyph& SkGlyphCache::getGlyphMetrics(SkGlyphID glyphID, SkPoint position) {
if (!fIsSubpixel) {
return this->getGlyphIDMetrics(glyphID);
} else {
SkIPoint lookupPosition = SkGlyphCacheCommon::SubpixelLookup(fAxisAlignment, position);
return this->getGlyphIDMetrics(glyphID, lookupPosition.x(), lookupPosition.y());
}
}
示例8: 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;
}
示例9: input
sk_sp<SkSpecialImage> SkDropShadowImageFilter::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;
}
const SkIRect inputBounds = SkIRect::MakeXYWH(inputOffset.x(), inputOffset.y(),
input->width(), input->height());
SkIRect bounds;
if (!this->applyCropRect(ctx, inputBounds, &bounds)) {
return nullptr;
}
const 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);
canvas->clear(0x0);
SkVector sigma = SkVector::Make(fSigmaX, fSigmaY);
ctx.ctm().mapVectors(&sigma, 1);
sigma.fX = SkMaxScalar(0, sigma.fX);
sigma.fY = SkMaxScalar(0, sigma.fY);
SkAutoTUnref<SkImageFilter> blurFilter(SkBlurImageFilter::Create(sigma.fX, sigma.fY));
SkPaint paint;
paint.setImageFilter(blurFilter.get());
paint.setColorFilter(SkColorFilter::MakeModeFilter(fColor, SkXfermode::kSrcIn_Mode));
paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
SkVector offsetVec = SkVector::Make(fDx, fDy);
ctx.ctm().mapVectors(&offsetVec, 1);
canvas->translate(SkIntToScalar(inputOffset.fX - bounds.fLeft),
SkIntToScalar(inputOffset.fY - bounds.fTop));
input->draw(canvas, offsetVec.fX, offsetVec.fY, &paint);
if (fShadowMode == kDrawShadowAndForeground_ShadowMode) {
input->draw(canvas, 0, 0, nullptr);
}
offset->fX = bounds.fLeft;
offset->fY = bounds.fTop;
return surf->makeImageSnapshot();
}
示例10: onDraw
void onDraw(SkCanvas* canvas) override {
auto cf = SkColorFilter::MakeModeFilter(SK_ColorGREEN, SkXfermode::kSrc_Mode);
sk_sp<SkImageFilter> filters[] = {
SkColorFilterImageFilter::Make(std::move(cf), nullptr),
SkBlurImageFilter::Make(2.0f, 2.0f, nullptr),
SkDropShadowImageFilter::Make(
10.0f, 5.0f, 3.0f, 3.0f, SK_ColorBLUE,
SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode,
nullptr),
};
SkIRect clipBounds[] {
{ -20, -20, 100, 100 },
{ 0, 0, 75, 75 },
{ 20, 20, 100, 100 },
{ -20, -20, 50, 50 },
{ 20, 20, 50, 50 },
};
SkImageInfo info = SkImageInfo::MakeN32(100, 100, kPremul_SkAlphaType);
SkScalar MARGIN = SkIntToScalar(40);
SkScalar DX = info.width() + MARGIN;
SkScalar DY = info.height() + MARGIN;
canvas->translate(MARGIN, MARGIN);
sk_sp<SkSurface> surface = canvas->makeSurface(info);
if (!surface) {
surface = SkSurface::MakeRaster(info);
}
sk_tool_utils::draw_checkerboard(surface->getCanvas());
sk_sp<SkImage> source = surface->makeImageSnapshot();
for (auto clipBound : clipBounds) {
canvas->save();
for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
SkIRect subset = SkIRect::MakeXYWH(25, 25, 50, 50);
SkIRect outSubset;
SkIPoint offset;
sk_sp<SkImage> result = source->makeWithFilter(filters[i].get(), subset, clipBound,
&outSubset, &offset);
SkASSERT(result);
SkASSERT(source->isTextureBacked() == result->isTextureBacked());
result = result->makeSubset(outSubset);
canvas->drawImage(result.get(), SkIntToScalar(offset.fX), SkIntToScalar(offset.fY));
show_bounds(canvas, SkIRect::MakeXYWH(offset.x(), offset.y(), outSubset.width(),
outSubset.height()), clipBound);
canvas->translate(DX, 0);
}
canvas->restore();
canvas->translate(0, DY);
}
}
示例11: 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;
}
示例12: lockAsBitmap
bool SkImage_Lazy::lockAsBitmap(SkBitmap* bitmap, SkImage::CachingHint chint, CachedFormat format,
const SkImageInfo& info,
SkTransferFunctionBehavior behavior) const {
if (this->lockAsBitmapOnlyIfAlreadyCached(bitmap, format)) {
return true;
}
uint32_t uniqueID = this->getUniqueID(format);
SkBitmap tmpBitmap;
SkBitmapCache::RecPtr cacheRec;
SkPixmap pmap;
if (SkImage::kAllow_CachingHint == chint) {
auto desc = SkBitmapCacheDesc::Make(uniqueID, info.width(), info.height());
cacheRec = SkBitmapCache::Alloc(desc, info, &pmap);
if (!cacheRec) {
return false;
}
} else {
if (!tmpBitmap.tryAllocPixels(info)) {
return false;
}
if (!tmpBitmap.peekPixels(&pmap)) {
return false;
}
}
ScopedGenerator generator(fSharedGenerator);
if (!generate_pixels(generator, pmap, fOrigin.x(), fOrigin.y(), behavior)) {
return false;
}
if (cacheRec) {
SkBitmapCache::Add(std::move(cacheRec), bitmap);
SkASSERT(bitmap->getPixels()); // we're locked
SkASSERT(bitmap->isImmutable());
SkASSERT(bitmap->getGenerationID() == uniqueID);
this->notifyAddedToCache();
} else {
*bitmap = tmpBitmap;
bitmap->pixelRef()->setImmutableWithID(uniqueID);
}
check_output_bitmap(*bitmap, uniqueID);
return true;
}
示例13: autoAquire
sk_sp<SkImage> SkImage_Lazy::onMakeColorSpace(sk_sp<SkColorSpace> target,
SkColorType targetColorType,
SkTransferFunctionBehavior premulBehavior) const {
SkAutoExclusive autoAquire(fOnMakeColorSpaceMutex);
if (target && fOnMakeColorSpaceTarget &&
SkColorSpace::Equals(target.get(), fOnMakeColorSpaceTarget.get())) {
return fOnMakeColorSpaceResult;
}
const SkIRect generatorSubset =
SkIRect::MakeXYWH(fOrigin.x(), fOrigin.y(), fInfo.width(), fInfo.height());
Validator validator(fSharedGenerator, &generatorSubset, target);
sk_sp<SkImage> result = validator ? sk_sp<SkImage>(new SkImage_Lazy(&validator)) : nullptr;
if (result) {
fOnMakeColorSpaceTarget = target;
fOnMakeColorSpaceResult = result;
}
return result;
}
示例14: drawBitmapAsSprite
void SkBaseDevice::drawBitmapAsSprite(const SkDraw& draw, const SkBitmap& bitmap, int x, int y,
const SkPaint& paint) {
SkImageFilter* filter = paint.getImageFilter();
if (filter && !this->canHandleImageFilter(filter)) {
SkImageFilter::DeviceProxy proxy(this);
SkBitmap dst;
SkIPoint offset = SkIPoint::Make(0, 0);
SkMatrix matrix = *draw.fMatrix;
matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
const SkIRect clipBounds = draw.fClip->getBounds().makeOffset(-x, -y);
SkAutoTUnref<SkImageFilter::Cache> cache(this->getImageFilterCache());
SkImageFilter::Context ctx(matrix, clipBounds, cache.get());
if (filter->filterImageDeprecated(&proxy, bitmap, ctx, &dst, &offset)) {
SkPaint tmpUnfiltered(paint);
tmpUnfiltered.setImageFilter(nullptr);
this->drawSprite(draw, dst, x + offset.x(), y + offset.y(), tmpUnfiltered);
}
} else {
this->drawSprite(draw, bitmap, x, y, paint);
}
}
示例15: SkInstallDiscardablePixelRef
bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, const SkIRect* subset, SkBitmap* dst,
SkDiscardableMemory::Factory* factory) {
SkAutoTDelete<SkImageGenerator> autoGenerator(generator);
if (NULL == autoGenerator.get()) {
return false;
}
SkImageInfo prInfo = autoGenerator->getInfo();
if (prInfo.isEmpty()) {
return false;
}
SkIPoint origin = SkIPoint::Make(0, 0);
SkImageInfo bmInfo = prInfo;
if (subset) {
const SkIRect prBounds = SkIRect::MakeWH(prInfo.width(), prInfo.height());
if (subset->isEmpty() || !prBounds.contains(*subset)) {
return false;
}
bmInfo = prInfo.makeWH(subset->width(), subset->height());
origin.set(subset->x(), subset->y());
}
// must compute our desired rowBytes w.r.t. the pixelRef's dimensions, not ours, which may be
// smaller.
if (!dst->setInfo(bmInfo, prInfo.minRowBytes())) {
return false;
}
// Since dst->setInfo() may have changed/fixed-up info, we check from the bitmap
SkASSERT(dst->info().colorType() != kUnknown_SkColorType);
if (dst->empty()) { // Use a normal pixelref.
return dst->tryAllocPixels();
}
SkAutoTUnref<SkDiscardablePixelRef> ref(
new SkDiscardablePixelRef(prInfo, autoGenerator.detach(), dst->rowBytes(), factory));
dst->setPixelRef(ref, origin.x(), origin.y());
return true;
}