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

Unified Diff: samplecode/SampleText.cpp

Issue 1724283003: Revert of Simple cleanups related to SkFixed. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkRect.h ('k') | src/core/SkBitmapFilter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleText.cpp
diff --git a/samplecode/SampleText.cpp b/samplecode/SampleText.cpp
index 87ca91406b7060438cba25e85022f8f60f98ee6e..f5f8dbefa0b6ef7e35ab167ab3941a1bd4137313 100644
--- a/samplecode/SampleText.cpp
+++ b/samplecode/SampleText.cpp
@@ -27,6 +27,41 @@
#include "SkStream.h"
#include "SkXMLParser.h"
+static void test_breakText() {
+ SkPaint paint;
+ const char* text = "sdfkljAKLDFJKEWkldfjlk#$%&sdfs.dsj";
+ size_t length = strlen(text);
+ SkScalar width = paint.measureText(text, length);
+
+ SkScalar mm = 0;
+ SkScalar nn = 0;
+ for (SkScalar w = 0; w <= width; w += SK_Scalar1) {
+ SkScalar m;
+ size_t n = paint.breakText(text, length, w, &m);
+
+ SkASSERT(n <= length);
+ SkASSERT(m <= width);
+
+ if (n == 0) {
+ SkASSERT(m == 0);
+ } else {
+ // now assert that we're monotonic
+ if (n == nn) {
+ SkASSERT(m == mm);
+ } else {
+ SkASSERT(n > nn);
+ SkASSERT(m > mm);
+ }
+ }
+ nn = SkIntToScalar((unsigned int)n);
+ mm = m;
+ }
+
+ SkDEBUGCODE(size_t length2 =) paint.breakText(text, length, width, &mm);
+ SkASSERT(length2 == length);
+ SkASSERT(mm == width);
+}
+
static const struct {
const char* fName;
uint32_t fFlags;
@@ -74,6 +109,8 @@
TextSpeedView() {
fHints = 0;
fClickX = 0;
+
+ test_breakText();
}
protected:
« no previous file with comments | « include/core/SkRect.h ('k') | src/core/SkBitmapFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698