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

Side by Side Diff: src/pipe/SkGPipeWrite.cpp

Issue 433463003: Fix way-over-allocation in pipe. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | tests/DeferredCanvasTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkAnnotation.h" 9 #include "SkAnnotation.h"
10 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 SkSafeUnref(fFactorySet); 468 SkSafeUnref(fFactorySet);
469 SkSafeUnref(fBitmapHeap); 469 SkSafeUnref(fBitmapHeap);
470 } 470 }
471 471
472 bool SkGPipeCanvas::needOpBytes(size_t needed) { 472 bool SkGPipeCanvas::needOpBytes(size_t needed) {
473 if (fDone) { 473 if (fDone) {
474 return false; 474 return false;
475 } 475 }
476 476
477 needed += 4; // size of DrawOp atom 477 needed += 4; // size of DrawOp atom
478 needed = SkTMax<size_t>(MIN_BLOCK_SIZE, needed);
479 needed = SkAlign4(needed); 478 needed = SkAlign4(needed);
480 if (fWriter.bytesWritten() + needed > fBlockSize) { 479 if (fWriter.bytesWritten() + needed > fBlockSize) {
481 // Before we wipe out any data that has already been written, read it 480 // Before we wipe out any data that has already been written, read it ou t.
482 // out.
483 this->doNotify(); 481 this->doNotify();
482
483 // If we're going to allocate a new block, allocate enough to make it wo rthwhile.
484 needed = SkTMax<size_t>(MIN_BLOCK_SIZE, needed);
485
484 void* block = fController->requestBlock(needed, &fBlockSize); 486 void* block = fController->requestBlock(needed, &fBlockSize);
485 if (NULL == block) { 487 if (NULL == block) {
486 // Do not notify the readers, which would call this function again. 488 // Do not notify the readers, which would call this function again.
487 this->finish(false); 489 this->finish(false);
488 return false; 490 return false;
489 } 491 }
490 SkASSERT(SkIsAlign4(fBlockSize)); 492 SkASSERT(SkIsAlign4(fBlockSize));
491 fWriter.reset(block, fBlockSize); 493 fWriter.reset(block, fBlockSize);
492 fBytesNotified = 0; 494 fBytesNotified = 0;
493 } 495 }
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 return fCanvas->shuttleBitmap(bitmap, slot); 1260 return fCanvas->shuttleBitmap(bitmap, slot);
1259 } 1261 }
1260 1262
1261 void BitmapShuttle::removeCanvas() { 1263 void BitmapShuttle::removeCanvas() {
1262 if (NULL == fCanvas) { 1264 if (NULL == fCanvas) {
1263 return; 1265 return;
1264 } 1266 }
1265 fCanvas->unref(); 1267 fCanvas->unref();
1266 fCanvas = NULL; 1268 fCanvas = NULL;
1267 } 1269 }
OLDNEW
« no previous file with comments | « no previous file | tests/DeferredCanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698