SkBitmap move
Running `Release/dm --gpu 0`, the number of times we call SkBitmap::operator=(const SkBitmap&) (which refs the pixelref) is reduced from ~214929 to ~214626. Review URL: https://codereview.chromium.org/1514503004
This commit is contained in:
parent
c9730831fc
commit
023bda0d83
@ -54,12 +54,24 @@ public:
|
||||
*/
|
||||
SkBitmap(const SkBitmap& src);
|
||||
|
||||
/**
|
||||
* Copy the settings from the src into this bitmap. If the src has pixels
|
||||
* allocated, ownership of the pixels will be taken.
|
||||
*/
|
||||
SkBitmap(SkBitmap&& src);
|
||||
|
||||
~SkBitmap();
|
||||
|
||||
/** Copies the src bitmap into this bitmap. Ownership of the src bitmap's pixels remains
|
||||
with the src bitmap.
|
||||
/** Copies the src bitmap into this bitmap. Ownership of the src
|
||||
bitmap's pixels is shared with the src bitmap.
|
||||
*/
|
||||
SkBitmap& operator=(const SkBitmap& src);
|
||||
|
||||
/** Copies the src bitmap into this bitmap. Takes ownership of the src
|
||||
bitmap's pixels.
|
||||
*/
|
||||
SkBitmap& operator=(SkBitmap&& src);
|
||||
|
||||
/** Swap the fields of the two bitmaps. This routine is guaranteed to never fail or throw.
|
||||
*/
|
||||
// This method is not exported to java.
|
||||
|
@ -39,6 +39,8 @@ SkBitmap::SkBitmap(const SkBitmap& src) {
|
||||
SkDEBUGCODE(this->validate();)
|
||||
}
|
||||
|
||||
SkBitmap::SkBitmap(SkBitmap&& other) : SkBitmap() { this->swap(other); }
|
||||
|
||||
SkBitmap::~SkBitmap() {
|
||||
SkDEBUGCODE(this->validate();)
|
||||
this->freePixels();
|
||||
@ -72,6 +74,14 @@ SkBitmap& SkBitmap::operator=(const SkBitmap& src) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
SkBitmap& SkBitmap::operator=(SkBitmap&& other) {
|
||||
if (this != &other) {
|
||||
this->swap(other);
|
||||
other.reset();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void SkBitmap::swap(SkBitmap& other) {
|
||||
SkTSwap(fColorTable, other.fColorTable);
|
||||
SkTSwap(fPixelRef, other.fPixelRef);
|
||||
|
Loading…
Reference in New Issue
Block a user