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

Side by Side Diff: Source/platform/graphics/GraphicsContext.cpp

Issue 519373002: Return width from drawText to stop re-measure in Canvas (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updating Test Expectation file Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « Source/platform/fonts/mac/FontMac.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 (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 1024
1025 // FIXME: This ownership should be reversed. We should pass BidiRunList 1025 // FIXME: This ownership should be reversed. We should pass BidiRunList
1026 // to BidiResolver in createBidiRunsForLine. 1026 // to BidiResolver in createBidiRunsForLine.
1027 BidiRunList<BidiCharacterRun>& bidiRuns = bidiResolver.runs(); 1027 BidiRunList<BidiCharacterRun>& bidiRuns = bidiResolver.runs();
1028 bidiResolver.createBidiRunsForLine(TextRunIterator(&run, run.length())); 1028 bidiResolver.createBidiRunsForLine(TextRunIterator(&run, run.length()));
1029 if (!bidiRuns.runCount()) 1029 if (!bidiRuns.runCount())
1030 return; 1030 return;
1031 1031
1032 FloatPoint currPoint = point; 1032 FloatPoint currPoint = point;
1033 BidiCharacterRun* bidiRun = bidiRuns.firstRun(); 1033 BidiCharacterRun* bidiRun = bidiRuns.firstRun();
1034 float width = 0;
1034 while (bidiRun) { 1035 while (bidiRun) {
1035 TextRun subrun = run.subRun(bidiRun->start(), bidiRun->stop() - bidiRun- >start()); 1036 TextRun subrun = run.subRun(bidiRun->start(), bidiRun->stop() - bidiRun- >start());
1036 bool isRTL = bidiRun->level() % 2; 1037 bool isRTL = bidiRun->level() % 2;
1037 subrun.setDirection(isRTL ? RTL : LTR); 1038 subrun.setDirection(isRTL ? RTL : LTR);
1038 subrun.setDirectionalOverride(bidiRun->dirOverride(false)); 1039 subrun.setDirectionalOverride(bidiRun->dirOverride(false));
1039 1040
1040 TextRunPaintInfo subrunInfo(subrun); 1041 TextRunPaintInfo subrunInfo(subrun);
1041 subrunInfo.bounds = runInfo.bounds; 1042 subrunInfo.bounds = runInfo.bounds;
1042 font.drawText(this, subrunInfo, currPoint, customFontNotReadyAction); 1043 width = font.drawText(this, subrunInfo, currPoint, customFontNotReadyAct ion);
1044
1043 1045
1044 bidiRun = bidiRun->next(); 1046 bidiRun = bidiRun->next();
1045 // FIXME: Have Font::drawText return the width of what it drew so that w e don't have to re-measure here.
1046 if (bidiRun) 1047 if (bidiRun)
1047 currPoint.move(font.width(subrun), 0); 1048 currPoint.move(width, 0);
1048 } 1049 }
1049 1050
1050 bidiRuns.deleteRuns(); 1051 bidiRuns.deleteRuns();
1051 } 1052 }
1052 1053
1053 void GraphicsContext::drawHighlightForText(const Font& font, const TextRun& run, const FloatPoint& point, int h, const Color& backgroundColor, int from, int to) 1054 void GraphicsContext::drawHighlightForText(const Font& font, const TextRun& run, const FloatPoint& point, int h, const Color& backgroundColor, int from, int to)
1054 { 1055 {
1055 if (contextDisabled()) 1056 if (contextDisabled())
1056 return; 1057 return;
1057 1058
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 // FIXME: This is to not break tests (it results in the filter bitmap fl ag 1980 // FIXME: This is to not break tests (it results in the filter bitmap fl ag
1980 // being set to true). We need to decide if we respect InterpolationNone 1981 // being set to true). We need to decide if we respect InterpolationNone
1981 // being returned from computeInterpolationQuality. 1982 // being returned from computeInterpolationQuality.
1982 resampling = InterpolationLow; 1983 resampling = InterpolationLow;
1983 } 1984 }
1984 resampling = limitInterpolationQuality(this, resampling); 1985 resampling = limitInterpolationQuality(this, resampling);
1985 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling)); 1986 paint->setFilterLevel(static_cast<SkPaint::FilterLevel>(resampling));
1986 } 1987 }
1987 1988
1988 } // namespace blink 1989 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/fonts/mac/FontMac.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698