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

Side by Side Diff: src/core/SkRect.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/SkRRect.cpp ('k') | src/core/SkStringUtils.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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkRect.h" 10 #include "SkRect.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 if (fLeft >= fRight || fTop >= fBottom) { 123 if (fLeft >= fRight || fTop >= fBottom) {
124 this->set(left, top, right, bottom); 124 this->set(left, top, right, bottom);
125 } else { 125 } else {
126 fLeft = SkMinScalar(fLeft, left); 126 fLeft = SkMinScalar(fLeft, left);
127 fTop = SkMinScalar(fTop, top); 127 fTop = SkMinScalar(fTop, top);
128 fRight = SkMaxScalar(fRight, right); 128 fRight = SkMaxScalar(fRight, right);
129 fBottom = SkMaxScalar(fBottom, bottom); 129 fBottom = SkMaxScalar(fBottom, bottom);
130 } 130 }
131 } 131 }
132 132
133 //////////////////////////////////////////////////////////////////////////////// ////////////////
134
135 #include "SkString.h"
136 #include "SkStringUtils.h"
137
138 static const char* set_scalar(SkString* storage, SkScalar value, SkScalarAsStrin gType asType) {
139 storage->reset();
140 SkAppendScalar(storage, value, asType);
141 return storage->c_str();
142 }
143
144 void SkRect::dump(bool asHex) const {
145 SkScalarAsStringType asType = asHex ? kHex_SkScalarAsStringType : kDec_SkSca larAsStringType;
146
147 SkString line;
148 if (asHex) {
149 SkString tmp;
150 line.printf( "SkRect::MakeLTRB(%s, /* %f */\n", set_scalar(&tmp, fLeft, asType), fLeft);
151 line.appendf(" %s, /* %f */\n", set_scalar(&tmp, fTop, a sType), fTop);
152 line.appendf(" %s, /* %f */\n", set_scalar(&tmp, fRight, asType), fRight);
153 line.appendf(" %s /* %f */);", set_scalar(&tmp, fBottom , asType), fBottom);
154 } else {
155 SkString strL, strT, strR, strB;
156 SkAppendScalarDec(&strL, fLeft);
157 SkAppendScalarDec(&strT, fTop);
158 SkAppendScalarDec(&strR, fRight);
159 SkAppendScalarDec(&strB, fBottom);
160 line.printf("SkRect::MakeLTRB(%s, %s, %s, %s);",
161 strL.c_str(), strT.c_str(), strR.c_str(), strB.c_str());
162 }
163 SkDebugf("%s\n", line.c_str());
164 }
OLDNEW
« no previous file with comments | « src/core/SkRRect.cpp ('k') | src/core/SkStringUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698