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

Side by Side Diff: tests/PathOpsSkpClipTest.cpp

Issue 513983002: Try out scalar picture sizes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update to ToT again 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/ImageFilterTest.cpp ('k') | tests/PictureTest.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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 } 387 }
388 if (time > 0 && slowCount < kMaxFiles) { 388 if (time > 0 && slowCount < kMaxFiles) {
389 *data->fSlowest.append() = *(SortByTime*) &testResult; 389 *data->fSlowest.append() = *(SortByTime*) &testResult;
390 return true; 390 return true;
391 } 391 }
392 return false; 392 return false;
393 } 393 }
394 394
395 static SkMSec timePict(SkPicture* pic, SkCanvas* canvas) { 395 static SkMSec timePict(SkPicture* pic, SkCanvas* canvas) {
396 canvas->save(); 396 canvas->save();
397 int pWidth = pic->width(); 397 SkScalar pWidth = pic->cullRect().width();
398 int pHeight = pic->height(); 398 SkScalar pHeight = pic->cullRect().height();
399 const int maxDimension = 1000; 399 const SkScalar maxDimension = 1000.0f;
400 const int slices = 3; 400 const int slices = 3;
401 int xInterval = SkTMax(pWidth - maxDimension, 0) / (slices - 1); 401 SkScalar xInterval = SkTMax(pWidth - maxDimension, 0.0f) / (slices - 1);
402 int yInterval = SkTMax(pHeight - maxDimension, 0) / (slices - 1); 402 SkScalar yInterval = SkTMax(pHeight - maxDimension, 0.0f) / (slices - 1);
403 SkRect rect = {0, 0, SkIntToScalar(SkTMin(maxDimension, pWidth)), 403 SkRect rect = {0, 0, SkTMin(maxDimension, pWidth), SkTMin(maxDimension, pHei ght) };
404 SkIntToScalar(SkTMin(maxDimension, pHeight))};
405 canvas->clipRect(rect); 404 canvas->clipRect(rect);
406 SkMSec start = SkTime::GetMSecs(); 405 SkMSec start = SkTime::GetMSecs();
407 for (int x = 0; x < slices; ++x) { 406 for (int x = 0; x < slices; ++x) {
408 for (int y = 0; y < slices; ++y) { 407 for (int y = 0; y < slices; ++y) {
409 pic->draw(canvas); 408 pic->draw(canvas);
410 canvas->translate(0, SkIntToScalar(yInterval)); 409 canvas->translate(0, yInterval);
411 } 410 }
412 canvas->translate(SkIntToScalar(xInterval), SkIntToScalar(-yInterval * s lices)); 411 canvas->translate(xInterval, -yInterval * slices);
413 } 412 }
414 SkMSec end = SkTime::GetMSecs(); 413 SkMSec end = SkTime::GetMSecs();
415 canvas->restore(); 414 canvas->restore();
416 return end - start; 415 return end - start;
417 } 416 }
418 417
419 static void drawPict(SkPicture* pic, SkCanvas* canvas, int scale) { 418 static void drawPict(SkPicture* pic, SkCanvas* canvas, int scale) {
420 canvas->clear(SK_ColorWHITE); 419 canvas->clear(SK_ColorWHITE);
421 if (scale != 1) { 420 if (scale != 1) {
422 canvas->save(); 421 canvas->save();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 SkFILEStream stream(path.c_str()); 465 SkFILEStream stream(path.c_str());
467 if (!stream.isValid()) { 466 if (!stream.isValid()) {
468 SkDebugf("invalid stream %s\n", path.c_str()); 467 SkDebugf("invalid stream %s\n", path.c_str());
469 goto finish; 468 goto finish;
470 } 469 }
471 pic = SkPicture::CreateFromStream(&stream, &SkImageDecoder::DecodeMemory ); 470 pic = SkPicture::CreateFromStream(&stream, &SkImageDecoder::DecodeMemory );
472 if (!pic) { 471 if (!pic) {
473 SkDebugf("unable to decode %s\n", fFilename); 472 SkDebugf("unable to decode %s\n", fFilename);
474 goto finish; 473 goto finish;
475 } 474 }
476 int width = pic->width(); 475 SkScalar width = pic->cullRect().width();
477 int height = pic->height(); 476 SkScalar height = pic->cullRect().height();
478 SkBitmap oldBitmap, opBitmap; 477 SkBitmap oldBitmap, opBitmap;
479 fScale = 1; 478 fScale = 1;
480 while (width / fScale > 32767 || height / fScale > 32767) { 479 while (width / fScale > 32767 || height / fScale > 32767) {
481 ++fScale; 480 ++fScale;
482 } 481 }
483 do { 482 do {
484 int dimX = (width + fScale - 1) / fScale; 483 int dimX = SkScalarCeilToInt(width / fScale);
485 int dimY = (height + fScale - 1) / fScale; 484 int dimY = SkScalarCeilToInt(height / fScale);
486 if (oldBitmap.allocN32Pixels(dimX, dimY) && 485 if (oldBitmap.allocN32Pixels(dimX, dimY) &&
487 opBitmap.allocN32Pixels(dimX, dimY)) { 486 opBitmap.allocN32Pixels(dimX, dimY)) {
488 break; 487 break;
489 } 488 }
490 SkDebugf("-%d-", fScale); 489 SkDebugf("-%d-", fScale);
491 } while (++fScale < 256); 490 } while (++fScale < 256);
492 if (fScale >= 256) { 491 if (fScale >= 256) {
493 SkDebugf("unable to allocate bitmap for %s (w=%d h=%d)\n", fFilename , 492 SkDebugf("unable to allocate bitmap for %s (w=%f h=%f)\n", fFilename ,
494 width, height); 493 width, height);
495 goto finish; 494 goto finish;
496 } 495 }
497 oldBitmap.eraseColor(SK_ColorWHITE); 496 oldBitmap.eraseColor(SK_ColorWHITE);
498 SkCanvas oldCanvas(oldBitmap); 497 SkCanvas oldCanvas(oldBitmap);
499 oldCanvas.setAllowSimplifyClip(false); 498 oldCanvas.setAllowSimplifyClip(false);
500 opBitmap.eraseColor(SK_ColorWHITE); 499 opBitmap.eraseColor(SK_ColorWHITE);
501 SkCanvas opCanvas(opBitmap); 500 SkCanvas opCanvas(opBitmap);
502 opCanvas.setAllowSimplifyClip(true); 501 opCanvas.setAllowSimplifyClip(true);
503 drawPict(pic, &oldCanvas, fScale); 502 drawPict(pic, &oldCanvas, fScale);
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 } 1111 }
1113 SkGraphics::Term(); 1112 SkGraphics::Term();
1114 return 0; 1113 return 0;
1115 } 1114 }
1116 1115
1117 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 1116 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
1118 int main(int argc, char * const argv[]) { 1117 int main(int argc, char * const argv[]) {
1119 return tool_main(argc, (char**) argv); 1118 return tool_main(argc, (char**) argv);
1120 } 1119 }
1121 #endif 1120 #endif
OLDNEW
« no previous file with comments | « tests/ImageFilterTest.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698