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

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: initvar 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 25189724ff698540324f0c05655a18f414b54e92..06bb5f0017170fd360e0c5b807a08e17bd846e4d 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -1112,15 +1112,15 @@ 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,
- // 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.get() ||
+ !SurfaceHasMatchingProperties(use_distance_field_text, can_use_lcd_text);
+ if (create_surface) {
class GrContext* gr_context = resource_provider_->GrContext();
// TODO(alokp): Implement TestContextProvider::GrContext().
if (!gr_context)
@@ -1139,15 +1139,34 @@ 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();
}
+bool ResourceProvider::ScopedWriteLockGr::SurfaceHasMatchingProperties(
+ bool use_distance_field_text,
+ bool can_use_lcd_text) const {
+ const SkSurface* surface = resource_->sk_surface.get();
+ bool surface_uses_distance_field_text =
+ surface->props().isUseDistanceFieldFonts();
+ bool surface_can_use_lcd_text =
+ surface->props().pixelGeometry() != kUnknown_SkPixelGeometry;
+ return use_distance_field_text == surface_uses_distance_field_text &&
+ can_use_lcd_text == surface_can_use_lcd_text;
+}
+
ResourceProvider::SynchronousFence::SynchronousFence(
gpu::gles2::GLES2Interface* gl)
: gl_(gl), has_synchronized_(true) {

Powered by Google App Engine
This is Rietveld 408576698