OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |