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

Unified Diff: content/child/browser_font_resource_trusted.cc

Issue 975533004: BrowserFontResource should not push opacity info to Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698