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

Unified Diff: src/gpu/GrAtlasTextContext.h

Issue 1083703002: Convert BitmapTextBlob from using STArray to AutoSTMalloc (Closed) Base URL: https://skia.googlesource.com/skia.git@atcolorslots
Patch Set: fix Created 5 years, 8 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/gpu/GrAtlasTextContext.h
diff --git a/src/gpu/GrAtlasTextContext.h b/src/gpu/GrAtlasTextContext.h
index 62b520753824926510a2613a97a368c7612f121a..79cb7a4169da545ebdf3128dc45006b0316412c2 100644
--- a/src/gpu/GrAtlasTextContext.h
+++ b/src/gpu/GrAtlasTextContext.h
@@ -86,12 +86,11 @@ private:
* would greatly increase the memory of these cached items.
*/
struct Run {
- Run() : fColor(GrColor_ILLEGAL), fInitialized(false), fDrawAsPaths(false) {
+ Run()
+ : fColor(GrColor_ILLEGAL)
+ , fInitialized(false)
+ , fDrawAsPaths(false) {
fVertexBounds.setLargestInverted();
- // We insert the first subrun to gurantee a run always has atleast one subrun.
- // We do this to simplify things when we 'hand off' data from one subrun to the
- // next
- fSubRunInfo.push_back();
}
struct SubRunInfo {
SubRunInfo()
@@ -108,7 +107,43 @@ private:
size_t fVertexEndIndex;
GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken;
};
- SkSTArray<1, SubRunInfo, true> fSubRunInfo;
+
+ class SubRunInfoArray {
+ public:
+ SubRunInfoArray()
+ : fSubRunCount(0)
+ , fSubRunAllocation(kMinSubRuns) {
+ fPtr = reinterpret_cast<SubRunInfo*>(fSubRunStorage.get());
+ this->push_back();
+ }
+
+ int count() const { return fSubRunCount; }
+ SubRunInfo& back() { return fPtr[fSubRunCount - 1]; }
+ SubRunInfo& push_back() {
+ if (fSubRunCount >= fSubRunAllocation) {
+ fSubRunAllocation = fSubRunAllocation << 1;
+ fSubRunStorage.realloc(fSubRunAllocation * sizeof(SubRunInfo));
+ fPtr = reinterpret_cast<SubRunInfo*>(fSubRunStorage.get());
+ }
+ SkNEW_PLACEMENT(&fPtr[fSubRunCount], SubRunInfo);
+ return fPtr[fSubRunCount++];
+ }
+ SubRunInfo& operator[](int index) {
+ return fPtr[index];
+ }
+ const SubRunInfo& operator[](int index) const {
+ return fPtr[index];
+ }
+
+ private:
+ static const int kMinSubRuns = 1;
+ static const int kMinSubRunStorage = kMinSubRuns * sizeof(SubRunInfo);
+ SkAutoSTMalloc<kMinSubRunStorage, unsigned char> fSubRunStorage;
+ int fSubRunCount;
+ int fSubRunAllocation;
+ SubRunInfo* fPtr;
+ };
+ SubRunInfoArray fSubRunInfo;
SkAutoDescriptor fDescriptor;
SkAutoTUnref<SkTypeface> fTypeface;
SkRect fVertexBounds;
« 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