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

Side by Side Diff: cc/resources/resource_provider.cc

Issue 733233003: Revert of cc: Toggle LCD text at raster time instead of record time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/test/fake_content_layer_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/resources/resource_provider.h" 5 #include "cc/resources/resource_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 : resource_provider_(resource_provider), 1093 : resource_provider_(resource_provider),
1094 resource_(resource_provider->LockForWrite(resource_id)) { 1094 resource_(resource_provider->LockForWrite(resource_id)) {
1095 } 1095 }
1096 1096
1097 ResourceProvider::ScopedWriteLockGr::~ScopedWriteLockGr() { 1097 ResourceProvider::ScopedWriteLockGr::~ScopedWriteLockGr() {
1098 DCHECK(thread_checker_.CalledOnValidThread()); 1098 DCHECK(thread_checker_.CalledOnValidThread());
1099 resource_provider_->UnlockForWrite(resource_); 1099 resource_provider_->UnlockForWrite(resource_);
1100 } 1100 }
1101 1101
1102 SkSurface* ResourceProvider::ScopedWriteLockGr::GetSkSurface( 1102 SkSurface* ResourceProvider::ScopedWriteLockGr::GetSkSurface(
1103 bool use_distance_field_text, 1103 bool use_distance_field_text) {
1104 bool can_use_lcd_text) {
1105 DCHECK(thread_checker_.CalledOnValidThread()); 1104 DCHECK(thread_checker_.CalledOnValidThread());
1106 DCHECK(resource_->locked_for_write); 1105 DCHECK(resource_->locked_for_write);
1107 1106
1108 bool create_surface = 1107 // If the surface doesn't exist, or doesn't have the correct dff setting,
1109 !resource_->sk_surface.get() || 1108 // recreate the surface within the resource.
1110 !SurfaceHasMatchingProperties(use_distance_field_text, can_use_lcd_text); 1109 if (!resource_->sk_surface ||
1111 if (create_surface) { 1110 use_distance_field_text !=
1111 resource_->sk_surface->props().isUseDistanceFieldFonts()) {
1112 class GrContext* gr_context = resource_provider_->GrContext(); 1112 class GrContext* gr_context = resource_provider_->GrContext();
1113 // TODO(alokp): Implement TestContextProvider::GrContext(). 1113 // TODO(alokp): Implement TestContextProvider::GrContext().
1114 if (!gr_context) 1114 if (!gr_context)
1115 return nullptr; 1115 return nullptr;
1116 1116
1117 resource_provider_->LazyAllocate(resource_); 1117 resource_provider_->LazyAllocate(resource_);
1118 1118
1119 GrBackendTextureDesc desc; 1119 GrBackendTextureDesc desc;
1120 desc.fFlags = kRenderTarget_GrBackendTextureFlag; 1120 desc.fFlags = kRenderTarget_GrBackendTextureFlag;
1121 desc.fWidth = resource_->size.width(); 1121 desc.fWidth = resource_->size.width();
1122 desc.fHeight = resource_->size.height(); 1122 desc.fHeight = resource_->size.height();
1123 desc.fConfig = ToGrPixelConfig(resource_->format); 1123 desc.fConfig = ToGrPixelConfig(resource_->format);
1124 desc.fOrigin = kTopLeft_GrSurfaceOrigin; 1124 desc.fOrigin = kTopLeft_GrSurfaceOrigin;
1125 desc.fTextureHandle = resource_->gl_id; 1125 desc.fTextureHandle = resource_->gl_id;
1126 skia::RefPtr<GrTexture> gr_texture = 1126 skia::RefPtr<GrTexture> gr_texture =
1127 skia::AdoptRef(gr_context->wrapBackendTexture(desc)); 1127 skia::AdoptRef(gr_context->wrapBackendTexture(desc));
1128 if (!gr_texture) 1128 if (!gr_texture)
1129 return nullptr; 1129 return nullptr;
1130 uint32_t flags = use_distance_field_text 1130 SkSurface::TextRenderMode text_render_mode =
1131 ? SkSurfaceProps::kUseDistanceFieldFonts_Flag 1131 use_distance_field_text ? SkSurface::kDistanceField_TextRenderMode
1132 : 0; 1132 : SkSurface::kStandard_TextRenderMode;
1133 // Use unknown pixel geometry to disable LCD text.
1134 SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry);
1135 if (can_use_lcd_text) {
1136 // LegacyFontHost will get LCD text and skia figures out what type to use.
1137 surface_props =
1138 SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType);
1139 }
1140 resource_->sk_surface = skia::AdoptRef(SkSurface::NewRenderTargetDirect( 1133 resource_->sk_surface = skia::AdoptRef(SkSurface::NewRenderTargetDirect(
1141 gr_texture->asRenderTarget(), &surface_props)); 1134 gr_texture->asRenderTarget(), text_render_mode));
1142 } 1135 }
1143 return resource_->sk_surface.get(); 1136 return resource_->sk_surface.get();
1144 } 1137 }
1145 1138
1146 bool ResourceProvider::ScopedWriteLockGr::SurfaceHasMatchingProperties(
1147 bool use_distance_field_text,
1148 bool can_use_lcd_text) const {
1149 const SkSurface* surface = resource_->sk_surface.get();
1150 bool surface_uses_distance_field_text =
1151 surface->props().isUseDistanceFieldFonts();
1152 bool surface_can_use_lcd_text =
1153 surface->props().pixelGeometry() != kUnknown_SkPixelGeometry;
1154 return use_distance_field_text == surface_uses_distance_field_text &&
1155 can_use_lcd_text == surface_can_use_lcd_text;
1156 }
1157
1158 ResourceProvider::SynchronousFence::SynchronousFence( 1139 ResourceProvider::SynchronousFence::SynchronousFence(
1159 gpu::gles2::GLES2Interface* gl) 1140 gpu::gles2::GLES2Interface* gl)
1160 : gl_(gl), has_synchronized_(true) { 1141 : gl_(gl), has_synchronized_(true) {
1161 } 1142 }
1162 1143
1163 ResourceProvider::SynchronousFence::~SynchronousFence() { 1144 ResourceProvider::SynchronousFence::~SynchronousFence() {
1164 } 1145 }
1165 1146
1166 void ResourceProvider::SynchronousFence::Set() { 1147 void ResourceProvider::SynchronousFence::Set() {
1167 has_synchronized_ = false; 1148 has_synchronized_ = false;
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 ContextProvider* context_provider = output_surface_->context_provider(); 2124 ContextProvider* context_provider = output_surface_->context_provider();
2144 return context_provider ? context_provider->ContextGL() : NULL; 2125 return context_provider ? context_provider->ContextGL() : NULL;
2145 } 2126 }
2146 2127
2147 class GrContext* ResourceProvider::GrContext() const { 2128 class GrContext* ResourceProvider::GrContext() const {
2148 ContextProvider* context_provider = output_surface_->context_provider(); 2129 ContextProvider* context_provider = output_surface_->context_provider();
2149 return context_provider ? context_provider->GrContext() : NULL; 2130 return context_provider ? context_provider->GrContext() : NULL;
2150 } 2131 }
2151 2132
2152 } // namespace cc 2133 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/test/fake_content_layer_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698