OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 FontCachePurgePreventer fontCachePurgePreventer; | 92 FontCachePurgePreventer fontCachePurgePreventer; |
93 FloatRect textClipRect(clip); | 93 FloatRect textClipRect(clip); |
94 TextRun textRun(run); | 94 TextRun textRun(run); |
95 TextRunPaintInfo runInfo(textRun); | 95 TextRunPaintInfo runInfo(textRun); |
96 runInfo.bounds = textClipRect; | 96 runInfo.bounds = textClipRect; |
97 | 97 |
98 IntRect intRect(clip); | 98 IntRect intRect(clip); |
99 SkPictureBuilder pictureBuilder(intRect); | 99 SkPictureBuilder pictureBuilder(intRect); |
100 GraphicsContext* context = &pictureBuilder.context(); | 100 GraphicsContext* context = &pictureBuilder.context(); |
101 | 101 |
102 { | 102 if (!DrawingRecorder::useCachedDrawingIfPossible(*context, *this, DisplayIte m::WebFont)) { |
Xianzhu
2015/07/03 01:24:42
Nit: Another similar place still uses ASSERT. Bett
pdr.
2015/07/03 02:38:05
Good catch. Fixed.
| |
103 DrawingRecorder drawingRecorder(*context, *this, DisplayItem::WebFont, i ntRect); | 103 DrawingRecorder drawingRecorder(*context, *this, DisplayItem::WebFont, i ntRect); |
104 ASSERT(!drawingRecorder.canUseCachedDrawing()); | |
105 context->save(); | 104 context->save(); |
106 context->setFillColor(color); | 105 context->setFillColor(color); |
107 context->clip(textClipRect); | 106 context->clip(textClipRect); |
108 context->drawText(m_font, runInfo, leftBaseline); | 107 context->drawText(m_font, runInfo, leftBaseline); |
109 context->restore(); | 108 context->restore(); |
110 } | 109 } |
111 | 110 |
112 pictureBuilder.endRecording()->playback(canvas); | 111 pictureBuilder.endRecording()->playback(canvas); |
113 } | 112 } |
114 | 113 |
115 int WebFontImpl::calculateWidth(const WebTextRun& run) const | 114 int WebFontImpl::calculateWidth(const WebTextRun& run) const |
116 { | 115 { |
117 return m_font.width(run, 0); | 116 return m_font.width(run, 0); |
118 } | 117 } |
119 | 118 |
120 int WebFontImpl::offsetForPosition(const WebTextRun& run, float position) const | 119 int WebFontImpl::offsetForPosition(const WebTextRun& run, float position) const |
121 { | 120 { |
122 return m_font.offsetForPosition(run, position, true); | 121 return m_font.offsetForPosition(run, position, true); |
123 } | 122 } |
124 | 123 |
125 WebFloatRect WebFontImpl::selectionRectForText(const WebTextRun& run, const WebF loatPoint& leftBaseline, int height, int from, int to) const | 124 WebFloatRect WebFontImpl::selectionRectForText(const WebTextRun& run, const WebF loatPoint& leftBaseline, int height, int from, int to) const |
126 { | 125 { |
127 return m_font.selectionRectForText(run, leftBaseline, height, from, to); | 126 return m_font.selectionRectForText(run, leftBaseline, height, from, to); |
128 } | 127 } |
129 | 128 |
130 } // namespace blink | 129 } // namespace blink |
OLD | NEW |