summaryrefslogtreecommitdiffstats
path: root/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-24 15:19:37 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-24 15:19:37 +0000
commitbbf076f18dbb27fba74de06f4994aa1480690ea3 (patch)
tree6dcabc6d408c997b18f8762fee0fac8470770fb4 /webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
parent081c03452bb7d97b138bed3ccc7cbe0903eae05c (diff)
downloadchromium_src-bbf076f18dbb27fba74de06f4994aa1480690ea3.zip
chromium_src-bbf076f18dbb27fba74de06f4994aa1480690ea3.tar.gz
chromium_src-bbf076f18dbb27fba74de06f4994aa1480690ea3.tar.bz2
Remove webkit::ppapi::Resource.
This makes all resource _impl's derive directly from ppapi::Resource so we can share code better. This means removing PluginInstances and converting them to PP_Instances. This adds a new ResourceHelper static class to help in the conversion of resources to PluginInstances for the _impl classes. Overall the new code is in general slightly worse than the old because using the ResourceHelper is more annoying than just calling instance() on the old webkit::ppapi::Resource object. However, I'm hoping that, because this will allow us to move more code into shared_impl and reduce duplicate logic, it will eventually have a net positive effect. This also adds a ScopedPPResource class that works just like a scoped_refptr. We need this in a few places. Most of the places that used the old ScopedResourceId class could be removed now since resources have PP_Resource IDs generated even when there's no plugin reference (this didn't use to be the case) so we can pass resources as input params to the plugin even when there's no plugin ref, as long as there's a scoped_refptr to the Resource. Review URL: http://codereview.chromium.org/7669055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98047 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins/ppapi/ppb_graphics_2d_impl.cc')
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index d32dc46..3a75e99 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -23,6 +23,7 @@
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
+#include "webkit/plugins/ppapi/resource_helper.h"
#if defined(OS_MACOSX)
#include "base/mac/mac_util.h"
@@ -150,7 +151,7 @@ struct PPB_Graphics2D_Impl::QueuedOperation {
scoped_refptr<PPB_ImageData_Impl> replace_image;
};
-PPB_Graphics2D_Impl::PPB_Graphics2D_Impl(PluginInstance* instance)
+PPB_Graphics2D_Impl::PPB_Graphics2D_Impl(PP_Instance instance)
: Resource(instance),
bound_instance_(NULL),
offscreen_flush_pending_(false),
@@ -161,7 +162,7 @@ PPB_Graphics2D_Impl::~PPB_Graphics2D_Impl() {
}
// static
-PP_Resource PPB_Graphics2D_Impl::Create(PluginInstance* instance,
+PP_Resource PPB_Graphics2D_Impl::Create(PP_Instance instance,
const PP_Size& size,
PP_Bool is_always_opaque) {
scoped_refptr<PPB_Graphics2D_Impl> graphics_2d(
@@ -175,7 +176,7 @@ PP_Resource PPB_Graphics2D_Impl::Create(PluginInstance* instance,
bool PPB_Graphics2D_Impl::Init(int width, int height, bool is_always_opaque) {
// The underlying PPB_ImageData_Impl will validate the dimensions.
- image_data_ = new PPB_ImageData_Impl(instance());
+ image_data_ = new PPB_ImageData_Impl(pp_instance());
if (!image_data_->Init(PPB_ImageData_Impl::GetNativeImageDataFormat(),
width, height, true) ||
!image_data_->Map()) {
@@ -488,7 +489,10 @@ void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas,
canvas->save();
canvas->clipRect(sk_plugin_rect);
- if (instance()->IsFullPagePlugin()) {
+ PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
+ if (!plugin_instance)
+ return;
+ if (plugin_instance->IsFullPagePlugin()) {
// When we're resizing a window with a full-frame plugin, the plugin may
// not yet have bound a new device, which will leave parts of the
// background exposed if the window is getting larger. We want this to