本文整理汇总了C++中sk_sp::height方法的典型用法代码示例。如果您正苦于以下问题:C++ sk_sp::height方法的具体用法?C++ sk_sp::height怎么用?C++ sk_sp::height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sk_sp
的用法示例。
在下文中一共展示了sk_sp::height方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SkASSERT
sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(const SkIRect& subset,
sk_sp<SkImage> image,
const SkSurfaceProps* props) {
SkASSERT(rect_fits(subset, image->width(), image->height()));
return sk_make_sp<SkSpecialImage_Image>(subset, image, props);
}
示例2: dopatch
static void dopatch(SkCanvas* canvas, const SkColor colors[], sk_sp<SkImage> img = nullptr) {
SkPaint paint;
const SkBlendMode modes[] = {
SkBlendMode::kSrc,
SkBlendMode::kDst,
SkBlendMode::kModulate,
};
SkPoint texStorage[4];
const SkPoint* tex = gTexCoords;
sk_sp<SkShader> shader;
if (img) {
SkScalar w = img->width();
SkScalar h = img->height();
shader = img->makeShader();
texStorage[0].set(0, 0);
texStorage[1].set(w, 0);
texStorage[2].set(w, h);
texStorage[3].set(0, h);
tex = texStorage;
} else {
shader = make_shader();
}
canvas->save();
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 4; x++) {
canvas->save();
canvas->translate(x * 350.0f, y * 350.0f);
switch (x) {
case 0:
canvas->drawPatch(gCubics, nullptr, nullptr, modes[y], paint);
break;
case 1:
canvas->drawPatch(gCubics, colors, nullptr, modes[y], paint);
break;
case 2:
paint.setShader(shader);
canvas->drawPatch(gCubics, nullptr, tex, modes[y], paint);
paint.setShader(nullptr);
break;
case 3:
paint.setShader(shader);
canvas->drawPatch(gCubics, colors, tex, modes[y], paint);
paint.setShader(nullptr);
break;
default:
break;
}
draw_control_points(canvas, gCubics);
canvas->restore();
}
}
canvas->restore();
}
示例3: SkImageShader
sk_sp<SkShader> SkImageShader::Make(sk_sp<SkImage> image,
TileMode tx, TileMode ty,
const SkMatrix* localMatrix,
bool clampAsIfUnpremul) {
if (!image || bitmap_is_too_big(image->width(), image->height())) {
return sk_make_sp<SkEmptyShader>();
}
return sk_sp<SkShader>{ new SkImageShader(image, tx,ty, localMatrix, clampAsIfUnpremul) };
}
示例4: SkASSERT
sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(const SkIRect& subset,
uint32_t uniqueID,
sk_sp<GrTexture> tex,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* props,
SkAlphaType at) {
SkASSERT(rect_fits(subset, tex->width(), tex->height()));
return sk_make_sp<SkSpecialImage_Gpu>(subset, uniqueID, std::move(tex), at,
std::move(colorSpace), props);
}
示例5: samplerState
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();
}
示例6: SkASSERT
sk_sp<SkSpecialImage> SkSpecialImage::MakeDeferredFromGpu(GrContext* context,
const SkIRect& subset,
uint32_t uniqueID,
sk_sp<GrTextureProxy> proxy,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* props,
SkAlphaType at) {
SkASSERT(rect_fits(subset, proxy->width(), proxy->height()));
return sk_make_sp<SkSpecialImage_Gpu>(context, subset, uniqueID, std::move(proxy), at,
std::move(colorSpace), props);
}
示例7: INHERITED
GrTextureAdjuster::GrTextureAdjuster(GrContext* context, sk_sp<GrTextureProxy> original,
SkAlphaType alphaType,
uint32_t uniqueID,
SkColorSpace* cs)
: INHERITED(original->width(), original->height(),
GrPixelConfigIsAlphaOnly(original->config()))
, fContext(context)
, fOriginal(std::move(original))
, fAlphaType(alphaType)
, fColorSpace(cs)
, fUniqueID(uniqueID) {}
示例8: INHERITED
SkImage_Gpu::SkImage_Gpu(GrContext* context, uint32_t uniqueID, SkAlphaType at,
sk_sp<GrTextureProxy> proxy,
sk_sp<SkColorSpace> colorSpace, SkBudgeted budgeted)
: INHERITED(proxy->width(), proxy->height(), uniqueID)
, fContext(context)
, fProxy(std::move(proxy))
, fAlphaType(at)
, fBudgeted(budgeted)
, fColorSpace(std::move(colorSpace))
, fAddedRasterVersionToCache(false) {
}
示例9:
sk_sp<SkSpecialImage> SkSpecialImage::MakeDeferredFromGpu(GrContext* context,
const SkIRect& subset,
uint32_t uniqueID,
sk_sp<GrTextureProxy> proxy,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* props,
SkAlphaType at) {
if (!context || context->contextPriv().abandoned() || !proxy) {
return nullptr;
}
SkASSERT_RELEASE(rect_fits(subset, proxy->width(), proxy->height()));
return sk_make_sp<SkSpecialImage_Gpu>(context, subset, uniqueID, std::move(proxy), at,
std::move(colorSpace), props);
}
示例10: INHERITED
SkSpecialSurface_Raster(const SkImageInfo& info,
sk_sp<SkPixelRef> pr,
const SkIRect& subset,
const SkSurfaceProps* props)
: INHERITED(subset, props) {
SkASSERT(info.width() == pr->width() && info.height() == pr->height());
fBitmap.setInfo(info, info.minRowBytes());
fBitmap.setPixelRef(std::move(pr), 0, 0);
fCanvas.reset(new SkCanvas(fBitmap, this->props()));
fCanvas->clipRect(SkRect::Make(subset));
#ifdef SK_IS_BOT
fCanvas->clear(SK_ColorRED); // catch any imageFilter sloppiness
#endif
}
示例11: device
sk_sp<SkSurface> SkSurface_Gpu::MakeWrappedRenderTarget(GrContext* context,
sk_sp<GrRenderTargetContext> rtc) {
if (!context) {
return nullptr;
}
sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc),
rtc->width(), rtc->height(),
SkGpuDevice::kUninit_InitContents));
if (!device) {
return nullptr;
}
return sk_make_sp<SkSurface_Gpu>(std::move(device));
}
示例12: MakeFromGpu
sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(const SkIRect& subset,
sk_sp<SkImage> image,
const SkSurfaceProps* props) {
SkASSERT(rect_fits(subset, image->width(), image->height()));
#if SK_SUPPORT_GPU
if (GrTexture* texture = as_IB(image)->peekTexture()) {
return MakeFromGpu(subset, image->uniqueID(), sk_ref_sp(texture),
sk_ref_sp(as_IB(image)->onImageInfo().colorSpace()), props);
} else
#endif
{
SkBitmap bm;
if (as_IB(image)->getROPixels(&bm)) {
return MakeFromRaster(subset, bm, props);
}
}
return nullptr;
}
示例13: test_basic_draw_as_src
// skbug.com/5932
static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* context,
sk_sp<GrTextureProxy> rectProxy, uint32_t expectedPixelValues[]) {
sk_sp<GrRenderTargetContext> rtContext(context->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kExact, rectProxy->width(),
rectProxy->height(), rectProxy->config(),
nullptr));
for (auto filter : {GrSamplerState::Filter::kNearest,
GrSamplerState::Filter::kBilerp,
GrSamplerState::Filter::kMipMap}) {
rtContext->clear(nullptr, 0xDDCCBBAA, GrRenderTargetContext::CanClearFullscreen::kYes);
auto fp = GrSimpleTextureEffect::Make(rectProxy, SkMatrix::I(), filter);
GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
paint.addColorFragmentProcessor(std::move(fp));
rtContext->drawPaint(GrNoClip(), std::move(paint), SkMatrix::I());
test_read_pixels(reporter, rtContext.get(), expectedPixelValues,
"RectangleTexture-basic-draw");
}
}
示例14: IntSize
bool
SourceSurfaceSkia::InitFromImage(sk_sp<SkImage> aImage,
SurfaceFormat aFormat,
DrawTargetSkia* aOwner)
{
if (!aImage) {
return false;
}
mSize = IntSize(aImage->width(), aImage->height());
// For the raster image case, we want to use the format and stride
// information that the underlying raster image is using, which is
// reliable.
// For the GPU case (for which peekPixels is false), we can't easily
// figure this information out. It is better to report the originally
// intended format and stride that we will convert to if this GPU
// image is ever read back into a raster image.
SkPixmap pixmap;
if (aImage->peekPixels(&pixmap)) {
mFormat =
aFormat != SurfaceFormat::UNKNOWN ?
aFormat :
SkiaColorTypeToGfxFormat(pixmap.colorType(), pixmap.alphaType());
mStride = pixmap.rowBytes();
} else if (aFormat != SurfaceFormat::UNKNOWN) {
mFormat = aFormat;
SkImageInfo info = MakeSkiaImageInfo(mSize, mFormat);
mStride = SkAlign4(info.minRowBytes());
} else {
return false;
}
mImage = aImage;
if (aOwner) {
mDrawTarget = aOwner;
}
return true;
}
示例15: MakeDeferredFromGpu
sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(const SkIRect& subset,
sk_sp<SkImage> image,
SkColorSpace* dstColorSpace,
const SkSurfaceProps* props) {
SkASSERT(rect_fits(subset, image->width(), image->height()));
#if SK_SUPPORT_GPU
if (sk_sp<GrTextureProxy> proxy = as_IB(image)->asTextureProxyRef()) {
GrContext* context = ((SkImage_Gpu*) as_IB(image))->context();
return MakeDeferredFromGpu(context, subset, image->uniqueID(), std::move(proxy),
as_IB(image)->onImageInfo().refColorSpace(), props);
} else
#endif
{
SkBitmap bm;
if (as_IB(image)->getROPixels(&bm, dstColorSpace)) {
return MakeFromRaster(subset, bm, props);
}
}
return nullptr;
}