本文整理汇总了C++中sk_sp类的典型用法代码示例。如果您正苦于以下问题:C++ sk_sp类的具体用法?C++ sk_sp怎么用?C++ sk_sp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sk_sp类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: onDraw
void onDraw(SkCanvas* canvas) override {
canvas->translate(20, 20);
const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
for (size_t i = 0; i < SK_ARRAY_COUNT(gProcs); ++i) {
sk_sp<SkImage> image(gProcs[i](canvas->getGrContext(), fPicture.get(), info));
if (image) {
this->testImage(canvas, image.get());
}
canvas->translate(120, 0);
}
}
开发者ID:AHPlankton,项目名称:skia,代码行数:13,代码来源:image_shader.cpp
示例2: initPathEffect
void GrStyle::initPathEffect(sk_sp<SkPathEffect> pe) {
SkASSERT(!fPathEffect);
SkASSERT(SkPathEffect::kNone_DashType == fDashInfo.fType);
SkASSERT(0 == fDashInfo.fIntervals.count());
if (!pe) {
return;
}
SkPathEffect::DashInfo info;
if (SkPathEffect::kDash_DashType == pe->asADash(&info)) {
SkStrokeRec::Style recStyle = fStrokeRec.getStyle();
if (recStyle != SkStrokeRec::kFill_Style && recStyle != SkStrokeRec::kStrokeAndFill_Style) {
fDashInfo.fType = SkPathEffect::kDash_DashType;
fDashInfo.fIntervals.reset(info.fCount);
fDashInfo.fPhase = info.fPhase;
info.fIntervals = fDashInfo.fIntervals.get();
pe->asADash(&info);
fPathEffect = std::move(pe);
}
} else {
fPathEffect = std::move(pe);
}
}
开发者ID:MIPS,项目名称:external-skia,代码行数:22,代码来源:GrStyle.cpp
示例3: SkASSERT
std::unique_ptr<GrDrawOp> GrDrawVerticesOp::Make(GrPaint&& paint,
sk_sp<SkVertices> vertices,
const SkMatrix& viewMatrix,
GrAAType aaType,
bool gammaCorrect,
sk_sp<GrColorSpaceXform> colorSpaceXform,
GrPrimitiveType* overridePrimType) {
SkASSERT(vertices);
GrPrimitiveType primType = overridePrimType ? *overridePrimType
: SkVertexModeToGrPrimitiveType(vertices->mode());
return Helper::FactoryHelper<GrDrawVerticesOp>(std::move(paint), std::move(vertices), primType,
aaType, gammaCorrect, std::move(colorSpaceXform),
viewMatrix);
}
开发者ID:MIPS,项目名称:external-skia,代码行数:14,代码来源:GrDrawVerticesOp.cpp
示例4: SkDEBUGFAIL
sk_sp<GrTextureContext> GrDrawingManager::makeTextureContext(sk_sp<GrSurfaceProxy> sProxy,
sk_sp<SkColorSpace> colorSpace) {
if (this->wasAbandoned() || !sProxy->asTextureProxy()) {
return nullptr;
}
// SkSurface catches bad color space usage at creation. This check handles anything that slips
// by, including internal usage.
if (!SkSurface_Gpu::Valid(fContext, sProxy->config(), colorSpace.get())) {
SkDEBUGFAIL("Invalid config and colorspace combination");
return nullptr;
}
// GrTextureRenderTargets should always be using a GrRenderTargetContext
SkASSERT(!sProxy->asRenderTargetProxy());
sk_sp<GrTextureProxy> textureProxy(sk_ref_sp(sProxy->asTextureProxy()));
return sk_sp<GrTextureContext>(new GrTextureContext(fContext, this, std::move(textureProxy),
std::move(colorSpace),
fContext->contextPriv().getAuditTrail(),
fSingleOwner));
}
开发者ID:vschs007,项目名称:skia,代码行数:23,代码来源:GrDrawingManager.cpp
示例5: sk_ref_sp
sk_sp<SkImage> SkImage::makeColorSpace(sk_sp<SkColorSpace> target,
SkTransferFunctionBehavior premulBehavior) const {
SkColorSpaceTransferFn fn;
if (!target || !target->isNumericalTransferFn(&fn)) {
return nullptr;
}
// No need to create a new image if:
// (1) The color spaces are equal.
// (2) The color type is kAlpha8.
if (SkColorSpace::Equals(this->colorSpace(), target.get()) ||
kAlpha_8_SkColorType == as_IB(this)->onImageInfo().colorType()) {
return sk_ref_sp(const_cast<SkImage*>(this));
}
SkColorType targetColorType = kN32_SkColorType;
if (SkTransferFunctionBehavior::kRespect == premulBehavior && target->gammaIsLinear()) {
targetColorType = kRGBA_F16_SkColorType;
}
// TODO: We might consider making this a deferred conversion?
return as_IB(this)->onMakeColorSpace(std::move(target), targetColorType, premulBehavior);
}
开发者ID:vschs007,项目名称:skia,代码行数:23,代码来源:SkImage.cpp
示例6: SkASSERT
void GrResourceIOProcessor::TextureSampler::reset(GrResourceProvider* resourceProvider,
sk_sp<GrTextureProxy> proxy,
GrSamplerParams::FilterMode filterMode,
SkShader::TileMode tileXAndY,
GrShaderFlags visibility) {
// For now, end the deferral at this time. Once all the TextureSamplers are swapped over
// to taking a GrSurfaceProxy just use the IORefs on the proxy
GrTexture* texture = proxy->instantiate(resourceProvider);
SkASSERT(texture);
fTexture.set(SkRef(texture), kRead_GrIOType);
filterMode = SkTMin(filterMode, texture->texturePriv().highestFilterMode());
fParams.reset(tileXAndY, filterMode);
fVisibility = visibility;
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:14,代码来源:GrProcessor.cpp
示例7: FuzzImageFilterDeserialize
void FuzzImageFilterDeserialize(sk_sp<SkData> bytes) {
const int BitmapSize = 24;
SkBitmap bitmap;
bitmap.allocN32Pixels(BitmapSize, BitmapSize);
SkCanvas canvas(bitmap);
canvas.clear(0x00000000);
auto flattenable = SkImageFilter::Deserialize(bytes->data(), bytes->size());
if (flattenable != nullptr) {
// Let's see if using the filters can cause any trouble...
SkPaint paint;
paint.setImageFilter(flattenable);
canvas.save();
canvas.clipRect(SkRect::MakeXYWH(
0, 0, SkIntToScalar(BitmapSize), SkIntToScalar(BitmapSize)));
// This call shouldn't crash or cause ASAN to flag any memory issues
// If nothing bad happens within this call, everything is fine
canvas.drawBitmap(bitmap, 0, 0, &paint);
canvas.restore();
}
}
开发者ID:HalCanary,项目名称:skia-hc,代码行数:24,代码来源:FuzzImageFilterDeserialize.cpp
示例8: test_surface
// Exercise the public API of SkSpecialSurface (e.g., getCanvas, newImageSnapshot)
static void test_surface(const sk_sp<SkSpecialSurface>& surf,
skiatest::Reporter* reporter,
int offset) {
const SkIRect surfSubset = TestingSpecialSurfaceAccess::Subset(surf.get());
REPORTER_ASSERT(reporter, offset == surfSubset.fLeft);
REPORTER_ASSERT(reporter, offset == surfSubset.fTop);
REPORTER_ASSERT(reporter, kSmallerSize == surfSubset.width());
REPORTER_ASSERT(reporter, kSmallerSize == surfSubset.height());
SkCanvas* canvas = surf->getCanvas();
SkASSERT_RELEASE(canvas);
canvas->clear(SK_ColorRED);
sk_sp<SkSpecialImage> img(surf->makeImageSnapshot());
REPORTER_ASSERT(reporter, img);
const SkIRect imgSubset = img->subset();
REPORTER_ASSERT(reporter, surfSubset == imgSubset);
// the canvas was invalidated by the newImageSnapshot call
REPORTER_ASSERT(reporter, !surf->getCanvas());
}
开发者ID:aseprite,项目名称:skia,代码行数:25,代码来源:SpecialSurfaceTest.cpp
示例9: AttachStroke
sk_sp<sksg::PaintNode> AttachStroke(const Json::Value& jstroke, AttachContext* ctx,
sk_sp<sksg::PaintNode> stroke_node) {
SkASSERT(jstroke.isObject());
if (!stroke_node)
return nullptr;
stroke_node->setStyle(SkPaint::kStroke_Style);
auto width_attached = BindProperty<ScalarValue>(jstroke["w"], &ctx->fAnimators,
[stroke_node](const ScalarValue& w) {
stroke_node->setStrokeWidth(w);
});
if (!width_attached)
return nullptr;
stroke_node->setStrokeMiter(ParseDefault(jstroke["ml"], 4.0f));
static constexpr SkPaint::Join gJoins[] = {
SkPaint::kMiter_Join,
SkPaint::kRound_Join,
SkPaint::kBevel_Join,
};
stroke_node->setStrokeJoin(gJoins[SkTPin<int>(ParseDefault(jstroke["lj"], 1) - 1,
0, SK_ARRAY_COUNT(gJoins) - 1)]);
static constexpr SkPaint::Cap gCaps[] = {
SkPaint::kButt_Cap,
SkPaint::kRound_Cap,
SkPaint::kSquare_Cap,
};
stroke_node->setStrokeCap(gCaps[SkTPin<int>(ParseDefault(jstroke["lc"], 1) - 1,
0, SK_ARRAY_COUNT(gCaps) - 1)]);
return stroke_node;
}
开发者ID:vschs007,项目名称:skia,代码行数:36,代码来源:Skottie.cpp
示例10: proc
sk_sp<SkPixelRef> SkMallocPixelRef::MakeWithProc(const SkImageInfo& info,
size_t rowBytes,
sk_sp<SkColorTable> ctable,
void* addr,
SkMallocPixelRef::ReleaseProc proc,
void* context) {
if (!is_valid(info, ctable.get())) {
if (proc) {
proc(addr, context);
}
return nullptr;
}
return sk_sp<SkPixelRef>(new SkMallocPixelRef(info, addr, rowBytes, std::move(ctable),
proc, context));
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:15,代码来源:SkMallocPixelRef.cpp
示例11: SkASSERT
sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context,
sk_sp<GrTextureProxy> inputProxy,
const CopyParams& copyParams,
bool dstWillRequireMipMaps) {
SkASSERT(context);
const SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight);
GrMipMapped mipMapped = dstWillRequireMipMaps ? GrMipMapped::kYes : GrMipMapped::kNo;
SkRect localRect = SkRect::MakeWH(inputProxy->width(), inputProxy->height());
bool needsDomain = false;
bool resizing = false;
if (copyParams.fFilter != GrSamplerState::Filter::kNearest) {
bool resizing = localRect.width() != dstRect.width() ||
localRect.height() != dstRect.height();
needsDomain = resizing && !GrProxyProvider::IsFunctionallyExact(inputProxy.get());
}
if (copyParams.fFilter == GrSamplerState::Filter::kNearest && !needsDomain && !resizing &&
dstWillRequireMipMaps) {
sk_sp<GrTextureProxy> proxy = GrCopyBaseMipMapToTextureProxy(context, inputProxy.get());
if (proxy) {
return proxy;
}
}
sk_sp<GrRenderTargetContext> copyRTC =
context->contextPriv().makeDeferredRenderTargetContextWithFallback(
SkBackingFit::kExact, dstRect.width(), dstRect.height(), inputProxy->config(),
nullptr, 1, mipMapped, inputProxy->origin());
if (!copyRTC) {
return nullptr;
}
GrPaint paint;
if (needsDomain) {
const SkRect domain = localRect.makeInset(0.5f, 0.5f);
// This would cause us to read values from outside the subset. Surely, the caller knows
// better!
SkASSERT(copyParams.fFilter != GrSamplerState::Filter::kMipMap);
paint.addColorFragmentProcessor(
GrTextureDomainEffect::Make(std::move(inputProxy), SkMatrix::I(), domain,
GrTextureDomain::kClamp_Mode, copyParams.fFilter));
} else {
GrSamplerState samplerState(GrSamplerState::WrapMode::kClamp, copyParams.fFilter);
paint.addColorTextureProcessor(std::move(inputProxy), SkMatrix::I(), samplerState);
}
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
copyRTC->fillRectToRect(GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(), dstRect,
localRect);
return copyRTC->asTextureProxyRef();
}
开发者ID:jasonLaster,项目名称:gecko-dev,代码行数:55,代码来源:GrTextureProducer.cpp
示例12: SkSpecialSurface_Gpu
SkSpecialSurface_Gpu(GrContext* context, sk_sp<GrRenderTargetContext> renderTargetContext,
int width, int height, const SkIRect& subset)
: INHERITED(subset, &renderTargetContext->surfaceProps())
, fRenderTargetContext(std::move(renderTargetContext)) {
sk_sp<SkBaseDevice> device(SkGpuDevice::Make(context, fRenderTargetContext, width, height,
SkGpuDevice::kUninit_InitContents));
if (!device) {
return;
}
fCanvas.reset(new SkCanvas(device));
fCanvas->clipRect(SkRect::Make(subset));
#ifdef SK_IS_BOT
fCanvas->clear(SK_ColorRED); // catch any imageFilter sloppiness
#endif
}
开发者ID:molikto,项目名称:Skia,代码行数:17,代码来源:SkSpecialSurface.cpp
示例13: gradCheck
void gradCheck(skiatest::Reporter* reporter, const sk_sp<SkShader>& shader,
SkShader::GradientInfo* info,
SkShader::GradientType gt) const {
SkAutoTMalloc<SkColor> colorStorage(fColorCount);
SkAutoTMalloc<SkScalar> posStorage(fColorCount);
info->fColorCount = fColorCount;
info->fColors = colorStorage;
info->fColorOffsets = posStorage.get();
REPORTER_ASSERT(reporter, shader->asAGradient(info) == gt);
REPORTER_ASSERT(reporter, info->fColorCount == fColorCount);
REPORTER_ASSERT(reporter,
!memcmp(info->fColors, fColors, fColorCount * sizeof(SkColor)));
REPORTER_ASSERT(reporter,
!memcmp(info->fColorOffsets, fPos, fColorCount * sizeof(SkScalar)));
REPORTER_ASSERT(reporter, fTileMode == (SkTileMode)info->fTileMode);
}
开发者ID:,项目名称:,代码行数:18,代码来源:
示例14: test_dont_find_if_diff_key
// If either id is different or the clip or the matrix are different the
// cached image won't be found. Even if it is caching the same bitmap.
static void test_dont_find_if_diff_key(skiatest::Reporter* reporter,
const sk_sp<SkSpecialImage>& image,
const sk_sp<SkSpecialImage>& subset) {
static const size_t kCacheSize = 1000000;
SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kCacheSize));
SkIRect clip1 = SkIRect::MakeWH(100, 100);
SkIRect clip2 = SkIRect::MakeWH(200, 200);
SkImageFilter::Cache::Key key0(0, SkMatrix::I(), clip1, image->uniqueID(), image->subset());
SkImageFilter::Cache::Key key1(1, SkMatrix::I(), clip1, image->uniqueID(), image->subset());
SkImageFilter::Cache::Key key2(0, SkMatrix::MakeTrans(5, 5), clip1,
image->uniqueID(), image->subset());
SkImageFilter::Cache::Key key3(0, SkMatrix::I(), clip2, image->uniqueID(), image->subset());
SkImageFilter::Cache::Key key4(0, SkMatrix::I(), clip1, subset->uniqueID(), subset->subset());
SkIPoint offset = SkIPoint::Make(3, 4);
cache->set(key0, image.get(), offset);
SkIPoint foundOffset;
REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset));
REPORTER_ASSERT(reporter, !cache->get(key2, &foundOffset));
REPORTER_ASSERT(reporter, !cache->get(key3, &foundOffset));
REPORTER_ASSERT(reporter, !cache->get(key4, &foundOffset));
}
开发者ID:BertiKarsunke,项目名称:skia,代码行数:26,代码来源:ImageFilterCacheTest.cpp
示例15: SkASSERT
std::unique_ptr<GrDrawOp> GrDrawVerticesOp::Make(GrRecordingContext* context,
GrPaint&& paint,
sk_sp<SkVertices> vertices,
const SkVertices::Bone bones[],
int boneCount,
const SkMatrix& viewMatrix,
GrAAType aaType,
sk_sp<GrColorSpaceXform> colorSpaceXform,
GrPrimitiveType* overridePrimType) {
SkASSERT(vertices);
GrPrimitiveType primType = overridePrimType ? *overridePrimType
: SkVertexModeToGrPrimitiveType(vertices->mode());
return GrSimpleMeshDrawOpHelper::FactoryHelper<DrawVerticesOp>(context, std::move(paint),
std::move(vertices),
bones, boneCount,
primType, aaType,
std::move(colorSpaceXform),
viewMatrix);
}
开发者ID:,项目名称:,代码行数:19,代码来源:
示例16: SkTMax
sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context, const GrBackendTexture& tex,
GrSurfaceOrigin origin, int sampleCnt,
SkColorType colorType,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* props) {
if (!context) {
return nullptr;
}
sampleCnt = SkTMax(1, sampleCnt);
GrBackendTexture texCopy = tex;
if (!validate_backend_texture(context, texCopy, &texCopy.fConfig,
sampleCnt, colorType, colorSpace, true)) {
return nullptr;
}
if (!context) {
return nullptr;
}
if (!SkSurface_Gpu::Valid(context, texCopy.config(), colorSpace.get())) {
return nullptr;
}
sampleCnt = SkTMax(1, sampleCnt);
sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeBackendTextureRenderTargetContext(
texCopy,
origin,
sampleCnt,
std::move(colorSpace),
props));
if (!rtc) {
return nullptr;
}
sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), texCopy.width(),
texCopy.height(),
SkGpuDevice::kUninit_InitContents));
if (!device) {
return nullptr;
}
return sk_make_sp<SkSurface_Gpu>(std::move(device));
}
开发者ID:vschs007,项目名称:skia,代码行数:41,代码来源:SkSurface_Gpu.cpp
示例17: SkToS32
sk_sp<SkPixelRef> SkMallocPixelRef::MakeUsing(void*(*alloc)(size_t),
const SkImageInfo& info,
size_t requestedRowBytes,
sk_sp<SkColorTable> ctable) {
if (!is_valid(info, ctable.get())) {
return nullptr;
}
// only want to permit 31bits of rowBytes
int64_t minRB = (int64_t)info.minRowBytes64();
if (minRB < 0 || !sk_64_isS32(minRB)) {
return nullptr; // allocation will be too large
}
if (requestedRowBytes > 0 && (int32_t)requestedRowBytes < minRB) {
return nullptr; // cannot meet requested rowbytes
}
int32_t rowBytes;
if (requestedRowBytes) {
rowBytes = SkToS32(requestedRowBytes);
} else {
rowBytes = minRB;
}
int64_t bigSize = (int64_t)info.height() * rowBytes;
if (!sk_64_isS32(bigSize)) {
return nullptr;
}
size_t size = sk_64_asS32(bigSize);
SkASSERT(size >= info.getSafeSize(rowBytes));
void* addr = alloc(size);
if (nullptr == addr) {
return nullptr;
}
return sk_sp<SkPixelRef>(new SkMallocPixelRef(info, addr, rowBytes, std::move(ctable),
sk_free_releaseproc, nullptr));
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:39,代码来源:SkMallocPixelRef.cpp
示例18: GrMakeCachedImageProxy
sk_sp<GrTextureProxy> GrMakeCachedImageProxy(GrProxyProvider* proxyProvider,
sk_sp<SkImage> srcImage,
SkBackingFit fit) {
sk_sp<GrTextureProxy> proxy;
GrUniqueKey originalKey;
create_unique_key_for_image(srcImage.get(), &originalKey);
if (originalKey.isValid()) {
proxy = proxyProvider->findOrCreateProxyByUniqueKey(originalKey, kTopLeft_GrSurfaceOrigin);
}
if (!proxy) {
proxy = proxyProvider->createTextureProxy(std::move(srcImage), kNone_GrSurfaceFlags,
kTopLeft_GrSurfaceOrigin, 1, SkBudgeted::kYes,
fit);
if (proxy && originalKey.isValid()) {
proxyProvider->assignUniqueKeyToProxy(originalKey, proxy.get());
}
}
return proxy;
}
开发者ID:android,项目名称:platform_external_skia,代码行数:22,代码来源:SkGr.cpp
示例19: rtc
sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context,
const GrBackendRenderTarget& rt,
GrSurfaceOrigin origin,
SkColorType colorType,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* props) {
if (!context) {
return nullptr;
}
GrBackendRenderTarget rtCopy = rt;
if (!validate_backend_render_target(context, rtCopy, &rtCopy.fConfig, colorType, colorSpace)) {
return nullptr;
}
if (!SkSurface_Gpu::Valid(context, rtCopy.config(), colorSpace.get())) {
return nullptr;
}
if (!context) {
return nullptr;
}
sk_sp<GrRenderTargetContext> rtc(
context->contextPriv().makeBackendRenderTargetRenderTargetContext(
rtCopy, origin, std::move(colorSpace), props));
if (!rtc) {
return nullptr;
}
sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc), rtCopy.width(),
rtCopy.height(),
SkGpuDevice::kUninit_InitContents));
if (!device) {
return nullptr;
}
return sk_make_sp<SkSurface_Gpu>(std::move(device));
}
开发者ID:vschs007,项目名称:skia,代码行数:38,代码来源:SkSurface_Gpu.cpp
示例20: drawContext
sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context,
sk_sp<GrFragmentProcessor> fp,
const SkIRect& bounds) {
GrPaint paint;
paint.addColorFragmentProcessor(fp.get());
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
sk_sp<GrDrawContext> drawContext(context->newDrawContext(GrContext::kLoose_BackingFit,
bounds.width(), bounds.height(),
kRGBA_8888_GrPixelConfig));
if (!drawContext) {
return nullptr;
}
SkRect srcRect = SkRect::Make(bounds);
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
GrClip clip(dstRect);
drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.height()),
kNeedNewImageUniqueID_SpecialImage,
drawContext->asTexture());
}
开发者ID:JavierJF,项目名称:skia,代码行数:23,代码来源:SkImageFilter.cpp
注:本文中的sk_sp类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论