Exemple #1
0
static void bounce_ref(void* data) {
    SkRefCnt* ref = static_cast<SkRefCnt*>(data);
    for (int i = 0; i < 100000; ++i) {
        ref->ref();
        ref->unref();
    }
}
Exemple #2
0
 virtual void onDraw(const int loops, SkCanvas*) {
     for (int i = 0; i < loops; ++i) {
         SkRefCnt ref;
         for (int j = 0; j < M; ++j) {
             ref.ref();
             ref.unref();
         }
     }
 }
Exemple #3
0
 virtual void onDraw(const int loops, SkCanvas*) {
     for (int i = 0; i < loops; ++i) {
         SkRefCnt* ref = new SkRefCnt();
         for (int j = 0; j < M; ++j) {
             ref->ref();
             ref->unref();
         }
         ref->unref();
     }
 }
Exemple #4
0
void* SkMetaData::RefCntProc(void* ptr, bool doRef) {
    SkASSERT(ptr);
    SkRefCnt* refcnt = reinterpret_cast<SkRefCnt*>(ptr);

    if (doRef) {
        refcnt->ref();
    } else {
        refcnt->unref();
    }
    return ptr;
}
Exemple #5
0
// Test that reset() "adopts" ownership from the caller, even if we are given the same ptr twice
//
DEF_TEST(sk_sp_reset, r) {
    SkRefCnt* rc = new SkRefCnt;
    REPORTER_ASSERT(r, rc->unique());

    sk_sp<SkRefCnt> sp;
    sp.reset(rc);
    // We have transfered our ownership over to sp
    REPORTER_ASSERT(r, rc->unique());

    rc->ref();  // now "rc" is also an owner
    REPORTER_ASSERT(r, !rc->unique());

    sp.reset(rc);   // this should transfer our ownership over to sp
    REPORTER_ASSERT(r, rc->unique());
}