Chromium Code Reviews| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 | 157 |
| 158 Paint paint; | 158 Paint paint; |
| 159 REPORTER_ASSERT(reporter, paint.fEffect.get() == nullptr); | 159 REPORTER_ASSERT(reporter, paint.fEffect.get() == nullptr); |
| 160 REPORTER_ASSERT(reporter, !paint.get()); | 160 REPORTER_ASSERT(reporter, !paint.get()); |
| 161 check(reporter, 0, 0, 0, 0); | 161 check(reporter, 0, 0, 0, 0); |
| 162 | 162 |
| 163 paint.set(Create()); | 163 paint.set(Create()); |
| 164 check(reporter, 0, 0, 1, 0); | 164 check(reporter, 0, 0, 1, 0); |
| 165 REPORTER_ASSERT(reporter, paint.fEffect.get()->fRefCnt == 1); | 165 REPORTER_ASSERT(reporter, paint.fEffect.get()->fRefCnt == 1); |
| 166 | 166 |
| 167 if (paint.get()) { | |
| 168 REPORTER_ASSERT(reporter, true); | |
| 169 } else { | |
| 170 REPORTER_ASSERT(reporter, false); | |
| 171 } | |
| 172 | |
| 167 paint.set(nullptr); | 173 paint.set(nullptr); |
| 168 check(reporter, 0, 1, 1, 1); | 174 check(reporter, 0, 1, 1, 1); |
| 169 | 175 |
| 176 if (paint.get()) { | |
| 177 REPORTER_ASSERT(reporter, false); | |
| 178 } else { | |
| 179 REPORTER_ASSERT(reporter, true); | |
| 180 } | |
| 181 | |
| 170 auto e = Create(); | 182 auto e = Create(); |
| 171 REPORTER_ASSERT(reporter, sizeof(e) == sizeof(void*)); | 183 REPORTER_ASSERT(reporter, sizeof(e) == sizeof(void*)); |
| 172 | 184 |
| 173 check(reporter, 0, 1, 2, 1); | 185 check(reporter, 0, 1, 2, 1); |
| 174 paint.set(e); | 186 paint.set(e); |
| 175 check(reporter, 1, 1, 2, 1); | 187 check(reporter, 1, 1, 2, 1); |
| 176 REPORTER_ASSERT(reporter, paint.fEffect.get()->fRefCnt == 2); | 188 REPORTER_ASSERT(reporter, paint.fEffect.get()->fRefCnt == 2); |
| 177 | 189 |
| 178 Paint paint2; | 190 Paint paint2; |
| 179 paint2.set(paint.get()); | 191 paint2.set(paint.get()); |
| 180 check(reporter, 2, 1, 2, 1); | 192 check(reporter, 2, 1, 2, 1); |
| 181 REPORTER_ASSERT(reporter, paint.fEffect.get()->fRefCnt == 3); | 193 REPORTER_ASSERT(reporter, paint.fEffect.get()->fRefCnt == 3); |
| 182 | 194 |
| 183 delete paint.get()->method(); | 195 delete (*paint.get()).method(); |
|
mtklein
2016/03/02 20:05:10
// tests operator*
| |
| 184 check(reporter, 2, 1, 2, 1); | 196 check(reporter, 2, 1, 2, 1); |
| 185 | 197 |
| 186 paint.set(nullptr); | 198 paint.set(nullptr); |
| 187 e = nullptr; | 199 e = nullptr; |
| 188 paint2.set(nullptr); | 200 paint2.set(nullptr); |
| 189 check(reporter, 2, 4, 2, 2); | 201 check(reporter, 2, 4, 2, 2); |
| 190 | 202 |
| 191 reset_counters(); | 203 reset_counters(); |
| 192 { | 204 { |
| 193 // Test convertible sk_sp assignment. | 205 // Test convertible sk_sp assignment. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 baz = EffectImpl::Create(); | 252 baz = EffectImpl::Create(); |
| 241 check(reporter, 0, 0, 1, 0); | 253 check(reporter, 0, 0, 1, 0); |
| 242 paint.set(baz); | 254 paint.set(baz); |
| 243 check(reporter, 1, 0, 1, 0); | 255 check(reporter, 1, 0, 1, 0); |
| 244 baz = nullptr; | 256 baz = nullptr; |
| 245 check(reporter, 1, 1, 1, 0); | 257 check(reporter, 1, 1, 1, 0); |
| 246 paint.set(nullptr); | 258 paint.set(nullptr); |
| 247 check(reporter, 1, 2, 1, 1); | 259 check(reporter, 1, 2, 1, 1); |
| 248 } | 260 } |
| 249 | 261 |
| OLD | NEW |