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

Unified Diff: include/core/SkTArray.h

Issue 902873002: Reimplement gpu message bus for invalidated bitmap gen IDs (Closed) Base URL: https://skia.googlesource.com/skia.git@one_tex
Patch Set: fix speeling error Created 5 years, 10 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 | include/gpu/GrGpuResource.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkTArray.h
diff --git a/include/core/SkTArray.h b/include/core/SkTArray.h
index 9de21179f06769688576c7e202fba550f2034379..9d410c12ea6940dc404ee1563ec325c64d2584d7 100644
--- a/include/core/SkTArray.h
+++ b/include/core/SkTArray.h
@@ -270,6 +270,23 @@ public:
}
}
+ /** Swaps the contents of this array with that array. Does a pointer swap if possible,
+ otherwise copies the T values. */
+ void swap(SkTArray* that) {
+ if (this->fPreAllocMemArray != this->fItemArray &&
+ that->fPreAllocMemArray != that->fItemArray) {
+ // If neither is using a preallocated array then just swap.
+ SkTSwap(fItemArray, that->fItemArray);
+ SkTSwap(fCount, that->fCount);
+ SkTSwap(fAllocCount, that->fAllocCount);
+ } else {
+ // This could be more optimal...
+ SkTArray copy(*that);
+ *that = *this;
+ *this = copy;
+ }
+ }
+
T* begin() {
return fItemArray;
}
@@ -375,7 +392,7 @@ protected:
}
void init(const T* array, int count,
- void* preAllocStorage, int preAllocOrReserveCount) {
+ void* preAllocStorage, int preAllocOrReserveCount) {
SkASSERT(count >= 0);
SkASSERT(preAllocOrReserveCount >= 0);
fCount = count;
@@ -452,10 +469,10 @@ private:
template<typename X> friend void SkTArrayExt::copy(SkTArray<X, false>* that, const X*);
template<typename X> friend void SkTArrayExt::copyAndDelete(SkTArray<X, false>* that, char*);
- int fReserveCount;
- int fCount;
- int fAllocCount;
- void* fPreAllocMemArray;
+ int fReserveCount;
+ int fCount;
+ int fAllocCount;
+ void* fPreAllocMemArray;
union {
T* fItemArray;
void* fMemArray;
« no previous file with comments | « no previous file | include/gpu/GrGpuResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698