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

Side by Side Diff: gm/gmmain.cpp

Issue 105893012: change offset to xy for pixelref subsetting (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 | « dm/DMSerializeTask.cpp ('k') | include/core/SkBitmap.h » ('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 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 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 recordFlags |= SkPicture::kOptimizeForClippedPlayback_RecordingFlag; 1004 recordFlags |= SkPicture::kOptimizeForClippedPlayback_RecordingFlag;
1005 } 1005 }
1006 SkCanvas* cv = pict->beginRecording(width, height, recordFlags); 1006 SkCanvas* cv = pict->beginRecording(width, height, recordFlags);
1007 cv->scale(scale, scale); 1007 cv->scale(scale, scale);
1008 invokeGM(gm, cv, false, false); 1008 invokeGM(gm, cv, false, false);
1009 pict->endRecording(); 1009 pict->endRecording();
1010 1010
1011 return pict; 1011 return pict;
1012 } 1012 }
1013 1013
1014 static SkData* bitmap_encoder(size_t* pixelRefOffset, const SkBitmap& bm) {
1015 SkPixelRef* pr = bm.pixelRef();
1016 if (pr != NULL) {
1017 SkData* data = pr->refEncodedData();
1018 if (data != NULL) {
1019 *pixelRefOffset = bm.pixelRefOffset();
1020 return data;
1021 }
1022 }
1023 return NULL;
1024 }
1025
1026 static SkPicture* stream_to_new_picture(const SkPicture& src) { 1014 static SkPicture* stream_to_new_picture(const SkPicture& src) {
1027 SkDynamicMemoryWStream storage; 1015 SkDynamicMemoryWStream storage;
1028 src.serialize(&storage, &bitmap_encoder); 1016 src.serialize(&storage, NULL);
1029 SkAutoTUnref<SkStreamAsset> pictReadback(storage.detachAsStream()); 1017 SkAutoTUnref<SkStreamAsset> pictReadback(storage.detachAsStream());
1030 SkPicture* retval = SkPicture::CreateFromStream(pictReadback, 1018 SkPicture* retval = SkPicture::CreateFromStream(pictReadback,
1031 &SkImageDecoder::DecodeM emory); 1019 &SkImageDecoder::DecodeM emory);
1032 return retval; 1020 return retval;
1033 } 1021 }
1034 1022
1035 // Test: draw into a bitmap or pdf. 1023 // Test: draw into a bitmap or pdf.
1036 // Depending on flags, possibly compare to an expected image. 1024 // Depending on flags, possibly compare to an expected image.
1037 // If writePath is not NULL, also write images (or documents) to the specifi ed path. 1025 // If writePath is not NULL, also write images (or documents) to the specifi ed path.
1038 ErrorCombination test_drawing(GM* gm, const ConfigData& gRec, 1026 ErrorCombination test_drawing(GM* gm, const ConfigData& gRec,
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 // or probably more readable would be to replace it with a set of a few predicat es 1455 // or probably more readable would be to replace it with a set of a few predicat es
1468 // Like --prerotate 100 200 10 --posttranslate 10, 10 1456 // Like --prerotate 100 200 10 --posttranslate 10, 10
1469 // Probably define spacial names like centerx, centery, top, bottom, left, right 1457 // Probably define spacial names like centerx, centery, top, bottom, left, right
1470 // then we can write something reabable like --rotate centerx centery 90 1458 // then we can write something reabable like --rotate centerx centery 90
1471 DEFINE_bool(forcePerspectiveMatrix, false, "Force a perspective matrix."); 1459 DEFINE_bool(forcePerspectiveMatrix, false, "Force a perspective matrix.");
1472 DEFINE_bool(useDocumentInsteadOfDevice, false, "Use SkDocument::CreateFoo instea d of SkFooDevice."); 1460 DEFINE_bool(useDocumentInsteadOfDevice, false, "Use SkDocument::CreateFoo instea d of SkFooDevice.");
1473 DEFINE_int32(pdfRasterDpi, 72, "Scale at which at which the non suported " 1461 DEFINE_int32(pdfRasterDpi, 72, "Scale at which at which the non suported "
1474 "features in PDF are rasterized. Must be be in range 0-10000. " 1462 "features in PDF are rasterized. Must be be in range 0-10000. "
1475 "Default is 72. N = 0 will disable rasterizing features like " 1463 "Default is 72. N = 0 will disable rasterizing features like "
1476 "text shadows or perspective bitmaps."); 1464 "text shadows or perspective bitmaps.");
1477 static SkData* encode_to_dct_data(size_t* pixelRefOffset, const SkBitmap& bitmap ) { 1465 static SkData* encode_to_dct_data(size_t*, const SkBitmap& bitmap) {
1478 // Filter output of warnings that JPEG is not available for the image. 1466 // Filter output of warnings that JPEG is not available for the image.
1479 if (bitmap.width() >= 65500 || bitmap.height() >= 65500) return NULL; 1467 if (bitmap.width() >= 65500 || bitmap.height() >= 65500) return NULL;
1480 if (FLAGS_pdfJpegQuality == -1) return NULL; 1468 if (FLAGS_pdfJpegQuality == -1) return NULL;
1481 1469
1482 SkBitmap bm = bitmap; 1470 SkBitmap bm = bitmap;
1483 #if defined(SK_BUILD_FOR_MAC) 1471 #if defined(SK_BUILD_FOR_MAC)
1484 // Workaround bug #1043 where bitmaps with referenced pixels cause 1472 // Workaround bug #1043 where bitmaps with referenced pixels cause
1485 // CGImageDestinationFinalize to crash 1473 // CGImageDestinationFinalize to crash
1486 SkBitmap copy; 1474 SkBitmap copy;
1487 bitmap.deepCopyTo(&copy, bitmap.config()); 1475 bitmap.deepCopyTo(&copy, bitmap.config());
1488 bm = copy; 1476 bm = copy;
1489 #endif 1477 #endif
1490 1478
1491 SkPixelRef* pr = bm.pixelRef(); 1479 SkPixelRef* pr = bm.pixelRef();
1492 if (pr != NULL) { 1480 if (pr != NULL) {
1493 SkData* data = pr->refEncodedData(); 1481 SkData* data = pr->refEncodedData();
1494 if (data != NULL) { 1482 if (data != NULL) {
1495 *pixelRefOffset = bm.pixelRefOffset();
1496 return data; 1483 return data;
1497 } 1484 }
1498 } 1485 }
1499 1486
1500 *pixelRefOffset = 0;
1501 return SkImageEncoder::EncodeData(bm, 1487 return SkImageEncoder::EncodeData(bm,
1502 SkImageEncoder::kJPEG_Type, 1488 SkImageEncoder::kJPEG_Type,
1503 FLAGS_pdfJpegQuality); 1489 FLAGS_pdfJpegQuality);
1504 } 1490 }
1505 1491
1506 static int findConfig(const char config[]) { 1492 static int findConfig(const char config[]) {
1507 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { 1493 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) {
1508 if (!strcmp(config, gRec[i].fName)) { 1494 if (!strcmp(config, gRec[i].fName)) {
1509 return (int) i; 1495 return (int) i;
1510 } 1496 }
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
2376 if (FLAGS_forceBWtext) { 2362 if (FLAGS_forceBWtext) {
2377 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); 2363 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref();
2378 } 2364 }
2379 } 2365 }
2380 2366
2381 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 2367 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
2382 int main(int argc, char * const argv[]) { 2368 int main(int argc, char * const argv[]) {
2383 return tool_main(argc, (char**) argv); 2369 return tool_main(argc, (char**) argv);
2384 } 2370 }
2385 #endif 2371 #endif
OLDNEW
« no previous file with comments | « dm/DMSerializeTask.cpp ('k') | include/core/SkBitmap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698