本文整理汇总了C++中GrIRect::setEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ GrIRect::setEmpty方法的具体用法?C++ GrIRect::setEmpty怎么用?C++ GrIRect::setEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrIRect
的用法示例。
在下文中一共展示了GrIRect::setEmpty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_cache
////////////////////////////////////////////////////////////////////////////////
// basic test of the cache's base functionality:
// push, pop, set, canReuse & getters
static void test_cache(skiatest::Reporter* reporter, GrContext* context) {
if (false) { // avoid bit rot, suppress warning
createTexture(context);
}
GrClipMaskCache cache;
cache.setContext(context);
SkClipStack emptyClip;
emptyClip.reset();
GrIRect emptyBound;
emptyBound.setEmpty();
// check initial state
check_state(reporter, cache, emptyClip, NULL, emptyBound);
// set the current state
GrIRect bound1;
bound1.set(0, 0, 100, 100);
SkClipStack clip1(bound1);
GrTextureDesc desc;
desc.fFlags = kRenderTarget_GrTextureFlagBit;
desc.fWidth = X_SIZE;
desc.fHeight = Y_SIZE;
desc.fConfig = kSkia8888_PM_GrPixelConfig;
cache.acquireMask(clip1, desc, bound1);
GrTexture* texture1 = cache.getLastMask();
REPORTER_ASSERT(reporter, texture1);
if (NULL == texture1) {
return;
}
// check that the set took
check_state(reporter, cache, clip1, texture1, bound1);
REPORTER_ASSERT(reporter, 1 == texture1->getRefCnt());
// push the state
cache.push();
// verify that the pushed state is initially empty
check_state(reporter, cache, emptyClip, NULL, emptyBound);
REPORTER_ASSERT(reporter, 1 == texture1->getRefCnt());
// modify the new state
GrIRect bound2;
bound2.set(-10, -10, 10, 10);
SkClipStack clip2(bound2);
cache.acquireMask(clip2, desc, bound2);
GrTexture* texture2 = cache.getLastMask();
REPORTER_ASSERT(reporter, texture2);
if (NULL == texture2) {
return;
}
// check that the changes took
check_state(reporter, cache, clip2, texture2, bound2);
REPORTER_ASSERT(reporter, 1 == texture1->getRefCnt());
REPORTER_ASSERT(reporter, 1 == texture2->getRefCnt());
// check to make sure canReuse works
REPORTER_ASSERT(reporter, cache.canReuse(clip2, bound2));
REPORTER_ASSERT(reporter, !cache.canReuse(clip1, bound1));
// pop the state
cache.pop();
// verify that the old state is restored
check_state(reporter, cache, clip1, texture1, bound1);
REPORTER_ASSERT(reporter, 1 == texture1->getRefCnt());
REPORTER_ASSERT(reporter, 1 == texture2->getRefCnt());
// manually clear the state
cache.reset();
// verify it is now empty
check_state(reporter, cache, emptyClip, NULL, emptyBound);
REPORTER_ASSERT(reporter, 1 == texture1->getRefCnt());
REPORTER_ASSERT(reporter, 1 == texture2->getRefCnt());
// pop again - so there is no state
cache.pop();
#if !defined(SK_DEBUG)
// verify that the getters don't crash
// only do in release since it generates asserts in debug
check_state(reporter, cache, emptyClip, NULL, emptyBound);
#endif
REPORTER_ASSERT(reporter, 1 == texture1->getRefCnt());
//.........这里部分代码省略.........