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

Side by Side Diff: tests/RecordDrawTest.cpp

Issue 789793004: Revert of Use SkPaint::getFontBounds() for text bounding boxes in pictures. (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/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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 const SkScalar xpos[] = { 10, 20 }; 184 const SkScalar xpos[] = { 10, 20 };
185 recorder.drawPosTextH(text, bytes, xpos, 30, SkPaint()); 185 recorder.drawPosTextH(text, bytes, xpos, 30, SkPaint());
186 186
187 const SkPoint pos[] = { {40, 50}, {60, 70} }; 187 const SkPoint pos[] = { {40, 50}, {60, 70} };
188 recorder.drawPosText(text, bytes, pos, SkPaint()); 188 recorder.drawPosText(text, bytes, pos, SkPaint());
189 189
190 TestBBH bbh; 190 TestBBH bbh;
191 SkRecordFillBounds(SkRect::MakeWH(SkIntToScalar(W), SkIntToScalar(H)), recor d, &bbh); 191 SkRecordFillBounds(SkRect::MakeWH(SkIntToScalar(W), SkIntToScalar(H)), recor d, &bbh);
192 REPORTER_ASSERT(r, bbh.fEntries.count() == 2); 192 REPORTER_ASSERT(r, bbh.fEntries.count() == 2);
193 193
194 // Font metrics are somewhat platform dependent, so these assertions may nee d to be adjusted. 194 // We can make these next assertions confidently because SkRecordFillBounds
195 // But these particular numbers are left over from the days when we used to wildly overestimate 195 // builds its bounds by overestimating font metrics in a platform-independen t way.
196 // font metrics, so these assertions should actually be pretty safe. 196 // If that changes, these tests will need to be more flexible.
197 REPORTER_ASSERT(r, SkRect::MakeLTRB(0, 0,140, 60).contains(bbh.fEntries[0].b ounds)); 197 REPORTER_ASSERT(r, sloppy_rect_eq(bbh.fEntries[0].bounds, SkRect::MakeLTRB(0 , 0, 140, 60)));
198 REPORTER_ASSERT(r, SkRect::MakeLTRB(0,20,180,100).contains(bbh.fEntries[1].b ounds)); 198 REPORTER_ASSERT(r, sloppy_rect_eq(bbh.fEntries[1].bounds, SkRect::MakeLTRB(0 , 20, 180, 100)));
199 } 199 }
200 200
201 // Base test to ensure start/stop range is respected 201 // Base test to ensure start/stop range is respected
202 DEF_TEST(RecordDraw_PartialStartStop, r) { 202 DEF_TEST(RecordDraw_PartialStartStop, r) {
203 static const int kWidth = 10, kHeight = 10; 203 static const int kWidth = 10, kHeight = 10;
204 204
205 SkRect r1 = { 0, 0, kWidth, kHeight }; 205 SkRect r1 = { 0, 0, kWidth, kHeight };
206 SkRect r2 = { 0, 0, kWidth, kHeight/2 }; 206 SkRect r2 = { 0, 0, kWidth, kHeight/2 };
207 SkRect r3 = { 0, 0, kWidth/2, kHeight }; 207 SkRect r3 = { 0, 0, kWidth/2, kHeight };
208 SkPaint p; 208 SkPaint p;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 324
325 { 325 {
326 SkRecord record; 326 SkRecord record;
327 SkRecorder recorder(&record, 10, 10); 327 SkRecorder recorder(&record, 10, 10);
328 recorder.drawImageRect(image, 0, SkRect::MakeWH(10, 10)); 328 recorder.drawImageRect(image, 0, SkRect::MakeWH(10, 10));
329 SkRecordDraw(record, &canvas, NULL, NULL, 0, NULL, 0); 329 SkRecordDraw(record, &canvas, NULL, NULL, 0, NULL, 0);
330 } 330 }
331 REPORTER_ASSERT(r, canvas.fDrawImageRectCalled); 331 REPORTER_ASSERT(r, canvas.fDrawImageRectCalled);
332 332
333 } 333 }
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