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

Side by Side Diff: tests/PathOpsSkpClipTest.cpp

Issue 162643002: replace setConfig+allocPixels with single call (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « tests/PathOpsExtendedTest.cpp ('k') | tests/PathUtilsTest.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 #include "SkBitmap.h" 2 #include "SkBitmap.h"
3 #include "SkCanvas.h" 3 #include "SkCanvas.h"
4 #include "SkColor.h" 4 #include "SkColor.h"
5 #include "SkColorPriv.h" 5 #include "SkColorPriv.h"
6 #include "SkDevice.h" 6 #include "SkDevice.h"
7 #include "SkGraphics.h" 7 #include "SkGraphics.h"
8 #include "SkImageDecoder.h" 8 #include "SkImageDecoder.h"
9 #include "SkImageEncoder.h" 9 #include "SkImageEncoder.h"
10 #include "SkOSFile.h" 10 #include "SkOSFile.h"
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 SkDebugf("unable to decode %s\n", fFilename); 396 SkDebugf("unable to decode %s\n", fFilename);
397 goto finish; 397 goto finish;
398 } 398 }
399 int width = pic->width(); 399 int width = pic->width();
400 int height = pic->height(); 400 int height = pic->height();
401 SkBitmap oldBitmap, opBitmap; 401 SkBitmap oldBitmap, opBitmap;
402 int scale = 1; 402 int scale = 1;
403 do { 403 do {
404 int dimX = (width + scale - 1) / scale; 404 int dimX = (width + scale - 1) / scale;
405 int dimY = (height + scale - 1) / scale; 405 int dimY = (height + scale - 1) / scale;
406 oldBitmap.setConfig(SkBitmap::kARGB_8888_Config, dimX, dimY); 406 if (oldBitmap.allocN32Pixels(dimX, dimY) &&
407 opBitmap.setConfig(SkBitmap::kARGB_8888_Config, dimX, dimY); 407 opBitmap.allocN32Pixels(dimX, dimY)) {
408 bool success = oldBitmap.allocPixels() && opBitmap.allocPixels();
409 if (success) {
410 break; 408 break;
411 } 409 }
412 SkDebugf("-%d-", scale); 410 SkDebugf("-%d-", scale);
413 } while ((scale *= 2) < 256); 411 } while ((scale *= 2) < 256);
414 if (scale >= 256) { 412 if (scale >= 256) {
415 SkDebugf("unable to allocate bitmap for %s (w=%d h=%d)\n", fFilename , 413 SkDebugf("unable to allocate bitmap for %s (w=%d h=%d)\n", fFilename ,
416 width, height); 414 width, height);
417 return; 415 return;
418 } 416 }
419 oldBitmap.eraseColor(SK_ColorWHITE); 417 oldBitmap.eraseColor(SK_ColorWHITE);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 SkAssertResult(make_in_dir_name(dirNo).size()); 668 SkAssertResult(make_in_dir_name(dirNo).size());
671 SkString filename(skipOverSept[testIndex].filename); 669 SkString filename(skipOverSept[testIndex].filename);
672 TestResult state; 670 TestResult state;
673 state.test(dirNo, filename); 671 state.test(dirNo, filename);
674 if (reporter->verbose()) { 672 if (reporter->verbose()) {
675 SkDebugf("%s", state.status().c_str()); 673 SkDebugf("%s", state.status().c_str());
676 } 674 }
677 state.fTestStep = kEncodeFiles; 675 state.fTestStep = kEncodeFiles;
678 state.testOne(); 676 state.testOne();
679 } 677 }
OLDNEW
« no previous file with comments | « tests/PathOpsExtendedTest.cpp ('k') | tests/PathUtilsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698