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

Side by Side Diff: gm/gmmain.cpp

Issue 13165011: Add tile rendering to GM (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: fixed typo Created 7 years, 8 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 | « no previous file | no next file » | 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 2011 Google Inc. 2 * Copyright 2011 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 /* 8 /*
9 * Code for the "gm" (Golden Master) rendering comparison tool. 9 * Code for the "gm" (Golden Master) rendering comparison tool.
10 * 10 *
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 size.fHeight); 406 size.fHeight);
407 canvas->readPixels(bitmap, 0, 0); 407 canvas->readPixels(bitmap, 0, 0);
408 } 408 }
409 #endif 409 #endif
410 complete_bitmap(bitmap); 410 complete_bitmap(bitmap);
411 return kEmpty_ErrorCombination; 411 return kEmpty_ErrorCombination;
412 } 412 }
413 413
414 static void generate_image_from_picture(GM* gm, const ConfigData& gRec, 414 static void generate_image_from_picture(GM* gm, const ConfigData& gRec,
415 SkPicture* pict, SkBitmap* bitmap, 415 SkPicture* pict, SkBitmap* bitmap,
416 SkScalar scale = SK_Scalar1) { 416 SkScalar scale = SK_Scalar1,
417 bool tile = false) {
417 SkISize size = gm->getISize(); 418 SkISize size = gm->getISize();
418 setup_bitmap(gRec, size, bitmap); 419 setup_bitmap(gRec, size, bitmap);
419 SkCanvas canvas(*bitmap); 420
420 installFilter(&canvas); 421 if (tile) {
421 canvas.scale(scale, scale); 422 // Generate the result image by rendering to tiles and accumulating
422 canvas.drawPicture(*pict); 423 // the results in 'bitmap'
423 complete_bitmap(bitmap); 424
425 // This 16x16 tiling matches the settings applied to 'pict' in
426 // 'generate_new_picture'
427 SkISize tileSize = SkISize::Make(16, 16);
428
429 SkBitmap tileBM;
430 setup_bitmap(gRec, tileSize, &tileBM);
431 SkCanvas tileCanvas(tileBM);
432 installFilter(&tileCanvas);
433
434 SkCanvas bmpCanvas(*bitmap);
435 SkPaint bmpPaint;
436 bmpPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
437
438 for (int yTile = 0; yTile < (size.height()+15)/16; ++yTile) {
439 for (int xTile = 0; xTile < (size.width()+15)/16; ++xTile) {
440 int saveCount = tileCanvas.save();
441 SkMatrix mat(tileCanvas.getTotalMatrix());
442 mat.postTranslate(SkIntToScalar(-xTile*tileSize.width()),
443 SkIntToScalar(-yTile*tileSize.height()));
444 tileCanvas.setMatrix(mat);
445 pict->draw(&tileCanvas);
446 tileCanvas.flush();
447 tileCanvas.restoreToCount(saveCount);
448 bmpCanvas.drawBitmap(tileBM,
449 SkIntToScalar(xTile * tileSize.width()) ,
450 SkIntToScalar(yTile * tileSize.height() ),
451 &bmpPaint);
452 }
453 }
454 } else {
455 SkCanvas canvas(*bitmap);
456 installFilter(&canvas);
457 canvas.scale(scale, scale);
458 canvas.drawPicture(*pict);
459 complete_bitmap(bitmap);
460 }
424 } 461 }
425 462
426 static void generate_pdf(GM* gm, SkDynamicMemoryWStream& pdf) { 463 static void generate_pdf(GM* gm, SkDynamicMemoryWStream& pdf) {
427 #ifdef SK_SUPPORT_PDF 464 #ifdef SK_SUPPORT_PDF
428 SkMatrix initialTransform = gm->getInitialTransform(); 465 SkMatrix initialTransform = gm->getInitialTransform();
429 SkISize pageSize = gm->getISize(); 466 SkISize pageSize = gm->getISize();
430 SkPDFDevice* dev = NULL; 467 SkPDFDevice* dev = NULL;
431 if (initialTransform.isIdentity()) { 468 if (initialTransform.isIdentity()) {
432 dev = new SkPDFDevice(pageSize, pageSize, initialTransform); 469 dev = new SkPDFDevice(pageSize, pageSize, initialTransform);
433 } else { 470 } else {
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 if ((gmFlags & GM::kSkipScaledReplay_Flag) && replayScale != 1) { 1349 if ((gmFlags & GM::kSkipScaledReplay_Flag) && replayScale != 1) {
1313 continue; 1350 continue;
1314 } 1351 }
1315 // We record with the reciprocal scale to obtain a replay 1352 // We record with the reciprocal scale to obtain a replay
1316 // result that can be validated against comparisonBitmap. 1353 // result that can be validated against comparisonBitmap.
1317 SkScalar recordScale = SkScalarInvert(replayScale); 1354 SkScalar recordScale = SkScalarInvert(replayScale);
1318 SkPicture* pict = gmmain.generate_new_picture( 1355 SkPicture* pict = gmmain.generate_new_picture(
1319 gm, kTileGrid_BbhType, SkPicture::kUsePathBoundsForClip_Recordin gFlag, recordScale); 1356 gm, kTileGrid_BbhType, SkPicture::kUsePathBoundsForClip_Recordin gFlag, recordScale);
1320 SkAutoUnref aur(pict); 1357 SkAutoUnref aur(pict);
1321 SkBitmap bitmap; 1358 SkBitmap bitmap;
1322 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap, replayScale); 1359 // We cannot yet pass 'true' to generate_image_from_picture to
1360 // perform actual tiled rendering (see Issue 1198 -
1361 // https://code.google.com/p/skia/issues/detail?id=1198)
1362 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap,
1363 replayScale /*, true */);
1323 SkString suffix("-tilegrid"); 1364 SkString suffix("-tilegrid");
1324 if (SK_Scalar1 != replayScale) { 1365 if (SK_Scalar1 != replayScale) {
1325 suffix += "-scale-"; 1366 suffix += "-scale-";
1326 suffix.appendScalar(replayScale); 1367 suffix.appendScalar(replayScale);
1327 } 1368 }
1328 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( 1369 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p(
1329 gm, compareConfig, suffix.c_str(), bitmap, &comparisonBitmap)); 1370 gm, compareConfig, suffix.c_str(), bitmap, &comparisonBitmap));
1330 } 1371 }
1331 } 1372 }
1332 1373
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 if (FLAGS_forceBWtext) { 1698 if (FLAGS_forceBWtext) {
1658 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); 1699 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref();
1659 } 1700 }
1660 } 1701 }
1661 1702
1662 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 1703 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
1663 int main(int argc, char * const argv[]) { 1704 int main(int argc, char * const argv[]) {
1664 return tool_main(argc, (char**) argv); 1705 return tool_main(argc, (char**) argv);
1665 } 1706 }
1666 #endif 1707 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698