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

Side by Side Diff: chrome/renderer/webplugin_delegate_pepper.cc

Issue 2794004: Add a font API to Pepper and implement on Linux based on agl's ... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 6 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #define PEPPER_APIS_ENABLED 1 5 #define PEPPER_APIS_ENABLED 1
6 6
7 #include "chrome/renderer/webplugin_delegate_pepper.h" 7 #include "chrome/renderer/webplugin_delegate_pepper.h"
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #if defined(OS_LINUX)
13 #include <unistd.h>
14 #endif
15
12 #include "base/file_util.h" 16 #include "base/file_util.h"
13 #include "base/keyboard_codes.h" 17 #include "base/keyboard_codes.h"
14 #if defined(OS_MACOSX) 18 #if defined(OS_MACOSX)
15 #include "base/mac_util.h" 19 #include "base/mac_util.h"
16 #endif 20 #endif
17 #include "base/md5.h" 21 #include "base/md5.h"
18 #include "base/message_loop.h" 22 #include "base/message_loop.h"
19 #include "base/process_util.h" 23 #include "base/process_util.h"
20 #if defined(OS_MACOSX) 24 #if defined(OS_MACOSX)
21 #include "base/scoped_cftyperef.h" 25 #include "base/scoped_cftyperef.h"
22 #endif 26 #endif
23 #include "base/scoped_ptr.h" 27 #include "base/scoped_ptr.h"
24 #include "base/stats_counters.h" 28 #include "base/stats_counters.h"
25 #include "base/string_util.h" 29 #include "base/string_util.h"
26 #include "base/time.h" 30 #include "base/time.h"
27 #include "chrome/common/render_messages.h" 31 #include "chrome/common/render_messages.h"
28 #include "chrome/renderer/pepper_widget.h" 32 #include "chrome/renderer/pepper_widget.h"
29 #include "chrome/renderer/render_thread.h" 33 #include "chrome/renderer/render_thread.h"
34 #if defined(OS_LINUX)
35 #include "chrome/renderer/renderer_sandbox_support_linux.h"
36 #endif
30 #include "chrome/renderer/webplugin_delegate_proxy.h" 37 #include "chrome/renderer/webplugin_delegate_proxy.h"
31 #include "gfx/blit.h" 38 #include "gfx/blit.h"
32 #if defined(OS_WIN) 39 #if defined(OS_WIN)
33 #include "gfx/codec/jpeg_codec.h" 40 #include "gfx/codec/jpeg_codec.h"
34 #include "gfx/gdi_util.h" 41 #include "gfx/gdi_util.h"
35 #include "skia/ext/vector_platform_device.h" 42 #include "skia/ext/vector_platform_device.h"
36 #endif 43 #endif
37 #include "third_party/npapi/bindings/npapi_extensions.h" 44 #include "third_party/npapi/bindings/npapi_extensions.h"
38 #include "third_party/npapi/bindings/npapi_extensions_private.h" 45 #include "third_party/npapi/bindings/npapi_extensions_private.h"
39 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" 46 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h"
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 COMPILE_ASSERT_MATCHING_ENUM(TypeNone, NPCursorTypeNone); 426 COMPILE_ASSERT_MATCHING_ENUM(TypeNone, NPCursorTypeNone);
420 COMPILE_ASSERT_MATCHING_ENUM(TypeNotAllowed, NPCursorTypeNotAllowed); 427 COMPILE_ASSERT_MATCHING_ENUM(TypeNotAllowed, NPCursorTypeNotAllowed);
421 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomIn, NPCursorTypeZoomIn); 428 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomIn, NPCursorTypeZoomIn);
422 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomOut, NPCursorTypeZoomOut); 429 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomOut, NPCursorTypeZoomOut);
423 430
424 bool WebPluginDelegatePepper::SetCursor(NPCursorType type) { 431 bool WebPluginDelegatePepper::SetCursor(NPCursorType type) {
425 cursor_.reset(new WebCursorInfo(static_cast<WebCursorInfo::Type>(type))); 432 cursor_.reset(new WebCursorInfo(static_cast<WebCursorInfo::Type>(type)));
426 return true; 433 return true;
427 } 434 }
428 435
436 NPError NPMatchFontWithFallback(NPP instance,
437 const NPFontDescription* description,
438 NPFontID* id) {
439 #if defined(OS_LINUX)
440 int fd = renderer_sandbox_support::MatchFontWithFallback(
441 description->face, description->weight >= 700, description->italic,
442 description->charset);
443 if (fd == -1)
444 return NPERR_GENERIC_ERROR;
445 *id = fd;
446 return NPERR_NO_ERROR;
447 #else
448 NOTIMPLEMENTED();
449 return NPERR_GENERIC_ERROR;
450 #endif
451 }
452
453 NPError GetFontTable(NPP instance,
454 NPFontID id,
455 uint32_t table,
456 void* output,
457 size_t* output_length) {
458 #if defined(OS_LINUX)
459 bool rv = renderer_sandbox_support::GetFontTable(
460 id, table, static_cast<uint8_t*>(output), output_length);
461 return rv ? NPERR_NO_ERROR : NPERR_GENERIC_ERROR;
462 #else
463 NOTIMPLEMENTED();
464 return NPERR_GENERIC_ERROR;
465 #endif
466 }
467
468 NPError NPDestroyFont(NPP instance, NPFontID id) {
469 #if defined(OS_LINUX)
470 close(id);
471 return NPERR_NO_ERROR;
472 #else
473 NOTIMPLEMENTED();
474 return NPERR_GENERIC_ERROR;
475 #endif
476 }
477
478 NPFontExtensions g_font_extensions = {
479 NPMatchFontWithFallback,
480 GetFontTable,
481 NPDestroyFont
482 };
483
484 NPFontExtensions* WebPluginDelegatePepper::GetFontExtensions() {
485 return &g_font_extensions;
486 }
487
429 void WebPluginDelegatePepper::Zoom(int factor) { 488 void WebPluginDelegatePepper::Zoom(int factor) {
430 NPPExtensions* extensions = NULL; 489 NPPExtensions* extensions = NULL;
431 instance()->NPP_GetValue(NPPVPepperExtensions, &extensions); 490 instance()->NPP_GetValue(NPPVPepperExtensions, &extensions);
432 if (extensions && extensions->zoom) 491 if (extensions && extensions->zoom)
433 extensions->zoom(instance()->npp(), factor); 492 extensions->zoom(instance()->npp(), factor);
434 } 493 }
435 494
436 void WebPluginDelegatePepper::Copy() { 495 void WebPluginDelegatePepper::Copy() {
437 NPPExtensions* extensions = NULL; 496 NPPExtensions* extensions = NULL;
438 instance()->NPP_GetValue(NPPVPepperExtensions, &extensions); 497 instance()->NPP_GetValue(NPPVPepperExtensions, &extensions);
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 bounds.origin.x = dest_rect.x(); 1611 bounds.origin.x = dest_rect.x();
1553 bounds.origin.y = canvas_height - dest_rect.y() - dest_rect.height(); 1612 bounds.origin.y = canvas_height - dest_rect.y() - dest_rect.height();
1554 bounds.size.width = dest_rect.width(); 1613 bounds.size.width = dest_rect.width();
1555 bounds.size.height = dest_rect.height(); 1614 bounds.size.height = dest_rect.height();
1556 1615
1557 CGContextDrawImage(canvas, bounds, image); 1616 CGContextDrawImage(canvas, bounds, image);
1558 CGContextRestoreGState(canvas); 1617 CGContextRestoreGState(canvas);
1559 } 1618 }
1560 #endif // defined(OS_MACOSX) 1619 #endif // defined(OS_MACOSX)
1561 1620
OLDNEW
« no previous file with comments | « chrome/renderer/webplugin_delegate_pepper.h ('k') | third_party/npapi/bindings/npapi_extensions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698