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

Unified Diff: src/gpu/GrBatchAtlas.cpp

Issue 1105913002: fix for using too much memory in GrBatchAtlas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback inc 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/GrBatchAtlas.cpp
diff --git a/src/gpu/GrBatchAtlas.cpp b/src/gpu/GrBatchAtlas.cpp
index 0bcd2f9e06325cd81bcbcce2435d104a6f83b027..faa26c49f4f13988befcac19d74eb1fd8b7cb592 100644
--- a/src/gpu/GrBatchAtlas.cpp
+++ b/src/gpu/GrBatchAtlas.cpp
@@ -50,7 +50,10 @@ public:
return false;
}
- SkASSERT(fData);
+ if (!fData) {
+ fData = reinterpret_cast<unsigned char*>(sk_calloc_throw(fBytesPerPixel * fWidth *
+ fHeight));
+ }
const unsigned char* imagePtr = (const unsigned char*)image;
// point ourselves at the right starting spot
unsigned char* dataPtr = fData;
@@ -88,9 +91,8 @@ public:
void uploadToTexture(GrBatchTarget::TextureUploader uploader) {
// We should only be issuing uploads if we are in fact dirty
- SkASSERT(fDirty);
+ SkASSERT(fDirty && fData && fTexture);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), "GrBatchPlot::uploadToTexture");
- SkASSERT(fTexture);
size_t rowBytes = fBytesPerPixel * fRects->width();
const unsigned char* dataPtr = fData;
dataPtr += rowBytes * fDirtyRect.fTop;
@@ -110,8 +112,9 @@ public:
fID = create_id(fIndex, fGenID);
// zero out the plot
- SkASSERT(fData);
- memset(fData, 0, fBytesPerPixel * fWidth * fHeight);
+ if (fData) {
+ sk_bzero(fData, fBytesPerPixel * fWidth * fHeight);
+ }
fDirtyRect.setEmpty();
SkDEBUGCODE(fDirty = false;)
@@ -166,10 +169,6 @@ private:
fDirtyRect.setEmpty();
SkDEBUGCODE(fDirty = false;)
fTexture = texture;
-
- // allocate backing store
- fData = SkNEW_ARRAY(unsigned char, fBytesPerPixel * width * height);
- memset(fData, 0, fBytesPerPixel * width * height);
}
BatchToken fLastUpload;
« 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