From: joshualitt Date: Fri, 24 Apr 2015 15:33:21 +0000 (-0700) Subject: fix for using too much memory in GrBatchAtlas X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~2663 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e062db9cc6478745138cca964ee46839e413ab7b;p=platform%2Fupstream%2FlibSkiaSharp.git fix for using too much memory in GrBatchAtlas BUG=skia: Review URL: https://codereview.chromium.org/1105913002 --- diff --git a/src/gpu/GrBatchAtlas.cpp b/src/gpu/GrBatchAtlas.cpp index 0bcd2f9..faa26c4 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(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;