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

Unified Diff: cc/resources/resource_provider.cc

Issue 684543006: cc: Toggle LCD text at raster time instead of record time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lcdraster: header Created 6 years, 1 month 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
Index: cc/resources/resource_provider.cc
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index 023a1cdbf068832875073a5601c29420043d74b5..6bef8109cec7ccc55412b331b1ddd5644cc82c6c 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -1100,15 +1100,26 @@ ResourceProvider::ScopedWriteLockGr::~ScopedWriteLockGr() {
}
SkSurface* ResourceProvider::ScopedWriteLockGr::GetSkSurface(
- bool use_distance_field_text) {
+ bool use_distance_field_text,
+ bool can_use_lcd_text) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(resource_->locked_for_write);
- // If the surface doesn't exist, or doesn't have the correct dff setting,
+ // If the surface doesn't exist, or its properties need to be updated,
// recreate the surface within the resource.
- if (!resource_->sk_surface ||
- use_distance_field_text !=
- resource_->sk_surface->props().isUseDistanceFieldFonts()) {
+ bool create_surface = !resource_->sk_surface;
+ if (!create_surface) {
+ bool surface_uses_distance_field_text =
+ resource_->sk_surface->props().isUseDistanceFieldFonts();
+ if (use_distance_field_text != surface_uses_distance_field_text)
+ create_surface = true;
+ bool surface_can_use_lcd_text =
+ resource_->sk_surface->props().pixelGeometry() !=
+ kUnknown_SkPixelGeometry;
+ if (can_use_lcd_text != surface_can_use_lcd_text)
+ create_surface = true;
+ }
+ if (create_surface) {
class GrContext* gr_context = resource_provider_->GrContext();
// TODO(alokp): Implement TestContextProvider::GrContext().
if (!gr_context)
@@ -1127,11 +1138,18 @@ SkSurface* ResourceProvider::ScopedWriteLockGr::GetSkSurface(
skia::AdoptRef(gr_context->wrapBackendTexture(desc));
if (!gr_texture)
return nullptr;
- SkSurface::TextRenderMode text_render_mode =
- use_distance_field_text ? SkSurface::kDistanceField_TextRenderMode
- : SkSurface::kStandard_TextRenderMode;
+ uint32_t flags = use_distance_field_text
+ ? SkSurfaceProps::kUseDistanceFieldFonts_Flag
+ : 0;
+ // Use unknown pixel geometry to disable LCD text.
+ SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry);
+ if (can_use_lcd_text) {
+ // LegacyFontHost will get LCD text and skia figures out what type to use.
+ surface_props =
+ SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType);
+ }
resource_->sk_surface = skia::AdoptRef(SkSurface::NewRenderTargetDirect(
- gr_texture->asRenderTarget(), text_render_mode));
+ gr_texture->asRenderTarget(), &surface_props));
}
return resource_->sk_surface.get();
}

Powered by Google App Engine
This is Rietveld 408576698