OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 if (pr) { | 288 if (pr) { |
289 const SkImageInfo& info = pr->info(); | 289 const SkImageInfo& info = pr->info(); |
290 fPixelRefOrigin.set(SkPin32(dx, 0, info.fWidth), | 290 fPixelRefOrigin.set(SkPin32(dx, 0, info.fWidth), |
291 SkPin32(dy, 0, info.fHeight)); | 291 SkPin32(dy, 0, info.fHeight)); |
292 } else { | 292 } else { |
293 // ignore dx,dy if there is no pixelref | 293 // ignore dx,dy if there is no pixelref |
294 fPixelRefOrigin.setZero(); | 294 fPixelRefOrigin.setZero(); |
295 } | 295 } |
296 | 296 |
297 if (fPixelRef != pr) { | 297 if (fPixelRef != pr) { |
298 if (fPixelRef != pr) { | 298 this->freePixels(); |
299 this->freePixels(); | 299 SkASSERT(NULL == fPixelRef); |
300 SkASSERT(NULL == fPixelRef); | |
301 | 300 |
302 SkSafeRef(pr); | 301 SkSafeRef(pr); |
303 fPixelRef = pr; | 302 fPixelRef = pr; |
304 } | |
305 this->updatePixelsFromRef(); | 303 this->updatePixelsFromRef(); |
306 } | 304 } |
307 | 305 |
308 SkDEBUGCODE(this->validate();) | 306 SkDEBUGCODE(this->validate();) |
309 return pr; | 307 return pr; |
310 } | 308 } |
311 | 309 |
312 void SkBitmap::lockPixels() const { | 310 void SkBitmap::lockPixels() const { |
313 if (NULL != fPixelRef && 0 == sk_atomic_inc(&fPixelLockCount)) { | 311 if (NULL != fPixelRef && 0 == sk_atomic_inc(&fPixelLockCount)) { |
314 fPixelRef->lockPixels(); | 312 fPixelRef->lockPixels(); |
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 /////////////////////////////////////////////////////////////////////////////// | 1424 /////////////////////////////////////////////////////////////////////////////// |
1427 | 1425 |
1428 #ifdef SK_DEBUG | 1426 #ifdef SK_DEBUG |
1429 void SkImageInfo::validate() const { | 1427 void SkImageInfo::validate() const { |
1430 SkASSERT(fWidth >= 0); | 1428 SkASSERT(fWidth >= 0); |
1431 SkASSERT(fHeight >= 0); | 1429 SkASSERT(fHeight >= 0); |
1432 SkASSERT(SkColorTypeIsValid(fColorType)); | 1430 SkASSERT(SkColorTypeIsValid(fColorType)); |
1433 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); | 1431 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); |
1434 } | 1432 } |
1435 #endif | 1433 #endif |
OLD | NEW |