本文整理汇总了C++中SkTArray::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ SkTArray::empty方法的具体用法?C++ SkTArray::empty怎么用?C++ SkTArray::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkTArray
的用法示例。
在下文中一共展示了SkTArray::empty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_self_assignment
static void test_self_assignment(skiatest::Reporter* reporter) {
SkTArray<int> a;
a.push_back(1);
REPORTER_ASSERT(reporter, !a.empty());
REPORTER_ASSERT(reporter, a.count() == 1);
REPORTER_ASSERT(reporter, a[0] == 1);
a = static_cast<decltype(a)&>(a);
REPORTER_ASSERT(reporter, !a.empty());
REPORTER_ASSERT(reporter, a.count() == 1);
REPORTER_ASSERT(reporter, a[0] == 1);
}
示例2: TestTSet_basic
static void TestTSet_basic(skiatest::Reporter* reporter) {
SkTArray<int, MEM_MOVE> a;
// Starts empty.
REPORTER_ASSERT(reporter, a.empty());
REPORTER_ASSERT(reporter, a.count() == 0);
// { }, add a default constructed element
a.push_back() = 0;
REPORTER_ASSERT(reporter, !a.empty());
REPORTER_ASSERT(reporter, a.count() == 1);
// { 0 }, removeShuffle the only element.
a.removeShuffle(0);
REPORTER_ASSERT(reporter, a.empty());
REPORTER_ASSERT(reporter, a.count() == 0);
// { }, add a default, add a 1, remove first
a.push_back() = 0;
REPORTER_ASSERT(reporter, a.push_back() = 1);
a.removeShuffle(0);
REPORTER_ASSERT(reporter, !a.empty());
REPORTER_ASSERT(reporter, a.count() == 1);
REPORTER_ASSERT(reporter, a[0] == 1);
// { 1 }, replace with new array
int b[5] = { 0, 1, 2, 3, 4 };
a.reset(b, SK_ARRAY_COUNT(b));
REPORTER_ASSERT(reporter, a.count() == SK_ARRAY_COUNT(b));
REPORTER_ASSERT(reporter, a[2] == 2);
REPORTER_ASSERT(reporter, a[4] == 4);
// { 0, 1, 2, 3, 4 }, removeShuffle the last
a.removeShuffle(4);
REPORTER_ASSERT(reporter, a.count() == SK_ARRAY_COUNT(b) - 1);
REPORTER_ASSERT(reporter, a[3] == 3);
// { 0, 1, 2, 3 }, remove a middle, note shuffle
a.removeShuffle(1);
REPORTER_ASSERT(reporter, a.count() == SK_ARRAY_COUNT(b) - 2);
REPORTER_ASSERT(reporter, a[0] == 0);
REPORTER_ASSERT(reporter, a[1] == 3);
REPORTER_ASSERT(reporter, a[2] == 2);
// {0, 3, 2 }
}
示例3: find_string
// finds the index of ext in strings or a negative result if ext is not found.
static int find_string(const SkTArray<SkString>& strings, const char ext[]) {
if (strings.empty()) {
return -1;
}
SkString extensionStr(ext);
int idx = SkTSearch<SkString, extension_compare>(&strings.front(),
strings.count(),
extensionStr,
sizeof(SkString));
return idx;
}
示例4: findDefaultStyleSet
void findDefaultStyleSet() {
SkASSERT(!fStyleSets.empty());
static const char* defaultNames[] = { "sans-serif" };
for (const char* defaultName : defaultNames) {
fDefaultStyleSet.reset(this->onMatchFamily(defaultName));
if (fDefaultStyleSet) {
break;
}
}
if (nullptr == fDefaultStyleSet) {
fDefaultStyleSet = fStyleSets[0];
}
SkASSERT(fDefaultStyleSet);
}
示例5: restore
// The SkiaCanvas::restore operation layers on the capability to preserve
// either (or both) the matrix and/or clip state after a SkCanvas::restore
// operation. It does this by explicitly saving off the clip & matrix state
// when requested and playing it back after the SkCanvas::restore.
void SkiaCanvas::restore() {
const SaveRec* rec = (NULL == mSaveStack.get())
? NULL
: static_cast<SaveRec*>(mSaveStack->back());
int currentSaveCount = mCanvas->getSaveCount();
SkASSERT(NULL == rec || currentSaveCount >= rec->saveCount);
if (NULL == rec || rec->saveCount != currentSaveCount) {
// Fast path - no record for this frame.
mCanvas->restore();
return;
}
bool preserveMatrix = !(rec->saveFlags & SaveFlags::Matrix);
bool preserveClip = !(rec->saveFlags & SaveFlags::Clip);
SkMatrix savedMatrix;
if (preserveMatrix) {
savedMatrix = mCanvas->getTotalMatrix();
}
SkTArray<SkClipStack::Element> savedClips;
int topClipStackFrame = mCanvas->getClipStack()->getSaveCount();
if (preserveClip) {
saveClipsForFrame(savedClips, topClipStackFrame);
}
mCanvas->restore();
if (preserveMatrix) {
mCanvas->setMatrix(savedMatrix);
}
if (preserveClip && !savedClips.empty() &&
topClipStackFrame != mCanvas->getClipStack()->getSaveCount()) {
// Only reapply the saved clips if the top clip stack frame was actually
// popped by restore(). If it wasn't, it means it doesn't belong to the
// restored canvas frame (SkCanvas lazy save/restore kicked in).
applyClips(savedClips);
}
mSaveStack->pop_back();
}
示例6: findDefaultFont
void findDefaultFont() {
SkASSERT(!fFontStyleSets.empty());
static const char* gDefaultNames[] = { "sans-serif" };
for (size_t i = 0; i < SK_ARRAY_COUNT(gDefaultNames); ++i) {
SkFontStyleSet* set = this->onMatchFamily(gDefaultNames[i]);
if (NULL == set) {
continue;
}
SkTypeface* tf = set->matchStyle(SkFontStyle());
if (NULL == tf) {
continue;
}
fDefaultFamily = set;
fDefaultTypeface = tf;
break;
}
if (NULL == fDefaultTypeface) {
fDefaultFamily = fFontStyleSets[0];
fDefaultTypeface = fDefaultFamily->createTypeface(0);
}
SkASSERT(fDefaultFamily);
SkASSERT(fDefaultTypeface);
}