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

Side by Side Diff: tests/PathOpsSkpClipTest.cpp

Issue 510423005: make allocPixels throw on failure (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 3 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 | « tests/KtxTest.cpp ('k') | tests/ReadPixelsTest.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 #include "CrashHandler.h" 1 #include "CrashHandler.h"
2 // #include "OverwriteLine.h" 2 // #include "OverwriteLine.h"
3 #include "Resources.h" 3 #include "Resources.h"
4 #include "SkBitmap.h" 4 #include "SkBitmap.h"
5 #include "SkCanvas.h" 5 #include "SkCanvas.h"
6 #include "SkColor.h" 6 #include "SkColor.h"
7 #include "SkColorPriv.h" 7 #include "SkColorPriv.h"
8 #include "SkCommandLineFlags.h" 8 #include "SkCommandLineFlags.h"
9 #include "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkForceLinking.h" 10 #include "SkForceLinking.h"
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 SkScalar width = pic->cullRect().width(); 475 SkScalar width = pic->cullRect().width();
476 SkScalar height = pic->cullRect().height(); 476 SkScalar height = pic->cullRect().height();
477 SkBitmap oldBitmap, opBitmap; 477 SkBitmap oldBitmap, opBitmap;
478 fScale = 1; 478 fScale = 1;
479 while (width / fScale > 32767 || height / fScale > 32767) { 479 while (width / fScale > 32767 || height / fScale > 32767) {
480 ++fScale; 480 ++fScale;
481 } 481 }
482 do { 482 do {
483 int dimX = SkScalarCeilToInt(width / fScale); 483 int dimX = SkScalarCeilToInt(width / fScale);
484 int dimY = SkScalarCeilToInt(height / fScale); 484 int dimY = SkScalarCeilToInt(height / fScale);
485 if (oldBitmap.allocN32Pixels(dimX, dimY) && 485 if (oldBitmap.tryAllocN32Pixels(dimX, dimY) && opBitmap.tryAllocN32P ixels(dimX, dimY)) {
486 opBitmap.allocN32Pixels(dimX, dimY)) {
487 break; 486 break;
488 } 487 }
489 SkDebugf("-%d-", fScale); 488 SkDebugf("-%d-", fScale);
490 } while (++fScale < 256); 489 } while (++fScale < 256);
491 if (fScale >= 256) { 490 if (fScale >= 256) {
492 SkDebugf("unable to allocate bitmap for %s (w=%f h=%f)\n", fFilename , 491 SkDebugf("unable to allocate bitmap for %s (w=%f h=%f)\n", fFilename ,
493 width, height); 492 width, height);
494 goto finish; 493 goto finish;
495 } 494 }
496 oldBitmap.eraseColor(SK_ColorWHITE); 495 oldBitmap.eraseColor(SK_ColorWHITE);
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 } 1110 }
1112 SkGraphics::Term(); 1111 SkGraphics::Term();
1113 return 0; 1112 return 0;
1114 } 1113 }
1115 1114
1116 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 1115 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
1117 int main(int argc, char * const argv[]) { 1116 int main(int argc, char * const argv[]) {
1118 return tool_main(argc, (char**) argv); 1117 return tool_main(argc, (char**) argv);
1119 } 1118 }
1120 #endif 1119 #endif
OLDNEW
« no previous file with comments | « tests/KtxTest.cpp ('k') | tests/ReadPixelsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698