aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-05-27 11:31:55 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-27 11:31:56 -0700
commit0881fb545c7fe53d9572c22167458efdf9deece5 (patch)
tree28fb3e4a92b19570a618b6ee225e4cd07dd76481 /src/core
parent1346c25071ff0482958101c6f09063db6cd17cfe (diff)
Rewrite assignment operator on SkBitmap, fix asan
TBR=mtklein@google.com BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2020683002 Review-Url: https://codereview.chromium.org/2020683002
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkBitmap.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index f9deb837fa..10a7e3299c 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -49,26 +49,22 @@ SkBitmap::~SkBitmap() {
SkBitmap& SkBitmap::operator=(const SkBitmap& src) {
if (this != &src) {
this->freePixels();
- memcpy(this, &src, sizeof(src));
-
- // inc src reference counts
- SkSafeRef(src.fPixelRef);
- SkSafeRef(src.fInfo.colorSpace());
-
+ this->fPixelRef = SkSafeRef(src.fPixelRef);
+ if (this->fPixelRef) {
+ // ignore the values if we have a pixelRef
+ this->fPixels = nullptr;
+ this->fColorTable = nullptr;
+ } else {
+ this->fPixels = src.fPixels;
+ this->fColorTable = src.fColorTable;
+ }
// we reset our locks if we get blown away
- fPixelLockCount = 0;
+ this->fPixelLockCount = 0;
- if (fPixelRef) {
- // ignore the values from the memcpy
- fPixels = nullptr;
- fColorTable = nullptr;
- // Note that what to for genID is somewhat arbitrary. We have no
- // way to track changes to raw pixels across multiple SkBitmaps.
- // Would benefit from an SkRawPixelRef type created by
- // setPixels.
- // Just leave the memcpy'ed one but they'll get out of sync
- // as soon either is modified.
- }
+ this->fPixelRefOrigin = src.fPixelRefOrigin;
+ this->fInfo = src.fInfo;
+ this->fRowBytes = src.fRowBytes;
+ this->fFlags = src.fFlags;
}
SkDEBUGCODE(this->validate();)