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..6306724e34968ef72b98bfe7a578d063d333211a 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" |
@@ -417,6 +416,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 +537,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); |
} |
@@ -1866,13 +1866,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 +2047,26 @@ PP_Bool PluginInstance::BindGraphics(PP_Instance instance, |
return PP_FALSE; |
EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false); |
- PPB_Graphics2D_Impl* graphics_2d = enter_2d.succeeded() ? |
- static_cast<PPB_Graphics2D_Impl*>(enter_2d.object()) : NULL; |
+ PPB_Graphics2D_API* graphics_2d = enter_2d.succeeded() ? |
+ enter_2d.object() : 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_->CreateGraphics2D( |
+ 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()); |
+ // bound_graphics_ is a reference-counted resource, so the conversion is |
+ // needed. Instead of passing graphics_2d as Graphics2DResource, which |
+ // adds package dependancy to ppapi/proxy, we cast it a Resource. |
+ bound_graphics_ = reinterpret_cast< ::ppapi::Resource*>(graphics_2d); |
+ setBackingTextureId(0, graphics_2d_platform_->is_always_opaque()); |
// BindToInstance will have invalidated the plugin if necessary. |
} else if (graphics_3d) { |
// Make sure graphics can only be bound to the instance it is |