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

Side by Side Diff: content/browser/renderer_host/render_message_filter.cc

Issue 2114583002: Windows: Make it possible to print text with GDI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase again, resolve conflicts Created 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "content/browser/renderer_host/render_message_filter.h" 5 #include "content/browser/renderer_host/render_message_filter.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <string.h> 8 #include <string.h>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedDiscardableSharedMemory, 205 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedDiscardableSharedMemory,
206 OnDeletedDiscardableSharedMemory) 206 OnDeletedDiscardableSharedMemory)
207 IPC_MESSAGE_HANDLER_DELAY_REPLY(RenderProcessHostMsg_Keygen, OnKeygen) 207 IPC_MESSAGE_HANDLER_DELAY_REPLY(RenderProcessHostMsg_Keygen, OnKeygen)
208 IPC_MESSAGE_HANDLER(RenderProcessHostMsg_DidGenerateCacheableMetadata, 208 IPC_MESSAGE_HANDLER(RenderProcessHostMsg_DidGenerateCacheableMetadata,
209 OnCacheableMetadataAvailable) 209 OnCacheableMetadataAvailable)
210 IPC_MESSAGE_HANDLER( 210 IPC_MESSAGE_HANDLER(
211 RenderProcessHostMsg_DidGenerateCacheableMetadataInCacheStorage, 211 RenderProcessHostMsg_DidGenerateCacheableMetadataInCacheStorage,
212 OnCacheableMetadataAvailableForCacheStorage) 212 OnCacheableMetadataAvailableForCacheStorage)
213 #if defined(OS_MACOSX) 213 #if defined(OS_MACOSX)
214 IPC_MESSAGE_HANDLER_DELAY_REPLY(RenderProcessHostMsg_LoadFont, OnLoadFont) 214 IPC_MESSAGE_HANDLER_DELAY_REPLY(RenderProcessHostMsg_LoadFont, OnLoadFont)
215 #elif defined(OS_WIN)
216 IPC_MESSAGE_HANDLER(RenderProcessHostMsg_PreCacheFontCharacters,
217 OnPreCacheFontCharacters)
218 #endif 215 #endif
219 IPC_MESSAGE_HANDLER(ViewHostMsg_MediaLogEvents, OnMediaLogEvents) 216 IPC_MESSAGE_HANDLER(ViewHostMsg_MediaLogEvents, OnMediaLogEvents)
220 IPC_MESSAGE_UNHANDLED(handled = false) 217 IPC_MESSAGE_UNHANDLED(handled = false)
221 IPC_END_MESSAGE_MAP() 218 IPC_END_MESSAGE_MAP()
222 219
223 return handled; 220 return handled;
224 } 221 }
225 222
226 void RenderMessageFilter::OnDestruct() const { 223 void RenderMessageFilter::OnDestruct() const {
227 const_cast<RenderMessageFilter*>(this)->resource_context_ = nullptr; 224 const_cast<RenderMessageFilter*>(this)->resource_context_ = nullptr;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 result->font_id = 0; 311 result->font_id = 0;
315 handle = base::SharedMemory::NULLHandle(); 312 handle = base::SharedMemory::NULLHandle();
316 } else { 313 } else {
317 result->font_data.GiveToProcess(base::GetCurrentProcessHandle(), &handle); 314 result->font_data.GiveToProcess(base::GetCurrentProcessHandle(), &handle);
318 } 315 }
319 RenderProcessHostMsg_LoadFont::WriteReplyParams( 316 RenderProcessHostMsg_LoadFont::WriteReplyParams(
320 reply, result->font_data_size, handle, result->font_id); 317 reply, result->font_data_size, handle, result->font_id);
321 Send(reply); 318 Send(reply);
322 } 319 }
323 320
324 #elif defined(OS_WIN) 321 #endif // defined(OS_MACOSX)
325
326 void RenderMessageFilter::OnPreCacheFontCharacters(
327 const LOGFONT& font,
328 const base::string16& str) {
329 // TODO(scottmg): pdf/ppapi still require the renderer to be able to precache
330 // GDI fonts (http://crbug.com/383227), even when using DirectWrite.
331 // Eventually this shouldn't be added and should be moved to
332 // FontCacheDispatcher too. http://crbug.com/356346.
333
334 // First, comments from FontCacheDispatcher::OnPreCacheFont do apply here too.
335 // Except that for True Type fonts,
336 // GetTextMetrics will not load the font in memory.
337 // The only way windows seem to load properly, it is to create a similar
338 // device (like the one in which we print), then do an ExtTextOut,
339 // as we do in the printing thread, which is sandboxed.
340 HDC hdc = CreateEnhMetaFile(NULL, NULL, NULL, NULL);
341 HFONT font_handle = CreateFontIndirect(&font);
342 DCHECK(NULL != font_handle);
343
344 HGDIOBJ old_font = SelectObject(hdc, font_handle);
345 DCHECK(NULL != old_font);
346
347 ExtTextOut(hdc, 0, 0, ETO_GLYPH_INDEX, 0, str.c_str(), str.length(), NULL);
348
349 SelectObject(hdc, old_font);
350 DeleteObject(font_handle);
351
352 HENHMETAFILE metafile = CloseEnhMetaFile(hdc);
353
354 if (metafile)
355 DeleteEnhMetaFile(metafile);
356 }
357
358
359 #endif // OS_*
360 322
361 void RenderMessageFilter::AllocateSharedMemoryOnFileThread( 323 void RenderMessageFilter::AllocateSharedMemoryOnFileThread(
362 uint32_t buffer_size, 324 uint32_t buffer_size,
363 IPC::Message* reply_msg) { 325 IPC::Message* reply_msg) {
364 base::SharedMemoryHandle handle; 326 base::SharedMemoryHandle handle;
365 ChildProcessHostImpl::AllocateSharedMemory(buffer_size, PeerHandle(), 327 ChildProcessHostImpl::AllocateSharedMemory(buffer_size, PeerHandle(),
366 &handle); 328 &handle);
367 ChildProcessHostMsg_SyncAllocateSharedMemory::WriteReplyParams(reply_msg, 329 ChildProcessHostMsg_SyncAllocateSharedMemory::WriteReplyParams(reply_msg,
368 handle); 330 handle);
369 Send(reply_msg); 331 Send(reply_msg);
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 void RenderMessageFilter::OnDeletedGpuMemoryBuffer( 650 void RenderMessageFilter::OnDeletedGpuMemoryBuffer(
689 gfx::GpuMemoryBufferId id, 651 gfx::GpuMemoryBufferId id,
690 const gpu::SyncToken& sync_token) { 652 const gpu::SyncToken& sync_token) {
691 DCHECK(BrowserGpuMemoryBufferManager::current()); 653 DCHECK(BrowserGpuMemoryBufferManager::current());
692 654
693 BrowserGpuMemoryBufferManager::current()->ChildProcessDeletedGpuMemoryBuffer( 655 BrowserGpuMemoryBufferManager::current()->ChildProcessDeletedGpuMemoryBuffer(
694 id, PeerHandle(), render_process_id_, sync_token); 656 id, PeerHandle(), render_process_id_, sync_token);
695 } 657 }
696 658
697 } // namespace content 659 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_message_filter.h ('k') | content/common/render_process_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698