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

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: fix DEPS 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 15 matching lines...) Expand all
107 #include "ui/gfx/codec/jpeg_codec.h" 106 #include "ui/gfx/codec/jpeg_codec.h"
108 #include "ui/gfx/gdi_util.h" 107 #include "ui/gfx/gdi_util.h"
109 #endif 108 #endif
110 109
111 using base::StringPrintf; 110 using base::StringPrintf;
112 using ppapi::InputEventData; 111 using ppapi::InputEventData;
113 using ppapi::PpapiGlobals; 112 using ppapi::PpapiGlobals;
114 using ppapi::PPB_InputEvent_Shared; 113 using ppapi::PPB_InputEvent_Shared;
115 using ppapi::PPB_View_Shared; 114 using ppapi::PPB_View_Shared;
116 using ppapi::PPP_Instance_Combined; 115 using ppapi::PPP_Instance_Combined;
116 using ppapi::Resource;
117 using ppapi::ScopedPPResource; 117 using ppapi::ScopedPPResource;
118 using ppapi::StringVar; 118 using ppapi::StringVar;
119 using ppapi::TrackedCallback; 119 using ppapi::TrackedCallback;
120 using ppapi::thunk::EnterResourceNoLock; 120 using ppapi::thunk::EnterResourceNoLock;
121 using ppapi::thunk::PPB_Buffer_API; 121 using ppapi::thunk::PPB_Buffer_API;
122 using ppapi::thunk::PPB_Graphics2D_API; 122 using ppapi::thunk::PPB_Graphics2D_API;
123 using ppapi::thunk::PPB_Graphics3D_API; 123 using ppapi::thunk::PPB_Graphics3D_API;
124 using ppapi::thunk::PPB_ImageData_API; 124 using ppapi::thunk::PPB_ImageData_API;
125 using ppapi::Var; 125 using ppapi::Var;
126 using ppapi::ArrayBufferVar; 126 using ppapi::ArrayBufferVar;
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 PluginModule* module, 410 PluginModule* module,
411 ::ppapi::PPP_Instance_Combined* instance_interface) 411 ::ppapi::PPP_Instance_Combined* instance_interface)
412 : delegate_(delegate), 412 : delegate_(delegate),
413 module_(module), 413 module_(module),
414 instance_interface_(instance_interface), 414 instance_interface_(instance_interface),
415 pp_instance_(0), 415 pp_instance_(0),
416 container_(NULL), 416 container_(NULL),
417 full_frame_(false), 417 full_frame_(false),
418 sent_initial_did_change_view_(false), 418 sent_initial_did_change_view_(false),
419 view_change_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 419 view_change_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
420 graphics_2d_platform_(NULL),
420 has_webkit_focus_(false), 421 has_webkit_focus_(false),
421 has_content_area_focus_(false), 422 has_content_area_focus_(false),
422 find_identifier_(-1), 423 find_identifier_(-1),
423 plugin_decryption_interface_(NULL), 424 plugin_decryption_interface_(NULL),
424 plugin_find_interface_(NULL), 425 plugin_find_interface_(NULL),
425 plugin_input_event_interface_(NULL), 426 plugin_input_event_interface_(NULL),
426 plugin_messaging_interface_(NULL), 427 plugin_messaging_interface_(NULL),
427 plugin_mouse_lock_interface_(NULL), 428 plugin_mouse_lock_interface_(NULL),
428 plugin_pdf_interface_(NULL), 429 plugin_pdf_interface_(NULL),
429 plugin_private_interface_(NULL), 430 plugin_private_interface_(NULL),
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 TRACE_EVENT0("ppapi", "PluginInstance::Paint"); 531 TRACE_EVENT0("ppapi", "PluginInstance::Paint");
531 if (module()->is_crashed()) { 532 if (module()->is_crashed()) {
532 // Crashed plugin painting. 533 // Crashed plugin painting.
533 if (!sad_plugin_) // Lazily initialize bitmap. 534 if (!sad_plugin_) // Lazily initialize bitmap.
534 sad_plugin_ = delegate_->GetSadPluginBitmap(); 535 sad_plugin_ = delegate_->GetSadPluginBitmap();
535 if (sad_plugin_) 536 if (sad_plugin_)
536 webkit::PaintSadPlugin(canvas, plugin_rect, *sad_plugin_); 537 webkit::PaintSadPlugin(canvas, plugin_rect, *sad_plugin_);
537 return; 538 return;
538 } 539 }
539 540
540 PPB_Graphics2D_Impl* bound_graphics_2d = GetBoundGraphics2D(); 541 PluginDelegate::PlatformGraphics2D* bound_graphics_2d = GetBoundGraphics2D();
541 if (bound_graphics_2d) 542 if (bound_graphics_2d)
542 bound_graphics_2d->Paint(canvas, plugin_rect, paint_rect); 543 bound_graphics_2d->Paint(canvas, plugin_rect, paint_rect);
543 } 544 }
544 545
545 void PluginInstance::InvalidateRect(const gfx::Rect& rect) { 546 void PluginInstance::InvalidateRect(const gfx::Rect& rect) {
546 if (fullscreen_container_) { 547 if (fullscreen_container_) {
547 if (rect.IsEmpty()) 548 if (rect.IsEmpty())
548 fullscreen_container_->Invalidate(); 549 fullscreen_container_->Invalidate();
549 else 550 else
550 fullscreen_container_->InvalidateRect(rect); 551 fullscreen_container_->InvalidateRect(rect);
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 } 990 }
990 991
991 bool PluginInstance::GetBitmapForOptimizedPluginPaint( 992 bool PluginInstance::GetBitmapForOptimizedPluginPaint(
992 const gfx::Rect& paint_bounds, 993 const gfx::Rect& paint_bounds,
993 TransportDIB** dib, 994 TransportDIB** dib,
994 gfx::Rect* location, 995 gfx::Rect* location,
995 gfx::Rect* clip, 996 gfx::Rect* clip,
996 float* scale_factor) { 997 float* scale_factor) {
997 if (!always_on_top_) 998 if (!always_on_top_)
998 return false; 999 return false;
999 if (!GetBoundGraphics2D() || !GetBoundGraphics2D()->is_always_opaque()) 1000 if (!GetBoundGraphics2D() || !GetBoundGraphics2D()->IsAlwaysOpaque())
1000 return false; 1001 return false;
1001 1002
1002 // We specifically want to compare against the area covered by the backing 1003 // We specifically want to compare against the area covered by the backing
1003 // store when seeing if we cover the given paint bounds, since the backing 1004 // store when seeing if we cover the given paint bounds, since the backing
1004 // store could be smaller than the declared plugin area. 1005 // store could be smaller than the declared plugin area.
1005 PPB_ImageData_Impl* image_data = GetBoundGraphics2D()->image_data(); 1006 PPB_ImageData_Impl* image_data = GetBoundGraphics2D()->ImageData();
1006 // ImageDatas created by NaCl don't have a PlatformImage, so can't be 1007 // ImageDatas created by NaCl don't have a PlatformImage, so can't be
1007 // optimized this way. 1008 // optimized this way.
1008 if (!image_data->PlatformImage()) 1009 if (!image_data->PlatformImage())
1009 return false; 1010 return false;
1010 1011
1011 gfx::Point plugin_origin = PP_ToGfxPoint(view_data_.rect.point); 1012 gfx::Point plugin_origin = PP_ToGfxPoint(view_data_.rect.point);
1012 // Convert |paint_bounds| to be relative to the left-top corner of the plugin. 1013 // Convert |paint_bounds| to be relative to the left-top corner of the plugin.
1013 gfx::Rect relative_paint_bounds(paint_bounds); 1014 gfx::Rect relative_paint_bounds(paint_bounds);
1014 relative_paint_bounds.Offset(-plugin_origin.x(), -plugin_origin.y()); 1015 relative_paint_bounds.Offset(-plugin_origin.x(), -plugin_origin.y());
1015 1016
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
1859 skia::EndPlatformPaint(canvas); 1860 skia::EndPlatformPaint(canvas);
1860 } 1861 }
1861 #endif // defined(OS_WIN) 1862 #endif // defined(OS_WIN)
1862 1863
1863 return ret; 1864 return ret;
1864 #else // defined(ENABLE_PRINTING) 1865 #else // defined(ENABLE_PRINTING)
1865 return false; 1866 return false;
1866 #endif 1867 #endif
1867 } 1868 }
1868 1869
1869 PPB_Graphics2D_Impl* PluginInstance::GetBoundGraphics2D() const { 1870 PluginDelegate::PlatformGraphics2D* PluginInstance::GetBoundGraphics2D() const {
1870 if (bound_graphics_.get() == NULL) 1871 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 } 1872 }
1877 1873
1878 PPB_Graphics3D_Impl* PluginInstance::GetBoundGraphics3D() const { 1874 PPB_Graphics3D_Impl* PluginInstance::GetBoundGraphics3D() const {
1879 if (bound_graphics_.get() == NULL) 1875 if (bound_graphics_.get() == NULL)
1880 return NULL; 1876 return NULL;
1881 1877
1882 if (bound_graphics_->AsPPB_Graphics3D_API()) 1878 if (bound_graphics_->AsPPB_Graphics3D_API())
1883 return static_cast<PPB_Graphics3D_Impl*>(bound_graphics_.get()); 1879 return static_cast<PPB_Graphics3D_Impl*>(bound_graphics_.get());
1884 return NULL; 1880 return NULL;
1885 } 1881 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2044 InvalidateRect(gfx::Rect()); 2040 InvalidateRect(gfx::Rect());
2045 return PP_TRUE; 2041 return PP_TRUE;
2046 } 2042 }
2047 2043
2048 // Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or 2044 // Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or
2049 // to/from fullscreen with PPB_Fullscreen. 2045 // to/from fullscreen with PPB_Fullscreen.
2050 if ((fullscreen_container_ && !flash_fullscreen_) || 2046 if ((fullscreen_container_ && !flash_fullscreen_) ||
2051 desired_fullscreen_state_ != view_data_.is_fullscreen) 2047 desired_fullscreen_state_ != view_data_.is_fullscreen)
2052 return PP_FALSE; 2048 return PP_FALSE;
2053 2049
2054 EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false); 2050 EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false);
brettw 2012/10/05 22:38:06 This call will fail when run out of process and th
victorhsieh 2012/10/08 19:17:02 I removed enter_2d and use graphics_2d_platform_ i
2055 PPB_Graphics2D_Impl* graphics_2d = enter_2d.succeeded() ? 2051 Resource* graphics_2d = enter_2d.succeeded() ? enter_2d.resource() : NULL;
2056 static_cast<PPB_Graphics2D_Impl*>(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_->GetGraphics2D(
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_ = graphics_2d;
2068 setBackingTextureId(0, graphics_2d->is_always_opaque()); 2066 setBackingTextureId(0, graphics_2d_platform_->IsAlwaysOpaque());
2069 // BindToInstance will have invalidated the plugin if necessary. 2067 // BindToInstance will have invalidated the plugin if necessary.
2070 } else if (graphics_3d) { 2068 } else if (graphics_3d) {
2071 // Make sure graphics can only be bound to the instance it is 2069 // Make sure graphics can only be bound to the instance it is
2072 // associated with. 2070 // associated with.
2073 if (graphics_3d->pp_instance() != pp_instance()) 2071 if (graphics_3d->pp_instance() != pp_instance())
2074 return PP_FALSE; 2072 return PP_FALSE;
2075 if (!graphics_3d->BindToInstance(true)) 2073 if (!graphics_3d->BindToInstance(true))
2076 return PP_FALSE; 2074 return PP_FALSE;
2077 2075
2078 bound_graphics_ = graphics_3d; 2076 bound_graphics_ = graphics_3d;
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
2689 screen_size_for_fullscreen_ = gfx::Size(); 2687 screen_size_for_fullscreen_ = gfx::Size();
2690 WebElement element = container_->element(); 2688 WebElement element = container_->element();
2691 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2689 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2692 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2690 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2693 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2691 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2694 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2692 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2695 } 2693 }
2696 2694
2697 } // namespace ppapi 2695 } // namespace ppapi
2698 } // namespace webkit 2696 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698