本文整理汇总了C++中SkAssertResult函数的典型用法代码示例。如果您正苦于以下问题:C++ SkAssertResult函数的具体用法?C++ SkAssertResult怎么用?C++ SkAssertResult使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SkAssertResult函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SkAssertResult
void SKPBench::onPerCanvasPreDraw(SkCanvas* canvas) {
SkIRect bounds;
SkAssertResult(canvas->getClipDeviceBounds(&bounds));
int xTiles = SkScalarCeilToInt(bounds.width() / SkIntToScalar(FLAGS_benchTile));
int yTiles = SkScalarCeilToInt(bounds.height() / SkIntToScalar(FLAGS_benchTile));
fSurfaces.setReserve(xTiles * yTiles);
fTileRects.setReserve(xTiles * yTiles);
SkImageInfo ii = canvas->imageInfo().makeWH(FLAGS_benchTile, FLAGS_benchTile);
for (int y = bounds.fTop; y < bounds.fBottom; y += FLAGS_benchTile) {
for (int x = bounds.fLeft; x < bounds.fRight; x += FLAGS_benchTile) {
const SkIRect tileRect = SkIRect::MakeXYWH(x, y, FLAGS_benchTile, FLAGS_benchTile);
*fTileRects.append() = tileRect;
*fSurfaces.push() = canvas->newSurface(ii);
// Never want the contents of a tile to include stuff the parent
// canvas clips out
SkRect clip = SkRect::Make(bounds);
clip.offset(-SkIntToScalar(tileRect.fLeft), -SkIntToScalar(tileRect.fTop));
fSurfaces.top()->getCanvas()->clipRect(clip);
fSurfaces.top()->getCanvas()->setMatrix(canvas->getTotalMatrix());
fSurfaces.top()->getCanvas()->scale(fScale, fScale);
}
}
}
示例2: GrCopyBaseMipMapToTextureProxy
sk_sp<GrTextureProxy> GrCopyBaseMipMapToTextureProxy(GrContext* ctx, GrTextureProxy* baseProxy) {
SkASSERT(baseProxy);
if (!ctx->caps()->isConfigCopyable(baseProxy->config())) {
return nullptr;
}
GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider();
GrSurfaceDesc desc;
desc.fFlags = kNone_GrSurfaceFlags;
desc.fOrigin = baseProxy->origin();
desc.fWidth = baseProxy->width();
desc.fHeight = baseProxy->height();
desc.fConfig = baseProxy->config();
desc.fSampleCnt = 1;
sk_sp<GrTextureProxy> proxy = proxyProvider->createMipMapProxy(desc, SkBudgeted::kYes);
if (!proxy) {
return nullptr;
}
// Copy the base layer to our proxy
sk_sp<SkColorSpace> colorSpace;
if (GrPixelConfigIsSRGB(proxy->config())) {
colorSpace = SkColorSpace::MakeSRGB();
}
sk_sp<GrSurfaceContext> sContext =
ctx->contextPriv().makeWrappedSurfaceContext(proxy, std::move(colorSpace));
SkASSERT(sContext);
SkAssertResult(sContext->copy(baseProxy));
return proxy;
}
示例3: setup_vk_attachment_description
void setup_vk_attachment_description(VkAttachmentDescription* attachment,
const AttachmentDesc& desc,
VkImageLayout layout) {
attachment->flags = 0;
attachment->format = desc.fFormat;
SkAssertResult(GrSampleCountToVkSampleCount(desc.fSamples, &attachment->samples));
switch (layout) {
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
attachment->loadOp = desc.fLoadStoreOps.fLoadOp;
attachment->storeOp = desc.fLoadStoreOps.fStoreOp;
attachment->stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
attachment->stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
break;
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
attachment->loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
attachment->storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
attachment->stencilLoadOp = desc.fLoadStoreOps.fLoadOp;
attachment->stencilStoreOp = desc.fLoadStoreOps.fStoreOp;
break;
default:
SkFAIL("Unexpected attachment layout");
}
attachment->initialLayout = layout;
attachment->finalLayout = layout;
}
示例4: INHERITED
GrGLPath::GrGLPath(GrGLGpu* gpu, const SkPath& origSkPath, const GrStrokeInfo& origStroke)
: INHERITED(gpu, origSkPath, origStroke),
fPathID(gpu->glPathRendering()->genPaths(1)) {
if (origSkPath.isEmpty()) {
InitPathObjectEmptyPath(gpu, fPathID);
fShouldStroke = false;
fShouldFill = false;
} else {
const SkPath* skPath = &origSkPath;
SkTLazy<SkPath> tmpPath;
const GrStrokeInfo* stroke = &origStroke;
GrStrokeInfo tmpStroke(SkStrokeRec::kFill_InitStyle);
if (stroke->isDashed()) {
// Skia stroking and NVPR stroking differ with respect to dashing
// pattern.
// Convert a dashing to either a stroke or a fill.
if (stroke->applyDashToPath(tmpPath.init(), &tmpStroke, *skPath)) {
skPath = tmpPath.get();
stroke = &tmpStroke;
}
}
bool didInit = false;
if (stroke->needToApply() && stroke->getCap() != SkPaint::kButt_Cap) {
// Skia stroking and NVPR stroking differ with respect to stroking
// end caps of empty subpaths.
// Convert stroke to fill if path contains empty subpaths.
didInit = InitPathObjectPathDataCheckingDegenerates(gpu, fPathID, *skPath);
if (!didInit) {
if (!tmpPath.isValid()) {
tmpPath.init();
}
SkAssertResult(stroke->applyToPath(tmpPath.get(), *skPath));
skPath = tmpPath.get();
tmpStroke.setFillStyle();
stroke = &tmpStroke;
}
}
if (!didInit) {
InitPathObjectPathData(gpu, fPathID, *skPath);
}
fShouldStroke = stroke->needToApply();
fShouldFill = stroke->isFillStyle() ||
stroke->getStyle() == SkStrokeRec::kStrokeAndFill_Style;
if (fShouldStroke) {
InitPathObjectStroke(gpu, fPathID, *stroke);
// FIXME: try to account for stroking, without rasterizing the stroke.
fBounds.outset(stroke->getWidth(), stroke->getWidth());
}
}
this->registerWithCache();
}
示例5: SkAssertResult
void SKPAnimationBench::onPerCanvasPreDraw(SkCanvas* canvas) {
INHERITED::onPerCanvasPreDraw(canvas);
SkIRect bounds;
SkAssertResult(canvas->getClipDeviceBounds(&bounds));
fCenter.set((bounds.fRight - bounds.fLeft) / 2.0f,
(bounds.fBottom - bounds.fTop) / 2.0f);
}
示例6: LightingView
LightingView() : fLightAngle(0.0f) , fColorFactor(0.0f) {
{
SkBitmap diffuseBitmap;
SkAssertResult(GetResourceAsBitmap("images/brickwork-texture.jpg", &diffuseBitmap));
fRect = SkRect::MakeIWH(diffuseBitmap.width(), diffuseBitmap.height());
fDiffuseShader = diffuseBitmap.makeShader();
}
{
SkBitmap normalBitmap;
SkAssertResult(GetResourceAsBitmap("images/brickwork_normal-map.jpg", &normalBitmap));
sk_sp<SkShader> normalMap = normalBitmap.makeShader();
fNormalSource = SkNormalSource::MakeFromNormalMap(std::move(normalMap), SkMatrix::I());
}
}
示例7: SkAssertResult
void SkOpContour::toReversePath(SkPathWriter* path) const {
const SkPoint& pt = fTail->pts()[0];
path->deferredMove(pt);
const SkOpSegment* segment = fTail;
do {
SkAssertResult(segment->addCurveTo(segment->tail(), segment->head(), path));
} while ((segment = segment->prev()));
path->close();
}
示例8: not4444
static const SkBitmap& not4444(const SkBitmap& input, SkBitmap* copy) {
if (input.colorType() != kARGB_4444_SkColorType) {
return input;
}
// ARGB_4444 is rarely used, so we can do a wasteful tmp copy.
SkAssertResult(input.copyTo(copy, kN32_SkColorType));
copy->setImmutable();
return *copy;
}
示例9: willUseFilterColor
bool willUseFilterColor() const {
SkXfermode::Coeff dstCoeff;
SkXfermode::Coeff srcCoeff;
SkAssertResult(SkXfermode::ModeAsCoeff(fMode, &srcCoeff, &dstCoeff));
if (SkXfermode::kZero_Coeff == srcCoeff) {
return GrBlendCoeffRefsSrc(sk_blend_to_grblend(dstCoeff));
}
return true;
}
示例10: SkAssertResult
// static
void SkPDFUtils::AppendTransform(const SkMatrix& matrix, SkWStream* content) {
SkScalar values[6];
SkAssertResult(matrix.pdfTransform(values));
for (size_t i = 0; i < SK_ARRAY_COUNT(values); i++) {
SkPDFScalar::Append(values[i], content);
content->writeText(" ");
}
content->writeText("cm\n");
}
示例11: fShader
SkShader::Context::Context(const SkShader& shader, const ContextRec& rec)
: fShader(shader), fCTM(*rec.fMatrix)
{
// Because the context parameters must be valid at this point, we know that the matrix is
// invertible.
SkAssertResult(fShader.computeTotalInverse(rec, &fTotalInverse));
fTotalInverseClass = (uint8_t)ComputeMatrixClass(fTotalInverse);
fPaintAlpha = rec.fPaint->getAlpha();
}
示例12: SkAssertResult
void SkPDFStream::emitObject(SkWStream* stream, SkPDFCatalog* catalog) {
if (!this->populate(catalog)) {
return fSubstitute->emitObject(stream, catalog);
}
this->INHERITED::emitObject(stream, catalog);
stream->writeText(" stream\n");
stream->writeStream(fDataStream.get(), fDataStream->getLength());
SkAssertResult(fDataStream->rewind());
stream->writeText("\nendstream");
}
示例13: DEF_TEST
/**
* A test for the SkDecodingImageGenerator::Create and
* SkInstallDiscardablePixelRef functions.
*/
DEF_TEST(ImprovedBitmapFactory, reporter) {
SkString pngFilename = GetResourcePath("randPixels.png");
SkAutoTDelete<SkStreamRewindable> stream(SkStream::NewFromFile(pngFilename.c_str()));
if (sk_exists(pngFilename.c_str())) {
SkBitmap bm;
SkAssertResult(bm.setInfo(SkImageInfo::MakeN32Premul(1, 1)));
REPORTER_ASSERT(reporter,
install_pixel_ref(&bm, stream.detach(), 1, true));
SkAutoLockPixels alp(bm);
REPORTER_ASSERT(reporter, bm.getPixels());
}
}
示例14: SkAssertResult
bool DecodingImageGenerator::getPixels(const SkImageInfo& info,
void* pixels,
size_t rowBytes) {
if (NULL == pixels) {
return false;
}
if (fInfo != info) {
// The caller has specified a different info. This is an
// error for this kind of SkImageGenerator. Use the Options
// to change the settings.
return false;
}
if (info.minRowBytes() > rowBytes) {
// The caller has specified a bad rowBytes.
return false;
}
SkAssertResult(fStream->rewind());
SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream));
if (NULL == decoder.get()) {
return false;
}
decoder->setDitherImage(fDitherImage);
decoder->setSampleSize(fSampleSize);
decoder->setRequireUnpremultipliedColors(
info.fAlphaType == kUnpremul_SkAlphaType);
SkBitmap bitmap;
TargetAllocator allocator(fInfo, pixels, rowBytes);
decoder->setAllocator(&allocator);
// TODO: need to be able to pass colortype directly to decoder
SkBitmap::Config legacyConfig = SkColorTypeToBitmapConfig(info.colorType());
bool success = decoder->decode(fStream, &bitmap, legacyConfig,
SkImageDecoder::kDecodePixels_Mode);
decoder->setAllocator(NULL);
if (!success) {
return false;
}
if (allocator.isReady()) { // Did not use pixels!
SkBitmap bm;
SkASSERT(bitmap.canCopyTo(info.colorType()));
bool copySuccess = bitmap.copyTo(&bm, info.colorType(), &allocator);
if (!copySuccess || allocator.isReady()) {
SkDEBUGFAIL("bitmap.copyTo(requestedConfig) failed.");
// Earlier we checked canCopyto(); we expect consistency.
return false;
}
SkASSERT(check_alpha(info.alphaType(), bm.alphaType()));
} else {
SkASSERT(check_alpha(info.alphaType(), bitmap.alphaType()));
}
return true;
}
示例15: onOnceBeforeDraw
void onOnceBeforeDraw() override {
// Copyright-free file from http://openclipart.org/detail/29213/paper-plane-by-ddoo
SkString pngFilename = GetResourcePath("plane.png");
SkAutoDataUnref data(SkData::NewFromFileName(pngFilename.c_str()));
if (data.get()) {
// Create a cache which will boot the pixels out anytime the
// bitmap is unlocked.
SkAutoTUnref<SkDiscardableMemoryPool> pool(
SkDiscardableMemoryPool::Create(1));
SkAssertResult(SkInstallDiscardablePixelRef(SkImageGenerator::NewFromData(data),
NULL, &fBitmap, pool));
}
}