本文整理汇总了C++中SkASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ SkASSERT函数的具体用法?C++ SkASSERT怎么用?C++ SkASSERT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SkASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SkFontMgr_New_FCI
SK_API sk_sp<SkFontMgr> SkFontMgr_New_FCI(sk_sp<SkFontConfigInterface> fci) {
SkASSERT(fci);
return sk_make_sp<SkFontMgr_FCI>(std::move(fci));
}
示例2: SkASSERT
void GrBitmapTextContext::drawText(const GrPaint& paint, const SkPaint& skPaint,
const char text[], size_t byteLength,
SkScalar x, SkScalar y) {
SkASSERT(byteLength == 0 || text != NULL);
// nothing to draw
if (text == NULL || byteLength == 0 /*|| fRC->isEmpty()*/) {
return;
}
this->init(paint, skPaint);
if (NULL == fDrawTarget) {
return;
}
SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &fContext->getMatrix());
SkGlyphCache* cache = autoCache.getCache();
GrFontScaler* fontScaler = GetGrFontScaler(cache);
if (NULL == fStrike) {
fStrike = fContext->getFontCache()->getStrike(fontScaler, false);
}
// transform our starting point
{
SkPoint loc;
fContext->getMatrix().mapXY(x, y, &loc);
x = loc.fX;
y = loc.fY;
}
// need to measure first
if (fSkPaint.getTextAlign() != SkPaint::kLeft_Align) {
SkVector stop;
MeasureText(cache, glyphCacheProc, text, byteLength, &stop);
SkScalar stopX = stop.fX;
SkScalar stopY = stop.fY;
if (fSkPaint.getTextAlign() == SkPaint::kCenter_Align) {
stopX = SkScalarHalf(stopX);
stopY = SkScalarHalf(stopY);
}
x -= stopX;
y -= stopY;
}
const char* stop = text + byteLength;
// allocate vertices
SkASSERT(NULL == fVertices);
bool useColorVerts = kA8_GrMaskFormat == fStrike->getMaskFormat();
if (useColorVerts) {
fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttribs>(
SK_ARRAY_COUNT(gTextVertexWithColorAttribs));
} else {
fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>(
SK_ARRAY_COUNT(gTextVertexAttribs));
}
int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL);
bool success = fDrawTarget->reserveVertexAndIndexSpace(4*numGlyphs,
0,
&fVertices,
NULL);
GrAlwaysAssert(success);
SkAutoKern autokern;
SkFixed fxMask = ~0;
SkFixed fyMask = ~0;
SkFixed halfSampleX, halfSampleY;
if (cache->isSubpixel()) {
halfSampleX = halfSampleY = (SK_FixedHalf >> SkGlyph::kSubBits);
SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(fContext->getMatrix());
if (kX_SkAxisAlignment == baseline) {
fyMask = 0;
halfSampleY = SK_FixedHalf;
} else if (kY_SkAxisAlignment == baseline) {
fxMask = 0;
halfSampleX = SK_FixedHalf;
}
} else {
示例3: skpaint_to_grpaint_impl
//.........这里部分代码省略.........
// The above may return null if compose results in a pass through of the prim color.
if (shaderFP) {
grPaint->addColorFragmentProcessor(std::move(shaderFP));
}
// We can ignore origColor here - alpha is unchanged by gamma
GrColor paintAlpha = SkColorAlphaToGrColor(skPaint.getColor());
if (GrColor_WHITE != paintAlpha) {
// No gamut conversion - paintAlpha is a (linear) alpha value, splatted to all
// color channels. It's value should be treated as the same in ANY color space.
grPaint->addColorFragmentProcessor(GrConstColorProcessor::Make(
GrColor4f::FromGrColor(paintAlpha),
GrConstColorProcessor::InputMode::kModulateRGBA));
}
} else {
// The shader's FP sees the paint unpremul color
grPaint->setColor4f(origColor);
grPaint->addColorFragmentProcessor(std::move(shaderFP));
}
} else {
if (primColorMode) {
// There is a blend between the primitive color and the paint color. The blend considers
// the opaque paint color. The paint's alpha is applied to the post-blended color.
auto processor = GrConstColorProcessor::Make(origColor.opaque(),
GrConstColorProcessor::InputMode::kIgnore);
processor = GrXfermodeFragmentProcessor::MakeFromSrcProcessor(std::move(processor),
*primColorMode);
if (processor) {
grPaint->addColorFragmentProcessor(std::move(processor));
}
grPaint->setColor4f(origColor.opaque());
// We can ignore origColor here - alpha is unchanged by gamma
GrColor paintAlpha = SkColorAlphaToGrColor(skPaint.getColor());
if (GrColor_WHITE != paintAlpha) {
// No gamut conversion - paintAlpha is a (linear) alpha value, splatted to all
// color channels. It's value should be treated as the same in ANY color space.
grPaint->addColorFragmentProcessor(GrConstColorProcessor::Make(
GrColor4f::FromGrColor(paintAlpha),
GrConstColorProcessor::InputMode::kModulateRGBA));
}
} else {
// No shader, no primitive color.
grPaint->setColor4f(origColor.premul());
applyColorFilterToPaintColor = true;
}
}
SkColorFilter* colorFilter = skPaint.getColorFilter();
if (colorFilter) {
if (applyColorFilterToPaintColor) {
// If we're in legacy mode, we *must* avoid using the 4f version of the color filter,
// because that will combine with the linearized version of the stored color.
if (colorSpaceInfo.isGammaCorrect()) {
grPaint->setColor4f(GrColor4f::FromSkColor4f(
colorFilter->filterColor4f(origColor.toSkColor4f())).premul());
} else {
grPaint->setColor4f(SkColorToPremulGrColor4fLegacy(
colorFilter->filterColor(skPaint.getColor())));
}
} else {
auto cfFP = colorFilter->asFragmentProcessor(context, colorSpaceInfo);
if (cfFP) {
grPaint->addColorFragmentProcessor(std::move(cfFP));
} else {
return false;
}
}
}
SkMaskFilterBase* maskFilter = as_MFB(skPaint.getMaskFilter());
if (maskFilter) {
if (auto mfFP = maskFilter->asFragmentProcessor(fpArgs)) {
grPaint->addCoverageFragmentProcessor(std::move(mfFP));
}
}
// When the xfermode is null on the SkPaint (meaning kSrcOver) we need the XPFactory field on
// the GrPaint to also be null (also kSrcOver).
SkASSERT(!grPaint->getXPFactory());
if (!skPaint.isSrcOver()) {
grPaint->setXPFactory(SkBlendMode_AsXPFactory(skPaint.getBlendMode()));
}
#ifndef SK_IGNORE_GPU_DITHER
// Conservative default, in case GrPixelConfigToColorType() fails.
SkColorType ct = SkColorType::kRGB_565_SkColorType;
GrPixelConfigToColorType(colorSpaceInfo.config(), &ct);
if (SkPaintPriv::ShouldDither(skPaint, ct) && grPaint->numColorFragmentProcessors() > 0 &&
!colorSpaceInfo.isGammaCorrect()) {
auto ditherFP = GrDitherEffect::Make(colorSpaceInfo.config());
if (ditherFP) {
grPaint->addColorFragmentProcessor(std::move(ditherFP));
}
}
#endif
return true;
}
示例4: SkASSERT
void GrVkPipelineState::writeSamplers(GrVkGpu* gpu,
const SkTArray<const GrTextureAccess*>& textureBindings) {
SkASSERT(fNumSamplers == textureBindings.count());
for (int i = 0; i < textureBindings.count(); ++i) {
const GrTextureParams& params = textureBindings[i]->getParams();
GrVkTexture* texture = static_cast<GrVkTexture*>(textureBindings[i]->getTexture());
if (GrTextureParams::kMipMap_FilterMode == params.filterMode()) {
if (texture->texturePriv().mipMapsAreDirty()) {
gpu->generateMipmap(texture);
texture->texturePriv().dirtyMipMaps(false);
}
}
fSamplers.push(gpu->resourceProvider().findOrCreateCompatibleSampler(params,
texture->texturePriv().maxMipMapLevel()));
const GrVkImage::Resource* textureResource = texture->resource();
textureResource->ref();
fTextures.push(textureResource);
const GrVkImageView* textureView = texture->textureView();
textureView->ref();
fTextureViews.push(textureView);
// Change texture layout so it can be read in shader
VkImageLayout layout = texture->currentLayout();
VkPipelineStageFlags srcStageMask = GrVkMemory::LayoutToPipelineStageFlags(layout);
VkPipelineStageFlags dstStageMask = VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT;
VkAccessFlags srcAccessMask = GrVkMemory::LayoutToSrcAccessMask(layout);
VkAccessFlags dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
texture->setImageLayout(gpu,
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
srcAccessMask,
dstAccessMask,
srcStageMask,
dstStageMask,
false);
VkDescriptorImageInfo imageInfo;
memset(&imageInfo, 0, sizeof(VkDescriptorImageInfo));
imageInfo.sampler = fSamplers[i]->sampler();
imageInfo.imageView = texture->textureView()->imageView();
imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
VkWriteDescriptorSet writeInfo;
memset(&writeInfo, 0, sizeof(VkWriteDescriptorSet));
writeInfo.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
writeInfo.pNext = nullptr;
writeInfo.dstSet = fDescriptorSets[GrVkUniformHandler::kSamplerDescSet];
writeInfo.dstBinding = i;
writeInfo.dstArrayElement = 0;
writeInfo.descriptorCount = 1;
writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
writeInfo.pImageInfo = &imageInfo;
writeInfo.pBufferInfo = nullptr;
writeInfo.pTexelBufferView = nullptr;
GR_VK_CALL(gpu->vkInterface(), UpdateDescriptorSets(gpu->device(),
1,
&writeInfo,
0,
nullptr));
}
}
示例5: xferProcessor
GrPipeline* GrPipeline::CreateAt(void* memory, const CreateArgs& args,
GrPipelineOptimizations* opts) {
const GrPipelineBuilder& builder = *args.fPipelineBuilder;
// Create XferProcessor from DS's XPFactory
SkAutoTUnref<GrXferProcessor> xferProcessor(
builder.getXPFactory()->createXferProcessor(args.fColorPOI, args.fCoveragePOI,
builder.hasMixedSamples(), &args.fDstTexture,
*args.fCaps));
if (!xferProcessor) {
return nullptr;
}
GrColor overrideColor = GrColor_ILLEGAL;
if (args.fColorPOI.firstEffectiveProcessorIndex() != 0) {
overrideColor = args.fColorPOI.inputColorToFirstEffectiveProccesor();
}
GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags;
optFlags = xferProcessor->getOptimizations(args.fColorPOI,
args.fCoveragePOI,
builder.getStencil().doesWrite(),
&overrideColor,
*args.fCaps);
// When path rendering the stencil settings are not always set on the GrPipelineBuilder
// so we must check the draw type. In cases where we will skip drawing we simply return a
// null GrPipeline.
if (GrXferProcessor::kSkipDraw_OptFlag & optFlags) {
return nullptr;
}
// No need to have an override color if it isn't even going to be used.
if (SkToBool(GrXferProcessor::kIgnoreColor_OptFlag & optFlags)) {
overrideColor = GrColor_ILLEGAL;
}
GrPipeline* pipeline = new (memory) GrPipeline;
pipeline->fXferProcessor.reset(xferProcessor.get());
pipeline->fRenderTarget.reset(builder.fRenderTarget.get());
SkASSERT(pipeline->fRenderTarget);
pipeline->fScissorState = *args.fScissor;
pipeline->fStencilSettings = builder.getStencil();
pipeline->fDrawFace = builder.getDrawFace();
pipeline->fFlags = 0;
if (builder.isHWAntialias()) {
pipeline->fFlags |= kHWAA_Flag;
}
if (builder.isDither()) {
pipeline->fFlags |= kDither_Flag;
}
if (builder.snapVerticesToPixelCenters()) {
pipeline->fFlags |= kSnapVertices_Flag;
}
int firstColorProcessorIdx = args.fColorPOI.firstEffectiveProcessorIndex();
// TODO: Once we can handle single or four channel input into coverage GrFragmentProcessors
// then we can use GrPipelineBuilder's coverageProcInfo (like color above) to set this initial
// information.
int firstCoverageProcessorIdx = 0;
pipeline->adjustProgramFromOptimizations(builder, optFlags, args.fColorPOI, args.fCoveragePOI,
&firstColorProcessorIdx, &firstCoverageProcessorIdx);
bool usesLocalCoords = false;
// Copy GrFragmentProcessors from GrPipelineBuilder to Pipeline
pipeline->fNumColorProcessors = builder.numColorFragmentProcessors() - firstColorProcessorIdx;
int numTotalProcessors = pipeline->fNumColorProcessors +
builder.numCoverageFragmentProcessors() - firstCoverageProcessorIdx;
pipeline->fFragmentProcessors.reset(numTotalProcessors);
int currFPIdx = 0;
for (int i = firstColorProcessorIdx; i < builder.numColorFragmentProcessors();
++i, ++currFPIdx) {
const GrFragmentProcessor* fp = builder.getColorFragmentProcessor(i);
pipeline->fFragmentProcessors[currFPIdx].reset(fp);
usesLocalCoords = usesLocalCoords || fp->usesLocalCoords();
fp->gatherCoordTransforms(&pipeline->fCoordTransforms);
}
for (int i = firstCoverageProcessorIdx; i < builder.numCoverageFragmentProcessors();
++i, ++currFPIdx) {
const GrFragmentProcessor* fp = builder.getCoverageFragmentProcessor(i);
pipeline->fFragmentProcessors[currFPIdx].reset(fp);
usesLocalCoords = usesLocalCoords || fp->usesLocalCoords();
fp->gatherCoordTransforms(&pipeline->fCoordTransforms);
}
// Setup info we need to pass to GrPrimitiveProcessors that are used with this GrPipeline.
opts->fFlags = 0;
if (!SkToBool(optFlags & GrXferProcessor::kIgnoreColor_OptFlag)) {
opts->fFlags |= GrPipelineOptimizations::kReadsColor_Flag;
}
if (GrColor_ILLEGAL != overrideColor) {
opts->fFlags |= GrPipelineOptimizations::kUseOverrideColor_Flag;
opts->fOverrideColor = overrideColor;
//.........这里部分代码省略.........
示例6: switch
bool GrDrawTarget::checkDraw(GrPrimitiveType type, int startVertex,
int startIndex, int vertexCount,
int indexCount) const {
const GrDrawState& drawState = this->getDrawState();
#ifdef SK_DEBUG
const GeometrySrcState& geoSrc = fGeoSrcStateStack.back();
int maxVertex = startVertex + vertexCount;
int maxValidVertex;
switch (geoSrc.fVertexSrc) {
case kNone_GeometrySrcType:
SkFAIL("Attempting to draw without vertex src.");
case kReserved_GeometrySrcType: // fallthrough
case kArray_GeometrySrcType:
maxValidVertex = geoSrc.fVertexCount;
break;
case kBuffer_GeometrySrcType:
maxValidVertex = static_cast<int>(geoSrc.fVertexBuffer->gpuMemorySize() / geoSrc.fVertexSize);
break;
}
if (maxVertex > maxValidVertex) {
SkFAIL("Drawing outside valid vertex range.");
}
if (indexCount > 0) {
int maxIndex = startIndex + indexCount;
int maxValidIndex;
switch (geoSrc.fIndexSrc) {
case kNone_GeometrySrcType:
SkFAIL("Attempting to draw indexed geom without index src.");
case kReserved_GeometrySrcType: // fallthrough
case kArray_GeometrySrcType:
maxValidIndex = geoSrc.fIndexCount;
break;
case kBuffer_GeometrySrcType:
maxValidIndex = static_cast<int>(geoSrc.fIndexBuffer->gpuMemorySize() / sizeof(uint16_t));
break;
}
if (maxIndex > maxValidIndex) {
SkFAIL("Index reads outside valid index range.");
}
}
SkASSERT(drawState.getRenderTarget());
if (drawState.hasGeometryProcessor()) {
const GrGeometryProcessor* gp = drawState.getGeometryProcessor()->getProcessor();
int numTextures = gp->numTextures();
for (int t = 0; t < numTextures; ++t) {
GrTexture* texture = gp->texture(t);
SkASSERT(texture->asRenderTarget() != drawState.getRenderTarget());
}
}
for (int s = 0; s < drawState.numColorStages(); ++s) {
const GrProcessor* effect = drawState.getColorStage(s).getProcessor();
int numTextures = effect->numTextures();
for (int t = 0; t < numTextures; ++t) {
GrTexture* texture = effect->texture(t);
SkASSERT(texture->asRenderTarget() != drawState.getRenderTarget());
}
}
for (int s = 0; s < drawState.numCoverageStages(); ++s) {
const GrProcessor* effect = drawState.getCoverageStage(s).getProcessor();
int numTextures = effect->numTextures();
for (int t = 0; t < numTextures; ++t) {
GrTexture* texture = effect->texture(t);
SkASSERT(texture->asRenderTarget() != drawState.getRenderTarget());
}
}
SkASSERT(drawState.validateVertexAttribs());
#endif
if (NULL == drawState.getRenderTarget()) {
return false;
}
return true;
}
示例7: SkASSERT
void GrDrawTarget::DrawInfo::adjustStartIndex(int indexOffset) {
SkASSERT(this->isIndexed());
fStartIndex += indexOffset;
SkASSERT(fStartIndex >= 0);
}
示例8: test_round_rect_general
// Test out the non-degenerate RR cases
static void test_round_rect_general(skiatest::Reporter* reporter) {
static const SkScalar kEps = 0.1f;
static const SkScalar kDist20 = 20 * (SK_Scalar1 - SK_ScalarRoot2Over2);
static const SkPoint pts[] = {
// Upper Left
{ kDist20 - kEps, kDist20 - kEps }, // out
{ kDist20 + kEps, kDist20 + kEps }, // in
// Upper Right
{ kWidth + kEps - kDist20, kDist20 - kEps }, // out
{ kWidth - kEps - kDist20, kDist20 + kEps }, // in
// Lower Right
{ kWidth + kEps - kDist20, kHeight + kEps - kDist20 }, // out
{ kWidth - kEps - kDist20, kHeight - kEps - kDist20 }, // in
// Lower Left
{ kDist20 - kEps, kHeight + kEps - kDist20 }, //out
{ kDist20 + kEps, kHeight - kEps - kDist20 }, // in
// Middle
{ SkIntToScalar(50), SkIntToScalar(50) } // in
};
static const bool isIn[] = { false, true, false, true, false, true, false, true, true };
SkASSERT(SK_ARRAY_COUNT(pts) == SK_ARRAY_COUNT(isIn));
//----
SkRect rect = SkRect::MakeLTRB(0, 0, kWidth, kHeight);
SkRRect rr1;
rr1.setRectXY(rect, 20, 20);
REPORTER_ASSERT(reporter, SkRRect::kSimple_Type == rr1.type());
for (size_t i = 0; i < SK_ARRAY_COUNT(pts); ++i) {
REPORTER_ASSERT(reporter, isIn[i] == rr1.contains(pts[i].fX, pts[i].fY));
}
//----
static const SkScalar kDist50 = 50*(SK_Scalar1 - SK_ScalarRoot2Over2);
static const SkPoint pts2[] = {
// Upper Left
{ -SK_Scalar1, -SK_Scalar1 }, // out
{ SK_Scalar1, SK_Scalar1 }, // in
// Upper Right
{ kWidth + kEps - kDist20, kDist20 - kEps }, // out
{ kWidth - kEps - kDist20, kDist20 + kEps }, // in
// Lower Right
{ kWidth + kEps - kDist50, kHeight + kEps - kDist50 }, // out
{ kWidth - kEps - kDist50, kHeight - kEps - kDist50 }, // in
// Lower Left
{ kDist20 - kEps, kHeight + kEps - kDist50 }, // out
{ kDist20 + kEps, kHeight - kEps - kDist50 }, // in
// Middle
{ SkIntToScalar(50), SkIntToScalar(50) } // in
};
SkASSERT(SK_ARRAY_COUNT(pts2) == SK_ARRAY_COUNT(isIn));
SkPoint radii[4] = { { 0, 0 }, { 20, 20 }, { 50, 50 }, { 20, 50 } };
SkRRect rr2;
rr2.setRectRadii(rect, radii);
REPORTER_ASSERT(reporter, SkRRect::kComplex_Type == rr2.type());
for (size_t i = 0; i < SK_ARRAY_COUNT(pts); ++i) {
REPORTER_ASSERT(reporter, isIn[i] == rr2.contains(pts2[i].fX, pts2[i].fY));
}
}
示例9: SkASSERT
size_t SkPDFStream::dataSize() const {
SkASSERT(fDataStream->hasLength());
return fDataStream->getLength();
}
示例10: releaseInfo
bool NativeInputWindowHandle::updateInfo()
{
AutoPtr<IInputWindowHandle> obj;
mObjWeak->Resolve(EIID_IInputWindowHandle, (IInterface**)&obj);
if (!obj) {
releaseInfo();
return false;
}
if (!mInfo) {
mInfo = new android::InputWindowInfo();
}
else {
mInfo->touchableRegion.clear();
}
Elastos::Droid::Server::Input::InputWindowHandle* handle =
(Elastos::Droid::Server::Input::InputWindowHandle*)obj.Get();
AutoPtr<IInputChannel> inputChannelObj = handle->mInputChannel;
if (inputChannelObj) {
Handle64 ptr;
inputChannelObj->GetNativeInputChannel(&ptr);
NativeInputChannel* nativeInputChannel = reinterpret_cast<NativeInputChannel*>(ptr);
mInfo->inputChannel = nativeInputChannel != NULL ? nativeInputChannel->getInputChannel() : NULL;
}
else {
mInfo->inputChannel.clear();
}
if (!handle->mName.IsNull()) {
mInfo->name.setTo(handle->mName.string());
}
else {
mInfo->name.setTo("<null>");
}
mInfo->layoutParamsFlags = handle->mLayoutParamsFlags;
mInfo->layoutParamsType = handle->mLayoutParamsType;
mInfo->dispatchingTimeout = handle->mDispatchingTimeoutNanos;
mInfo->frameLeft = handle->mFrameLeft;
mInfo->frameTop = handle->mFrameTop;
mInfo->frameRight = handle->mFrameRight;
mInfo->frameBottom = handle->mFrameBottom;
mInfo->scaleFactor = handle->mScaleFactor;
AutoPtr<IRegion> regionObj = handle->mTouchableRegion;
if (regionObj) {
Int64 regionHandle;
regionObj->GetNativeRegion((Handle64*)®ionHandle);
SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle);
SkASSERT(region != NULL);
for (SkRegion::Iterator it(*region); !it.done(); it.next()) {
const SkIRect& rect = it.rect();
mInfo->addTouchableRegion(android::Rect(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom));
}
}
mInfo->visible = handle->mVisible;
mInfo->canReceiveKeys = handle->mCanReceiveKeys;
mInfo->hasFocus = handle->mHasFocus;
mInfo->hasWallpaper = handle->mHasWallpaper;
mInfo->paused = handle->mPaused;
mInfo->layer = handle->mLayer;
mInfo->ownerPid = handle->mOwnerPid;
mInfo->ownerUid = handle->mOwnerUid;
mInfo->inputFeatures = handle->mInputFeatures;
mInfo->displayId = handle->mDisplayId;
return true;
}
示例11: test_round_rect_rects
// Test out the cases when the RR degenerates to a rect
static void test_round_rect_rects(skiatest::Reporter* reporter) {
SkRect r;
static const SkPoint pts[] = {
// Upper Left
{ -SK_Scalar1, -SK_Scalar1 }, // out
{ SK_Scalar1, SK_Scalar1 }, // in
// Upper Right
{ SkIntToScalar(101), -SK_Scalar1}, // out
{ SkIntToScalar(99), SK_Scalar1 }, // in
// Lower Right
{ SkIntToScalar(101), SkIntToScalar(101) }, // out
{ SkIntToScalar(99), SkIntToScalar(99) }, // in
// Lower Left
{ -SK_Scalar1, SkIntToScalar(101) }, // out
{ SK_Scalar1, SkIntToScalar(99) }, // in
// Middle
{ SkIntToScalar(50), SkIntToScalar(50) } // in
};
static const bool isIn[] = { false, true, false, true, false, true, false, true, true };
SkASSERT(SK_ARRAY_COUNT(pts) == SK_ARRAY_COUNT(isIn));
//----
SkRRect empty;
empty.setEmpty();
REPORTER_ASSERT(reporter, SkRRect::kEmpty_Type == empty.type());
r = empty.rect();
REPORTER_ASSERT(reporter, 0 == r.fLeft && 0 == r.fTop && 0 == r.fRight && 0 == r.fBottom);
//----
SkRect rect = SkRect::MakeLTRB(0, 0, kWidth, kHeight);
SkRRect rr1;
rr1.setRectXY(rect, 0, 0);
REPORTER_ASSERT(reporter, SkRRect::kRect_Type == rr1.type());
r = rr1.rect();
REPORTER_ASSERT(reporter, rect == r);
for (size_t i = 0; i < SK_ARRAY_COUNT(pts); ++i) {
REPORTER_ASSERT(reporter, isIn[i] == rr1.contains(pts[i].fX, pts[i].fY));
}
//----
SkPoint radii[4] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } };
SkRRect rr2;
rr2.setRectRadii(rect, radii);
REPORTER_ASSERT(reporter, SkRRect::kRect_Type == rr2.type());
r = rr2.rect();
REPORTER_ASSERT(reporter, rect == r);
for (size_t i = 0; i < SK_ARRAY_COUNT(pts); ++i) {
REPORTER_ASSERT(reporter, isIn[i] == rr2.contains(pts[i].fX, pts[i].fY));
}
//----
SkPoint radii2[4] = { { 0, 0 }, { 20, 20 }, { 50, 50 }, { 20, 50 } };
SkRRect rr3;
rr3.setRectRadii(rect, radii2);
REPORTER_ASSERT(reporter, SkRRect::kComplex_Type == rr3.type());
}
示例12: SkASSERT
~AutoCachePurge() {
SkASSERT(fXformer->fReentryCount > 0);
if (--fXformer->fReentryCount == 0) {
fXformer->purgeCaches();
}
}
示例13: createTypeface
SkTypeface* createTypeface(int index) override { SkASSERT(false); return nullptr; }
示例14: getStyle
void getStyle(int index, SkFontStyle*, SkString* style) override { SkASSERT(false); }
示例15: SkASSERT
void GrResourceEntry::validate() const {
SkASSERT(fResource);
SkASSERT(fResource->getCacheEntry() == this);
fResource->validate();
}