Index: webkit/plugins/ppapi/ppapi_plugin_instance.cc |
=================================================================== |
--- webkit/plugins/ppapi/ppapi_plugin_instance.cc (revision 92890) |
+++ webkit/plugins/ppapi/ppapi_plugin_instance.cc (working copy) |
@@ -55,6 +55,7 @@ |
#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_input_event_impl.h" |
#include "webkit/plugins/ppapi/ppb_surface_3d_impl.h" |
@@ -89,6 +90,7 @@ |
using ppapi::thunk::EnterResourceNoLock; |
using ppapi::thunk::PPB_Buffer_API; |
using ppapi::thunk::PPB_Graphics2D_API; |
+using ppapi::thunk::PPB_Graphics3D_API; |
using ppapi::thunk::PPB_ImageData_API; |
using ppapi::thunk::PPB_Instance_FunctionAPI; |
using ppapi::thunk::PPB_Surface3D_API; |
@@ -321,10 +323,12 @@ |
} |
unsigned PluginInstance::GetBackingTextureId() { |
- if (!bound_graphics_3d()) |
- return 0; |
+ if (bound_graphics_3d()) |
+ return bound_graphics_3d()->GetBackingTextureId(); |
+ else if (bound_surface_3d()) |
+ return bound_surface_3d()->GetBackingTextureId(); |
- return bound_graphics_3d()->GetBackingTextureId(); |
+ return 0; |
} |
void PluginInstance::CommitBackingTexture() { |
@@ -546,8 +550,10 @@ |
void PluginInstance::ViewInitiatedPaint() { |
if (bound_graphics_2d()) |
bound_graphics_2d()->ViewInitiatedPaint(); |
- if (bound_graphics_3d()) |
+ else if (bound_graphics_3d()) |
bound_graphics_3d()->ViewInitiatedPaint(); |
+ else if (bound_surface_3d()) |
+ bound_surface_3d()->ViewInitiatedPaint(); |
} |
void PluginInstance::ViewFlushedPaint() { |
@@ -555,8 +561,10 @@ |
scoped_refptr<PluginInstance> ref(this); |
if (bound_graphics_2d()) |
bound_graphics_2d()->ViewFlushedPaint(); |
- if (bound_graphics_3d()) |
+ else if (bound_graphics_3d()) |
bound_graphics_3d()->ViewFlushedPaint(); |
+ else if (bound_surface_3d()) |
+ bound_surface_3d()->ViewFlushedPaint(); |
} |
bool PluginInstance::GetBitmapForOptimizedPluginPaint( |
@@ -1267,10 +1275,19 @@ |
return NULL; |
} |
-PPB_Surface3D_Impl* PluginInstance::bound_graphics_3d() const { |
+PPB_Graphics3D_Impl* PluginInstance::bound_graphics_3d() const { |
if (bound_graphics_.get() == NULL) |
return NULL; |
+ if (bound_graphics_->AsPPB_Graphics3D_API()) |
+ return static_cast<PPB_Graphics3D_Impl*>(bound_graphics_.get()); |
+ return NULL; |
+} |
+ |
+PPB_Surface3D_Impl* PluginInstance::bound_surface_3d() const { |
+ if (bound_graphics_.get() == NULL) |
+ return NULL; |
+ |
if (bound_graphics_->AsPPB_Surface3D_API()) |
return static_cast<PPB_Surface3D_Impl*>(bound_graphics_.get()); |
return NULL; |
@@ -1347,8 +1364,10 @@ |
if (bound_graphics_.get()) { |
if (bound_graphics_2d()) { |
bound_graphics_2d()->BindToInstance(NULL); |
- } else if (bound_graphics_.get()) { |
+ } else if (bound_graphics_3d()) { |
bound_graphics_3d()->BindToInstance(false); |
+ } else if (bound_surface_3d()) { |
+ bound_graphics_3d()->BindToInstance(false); |
} |
setBackingTextureId(0); |
InvalidateRect(gfx::Rect()); |
@@ -1357,17 +1376,21 @@ |
return PP_TRUE; |
} |
+ // Refuse to bind if we're transitioning to fullscreen. |
+ if (fullscreen_container_ && !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; |
- EnterResourceNoLock<PPB_Surface3D_API> enter_3d(device, false); |
- PPB_Surface3D_Impl* graphics_3d = enter_3d.succeeded() ? |
- static_cast<PPB_Surface3D_Impl*>(enter_3d.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; |
+ EnterResourceNoLock<PPB_Surface3D_API> enter_surface_3d(device, false); |
+ PPB_Surface3D_Impl* surface_3d = enter_surface_3d.succeeded() ? |
+ static_cast<PPB_Surface3D_Impl*>(enter_surface_3d.object()) : NULL; |
if (graphics_2d) { |
- // Refuse to bind if we're transitioning to fullscreen. |
- if (fullscreen_container_ && !fullscreen_) |
- return PP_FALSE; |
if (graphics_2d->instance() != this) |
return PP_FALSE; // Can't bind other instance's contexts. |
if (!graphics_2d->BindToInstance(this)) |
@@ -1377,9 +1400,6 @@ |
setBackingTextureId(0); |
// BindToInstance will have invalidated the plugin if necessary. |
} else if (graphics_3d) { |
- // Refuse to bind if we're transitioning to fullscreen. |
- if (fullscreen_container_ && !fullscreen_) |
- return PP_FALSE; |
// Make sure graphics can only be bound to the instance it is |
// associated with. |
if (graphics_3d->instance() != this) |
@@ -1387,8 +1407,18 @@ |
if (!graphics_3d->BindToInstance(true)) |
return PP_FALSE; |
+ bound_graphics_ = graphics_3d; |
setBackingTextureId(graphics_3d->GetBackingTextureId()); |
- bound_graphics_ = graphics_3d; |
+ } else if (surface_3d) { |
+ // Make sure graphics can only be bound to the instance it is |
+ // associated with. |
+ if (surface_3d->instance() != this) |
+ return PP_FALSE; |
+ if (!surface_3d->BindToInstance(true)) |
+ return PP_FALSE; |
+ |
+ bound_graphics_ = surface_3d; |
+ setBackingTextureId(surface_3d->GetBackingTextureId()); |
} else { |
// The device is not a valid resource type. |
return PP_FALSE; |