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

Side by Side Diff: src/core/SkRRect.cpp

Issue 801383002: add dumpHex option to rect and rrect, to match path (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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 | « src/core/SkPath.cpp ('k') | src/core/SkRect.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 2012 Google Inc. 2 * Copyright 2012 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 "SkRRect.h" 8 #include "SkRRect.h"
9 #include "SkMatrix.h" 9 #include "SkMatrix.h"
10 10
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 SkASSERT(sizeof(storage) == kSizeInMemory); 438 SkASSERT(sizeof(storage) == kSizeInMemory);
439 439
440 // we make a local copy, to ensure alignment before we cast 440 // we make a local copy, to ensure alignment before we cast
441 memcpy(storage, buffer, kSizeInMemory); 441 memcpy(storage, buffer, kSizeInMemory);
442 442
443 this->setRectRadii(*(const SkRect*)&storage[0], 443 this->setRectRadii(*(const SkRect*)&storage[0],
444 (const SkVector*)&storage[4]); 444 (const SkVector*)&storage[4]);
445 return kSizeInMemory; 445 return kSizeInMemory;
446 } 446 }
447 447
448 #ifdef SK_DEVELOPER 448 #include "SkString.h"
449 void SkRRect::dump() const { 449 #include "SkStringUtils.h"
450 SkDebugf("Rect: "); 450
451 fRect.dump(); 451 void SkRRect::dump(bool asHex) const {
452 SkDebugf(" Corners: { TL: (%f, %f), TR: (%f, %f), BR: (%f, %f), BL: (%f, %f) }", 452 SkScalarAsStringType asType = asHex ? kHex_SkScalarAsStringType : kDec_SkSca larAsStringType;
453 fRadii[kUpperLeft_Corner].fX, fRadii[kUpperLeft_Corner].fY, 453
454 fRadii[kUpperRight_Corner].fX, fRadii[kUpperRight_Corner].fY, 454 fRect.dump(asHex);
455 fRadii[kLowerRight_Corner].fX, fRadii[kLowerRight_Corner].fY, 455 SkString line("const SkPoint corners[] = {\n");
456 fRadii[kLowerLeft_Corner].fX, fRadii[kLowerLeft_Corner].fY); 456 for (int i = 0; i < 4; ++i) {
457 SkString strX, strY;
458 SkAppendScalar(&strX, fRadii[i].x(), asType);
459 SkAppendScalar(&strY, fRadii[i].y(), asType);
460 line.appendf(" { %s, %s },", strX.c_str(), strY.c_str());
461 if (asHex) {
462 line.appendf(" /* %f %f */", fRadii[i].x(), fRadii[i].y());
463 }
464 line.append("\n");
465 }
466 line.append("};");
467 SkDebugf("%s\n", line.c_str());
457 } 468 }
458 #endif
459 469
460 /////////////////////////////////////////////////////////////////////////////// 470 ///////////////////////////////////////////////////////////////////////////////
461 471
462 #ifdef SK_DEBUG 472 #ifdef SK_DEBUG
463 void SkRRect::validate() const { 473 void SkRRect::validate() const {
464 bool allRadiiZero = (0 == fRadii[0].fX && 0 == fRadii[0].fY); 474 bool allRadiiZero = (0 == fRadii[0].fX && 0 == fRadii[0].fY);
465 bool allCornersSquare = (0 == fRadii[0].fX || 0 == fRadii[0].fY); 475 bool allCornersSquare = (0 == fRadii[0].fX || 0 == fRadii[0].fY);
466 bool allRadiiSame = true; 476 bool allRadiiSame = true;
467 477
468 for (int i = 1; i < 4; ++i) { 478 for (int i = 1; i < 4; ++i) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 SkASSERT(!patchesOfNine); 523 SkASSERT(!patchesOfNine);
514 break; 524 break;
515 case kUnknown_Type: 525 case kUnknown_Type:
516 // no limits on this 526 // no limits on this
517 break; 527 break;
518 } 528 }
519 } 529 }
520 #endif // SK_DEBUG 530 #endif // SK_DEBUG
521 531
522 /////////////////////////////////////////////////////////////////////////////// 532 ///////////////////////////////////////////////////////////////////////////////
OLDNEW
« no previous file with comments | « src/core/SkPath.cpp ('k') | src/core/SkRect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698