Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Unified Diff: src/core/SkBitmap.cpp

Issue 2020683002: Rewrite assignment operator on SkBitmap, fix asan (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remember all the fields Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmap.cpp
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index f9deb837fad634a3ecd2697a3add42d240ff1644..10a7e3299c1b834a474294d072822e4f4d72b2bc 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();)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698