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

Side by Side Diff: tests/RecordDrawTest.cpp

Issue 680363003: Use SkTypeface::getBounds() in bounding-box calculations. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fudge differently Created 6 years, 1 month 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/SkRecordDraw.cpp ('k') | 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 2014 Google Inc. 2 * Copyright 2014 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 "Test.h" 8 #include "Test.h"
9 #include "RecordTestUtils.h" 9 #include "RecordTestUtils.h"
10 10
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 const SkScalar xpos[] = { 10, 20 }; 159 const SkScalar xpos[] = { 10, 20 };
160 recorder.drawPosTextH(text, bytes, xpos, 30, SkPaint()); 160 recorder.drawPosTextH(text, bytes, xpos, 30, SkPaint());
161 161
162 const SkPoint pos[] = { {40, 50}, {60, 70} }; 162 const SkPoint pos[] = { {40, 50}, {60, 70} };
163 recorder.drawPosText(text, bytes, pos, SkPaint()); 163 recorder.drawPosText(text, bytes, pos, SkPaint());
164 164
165 TestBBH bbh; 165 TestBBH bbh;
166 SkRecordFillBounds(record, &bbh); 166 SkRecordFillBounds(record, &bbh);
167 REPORTER_ASSERT(r, bbh.fEntries.count() == 2); 167 REPORTER_ASSERT(r, bbh.fEntries.count() == 2);
168 168
169 // We can make these next assertions confidently because SkRecordFillBounds 169 // Font metrics are somewhat platform dependent. These assertions may need to be adjusted.
170 // builds its bounds by overestimating font metrics in a platform-independen t way. 170 // However, these particular numbers are left over from the days when we use d to wildly
171 // If that changes, these tests will need to be more flexible. 171 // overestimate font metrics, so these assertions should be pretty conservat ive.
172 REPORTER_ASSERT(r, sloppy_rect_eq(bbh.fEntries[0].bounds, SkRect::MakeLTRB(- 110, 0, 140, 60))); 172 REPORTER_ASSERT(r, SkRect::MakeLTRB(-110, 0, 140, 60) .contains(bbh.fEntries [0].bounds));
173 REPORTER_ASSERT(r, sloppy_rect_eq(bbh.fEntries[1].bounds, SkRect::MakeLTRB(- 80, 20, 180, 100))); 173 REPORTER_ASSERT(r, SkRect::MakeLTRB(-80, 20, 180, 100).contains(bbh.fEntries [1].bounds));
174 } 174 }
175 175
176 // Base test to ensure start/stop range is respected 176 // Base test to ensure start/stop range is respected
177 DEF_TEST(RecordDraw_PartialStartStop, r) { 177 DEF_TEST(RecordDraw_PartialStartStop, r) {
178 static const int kWidth = 10, kHeight = 10; 178 static const int kWidth = 10, kHeight = 10;
179 179
180 SkRect r1 = { 0, 0, kWidth, kHeight }; 180 SkRect r1 = { 0, 0, kWidth, kHeight };
181 SkRect r2 = { 0, 0, kWidth, kHeight/2 }; 181 SkRect r2 = { 0, 0, kWidth, kHeight/2 };
182 SkRect r3 = { 0, 0, kWidth/2, kHeight }; 182 SkRect r3 = { 0, 0, kWidth/2, kHeight };
183 SkPaint p; 183 SkPaint p;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 305
306 { 306 {
307 SkRecord record; 307 SkRecord record;
308 SkRecorder recorder(&record, 10, 10); 308 SkRecorder recorder(&record, 10, 10);
309 recorder.drawImageRect(image, 0, SkRect::MakeWH(10, 10)); 309 recorder.drawImageRect(image, 0, SkRect::MakeWH(10, 10));
310 SkRecordDraw(record, &canvas, 0, 0); 310 SkRecordDraw(record, &canvas, 0, 0);
311 } 311 }
312 REPORTER_ASSERT(r, canvas.fDrawImageRectCalled); 312 REPORTER_ASSERT(r, canvas.fDrawImageRectCalled);
313 313
314 } 314 }
OLDNEW
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698