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

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 11053003: Migrate Graphics2D to new design. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 2 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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 #include "webkit/plugins/ppapi/common.h" 71 #include "webkit/plugins/ppapi/common.h"
72 #include "webkit/plugins/ppapi/event_conversion.h" 72 #include "webkit/plugins/ppapi/event_conversion.h"
73 #include "webkit/plugins/ppapi/fullscreen_container.h" 73 #include "webkit/plugins/ppapi/fullscreen_container.h"
74 #include "webkit/plugins/ppapi/gfx_conversion.h" 74 #include "webkit/plugins/ppapi/gfx_conversion.h"
75 #include "webkit/plugins/ppapi/host_globals.h" 75 #include "webkit/plugins/ppapi/host_globals.h"
76 #include "webkit/plugins/ppapi/message_channel.h" 76 #include "webkit/plugins/ppapi/message_channel.h"
77 #include "webkit/plugins/ppapi/npapi_glue.h" 77 #include "webkit/plugins/ppapi/npapi_glue.h"
78 #include "webkit/plugins/ppapi/plugin_module.h" 78 #include "webkit/plugins/ppapi/plugin_module.h"
79 #include "webkit/plugins/ppapi/plugin_object.h" 79 #include "webkit/plugins/ppapi/plugin_object.h"
80 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" 80 #include "webkit/plugins/ppapi/ppb_buffer_impl.h"
81 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
82 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" 81 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
83 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" 82 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
84 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h" 83 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
85 #include "webkit/plugins/ppapi/url_request_info_util.h" 84 #include "webkit/plugins/ppapi/url_request_info_util.h"
86 #include "webkit/plugins/ppapi/ppp_pdf.h" 85 #include "webkit/plugins/ppapi/ppp_pdf.h"
87 #include "webkit/plugins/sad_plugin.h" 86 #include "webkit/plugins/sad_plugin.h"
88 87
89 #if defined(OS_MACOSX) 88 #if defined(OS_MACOSX)
90 #include "printing/metafile_impl.h" 89 #include "printing/metafile_impl.h"
91 #if !defined(USE_SKIA) 90 #if !defined(USE_SKIA)
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 PluginModule* module, 409 PluginModule* module,
411 ::ppapi::PPP_Instance_Combined* instance_interface) 410 ::ppapi::PPP_Instance_Combined* instance_interface)
412 : delegate_(delegate), 411 : delegate_(delegate),
413 module_(module), 412 module_(module),
414 instance_interface_(instance_interface), 413 instance_interface_(instance_interface),
415 pp_instance_(0), 414 pp_instance_(0),
416 container_(NULL), 415 container_(NULL),
417 full_frame_(false), 416 full_frame_(false),
418 sent_initial_did_change_view_(false), 417 sent_initial_did_change_view_(false),
419 view_change_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 418 view_change_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
419 graphics_2d_platform_(NULL),
420 has_webkit_focus_(false), 420 has_webkit_focus_(false),
421 has_content_area_focus_(false), 421 has_content_area_focus_(false),
422 find_identifier_(-1), 422 find_identifier_(-1),
423 plugin_decryption_interface_(NULL), 423 plugin_decryption_interface_(NULL),
424 plugin_find_interface_(NULL), 424 plugin_find_interface_(NULL),
425 plugin_input_event_interface_(NULL), 425 plugin_input_event_interface_(NULL),
426 plugin_messaging_interface_(NULL), 426 plugin_messaging_interface_(NULL),
427 plugin_mouse_lock_interface_(NULL), 427 plugin_mouse_lock_interface_(NULL),
428 plugin_pdf_interface_(NULL), 428 plugin_pdf_interface_(NULL),
429 plugin_private_interface_(NULL), 429 plugin_private_interface_(NULL),
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 TRACE_EVENT0("ppapi", "PluginInstance::Paint"); 530 TRACE_EVENT0("ppapi", "PluginInstance::Paint");
531 if (module()->is_crashed()) { 531 if (module()->is_crashed()) {
532 // Crashed plugin painting. 532 // Crashed plugin painting.
533 if (!sad_plugin_) // Lazily initialize bitmap. 533 if (!sad_plugin_) // Lazily initialize bitmap.
534 sad_plugin_ = delegate_->GetSadPluginBitmap(); 534 sad_plugin_ = delegate_->GetSadPluginBitmap();
535 if (sad_plugin_) 535 if (sad_plugin_)
536 webkit::PaintSadPlugin(canvas, plugin_rect, *sad_plugin_); 536 webkit::PaintSadPlugin(canvas, plugin_rect, *sad_plugin_);
537 return; 537 return;
538 } 538 }
539 539
540 PPB_Graphics2D_Impl* bound_graphics_2d = GetBoundGraphics2D(); 540 PluginDelegate::PlatformGraphics2D* bound_graphics_2d = GetBoundGraphics2D();
541 if (bound_graphics_2d) 541 if (bound_graphics_2d)
542 bound_graphics_2d->Paint(canvas, plugin_rect, paint_rect); 542 bound_graphics_2d->Paint(canvas, plugin_rect, paint_rect);
543 } 543 }
544 544
545 void PluginInstance::InvalidateRect(const gfx::Rect& rect) { 545 void PluginInstance::InvalidateRect(const gfx::Rect& rect) {
546 if (fullscreen_container_) { 546 if (fullscreen_container_) {
547 if (rect.IsEmpty()) 547 if (rect.IsEmpty())
548 fullscreen_container_->Invalidate(); 548 fullscreen_container_->Invalidate();
549 else 549 else
550 fullscreen_container_->InvalidateRect(rect); 550 fullscreen_container_->InvalidateRect(rect);
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1859 skia::EndPlatformPaint(canvas); 1859 skia::EndPlatformPaint(canvas);
1860 } 1860 }
1861 #endif // defined(OS_WIN) 1861 #endif // defined(OS_WIN)
1862 1862
1863 return ret; 1863 return ret;
1864 #else // defined(ENABLE_PRINTING) 1864 #else // defined(ENABLE_PRINTING)
1865 return false; 1865 return false;
1866 #endif 1866 #endif
1867 } 1867 }
1868 1868
1869 PPB_Graphics2D_Impl* PluginInstance::GetBoundGraphics2D() const { 1869 PluginDelegate::PlatformGraphics2D* PluginInstance::GetBoundGraphics2D() const {
1870 if (bound_graphics_.get() == NULL) 1870 return graphics_2d_platform_;
1871 return NULL;
1872
1873 if (bound_graphics_->AsPPB_Graphics2D_API())
1874 return static_cast<PPB_Graphics2D_Impl*>(bound_graphics_.get());
1875 return NULL;
1876 } 1871 }
1877 1872
1878 PPB_Graphics3D_Impl* PluginInstance::GetBoundGraphics3D() const { 1873 PPB_Graphics3D_Impl* PluginInstance::GetBoundGraphics3D() const {
1879 if (bound_graphics_.get() == NULL) 1874 if (bound_graphics_.get() == NULL)
1880 return NULL; 1875 return NULL;
1881 1876
1882 if (bound_graphics_->AsPPB_Graphics3D_API()) 1877 if (bound_graphics_->AsPPB_Graphics3D_API())
1883 return static_cast<PPB_Graphics3D_Impl*>(bound_graphics_.get()); 1878 return static_cast<PPB_Graphics3D_Impl*>(bound_graphics_.get());
1884 return NULL; 1879 return NULL;
1885 } 1880 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2045 return PP_TRUE; 2040 return PP_TRUE;
2046 } 2041 }
2047 2042
2048 // Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or 2043 // Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or
2049 // to/from fullscreen with PPB_Fullscreen. 2044 // to/from fullscreen with PPB_Fullscreen.
2050 if ((fullscreen_container_ && !flash_fullscreen_) || 2045 if ((fullscreen_container_ && !flash_fullscreen_) ||
2051 desired_fullscreen_state_ != view_data_.is_fullscreen) 2046 desired_fullscreen_state_ != view_data_.is_fullscreen)
2052 return PP_FALSE; 2047 return PP_FALSE;
2053 2048
2054 EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false); 2049 EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false);
2055 PPB_Graphics2D_Impl* graphics_2d = enter_2d.succeeded() ? 2050 PPB_Graphics2D_API* graphics_2d = enter_2d.succeeded() ?
2056 static_cast<PPB_Graphics2D_Impl*>(enter_2d.object()) : NULL; 2051 enter_2d.object() : NULL;
2057 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); 2052 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false);
2058 PPB_Graphics3D_Impl* graphics_3d = enter_3d.succeeded() ? 2053 PPB_Graphics3D_Impl* graphics_3d = enter_3d.succeeded() ?
2059 static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) : NULL; 2054 static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) : NULL;
2060 2055
2061 if (graphics_2d) { 2056 if (graphics_2d) {
2062 if (graphics_2d->pp_instance() != pp_instance()) 2057 // Converts Graphics2D resource to PlatformGraphics2D
2063 return PP_FALSE; // Can't bind other instance's contexts. 2058 graphics_2d_platform_ = delegate_->CreateGraphics2D(
2064 if (!graphics_2d->BindToInstance(this)) 2059 this, device);
2060 if (graphics_2d_platform_ == NULL)
2061 return PP_FALSE;
2062 if (!graphics_2d_platform_->BindToInstance(this))
2065 return PP_FALSE; // Can't bind to more than one instance. 2063 return PP_FALSE; // Can't bind to more than one instance.
2066 2064
2067 bound_graphics_ = graphics_2d; 2065 // bound_graphics_ is a reference-counted resource, so the conversion is
2068 setBackingTextureId(0, graphics_2d->is_always_opaque()); 2066 // needed. Instead of passing graphics_2d as Graphics2DResource, which
2067 // adds package dependancy to ppapi/proxy, we cast it a Resource.
2068 bound_graphics_ = reinterpret_cast< ::ppapi::Resource*>(graphics_2d);
2069 setBackingTextureId(0, graphics_2d_platform_->is_always_opaque());
2069 // BindToInstance will have invalidated the plugin if necessary. 2070 // BindToInstance will have invalidated the plugin if necessary.
2070 } else if (graphics_3d) { 2071 } else if (graphics_3d) {
2071 // Make sure graphics can only be bound to the instance it is 2072 // Make sure graphics can only be bound to the instance it is
2072 // associated with. 2073 // associated with.
2073 if (graphics_3d->pp_instance() != pp_instance()) 2074 if (graphics_3d->pp_instance() != pp_instance())
2074 return PP_FALSE; 2075 return PP_FALSE;
2075 if (!graphics_3d->BindToInstance(true)) 2076 if (!graphics_3d->BindToInstance(true))
2076 return PP_FALSE; 2077 return PP_FALSE;
2077 2078
2078 bound_graphics_ = graphics_3d; 2079 bound_graphics_ = graphics_3d;
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
2689 screen_size_for_fullscreen_ = gfx::Size(); 2690 screen_size_for_fullscreen_ = gfx::Size();
2690 WebElement element = container_->element(); 2691 WebElement element = container_->element();
2691 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2692 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2692 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2693 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2693 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2694 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2694 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2695 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2695 } 2696 }
2696 2697
2697 } // namespace ppapi 2698 } // namespace ppapi
2698 } // namespace webkit 2699 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698