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

Side by Side Diff: android_webview/native/aw_contents.cc

Issue 23609051: [Android WebView] Use bitmap fonts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: do not use default hinting Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 "android_webview/native/aw_contents.h" 5 #include "android_webview/native/aw_contents.h"
6 6
7 #include "android_webview/browser/aw_browser_context.h" 7 #include "android_webview/browser/aw_browser_context.h"
8 #include "android_webview/browser/aw_browser_main_parts.h" 8 #include "android_webview/browser/aw_browser_main_parts.h"
9 #include "android_webview/browser/gpu_memory_buffer_factory_impl.h" 9 #include "android_webview/browser/gpu_memory_buffer_factory_impl.h"
10 #include "android_webview/browser/in_process_view_renderer.h" 10 #include "android_webview/browser/in_process_view_renderer.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "content/public/browser/render_process_host.h" 44 #include "content/public/browser/render_process_host.h"
45 #include "content/public/browser/render_view_host.h" 45 #include "content/public/browser/render_view_host.h"
46 #include "content/public/browser/web_contents.h" 46 #include "content/public/browser/web_contents.h"
47 #include "content/public/common/renderer_preferences.h" 47 #include "content/public/common/renderer_preferences.h"
48 #include "content/public/common/ssl_status.h" 48 #include "content/public/common/ssl_status.h"
49 #include "jni/AwContents_jni.h" 49 #include "jni/AwContents_jni.h"
50 #include "net/cert/x509_certificate.h" 50 #include "net/cert/x509_certificate.h"
51 #include "third_party/skia/include/core/SkPicture.h" 51 #include "third_party/skia/include/core/SkPicture.h"
52 #include "ui/base/l10n/l10n_util_android.h" 52 #include "ui/base/l10n/l10n_util_android.h"
53 #include "ui/gfx/android/java_bitmap.h" 53 #include "ui/gfx/android/java_bitmap.h"
54 #include "ui/gfx/font_render_params_linux.h"
54 #include "ui/gfx/image/image.h" 55 #include "ui/gfx/image/image.h"
55 56
56 struct AwDrawSWFunctionTable; 57 struct AwDrawSWFunctionTable;
57 struct AwDrawGLFunctionTable; 58 struct AwDrawGLFunctionTable;
58 59
59 using autofill::AutofillDriverImpl; 60 using autofill::AutofillDriverImpl;
60 using autofill::AutofillManager; 61 using autofill::AutofillManager;
61 using base::android::AttachCurrentThread; 62 using base::android::AttachCurrentThread;
62 using base::android::ConvertJavaStringToUTF16; 63 using base::android::ConvertJavaStringToUTF16;
63 using base::android::ConvertJavaStringToUTF8; 64 using base::android::ConvertJavaStringToUTF8;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 web_contents->GetUserData(kAwContentsUserDataKey)); 105 web_contents->GetUserData(kAwContentsUserDataKey));
105 return data ? data->contents_ : NULL; 106 return data ? data->contents_ : NULL;
106 } 107 }
107 108
108 private: 109 private:
109 AwContents* contents_; 110 AwContents* contents_;
110 }; 111 };
111 112
112 base::subtle::Atomic32 g_instance_count = 0; 113 base::subtle::Atomic32 g_instance_count = 0;
113 114
115 // TODO(boliu): Deduplicate with chrome/ code.
116 content::RendererPreferencesSubpixelRenderingEnum
117 GetRendererPreferencesSubpixelRenderingEnum(
118 gfx::FontRenderParams::SubpixelRendering subpixel_rendering) {
119 switch (subpixel_rendering) {
120 case gfx::FontRenderParams::SUBPIXEL_RENDERING_NONE:
121 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE;
122 case gfx::FontRenderParams::SUBPIXEL_RENDERING_RGB:
123 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB;
124 case gfx::FontRenderParams::SUBPIXEL_RENDERING_BGR:
125 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR;
126 case gfx::FontRenderParams::SUBPIXEL_RENDERING_VRGB:
127 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB;
128 case gfx::FontRenderParams::SUBPIXEL_RENDERING_VBGR:
129 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR;
130 default:
131 NOTREACHED() << "Unhandled subpixel rendering style "
132 << subpixel_rendering;
133 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT;
134 }
135 }
136
114 } // namespace 137 } // namespace
115 138
116 // static 139 // static
117 AwContents* AwContents::FromWebContents(WebContents* web_contents) { 140 AwContents* AwContents::FromWebContents(WebContents* web_contents) {
118 return AwContentsUserData::GetContents(web_contents); 141 return AwContentsUserData::GetContents(web_contents);
119 } 142 }
120 143
121 // static 144 // static
122 AwContents* AwContents::FromID(int render_process_id, int render_view_id) { 145 AwContents* AwContents::FromID(int render_process_id, int render_view_id) {
123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 AutofillDriverImpl::CreateForWebContentsAndDelegate( 233 AutofillDriverImpl::CreateForWebContentsAndDelegate(
211 web_contents, 234 web_contents,
212 AwAutofillManagerDelegate::FromWebContents(web_contents), 235 AwAutofillManagerDelegate::FromWebContents(web_contents),
213 l10n_util::GetDefaultLocale(), 236 l10n_util::GetDefaultLocale(),
214 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER); 237 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER);
215 } 238 }
216 239
217 void AwContents::SetAndroidWebViewRendererPrefs() { 240 void AwContents::SetAndroidWebViewRendererPrefs() {
218 content::RendererPreferences* prefs = 241 content::RendererPreferences* prefs =
219 web_contents_->GetMutableRendererPrefs(); 242 web_contents_->GetMutableRendererPrefs();
220 prefs->hinting = content::RENDERER_PREFERENCES_HINTING_SLIGHT;
221 prefs->tap_multiple_targets_strategy = 243 prefs->tap_multiple_targets_strategy =
222 content::TAP_MULTIPLE_TARGETS_STRATEGY_NONE; 244 content::TAP_MULTIPLE_TARGETS_STRATEGY_NONE;
223 prefs->use_subpixel_positioning = true; 245
246 // TODO(boliu): Deduplicate with chrome/ code.
247 const gfx::FontRenderParams& params = gfx::GetDefaultWebKitFontRenderParams();
248 prefs->should_antialias_text = params.antialiasing;
249 prefs->use_subpixel_positioning = params.subpixel_positioning;
250 prefs->use_autohinter = params.autohinter;
251 prefs->use_bitmaps = params.use_bitmaps;
252 prefs->subpixel_rendering =
253 GetRendererPreferencesSubpixelRenderingEnum(params.subpixel_rendering);
254 // Intentionally not using default from gfx.
255 prefs->hinting = content::RENDERER_PREFERENCES_HINTING_SLIGHT;
benm (inactive) 2013/09/14 18:26:24 actually - it looks like the default on android is
boliu 2013/09/14 18:35:00 Bah, misread again, was looking at SUBPIXEL_RENDER
256
224 content::RenderViewHost* host = web_contents_->GetRenderViewHost(); 257 content::RenderViewHost* host = web_contents_->GetRenderViewHost();
225 if (host) 258 if (host)
226 host->SyncRendererPrefs(); 259 host->SyncRendererPrefs();
227 } 260 }
228 261
229 void AwContents::SetAwAutofillManagerDelegate(jobject delegate) { 262 void AwContents::SetAwAutofillManagerDelegate(jobject delegate) {
230 JNIEnv* env = AttachCurrentThread(); 263 JNIEnv* env = AttachCurrentThread();
231 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 264 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
232 if (obj.is_null()) 265 if (obj.is_null())
233 return; 266 return;
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 browser_view_renderer_->EnableOnNewPicture(enabled); 829 browser_view_renderer_->EnableOnNewPicture(enabled);
797 } 830 }
798 831
799 void AwContents::SetJsOnlineProperty(JNIEnv* env, 832 void AwContents::SetJsOnlineProperty(JNIEnv* env,
800 jobject obj, 833 jobject obj,
801 jboolean network_up) { 834 jboolean network_up) {
802 render_view_host_ext_->SetJsOnlineProperty(network_up); 835 render_view_host_ext_->SetJsOnlineProperty(network_up);
803 } 836 }
804 837
805 } // namespace android_webview 838 } // namespace android_webview
OLDNEW
« 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