本文整理汇总了C++中SkDeque类的典型用法代码示例。如果您正苦于以下问题:C++ SkDeque类的具体用法?C++ SkDeque怎么用?C++ SkDeque使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SkDeque类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setStateStack
void setStateStack(SkDeque& stateStack)
{
while (stateStack.count() > 0)
{
State* copyState = static_cast<State*>(stateStack.back());
State* newState = static_cast<State*>(m_stateStack.push_back());
new (newState) State(*copyState);
stateStack.pop_back();
}
}
示例2: SkNEW_ARGS
SkDeque* SkLayerRasterizer::ReadLayers(SkReadBuffer& buffer) {
int count = buffer.readInt();
SkDeque* layers = SkNEW_ARGS(SkDeque, (sizeof(SkLayerRasterizer_Rec)));
for (int i = 0; i < count; i++) {
SkLayerRasterizer_Rec* rec = (SkLayerRasterizer_Rec*)layers->push_back();
SkNEW_PLACEMENT(&rec->fPaint, SkPaint);
buffer.readPaint(&rec->fPaint);
buffer.readPoint(&rec->fOffset);
}
return layers;
}
示例3: assert_blocks
static void assert_blocks(skiatest::Reporter* reporter,
const SkDeque& deq,
int allocCount) {
DequeUnitTestHelper helper(deq);
if (0 == deq.count()) {
REPORTER_ASSERT(reporter, 1 == helper.fNumBlocksAllocated);
} else {
int expected = (deq.count() + allocCount - 1) / allocCount;
// A block isn't freed in the deque when it first becomes empty so
// sometimes an extra block lingers around
REPORTER_ASSERT(reporter,
expected == helper.fNumBlocksAllocated ||
expected+1 == helper.fNumBlocksAllocated);
}
}
示例4: assert_iter
static void assert_iter(skiatest::Reporter* reporter, const SkDeque& deq,
int max, int min) {
// test forward iteration
SkDeque::Iter iter(deq, SkDeque::Iter::kFront_IterStart);
void* ptr;
int value = max;
while ((ptr = iter.next())) {
REPORTER_ASSERT(reporter, value == *(int*)ptr);
value -= 1;
}
REPORTER_ASSERT(reporter, value+1 == min);
// test reverse iteration
iter.reset(deq, SkDeque::Iter::kBack_IterStart);
value = min;
while ((ptr = iter.prev())) {
REPORTER_ASSERT(reporter, value == *(int*)ptr);
value += 1;
}
REPORTER_ASSERT(reporter, value-1 == max);
// test mixed iteration
iter.reset(deq, SkDeque::Iter::kFront_IterStart);
value = max;
// forward iteration half-way
for (int i = 0; i < deq.count()/2 && (ptr = iter.next()); i++) {
REPORTER_ASSERT(reporter, value == *(int*)ptr);
value -= 1;
}
// then back down w/ reverse iteration
while ((ptr = iter.prev())) {
REPORTER_ASSERT(reporter, value == *(int*)ptr);
value += 1;
}
REPORTER_ASSERT(reporter, value-1 == max);
}
示例5: void
namespace android {
TimerClient* JavaSharedClient::GetTimerClient()
{
return gTimerClient;
}
CookieClient* JavaSharedClient::GetCookieClient()
{
return gCookieClient;
}
PluginClient* JavaSharedClient::GetPluginClient()
{
return gPluginClient;
}
KeyGeneratorClient* JavaSharedClient::GetKeyGeneratorClient()
{
return gKeyGeneratorClient;
}
void JavaSharedClient::SetTimerClient(TimerClient* client)
{
gTimerClient = client;
}
void JavaSharedClient::SetCookieClient(CookieClient* client)
{
gCookieClient = client;
}
void JavaSharedClient::SetPluginClient(PluginClient* client)
{
gPluginClient = client;
}
void JavaSharedClient::SetKeyGeneratorClient(KeyGeneratorClient* client)
{
gKeyGeneratorClient = client;
}
TimerClient* JavaSharedClient::gTimerClient = NULL;
CookieClient* JavaSharedClient::gCookieClient = NULL;
PluginClient* JavaSharedClient::gPluginClient = NULL;
KeyGeneratorClient* JavaSharedClient::gKeyGeneratorClient = NULL;
///////////////////////////////////////////////////////////////////////////
struct FuncPtrRec {
void (*fProc)(void* payload);
void* fPayload;
};
static SkMutex gFuncPtrQMutex;
static SkDeque gFuncPtrQ(sizeof(FuncPtrRec));
void JavaSharedClient::EnqueueFunctionPtr(void (*proc)(void* payload),
void* payload)
{
gFuncPtrQMutex.acquire();
FuncPtrRec* rec = (FuncPtrRec*)gFuncPtrQ.push_back();
rec->fProc = proc;
rec->fPayload = payload;
gFuncPtrQMutex.release();
gTimerClient->signalServiceFuncPtrQueue();
}
void JavaSharedClient::ServiceFunctionPtrQueue()
{
for (;;) {
void (*proc)(void*) = 0;
void* payload = 0;
const FuncPtrRec* rec;
// we have to copy the proc/payload (if present). we do this so we
// don't call the proc inside the mutex (possible deadlock!)
gFuncPtrQMutex.acquire();
rec = (const FuncPtrRec*)gFuncPtrQ.front();
if (rec) {
proc = rec->fProc;
payload = rec->fPayload;
gFuncPtrQ.pop_front();
}
gFuncPtrQMutex.release();
if (!rec)
break;
proc(payload);
}
}
}
示例6: AndroidSignalServiceFuncPtrQueue
namespace android {
void AndroidSignalServiceFuncPtrQueue();
TimerClient* JavaSharedClient::GetTimerClient()
{
//LOG_ASSERT(gTimerClient != NULL, "gTimerClient not initialized!!!");
return gTimerClient;
}
CookieClient* JavaSharedClient::GetCookieClient()
{
//LOG_ASSERT(gCookieClient != NULL, "gCookieClient not initialized!!!");
return gCookieClient;
}
KeyGeneratorClient* JavaSharedClient::GetKeyGeneratorClient()
{
//LOG_ASSERT(gKeyGeneratorClient != NULL, "gKeyGeneratorClient not initialized!!!");
return gKeyGeneratorClient;
}
void JavaSharedClient::SetTimerClient(TimerClient* client)
{
//LOG_ASSERT(gTimerClient == NULL || client == NULL, "gTimerClient already set, aborting...");
gTimerClient = client;
}
void JavaSharedClient::SetCookieClient(CookieClient* client)
{
//LOG_ASSERT(gCookieClient == NULL || client == NULL, "gCookieClient already set, aborting...");
gCookieClient = client;
}
void JavaSharedClient::SetKeyGeneratorClient(KeyGeneratorClient* client)
{
//LOG_ASSERT(gKeyGeneratorClient == NULL || client == NULL, "gKeyGeneratorClient already set, aborting...");
gKeyGeneratorClient = client;
}
TimerClient* JavaSharedClient::gTimerClient = NULL;
CookieClient* JavaSharedClient::gCookieClient = NULL;
KeyGeneratorClient* JavaSharedClient::gKeyGeneratorClient = NULL;
///////////////////////////////////////////////////////////////////////////
struct FuncPtrRec {
void (*fProc)(void* payload);
void* fPayload;
};
static SkMutex gFuncPtrQMutex;
static SkDeque gFuncPtrQ(sizeof(FuncPtrRec));
void JavaSharedClient::EnqueueFunctionPtr(void (*proc)(void* payload),
void* payload)
{
gFuncPtrQMutex.acquire();
FuncPtrRec* rec = (FuncPtrRec*)gFuncPtrQ.push_back();
rec->fProc = proc;
rec->fPayload = payload;
gFuncPtrQMutex.release();
android::AndroidSignalServiceFuncPtrQueue();
}
void JavaSharedClient::ServiceFunctionPtrQueue()
{
for (;;) {
void (*proc)(void*);
void* payload;
const FuncPtrRec* rec;
// we have to copy the proc/payload (if present). we do this so we
// don't call the proc inside the mutex (possible deadlock!)
gFuncPtrQMutex.acquire();
rec = (const FuncPtrRec*)gFuncPtrQ.front();
if (NULL != rec) {
proc = rec->fProc;
payload = rec->fPayload;
gFuncPtrQ.pop_front();
}
gFuncPtrQMutex.release();
if (NULL == rec) {
break;
}
proc(payload);
}
}
}
示例7: DequeUnitTestHelper
DequeUnitTestHelper(const SkDeque& deq) {
fNumBlocksAllocated = deq.numBlocksAllocated();
}
示例8: assert_count
static void assert_count(skiatest::Reporter* reporter, const SkDeque& deq, int count) {
if (0 == count) {
REPORTER_ASSERT(reporter, deq.empty());
REPORTER_ASSERT(reporter, 0 == deq.count());
REPORTER_ASSERT(reporter, sizeof(int) == deq.elemSize());
REPORTER_ASSERT(reporter, nullptr == deq.front());
REPORTER_ASSERT(reporter, nullptr == deq.back());
} else {
REPORTER_ASSERT(reporter, !deq.empty());
REPORTER_ASSERT(reporter, count == deq.count());
REPORTER_ASSERT(reporter, sizeof(int) == deq.elemSize());
REPORTER_ASSERT(reporter, deq.front());
REPORTER_ASSERT(reporter, deq.back());
if (1 == count) {
REPORTER_ASSERT(reporter, deq.back() == deq.front());
} else {
REPORTER_ASSERT(reporter, deq.back() != deq.front());
}
}
}
示例9: GraphicsContextPlatformPrivate
GraphicsContextPlatformPrivate(GraphicsContext* cg, PlatformGraphicsContext* pgc)
: mCG(cg)
, mPgc(pgc), mStateStack(sizeof(State)) {
State* state = (State*)mStateStack.push_back();
new (state) State();
mState = state;
}
示例10: while
~GraphicsContextPlatformPrivate() {
if (mPgc && mPgc->deleteUs())
delete mPgc;
// we force restores so we don't leak any subobjects owned by our
// stack of State records.
while (mStateStack.count() > 0)
this->restore();
}
示例11: EnqueueFunctionPtr
void JavaSharedClient::EnqueueFunctionPtr(void (*proc)(void* payload),
void* payload)
{
gFuncPtrQMutex.acquire();
FuncPtrRec* rec = (FuncPtrRec*)gFuncPtrQ.push_back();
rec->fProc = proc;
rec->fPayload = payload;
gFuncPtrQMutex.release();
gTimerClient->signalServiceFuncPtrQueue();
}
示例12: ServiceFunctionPtrQueue
void JavaSharedClient::ServiceFunctionPtrQueue()
{
for (;;) {
void (*proc)(void*) = 0;
void* payload = 0;
const FuncPtrRec* rec;
// we have to copy the proc/payload (if present). we do this so we
// don't call the proc inside the mutex (possible deadlock!)
gFuncPtrQMutex.acquire();
rec = (const FuncPtrRec*)gFuncPtrQ.front();
if (rec) {
proc = rec->fProc;
payload = rec->fPayload;
gFuncPtrQ.pop_front();
}
gFuncPtrQMutex.release();
if (!rec)
break;
proc(payload);
}
}
示例13: restore
void restore() {
mState->~State();
mStateStack.pop_back();
mState = (State*)mStateStack.back();
}
示例14: save
void save() {
State* newState = (State*)mStateStack.push_back();
new (newState) State(*mState);
mState = newState;
}