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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 this->freePixels(); | 46 this->freePixels(); |
47 } | 47 } |
48 | 48 |
49 SkBitmap& SkBitmap::operator=(const SkBitmap& src) { | 49 SkBitmap& SkBitmap::operator=(const SkBitmap& src) { |
50 if (this != &src) { | 50 if (this != &src) { |
51 this->freePixels(); | 51 this->freePixels(); |
52 memcpy(this, &src, sizeof(src)); | 52 memcpy(this, &src, sizeof(src)); |
53 | 53 |
54 // inc src reference counts | 54 // inc src reference counts |
55 SkSafeRef(src.fPixelRef); | 55 SkSafeRef(src.fPixelRef); |
| 56 SkSafeRef(src.fInfo.colorSpace()); |
56 | 57 |
57 // we reset our locks if we get blown away | 58 // we reset our locks if we get blown away |
58 fPixelLockCount = 0; | 59 fPixelLockCount = 0; |
59 | 60 |
60 if (fPixelRef) { | 61 if (fPixelRef) { |
61 // ignore the values from the memcpy | 62 // ignore the values from the memcpy |
62 fPixels = nullptr; | 63 fPixels = nullptr; |
63 fColorTable = nullptr; | 64 fColorTable = nullptr; |
64 // Note that what to for genID is somewhat arbitrary. We have no | 65 // Note that what to for genID is somewhat arbitrary. We have no |
65 // way to track changes to raw pixels across multiple SkBitmaps. | 66 // way to track changes to raw pixels across multiple SkBitmaps. |
(...skipping 24 matching lines...) Expand all Loading... |
90 SkTSwap(fPixels, other.fPixels); | 91 SkTSwap(fPixels, other.fPixels); |
91 SkTSwap(fInfo, other.fInfo); | 92 SkTSwap(fInfo, other.fInfo); |
92 SkTSwap(fRowBytes, other.fRowBytes); | 93 SkTSwap(fRowBytes, other.fRowBytes); |
93 SkTSwap(fFlags, other.fFlags); | 94 SkTSwap(fFlags, other.fFlags); |
94 | 95 |
95 SkDEBUGCODE(this->validate();) | 96 SkDEBUGCODE(this->validate();) |
96 } | 97 } |
97 | 98 |
98 void SkBitmap::reset() { | 99 void SkBitmap::reset() { |
99 this->freePixels(); | 100 this->freePixels(); |
| 101 this->fInfo.reset(); |
100 sk_bzero(this, sizeof(*this)); | 102 sk_bzero(this, sizeof(*this)); |
101 } | 103 } |
102 | 104 |
103 void SkBitmap::getBounds(SkRect* bounds) const { | 105 void SkBitmap::getBounds(SkRect* bounds) const { |
104 SkASSERT(bounds); | 106 SkASSERT(bounds); |
105 bounds->set(0, 0, | 107 bounds->set(0, 0, |
106 SkIntToScalar(fInfo.width()), SkIntToScalar(fInfo.height())); | 108 SkIntToScalar(fInfo.width()), SkIntToScalar(fInfo.height())); |
107 } | 109 } |
108 | 110 |
109 void SkBitmap::getBounds(SkIRect* bounds) const { | 111 void SkBitmap::getBounds(SkIRect* bounds) const { |
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 /////////////////////////////////////////////////////////////////////////////// | 1351 /////////////////////////////////////////////////////////////////////////////// |
1350 | 1352 |
1351 #ifdef SK_DEBUG | 1353 #ifdef SK_DEBUG |
1352 void SkImageInfo::validate() const { | 1354 void SkImageInfo::validate() const { |
1353 SkASSERT(fWidth >= 0); | 1355 SkASSERT(fWidth >= 0); |
1354 SkASSERT(fHeight >= 0); | 1356 SkASSERT(fHeight >= 0); |
1355 SkASSERT(SkColorTypeIsValid(fColorType)); | 1357 SkASSERT(SkColorTypeIsValid(fColorType)); |
1356 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); | 1358 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); |
1357 } | 1359 } |
1358 #endif | 1360 #endif |
OLD | NEW |