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

Side by Side Diff: tests/SkpSkGrTest.cpp

Issue 1811613004: Change SkTime::GetMSecs to double; ensure values stored in SkMSec do not overflow. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Rebase. Created 4 years, 9 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/PathOpsSkpClipTest.cpp ('k') | tests/StrokerTest.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 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrContext.h" 8 #include "GrContext.h"
9 #include "GrContextFactory.h" 9 #include "GrContextFactory.h"
10 #include "GrRenderTarget.h" 10 #include "GrRenderTarget.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 strcpy(fFilename, filename.c_str()); 99 strcpy(fFilename, filename.c_str());
100 testOne(); 100 testOne();
101 } 101 }
102 102
103 void testOne(); 103 void testOne();
104 104
105 char fFilename[kMaxLength]; 105 char fFilename[kMaxLength];
106 TestStep fTestStep; 106 TestStep fTestStep;
107 int fDirNo; 107 int fDirNo;
108 int fPixelError; 108 int fPixelError;
109 int fTime; 109 SkMSec fTime;
110 bool fScaleOversized; 110 bool fScaleOversized;
111 }; 111 };
112 112
113 struct SkpSkGrThreadState { 113 struct SkpSkGrThreadState {
114 void init(int dirNo) { 114 void init(int dirNo) {
115 fResult.init(dirNo); 115 fResult.init(dirNo);
116 fFoundCount = 0; 116 fFoundCount = 0;
117 fSmallestError = 0; 117 fSmallestError = 0;
118 sk_bzero(fFilesFound, sizeof(fFilesFound)); 118 sk_bzero(fFilesFound, sizeof(fFilesFound));
119 sk_bzero(fDirsFound, sizeof(fDirsFound)); 119 sk_bzero(fDirsFound, sizeof(fDirsFound));
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 canvas->save(); 336 canvas->save();
337 int pWidth = pic->width(); 337 int pWidth = pic->width();
338 int pHeight = pic->height(); 338 int pHeight = pic->height();
339 const int maxDimension = 1000; 339 const int maxDimension = 1000;
340 const int slices = 3; 340 const int slices = 3;
341 int xInterval = SkTMax(pWidth - maxDimension, 0) / (slices - 1); 341 int xInterval = SkTMax(pWidth - maxDimension, 0) / (slices - 1);
342 int yInterval = SkTMax(pHeight - maxDimension, 0) / (slices - 1); 342 int yInterval = SkTMax(pHeight - maxDimension, 0) / (slices - 1);
343 SkRect rect = {0, 0, SkIntToScalar(SkTMin(maxDimension, pWidth)), 343 SkRect rect = {0, 0, SkIntToScalar(SkTMin(maxDimension, pWidth)),
344 SkIntToScalar(SkTMin(maxDimension, pHeight))}; 344 SkIntToScalar(SkTMin(maxDimension, pHeight))};
345 canvas->clipRect(rect); 345 canvas->clipRect(rect);
346 SkMSec start = SkTime::GetMSecs(); 346 skiatest::Timer timer;
347 for (int x = 0; x < slices; ++x) { 347 for (int x = 0; x < slices; ++x) {
348 for (int y = 0; y < slices; ++y) { 348 for (int y = 0; y < slices; ++y) {
349 pic->draw(canvas); 349 pic->draw(canvas);
350 canvas->translate(0, SkIntToScalar(yInterval)); 350 canvas->translate(0, SkIntToScalar(yInterval));
351 } 351 }
352 canvas->translate(SkIntToScalar(xInterval), SkIntToScalar(-yInterval * s lices)); 352 canvas->translate(SkIntToScalar(xInterval), SkIntToScalar(-yInterval * s lices));
353 } 353 }
354 SkMSec end = SkTime::GetMSecs(); 354 SkMSec elapsed = timer.elapsedMsInt();
355 canvas->restore(); 355 canvas->restore();
356 return end - start; 356 return elapsed;
357 } 357 }
358 358
359 static void drawPict(SkPicture* pic, SkCanvas* canvas, int scale) { 359 static void drawPict(SkPicture* pic, SkCanvas* canvas, int scale) {
360 canvas->clear(SK_ColorWHITE); 360 canvas->clear(SK_ColorWHITE);
361 if (scale != 1) { 361 if (scale != 1) {
362 canvas->save(); 362 canvas->save();
363 canvas->scale(1.0f / scale, 1.0f / scale); 363 canvas->scale(1.0f / scale, 1.0f / scale);
364 } 364 }
365 pic->draw(canvas); 365 pic->draw(canvas);
366 if (scale != 1) { 366 if (scale != 1) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 SkGpuDevice grDevice(context, texture.get()); 455 SkGpuDevice grDevice(context, texture.get());
456 SkCanvas grCanvas(&grDevice); 456 SkCanvas grCanvas(&grDevice);
457 drawPict(pic.get(), &grCanvas, fScaleOversized ? scale : 1); 457 drawPict(pic.get(), &grCanvas, fScaleOversized ? scale : 1);
458 458
459 SkBitmap grBitmap; 459 SkBitmap grBitmap;
460 grBitmap.allocPixels(grCanvas.imageInfo()); 460 grBitmap.allocPixels(grCanvas.imageInfo());
461 grCanvas.readPixels(&grBitmap, 0, 0); 461 grCanvas.readPixels(&grBitmap, 0, 0);
462 462
463 if (fTestStep == kCompareBits) { 463 if (fTestStep == kCompareBits) {
464 fPixelError = similarBits(grBitmap, bitmap); 464 fPixelError = similarBits(grBitmap, bitmap);
465 int skTime = timePict(pic, &skCanvas); 465 SkMSec skTime = timePict(pic, &skCanvas);
466 int grTime = timePict(pic, &grCanvas); 466 SkMSec grTime = timePict(pic, &grCanvas);
467 fTime = skTime - grTime; 467 fTime = skTime - grTime;
468 } else if (fTestStep == kEncodeFiles) { 468 } else if (fTestStep == kEncodeFiles) {
469 SkString pngStr = make_png_name(fFilename); 469 SkString pngStr = make_png_name(fFilename);
470 const char* pngName = pngStr.c_str(); 470 const char* pngName = pngStr.c_str();
471 writePict(grBitmap, outGrDir, pngName); 471 writePict(grBitmap, outGrDir, pngName);
472 writePict(bitmap, outSkDir, pngName); 472 writePict(bitmap, outSkDir, pngName);
473 } 473 }
474 } 474 }
475 } 475 }
476 476
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 int testIndex = 166; 745 int testIndex = 166;
746 int dirIndex = skipOverSkGr[testIndex - 166].directory; 746 int dirIndex = skipOverSkGr[testIndex - 166].directory;
747 SkString pictDir = make_in_dir_name(dirIndex); 747 SkString pictDir = make_in_dir_name(dirIndex);
748 if (pictDir.size() == 0) { 748 if (pictDir.size() == 0) {
749 return; 749 return;
750 } 750 }
751 SkString filename(skipOverSkGr[testIndex - 166].filename); 751 SkString filename(skipOverSkGr[testIndex - 166].filename);
752 TestResult::Test(dirIndex, filename.c_str(), kCompareBits, reporter->verbose ()); 752 TestResult::Test(dirIndex, filename.c_str(), kCompareBits, reporter->verbose ());
753 TestResult::Test(dirIndex, filename.c_str(), kEncodeFiles, reporter->verbose ()); 753 TestResult::Test(dirIndex, filename.c_str(), kEncodeFiles, reporter->verbose ());
754 } 754 }
OLDNEW
« no previous file with comments | « tests/PathOpsSkpClipTest.cpp ('k') | tests/StrokerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698