Chromium Code Reviews| Index: webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| index 19b3cbcea983b915e8dc274a4f366a31f28e709a..e0a00a6b03b9d2ab3643b2335809567e92459c50 100644 |
| --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| @@ -78,7 +78,6 @@ |
| #include "webkit/plugins/ppapi/plugin_module.h" |
| #include "webkit/plugins/ppapi/plugin_object.h" |
| #include "webkit/plugins/ppapi/ppb_buffer_impl.h" |
| -#include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" |
| #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" |
| #include "webkit/plugins/ppapi/ppb_image_data_impl.h" |
| #include "webkit/plugins/ppapi/ppb_url_loader_impl.h" |
| @@ -114,6 +113,7 @@ using ppapi::PpapiGlobals; |
| using ppapi::PPB_InputEvent_Shared; |
| using ppapi::PPB_View_Shared; |
| using ppapi::PPP_Instance_Combined; |
| +using ppapi::Resource; |
| using ppapi::ScopedPPResource; |
| using ppapi::StringVar; |
| using ppapi::TrackedCallback; |
| @@ -417,6 +417,7 @@ PluginInstance::PluginInstance( |
| full_frame_(false), |
| sent_initial_did_change_view_(false), |
| view_change_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| + graphics_2d_platform_(NULL), |
| has_webkit_focus_(false), |
| has_content_area_focus_(false), |
| find_identifier_(-1), |
| @@ -537,7 +538,7 @@ void PluginInstance::Paint(WebCanvas* canvas, |
| return; |
| } |
| - PPB_Graphics2D_Impl* bound_graphics_2d = GetBoundGraphics2D(); |
| + PluginDelegate::PlatformGraphics2D* bound_graphics_2d = GetBoundGraphics2D(); |
| if (bound_graphics_2d) |
| bound_graphics_2d->Paint(canvas, plugin_rect, paint_rect); |
| } |
| @@ -996,13 +997,13 @@ bool PluginInstance::GetBitmapForOptimizedPluginPaint( |
| float* scale_factor) { |
| if (!always_on_top_) |
| return false; |
| - if (!GetBoundGraphics2D() || !GetBoundGraphics2D()->is_always_opaque()) |
| + if (!GetBoundGraphics2D() || !GetBoundGraphics2D()->IsAlwaysOpaque()) |
| return false; |
| // We specifically want to compare against the area covered by the backing |
| // store when seeing if we cover the given paint bounds, since the backing |
| // store could be smaller than the declared plugin area. |
| - PPB_ImageData_Impl* image_data = GetBoundGraphics2D()->image_data(); |
| + PPB_ImageData_Impl* image_data = GetBoundGraphics2D()->ImageData(); |
| // ImageDatas created by NaCl don't have a PlatformImage, so can't be |
| // optimized this way. |
| if (!image_data->PlatformImage()) |
| @@ -1866,13 +1867,8 @@ bool PluginInstance::PrintPDFOutput(PP_Resource print_output, |
| #endif |
| } |
| -PPB_Graphics2D_Impl* PluginInstance::GetBoundGraphics2D() const { |
| - if (bound_graphics_.get() == NULL) |
| - return NULL; |
| - |
| - if (bound_graphics_->AsPPB_Graphics2D_API()) |
| - return static_cast<PPB_Graphics2D_Impl*>(bound_graphics_.get()); |
| - return NULL; |
| +PluginDelegate::PlatformGraphics2D* PluginInstance::GetBoundGraphics2D() const { |
| + return graphics_2d_platform_; |
| } |
| PPB_Graphics3D_Impl* PluginInstance::GetBoundGraphics3D() const { |
| @@ -2052,20 +2048,22 @@ PP_Bool PluginInstance::BindGraphics(PP_Instance instance, |
| return PP_FALSE; |
| 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
|
| - PPB_Graphics2D_Impl* graphics_2d = enter_2d.succeeded() ? |
| - static_cast<PPB_Graphics2D_Impl*>(enter_2d.object()) : NULL; |
| + Resource* graphics_2d = enter_2d.succeeded() ? enter_2d.resource() : NULL; |
| EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); |
| PPB_Graphics3D_Impl* graphics_3d = enter_3d.succeeded() ? |
| static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) : NULL; |
| if (graphics_2d) { |
| - if (graphics_2d->pp_instance() != pp_instance()) |
| - return PP_FALSE; // Can't bind other instance's contexts. |
| - if (!graphics_2d->BindToInstance(this)) |
| + // Converts Graphics2D resource to PlatformGraphics2D |
| + graphics_2d_platform_ = delegate_->GetGraphics2D( |
| + this, device); |
| + if (graphics_2d_platform_ == NULL) |
| + return PP_FALSE; |
| + if (!graphics_2d_platform_->BindToInstance(this)) |
| return PP_FALSE; // Can't bind to more than one instance. |
| bound_graphics_ = graphics_2d; |
| - setBackingTextureId(0, graphics_2d->is_always_opaque()); |
| + setBackingTextureId(0, graphics_2d_platform_->IsAlwaysOpaque()); |
| // BindToInstance will have invalidated the plugin if necessary. |
| } else if (graphics_3d) { |
| // Make sure graphics can only be bound to the instance it is |