OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkRefCnt.h" | 8 #include "SkRefCnt.h" |
9 #include "SkThreadUtils.h" | 9 #include "SkThreadUtils.h" |
10 #include "SkTypes.h" | 10 #include "SkTypes.h" |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 sp.reset(rc); | 378 sp.reset(rc); |
379 // We have transfered our ownership over to sp | 379 // We have transfered our ownership over to sp |
380 REPORTER_ASSERT(r, rc->unique()); | 380 REPORTER_ASSERT(r, rc->unique()); |
381 | 381 |
382 rc->ref(); // now "rc" is also an owner | 382 rc->ref(); // now "rc" is also an owner |
383 REPORTER_ASSERT(r, !rc->unique()); | 383 REPORTER_ASSERT(r, !rc->unique()); |
384 | 384 |
385 sp.reset(rc); // this should transfer our ownership over to sp | 385 sp.reset(rc); // this should transfer our ownership over to sp |
386 REPORTER_ASSERT(r, rc->unique()); | 386 REPORTER_ASSERT(r, rc->unique()); |
387 } | 387 } |
| 388 |
| 389 DEF_TEST(sk_sp_ref, r) { |
| 390 SkRefCnt* rc = new SkRefCnt; |
| 391 REPORTER_ASSERT(r, rc->unique()); |
| 392 |
| 393 { |
| 394 sk_sp<SkRefCnt> sp = sk_ref_sp(rc); |
| 395 REPORTER_ASSERT(r, !rc->unique()); |
| 396 } |
| 397 |
| 398 REPORTER_ASSERT(r, rc->unique()); |
| 399 rc->unref(); |
| 400 } |
OLD | NEW |