| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
| 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 "SkAtomics.h" | 8 #include "SkAtomics.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 sk_bzero(this, sizeof(*this)); | 32 sk_bzero(this, sizeof(*this)); |
| 33 } | 33 } |
| 34 | 34 |
| 35 SkBitmap::SkBitmap(const SkBitmap& src) { | 35 SkBitmap::SkBitmap(const SkBitmap& src) { |
| 36 SkDEBUGCODE(src.validate();) | 36 SkDEBUGCODE(src.validate();) |
| 37 sk_bzero(this, sizeof(*this)); | 37 sk_bzero(this, sizeof(*this)); |
| 38 *this = src; | 38 *this = src; |
| 39 SkDEBUGCODE(this->validate();) | 39 SkDEBUGCODE(this->validate();) |
| 40 } | 40 } |
| 41 | 41 |
| 42 SkBitmap::SkBitmap(SkBitmap&& other) : SkBitmap() { this->swap(other); } |
| 43 |
| 42 SkBitmap::~SkBitmap() { | 44 SkBitmap::~SkBitmap() { |
| 43 SkDEBUGCODE(this->validate();) | 45 SkDEBUGCODE(this->validate();) |
| 44 this->freePixels(); | 46 this->freePixels(); |
| 45 } | 47 } |
| 46 | 48 |
| 47 SkBitmap& SkBitmap::operator=(const SkBitmap& src) { | 49 SkBitmap& SkBitmap::operator=(const SkBitmap& src) { |
| 48 if (this != &src) { | 50 if (this != &src) { |
| 49 this->freePixels(); | 51 this->freePixels(); |
| 50 memcpy(this, &src, sizeof(src)); | 52 memcpy(this, &src, sizeof(src)); |
| 51 | 53 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 65 // setPixels. | 67 // setPixels. |
| 66 // Just leave the memcpy'ed one but they'll get out of sync | 68 // Just leave the memcpy'ed one but they'll get out of sync |
| 67 // as soon either is modified. | 69 // as soon either is modified. |
| 68 } | 70 } |
| 69 } | 71 } |
| 70 | 72 |
| 71 SkDEBUGCODE(this->validate();) | 73 SkDEBUGCODE(this->validate();) |
| 72 return *this; | 74 return *this; |
| 73 } | 75 } |
| 74 | 76 |
| 77 SkBitmap& SkBitmap::operator=(SkBitmap&& other) { |
| 78 if (this != &other) { |
| 79 this->swap(other); |
| 80 other.reset(); |
| 81 } |
| 82 return *this; |
| 83 } |
| 84 |
| 75 void SkBitmap::swap(SkBitmap& other) { | 85 void SkBitmap::swap(SkBitmap& other) { |
| 76 SkTSwap(fColorTable, other.fColorTable); | 86 SkTSwap(fColorTable, other.fColorTable); |
| 77 SkTSwap(fPixelRef, other.fPixelRef); | 87 SkTSwap(fPixelRef, other.fPixelRef); |
| 78 SkTSwap(fPixelRefOrigin, other.fPixelRefOrigin); | 88 SkTSwap(fPixelRefOrigin, other.fPixelRefOrigin); |
| 79 SkTSwap(fPixelLockCount, other.fPixelLockCount); | 89 SkTSwap(fPixelLockCount, other.fPixelLockCount); |
| 80 SkTSwap(fPixels, other.fPixels); | 90 SkTSwap(fPixels, other.fPixels); |
| 81 SkTSwap(fInfo, other.fInfo); | 91 SkTSwap(fInfo, other.fInfo); |
| 82 SkTSwap(fRowBytes, other.fRowBytes); | 92 SkTSwap(fRowBytes, other.fRowBytes); |
| 83 SkTSwap(fFlags, other.fFlags); | 93 SkTSwap(fFlags, other.fFlags); |
| 84 | 94 |
| (...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 /////////////////////////////////////////////////////////////////////////////// | 1338 /////////////////////////////////////////////////////////////////////////////// |
| 1329 | 1339 |
| 1330 #ifdef SK_DEBUG | 1340 #ifdef SK_DEBUG |
| 1331 void SkImageInfo::validate() const { | 1341 void SkImageInfo::validate() const { |
| 1332 SkASSERT(fWidth >= 0); | 1342 SkASSERT(fWidth >= 0); |
| 1333 SkASSERT(fHeight >= 0); | 1343 SkASSERT(fHeight >= 0); |
| 1334 SkASSERT(SkColorTypeIsValid(fColorType)); | 1344 SkASSERT(SkColorTypeIsValid(fColorType)); |
| 1335 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); | 1345 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); |
| 1336 } | 1346 } |
| 1337 #endif | 1347 #endif |
| OLD | NEW |