Chromium Code Reviews| Index: content/child/browser_font_resource_trusted.cc |
| diff --git a/content/child/browser_font_resource_trusted.cc b/content/child/browser_font_resource_trusted.cc |
| index 9450a001ebedda023a69994d881e5007330d7226..2244bafc7ecda4376cecccf56328d80d446918fe 100644 |
| --- a/content/child/browser_font_resource_trusted.cc |
| +++ b/content/child/browser_font_resource_trusted.cc |
| @@ -24,6 +24,7 @@ |
| #include "third_party/WebKit/public/web/WebTextRun.h" |
| #include "third_party/icu/source/common/unicode/ubidi.h" |
| #include "third_party/skia/include/core/SkRect.h" |
| +#include "third_party/skia/include/effects/SkPaintFlagsDrawFilter.h" |
| using ppapi::StringVar; |
| using ppapi::thunk::EnterResourceNoLock; |
| @@ -409,13 +410,24 @@ void BrowserFontResource_Trusted::DrawTextToCanvas( |
| clip->size.width, clip->size.height); |
| } |
| + SkAutoCanvasRestore auto_restore(destination, false); |
| + if (!PP_ToBool(image_data_is_opaque)) { |
| + // Ideally, LCD text should be configured at canvas creation time using |
| + // SkSurfaceProps. But because the API exposes image_data_is_opaque per |
| + // draw text call (allowing clients to essentially change their mind), |
| + // we have to handle it here. |
| + destination->save(); |
|
reed1
2015/03/03 15:04:42
save(); // will be balanced automatically by auto_
|
| + skia::RefPtr<SkDrawFilter> lcd_filter = skia::AdoptRef( |
| + new SkPaintFlagsDrawFilter(SkPaint::kLCDRenderText_Flag, 0)); |
| + destination->setDrawFilter(lcd_filter.get()); |
| + } |
| + |
| TextRunCollection runs(text); |
| for (int i = 0; i < runs.num_runs(); i++) { |
| int32_t run_begin = 0; |
| int32_t run_len = 0; |
| WebTextRun run = runs.GetRunAt(i, &run_begin, &run_len); |
| - font_->drawText(destination, run, web_position, color, web_clip, |
| - PP_ToBool(image_data_is_opaque)); |
| + font_->drawText(destination, run, web_position, color, web_clip); |
| // Advance to the next run. Note that we avoid doing this for the last run |
| // since it's unnecessary, measuring text is slow, and most of the time |