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

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: v2 - temp canvas instead of draw filter 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 | « content/child/browser_font_resource_trusted.h ('k') | 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..b75c79d4ea189237f2ca6607fb84638466f090f0 100644
--- a/content/child/browser_font_resource_trusted.cc
+++ b/content/child/browser_font_resource_trusted.cc
@@ -319,7 +319,28 @@ PP_Bool BrowserFontResource_Trusted::DrawTextAt(
return result; // Failure mapping.
}
- DrawTextToCanvas(canvas, *text, position, color, clip, image_data_is_opaque);
+ 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.
+ SkImageInfo info;
+ size_t row_bytes;
+ void* pixels = canvas->accessTopLayerPixels(&info, &row_bytes);
+ if (!pixels)
+ return result;
+
+ SkBitmap bm;
+ if (!bm.installPixels(info, pixels, row_bytes))
+ return result;
+
+ SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
+ SkCanvas temp_canvas(bm, props);
+
+ DrawTextToCanvas(&temp_canvas, *text, position, color, clip);
+ } else {
+ DrawTextToCanvas(canvas, *text, position, color, clip);
+ }
if (needs_unmapping)
image->Unmap();
@@ -391,8 +412,7 @@ void BrowserFontResource_Trusted::DrawTextToCanvas(
const PP_BrowserFont_Trusted_TextRun& text,
const PP_Point* position,
uint32_t color,
- const PP_Rect* clip,
- PP_Bool image_data_is_opaque) {
+ const PP_Rect* clip) {
// Convert position and clip.
WebFloatPoint web_position(static_cast<float>(position->x),
static_cast<float>(position->y));
@@ -414,8 +434,7 @@ void BrowserFontResource_Trusted::DrawTextToCanvas(
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 | « content/child/browser_font_resource_trusted.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698