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 e6d0eeeef7bc34e270c52e5f11db130db19aee18..ef6340bcd07db57a6c428de28b2dbe3e60a5bca4 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; |
@@ -418,6 +418,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), |
@@ -538,7 +539,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); |
} |
@@ -997,13 +998,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()) |
@@ -1885,21 +1886,16 @@ 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 { |
- if (bound_graphics_.get() == NULL) |
+ if (bound_graphics_3d_.get() == NULL) |
return NULL; |
- if (bound_graphics_->AsPPB_Graphics3D_API()) |
- return static_cast<PPB_Graphics3D_Impl*>(bound_graphics_.get()); |
+ if (bound_graphics_3d_->AsPPB_Graphics3D_API()) |
brettw
2012/10/09 20:47:13
This if shouldn't be necessary since it should't g
victorhsieh
2012/10/11 22:56:23
Done.
|
+ return static_cast<PPB_Graphics3D_Impl*>(bound_graphics_3d_.get()); |
return NULL; |
} |
@@ -2047,14 +2043,16 @@ PP_Bool PluginInstance::BindGraphics(PP_Instance instance, |
TRACE_EVENT0("ppapi", "PluginInstance::BindGraphics"); |
// The Graphics3D instance can't be destroyed until we call |
// setBackingTextureId. |
- scoped_refptr< ::ppapi::Resource> old_graphics = bound_graphics_; |
- if (bound_graphics_.get()) { |
- if (GetBoundGraphics2D()) { |
- GetBoundGraphics2D()->BindToInstance(NULL); |
- } else if (GetBoundGraphics3D()) { |
+ scoped_refptr< ::ppapi::Resource> old_graphics = bound_graphics_3d_; |
+ if (bound_graphics_3d_.get()) { |
+ if (GetBoundGraphics3D()) { |
GetBoundGraphics3D()->BindToInstance(false); |
} |
- bound_graphics_ = NULL; |
+ bound_graphics_3d_ = NULL; |
+ } |
+ if (graphics_2d_platform_) { |
+ GetBoundGraphics2D()->BindToInstance(NULL); |
+ graphics_2d_platform_ = NULL; |
} |
// Special-case clearing the current device. |
@@ -2070,21 +2068,16 @@ PP_Bool PluginInstance::BindGraphics(PP_Instance instance, |
desired_fullscreen_state_ != view_data_.is_fullscreen) |
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; |
+ graphics_2d_platform_ = delegate_->GetGraphics2D(this, device); |
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)) |
+ if (graphics_2d_platform_) { |
+ 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 |
@@ -2094,7 +2087,7 @@ PP_Bool PluginInstance::BindGraphics(PP_Instance instance, |
if (!graphics_3d->BindToInstance(true)) |
return PP_FALSE; |
- bound_graphics_ = graphics_3d; |
+ bound_graphics_3d_ = graphics_3d; |
setBackingTextureId(graphics_3d->GetBackingTextureId(), |
graphics_3d->IsOpaque()); |
} else { |