summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-22 20:57:00 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-22 20:57:00 +0000
commite18e6392bb61e5a525b87951b9e42df0f2d07c83 (patch)
tree55c67d9ffaf42151ca259e32f043030c9afa7d16 /webkit
parent627c4549e3d258ed34d896ac7910f04694cbc7b0 (diff)
downloadchromium_src-e18e6392bb61e5a525b87951b9e42df0f2d07c83.zip
chromium_src-e18e6392bb61e5a525b87951b9e42df0f2d07c83.tar.gz
chromium_src-e18e6392bb61e5a525b87951b9e42df0f2d07c83.tar.bz2
Convert most remaining resources to use the API/thunk system. The significant
changes here are around the 3D API. Having separate files for the texture mapping interface is no longer necessary for the proxy and the implementation. This also removes the uses of the "old" dynamic casting system (using "GetAs") for other resources that I could find. TEST=ui tests BUG=none Review URL: http://codereview.chromium.org/7206016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90096 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/webkit_glue.gypi2
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc38
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc45
-rw-r--r--webkit/plugins/ppapi/ppb_broker_impl.cc4
-rw-r--r--webkit/plugins/ppapi/ppb_broker_impl.h3
-rw-r--r--webkit/plugins/ppapi/ppb_context_3d_impl.cc376
-rw-r--r--webkit/plugins/ppapi/ppb_context_3d_impl.h83
-rw-r--r--webkit/plugins/ppapi/ppb_directory_reader_impl.cc5
-rw-r--r--webkit/plugins/ppapi/ppb_directory_reader_impl.h3
-rw-r--r--webkit/plugins/ppapi/ppb_flash_file_impl.cc16
-rw-r--r--webkit/plugins/ppapi/ppb_flash_impl.cc11
-rw-r--r--webkit/plugins/ppapi/ppb_flash_impl_linux.cc12
-rw-r--r--webkit/plugins/ppapi/ppb_font_impl.cc17
-rw-r--r--webkit/plugins/ppapi/ppb_font_impl.h3
-rw-r--r--webkit/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.cc53
-rw-r--r--webkit/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.h22
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc28
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_3d_impl.cc93
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_3d_impl.h24
-rw-r--r--webkit/plugins/ppapi/ppb_image_data_impl.cc4
-rw-r--r--webkit/plugins/ppapi/ppb_image_data_impl.h3
-rw-r--r--webkit/plugins/ppapi/ppb_layer_compositor_impl.cc66
-rw-r--r--webkit/plugins/ppapi/ppb_layer_compositor_impl.h27
-rw-r--r--webkit/plugins/ppapi/ppb_opengles_impl.cc638
-rw-r--r--webkit/plugins/ppapi/ppb_proxy_impl.cc14
-rw-r--r--webkit/plugins/ppapi/ppb_scrollbar_impl.cc35
-rw-r--r--webkit/plugins/ppapi/ppb_scrollbar_impl.h17
-rw-r--r--webkit/plugins/ppapi/ppb_surface_3d_impl.cc116
-rw-r--r--webkit/plugins/ppapi/ppb_surface_3d_impl.h28
-rw-r--r--webkit/plugins/ppapi/ppb_transport_impl.cc94
-rw-r--r--webkit/plugins/ppapi/ppb_transport_impl.h40
-rw-r--r--webkit/plugins/ppapi/ppb_video_decoder_impl.cc23
-rw-r--r--webkit/plugins/ppapi/ppb_widget_impl.cc79
-rw-r--r--webkit/plugins/ppapi/ppb_widget_impl.h31
-rw-r--r--webkit/plugins/ppapi/resource.h30
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.cc36
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.h15
37 files changed, 813 insertions, 1321 deletions
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index 33a9646..8446100 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -264,8 +264,6 @@
'../plugins/ppapi/ppb_flash_net_connector_impl.h',
'../plugins/ppapi/ppb_font_impl.cc',
'../plugins/ppapi/ppb_font_impl.h',
- '../plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.cc',
- '../plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.h',
'../plugins/ppapi/ppb_graphics_2d_impl.cc',
'../plugins/ppapi/ppb_graphics_2d_impl.h',
'../plugins/ppapi/ppb_graphics_3d_impl.cc',
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 8181c96..d9db923 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -33,6 +33,7 @@
#include "ppapi/c/dev/ppb_layer_compositor_dev.h"
#include "ppapi/c/dev/ppb_opengles_dev.h"
#include "ppapi/c/dev/ppb_scrollbar_dev.h"
+#include "ppapi/c/dev/ppb_surface_3d_dev.h"
#include "ppapi/c/dev/ppb_testing_dev.h"
#include "ppapi/c/dev/ppb_transport_dev.h"
#include "ppapi/c/dev/ppb_url_util_dev.h"
@@ -69,6 +70,7 @@
#include "ppapi/c/trusted/ppb_buffer_trusted.h"
#include "ppapi/c/trusted/ppb_image_data_trusted.h"
#include "ppapi/c/trusted/ppb_url_loader_trusted.h"
+#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/thunk.h"
#include "webkit/plugins/ppapi/callbacks.h"
#include "webkit/plugins/ppapi/common.h"
@@ -86,25 +88,19 @@
#include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
#include "webkit/plugins/ppapi/ppb_layer_compositor_impl.h"
+#include "webkit/plugins/ppapi/ppb_opengles_impl.h"
#include "webkit/plugins/ppapi/ppb_proxy_impl.h"
#include "webkit/plugins/ppapi/ppb_scrollbar_impl.h"
-#include "webkit/plugins/ppapi/ppb_transport_impl.h"
#include "webkit/plugins/ppapi/ppb_uma_private_impl.h"
#include "webkit/plugins/ppapi/ppb_url_util_impl.h"
#include "webkit/plugins/ppapi/ppb_video_decoder_impl.h"
#include "webkit/plugins/ppapi/ppb_video_layer_impl.h"
-#include "webkit/plugins/ppapi/ppb_widget_impl.h"
#include "webkit/plugins/ppapi/resource_tracker.h"
#include "webkit/plugins/ppapi/var.h"
#include "webkit/plugins/ppapi/webkit_forwarding_impl.h"
-#ifdef ENABLE_GPU
-#include "webkit/plugins/ppapi/ppb_context_3d_impl.h"
-#include "webkit/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.h"
-#include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
-#include "webkit/plugins/ppapi/ppb_opengles_impl.h"
-#include "webkit/plugins/ppapi/ppb_surface_3d_impl.h"
-#endif // ENABLE_GPU
+using ppapi::thunk::EnterResource;
+using ppapi::thunk::PPB_Graphics2D_API;
namespace webkit {
namespace ppapi {
@@ -188,11 +184,11 @@ const PPB_Core core_interface = {
PP_Bool ReadImageData(PP_Resource device_context_2d,
PP_Resource image,
const PP_Point* top_left) {
- scoped_refptr<PPB_Graphics2D_Impl> context(
- Resource::GetAs<PPB_Graphics2D_Impl>(device_context_2d));
- if (!context.get())
+ EnterResource<PPB_Graphics2D_API> enter(device_context_2d, true);
+ if (enter.failed())
return PP_FALSE;
- return BoolToPPBool(context->ReadImageData(image, top_left));
+ return BoolToPPBool(static_cast<PPB_Graphics2D_Impl*>(enter.object())->
+ ReadImageData(image, top_left));
}
void RunMessageLoop(PP_Instance instance) {
@@ -329,7 +325,7 @@ const void* GetInterface(const char* name) {
if (strcmp(name, PPB_VIDEOLAYER_DEV_INTERFACE) == 0)
return ::ppapi::thunk::GetPPB_VideoLayer_Thunk();
if (strcmp(name, PPB_WIDGET_DEV_INTERFACE) == 0)
- return PPB_Widget_Impl::GetInterface();
+ return ::ppapi::thunk::GetPPB_Widget_Thunk();
if (strcmp(name, PPB_ZOOM_DEV_INTERFACE) == 0)
return PluginInstance::GetZoomInterface();
@@ -337,19 +333,19 @@ const void* GetInterface(const char* name) {
// This should really refer to switches::kDisable3DAPIs.
if (!CommandLine::ForCurrentProcess()->HasSwitch("disable-3d-apis")) {
if (strcmp(name, PPB_GRAPHICS_3D_DEV_INTERFACE) == 0)
- return PPB_Graphics3D_Impl::GetInterface();
+ return ::ppapi::thunk::GetPPB_Graphics3D_Thunk();
if (strcmp(name, PPB_CONTEXT_3D_DEV_INTERFACE) == 0)
- return PPB_Context3D_Impl::GetInterface();
+ return ::ppapi::thunk::GetPPB_Context3D_Thunk();
if (strcmp(name, PPB_CONTEXT_3D_TRUSTED_DEV_INTERFACE) == 0)
- return PPB_Context3D_Impl::GetTrustedInterface();
+ return ::ppapi::thunk::GetPPB_Context3DTrusted_Thunk();
if (strcmp(name, PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_INTERFACE) == 0)
- return PPB_GLESChromiumTextureMapping_Impl::GetInterface();
+ return ::ppapi::thunk::GetPPB_GLESChromiumTextureMapping_Thunk();
if (strcmp(name, PPB_OPENGLES2_DEV_INTERFACE) == 0)
return PPB_OpenGLES_Impl::GetInterface();
if (strcmp(name, PPB_SURFACE_3D_DEV_INTERFACE) == 0)
- return PPB_Surface3D_Impl::GetInterface();
+ return ::ppapi::thunk::GetPPB_Surface3D_Thunk();
if (strcmp(name, PPB_LAYER_COMPOSITOR_DEV_INTERFACE) == 0)
- return PPB_LayerCompositor_Impl::GetInterface();
+ return ::ppapi::thunk::GetPPB_LayerCompositor_Thunk();
}
#endif // ENABLE_GPU
@@ -360,7 +356,7 @@ const void* GetInterface(const char* name) {
#if defined(ENABLE_P2P_APIS)
if (strcmp(name, PPB_TRANSPORT_DEV_INTERFACE) == 0)
- return PPB_Transport_Impl::GetInterface();
+ return ::ppapi::thunk::GetPPB_Transport_Thunk();
#endif
// Only support the testing interface when the command line switch is
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 9809fdf..65faa07 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -85,10 +85,12 @@
#include "skia/ext/skia_utils_mac.h"
#endif
-using ::ppapi::thunk::EnterResourceNoLock;
-using ::ppapi::thunk::PPB_Buffer_API;
-using ::ppapi::thunk::PPB_Graphics2D_API;
-using ::ppapi::thunk::PPB_Instance_FunctionAPI;
+using ppapi::thunk::EnterResourceNoLock;
+using ppapi::thunk::PPB_Buffer_API;
+using ppapi::thunk::PPB_Graphics2D_API;
+using ppapi::thunk::PPB_ImageData_API;
+using ppapi::thunk::PPB_Instance_FunctionAPI;
+using ppapi::thunk::PPB_Surface3D_API;
using WebKit::WebBindings;
using WebKit::WebCanvas;
using WebKit::WebCursorInfo;
@@ -400,10 +402,11 @@ bool PluginInstance::SetCursor(PP_CursorType_Dev type,
if (!hot_spot)
return false;
- scoped_refptr<PPB_ImageData_Impl> image_data(
- Resource::GetAs<PPB_ImageData_Impl>(custom_image));
- if (!image_data.get())
+ EnterResourceNoLock<PPB_ImageData_API> enter(custom_image, true);
+ if (enter.failed())
return false;
+ PPB_ImageData_Impl* image_data =
+ static_cast<PPB_ImageData_Impl*>(enter.object());
if (image_data->format() != PPB_ImageData_Impl::GetNativeImageDataFormat()) {
// TODO(yzshen): Handle the case that the image format is different from the
@@ -1136,9 +1139,17 @@ bool PluginInstance::PrintPDFOutput(PP_Resource print_output,
bool PluginInstance::PrintRasterOutput(PP_Resource print_output,
WebKit::WebCanvas* canvas) {
- scoped_refptr<PPB_ImageData_Impl> image(
- Resource::GetAs<PPB_ImageData_Impl>(print_output));
- if (!image.get() || !image->is_mapped())
+ EnterResourceNoLock<PPB_ImageData_API> enter(print_output, true);
+ if (enter.failed())
+ return false;
+ PPB_ImageData_Impl* image =
+ static_cast<PPB_ImageData_Impl*>(enter.object());
+
+ // TODO(brettw) this should not require the image to be mapped. It should
+ // instead map on demand. The DCHECK here is to remind you if you see the
+ // assert fire, fix the bug rather than mapping the data.
+ DCHECK(image->is_mapped());
+ if (!image->is_mapped())
return false;
const SkBitmap* bitmap = image->GetMappedBitmap();
@@ -1278,14 +1289,18 @@ PPB_Graphics2D_Impl* PluginInstance::bound_graphics_2d() const {
if (bound_graphics_.get() == NULL)
return NULL;
- return bound_graphics_->Cast<PPB_Graphics2D_Impl>();
+ if (bound_graphics_->AsPPB_Graphics2D_API())
+ return static_cast<PPB_Graphics2D_Impl*>(bound_graphics_.get());
+ return NULL;
}
PPB_Surface3D_Impl* PluginInstance::bound_graphics_3d() const {
if (bound_graphics_.get() == NULL)
return NULL;
- return bound_graphics_->Cast<PPB_Surface3D_Impl>();
+ if (bound_graphics_->AsPPB_Surface3D_API())
+ return static_cast<PPB_Surface3D_Impl*>(bound_graphics_.get());
+ return NULL;
}
void PluginInstance::setBackingTextureId(unsigned int id) {
@@ -1372,9 +1387,9 @@ PP_Bool PluginInstance::BindGraphics(PP_Instance instance,
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;
- // Surface3D not converted to API yet.
- scoped_refptr<PPB_Surface3D_Impl> graphics_3d =
- Resource::GetAs<PPB_Surface3D_Impl>(device);
+ 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;
if (graphics_2d) {
// Refuse to bind if we're transitioning to fullscreen.
diff --git a/webkit/plugins/ppapi/ppb_broker_impl.cc b/webkit/plugins/ppapi/ppb_broker_impl.cc
index 7d2aec0..4646faf 100644
--- a/webkit/plugins/ppapi/ppb_broker_impl.cc
+++ b/webkit/plugins/ppapi/ppb_broker_impl.cc
@@ -57,10 +57,6 @@ PP_Resource PPB_Broker_Impl::Create(PP_Instance instance_id) {
return broker->GetReference();
}
-PPB_Broker_Impl* PPB_Broker_Impl::AsPPB_Broker_Impl() {
- return this;
-}
-
PPB_Broker_API* PPB_Broker_Impl::AsPPB_Broker_API() {
return this;
}
diff --git a/webkit/plugins/ppapi/ppb_broker_impl.h b/webkit/plugins/ppapi/ppb_broker_impl.h
index 9ae920e..d3c6295 100644
--- a/webkit/plugins/ppapi/ppb_broker_impl.h
+++ b/webkit/plugins/ppapi/ppb_broker_impl.h
@@ -28,9 +28,6 @@ class PPB_Broker_Impl : public Resource,
static PP_Resource Create(PP_Instance instance_id);
- // Resource override.
- virtual PPB_Broker_Impl* AsPPB_Broker_Impl() OVERRIDE;
-
// ResourceObjectBase override.
virtual ::ppapi::thunk::PPB_Broker_API* AsPPB_Broker_API() OVERRIDE;
diff --git a/webkit/plugins/ppapi/ppb_context_3d_impl.cc b/webkit/plugins/ppapi/ppb_context_3d_impl.cc
index 250f6b1..e680217 100644
--- a/webkit/plugins/ppapi/ppb_context_3d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_context_3d_impl.cc
@@ -10,10 +10,15 @@
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "gpu/command_buffer/common/command_buffer.h"
#include "ppapi/c/dev/ppb_context_3d_trusted_dev.h"
+#include "ppapi/thunk/enter.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_surface_3d_impl.h"
+using ppapi::thunk::EnterResourceNoLock;
+using ppapi::thunk::PPB_Context3D_API;
+using ppapi::thunk::PPB_Surface3D_API;
+
namespace webkit {
namespace ppapi {
@@ -23,21 +28,27 @@ namespace {
const int32 kCommandBufferSize = 1024 * 1024;
const int32 kTransferBufferSize = 1024 * 1024;
-bool ShmToHandle(base::SharedMemory* shm,
- size_t size,
- int* shm_handle,
- uint32_t* shm_size) {
+PP_Bool ShmToHandle(base::SharedMemory* shm,
+ size_t size,
+ int* shm_handle,
+ uint32_t* shm_size) {
if (!shm || !shm_handle || !shm_size)
- return false;
+ return PP_FALSE;
#if defined(OS_POSIX)
- *shm_handle = shm->handle().fd;
+ *shm_handle = shm->handle().fd;
#elif defined(OS_WIN)
- *shm_handle = reinterpret_cast<int>(shm->handle());
+ *shm_handle = reinterpret_cast<int>(shm->handle());
#else
- #error "Platform not supported."
+ #error "Platform not supported."
#endif
- *shm_size = size;
- return true;
+ *shm_size = size;
+ return PP_TRUE;
+}
+
+PP_Context3DTrustedState GetErrorState() {
+ PP_Context3DTrustedState error_state = { 0 };
+ error_state.error = kGenericError;
+ return error_state;
}
PP_Context3DTrustedState PPStateFromGPUState(
@@ -53,16 +64,32 @@ PP_Context3DTrustedState PPStateFromGPUState(
return state;
}
-PP_Resource Create(PP_Instance instance_id,
- PP_Config3D_Dev config,
- PP_Resource share_context,
- const int32_t* attrib_list) {
+} // namespace
+
+PPB_Context3D_Impl::PPB_Context3D_Impl(PluginInstance* instance)
+ : Resource(instance),
+ instance_(instance),
+ transfer_buffer_id_(0),
+ draw_surface_(NULL),
+ read_surface_(NULL),
+ callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+}
+
+PPB_Context3D_Impl::~PPB_Context3D_Impl() {
+ Destroy();
+}
+
+// static
+PP_Resource PPB_Context3D_Impl::Create(PP_Instance pp_instance,
+ PP_Config3D_Dev config,
+ PP_Resource share_context,
+ const int32_t* attrib_list) {
// TODO(alokp): Support shared context.
DCHECK_EQ(0, share_context);
if (share_context != 0)
return 0;
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance);
if (!instance)
return 0;
@@ -74,63 +101,17 @@ PP_Resource Create(PP_Instance instance_id,
return context->GetReference();
}
-PP_Bool IsContext3D(PP_Resource resource) {
- return BoolToPPBool(!!Resource::GetAs<PPB_Context3D_Impl>(resource));
-}
-
-int32_t GetAttrib(PP_Resource context,
- int32_t attribute,
- int32_t* value) {
- // TODO(alokp): Implement me.
- return 0;
-}
-
-int32_t BindSurfaces(PP_Resource context_id,
- PP_Resource draw,
- PP_Resource read) {
- scoped_refptr<PPB_Context3D_Impl> context(
- Resource::GetAs<PPB_Context3D_Impl>(context_id));
- if (!context.get())
- return PP_ERROR_BADRESOURCE;
-
- scoped_refptr<PPB_Surface3D_Impl> draw_surface(
- Resource::GetAs<PPB_Surface3D_Impl>(draw));
- if (!draw_surface.get())
- return PP_ERROR_BADRESOURCE;
-
- scoped_refptr<PPB_Surface3D_Impl> read_surface(
- Resource::GetAs<PPB_Surface3D_Impl>(read));
- if (!read_surface.get())
- return PP_ERROR_BADRESOURCE;
-
- return context->BindSurfaces(draw_surface.get(), read_surface.get());
-}
-
-int32_t GetBoundSurfaces(PP_Resource context,
- PP_Resource* draw,
- PP_Resource* read) {
- // TODO(alokp): Implement me.
- return 0;
-}
-
-const PPB_Context3D_Dev ppb_context3d = {
- &Create,
- &IsContext3D,
- &GetAttrib,
- &BindSurfaces,
- &GetBoundSurfaces,
-};
-
-PP_Resource CreateRaw(PP_Instance instance_id,
- PP_Config3D_Dev config,
- PP_Resource share_context,
- const int32_t* attrib_list) {
+// static
+PP_Resource PPB_Context3D_Impl::CreateRaw(PP_Instance pp_instance,
+ PP_Config3D_Dev config,
+ PP_Resource share_context,
+ const int32_t* attrib_list) {
// TODO(alokp): Support shared context.
DCHECK_EQ(0, share_context);
if (share_context != 0)
return 0;
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance);
if (!instance)
return 0;
@@ -142,142 +123,157 @@ PP_Resource CreateRaw(PP_Instance instance_id,
return context->GetReference();
}
-PP_Bool Initialize(PP_Resource context_id, int32_t size) {
- scoped_refptr<PPB_Context3D_Impl> context(
- Resource::GetAs<PPB_Context3D_Impl>(context_id));
- if (!context.get() || !context->command_buffer())
- return PP_FALSE;
- return context->command_buffer()->Initialize(size) ? PP_TRUE : PP_FALSE;
+PPB_Context3D_API* PPB_Context3D_Impl::AsPPB_Context3D_API() {
+ return this;
}
-PP_Bool GetRingBuffer(PP_Resource context_id,
- int* shm_handle,
- uint32_t* shm_size) {
- scoped_refptr<PPB_Context3D_Impl> context(
- Resource::GetAs<PPB_Context3D_Impl>(context_id));
- if (!context.get() || !context->command_buffer())
- return PP_FALSE;
+int32_t PPB_Context3D_Impl::GetAttrib(int32_t attribute, int32_t* value) {
+ // TODO(alokp): Implement me.
+ return 0;
+}
+
+int32_t PPB_Context3D_Impl::BindSurfaces(PP_Resource draw, PP_Resource read) {
+ EnterResourceNoLock<PPB_Surface3D_API> enter_draw(draw, true);
+ if (enter_draw.failed())
+ return PP_ERROR_BADRESOURCE;
+ PPB_Surface3D_Impl* new_draw =
+ static_cast<PPB_Surface3D_Impl*>(enter_draw.object());
+
+ EnterResourceNoLock<PPB_Surface3D_API> enter_read(read, true);
+ if (enter_read.failed())
+ return PP_ERROR_BADRESOURCE;
+ PPB_Surface3D_Impl* new_read =
+ static_cast<PPB_Surface3D_Impl*>(enter_read.object());
- gpu::Buffer buffer = context->command_buffer()->GetRingBuffer();
+ // TODO(alokp): Support separate draw-read surfaces.
+ DCHECK_EQ(new_draw, new_read);
+ if (new_draw != new_read)
+ return PP_GRAPHICS3DERROR_BAD_MATCH;
+
+ if (new_draw == draw_surface_)
+ return PP_OK;
- return ShmToHandle(buffer.shared_memory, buffer.size, shm_handle, shm_size)
- ? PP_TRUE : PP_FALSE;
+ if (new_draw->context())
+ return PP_GRAPHICS3DERROR_BAD_ACCESS; // Already bound.
+
+ if (draw_surface_)
+ draw_surface_->BindToContext(NULL);
+ if (!new_draw->BindToContext(this))
+ return PP_ERROR_NOMEMORY;
+
+ draw_surface_ = new_draw;
+ read_surface_ = new_read;
+ return PP_OK;
}
-PP_Context3DTrustedState GetState(PP_Resource context_id) {
- scoped_refptr<PPB_Context3D_Impl> context(
- Resource::GetAs<PPB_Context3D_Impl>(context_id));
- if (!context.get() || !context->command_buffer()) {
- PP_Context3DTrustedState error_state = { 0 };
- return error_state;
- }
+int32_t PPB_Context3D_Impl::GetBoundSurfaces(PP_Resource* draw,
+ PP_Resource* read) {
+ // TODO(alokp): Implement me.
+ return 0;
+}
- return PPStateFromGPUState(context->command_buffer()->GetState());
+PP_Bool PPB_Context3D_Impl::InitializeTrusted(int32_t size) {
+ if (!platform_context_.get())
+ return PP_FALSE;
+ return PP_FromBool(platform_context_->GetCommandBuffer()->Initialize(size));
}
-PP_Bool Flush(PP_Resource context_id, int32_t put_offset) {
- scoped_refptr<PPB_Context3D_Impl> context(
- Resource::GetAs<PPB_Context3D_Impl>(context_id));
- if (!context.get() || !context->command_buffer())
+PP_Bool PPB_Context3D_Impl::GetRingBuffer(int* shm_handle,
+ uint32_t* shm_size) {
+ if (!platform_context_.get())
return PP_FALSE;
+ gpu::Buffer buffer = platform_context_->GetCommandBuffer()->GetRingBuffer();
+ return ShmToHandle(buffer.shared_memory, buffer.size, shm_handle, shm_size);
+}
- context->command_buffer()->Flush(put_offset);
- return PP_TRUE;
+PP_Context3DTrustedState PPB_Context3D_Impl::GetState() {
+ if (!platform_context_.get())
+ return GetErrorState();
+ return PPStateFromGPUState(platform_context_->GetCommandBuffer()->GetState());
}
-PP_Context3DTrustedState FlushSync(PP_Resource context_id, int32_t put_offset) {
- scoped_refptr<PPB_Context3D_Impl> context(
- Resource::GetAs<PPB_Context3D_Impl>(context_id));
- if (!context.get() || !context->command_buffer()) {
- PP_Context3DTrustedState error_state = { 0 };
- return error_state;
- }
+PP_Bool PPB_Context3D_Impl::Flush(int32_t put_offset) {
+ if (!platform_context_.get())
+ return PP_FALSE;
+ platform_context_->GetCommandBuffer()->Flush(put_offset);
+ return PP_TRUE;
+}
- gpu::CommandBuffer::State state = context->command_buffer()->GetState();
+PP_Context3DTrustedState PPB_Context3D_Impl::FlushSync(int32_t put_offset) {
+ if (!platform_context_.get())
+ return GetErrorState();
+ gpu::CommandBuffer::State state =
+ platform_context_->GetCommandBuffer()->GetState();
return PPStateFromGPUState(
- context->command_buffer()->FlushSync(put_offset, state.get_offset));
+ platform_context_->GetCommandBuffer()->FlushSync(put_offset,
+ state.get_offset));
}
-int32_t CreateTransferBuffer(PP_Resource context_id, uint32_t size) {
- scoped_refptr<PPB_Context3D_Impl> context(
- Resource::GetAs<PPB_Context3D_Impl>(context_id));
- if (!context.get() || !context->command_buffer())
+int32_t PPB_Context3D_Impl::CreateTransferBuffer(uint32_t size) {
+ if (!platform_context_.get())
return 0;
- return context->command_buffer()->CreateTransferBuffer(size, -1);
+ return platform_context_->GetCommandBuffer()->CreateTransferBuffer(size, -1);
}
-PP_Bool DestroyTransferBuffer(PP_Resource context_id, int32_t id) {
- scoped_refptr<PPB_Context3D_Impl> context(
- Resource::GetAs<PPB_Context3D_Impl>(context_id));
- if (!context.get() || !context->command_buffer())
+PP_Bool PPB_Context3D_Impl::DestroyTransferBuffer(int32_t id) {
+ if (!platform_context_.get())
return PP_FALSE;
- context->command_buffer()->DestroyTransferBuffer(id);
+ platform_context_->GetCommandBuffer()->DestroyTransferBuffer(id);
return PP_TRUE;
}
-PP_Bool GetTransferBuffer(PP_Resource context_id,
- int32_t id,
- int* shm_handle,
- uint32_t* shm_size) {
- scoped_refptr<PPB_Context3D_Impl> context(
- Resource::GetAs<PPB_Context3D_Impl>(context_id));
- if (!context.get() || !context->command_buffer())
+PP_Bool PPB_Context3D_Impl::GetTransferBuffer(int32_t id,
+ int* shm_handle,
+ uint32_t* shm_size) {
+ if (!platform_context_.get())
return PP_FALSE;
- gpu::Buffer buffer = context->command_buffer()->GetTransferBuffer(id);
-
- return ShmToHandle(buffer.shared_memory, buffer.size, shm_handle, shm_size)
- ? PP_TRUE : PP_FALSE;
+ gpu::Buffer buffer =
+ platform_context_->GetCommandBuffer()->GetTransferBuffer(id);
+ return ShmToHandle(buffer.shared_memory, buffer.size, shm_handle, shm_size);
}
-PP_Context3DTrustedState FlushSyncFast(
- PP_Resource context_id, int32_t put_offset, int32 last_known_get) {
- scoped_refptr<PPB_Context3D_Impl> context(
- Resource::GetAs<PPB_Context3D_Impl>(context_id));
- if (!context.get() || !context->command_buffer()) {
- PP_Context3DTrustedState error_state = { 0 };
- return error_state;
- }
-
+PP_Context3DTrustedState PPB_Context3D_Impl::FlushSyncFast(
+ int32_t put_offset,
+ int32_t last_known_get) {
+ if (!platform_context_.get())
+ return GetErrorState();
return PPStateFromGPUState(
- context->command_buffer()->FlushSync(put_offset, last_known_get));
+ platform_context_->GetCommandBuffer()->FlushSync(put_offset,
+ last_known_get));
}
-} // namespace
-PPB_Context3D_Impl::PPB_Context3D_Impl(PluginInstance* instance)
- : Resource(instance),
- instance_(instance),
- transfer_buffer_id_(0),
- draw_surface_(NULL),
- read_surface_(NULL),
- callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+void* PPB_Context3D_Impl::MapTexSubImage2DCHROMIUM(GLenum target,
+ GLint level,
+ GLint xoffset,
+ GLint yoffset,
+ GLsizei width,
+ GLsizei height,
+ GLenum format,
+ GLenum type,
+ GLenum access) {
+ if (!gles2_impl_.get())
+ return NULL;
+ return gles2_impl_->MapTexSubImage2DCHROMIUM(
+ target, level, xoffset, yoffset, width, height, format, type, access);
}
-PPB_Context3D_Impl::~PPB_Context3D_Impl() {
- Destroy();
+void PPB_Context3D_Impl::UnmapTexSubImage2DCHROMIUM(const void* mem) {
+ if (gles2_impl_.get())
+ gles2_impl_->UnmapTexSubImage2DCHROMIUM(mem);
}
-const PPB_Context3D_Dev* PPB_Context3D_Impl::GetInterface() {
- return &ppb_context3d;
-}
+bool PPB_Context3D_Impl::Init(PP_Config3D_Dev config,
+ PP_Resource share_context,
+ const int32_t* attrib_list) {
+ if (!InitRaw(config, share_context, attrib_list))
+ return false;
-const PPB_Context3DTrusted_Dev* PPB_Context3D_Impl::GetTrustedInterface() {
- static const PPB_Context3DTrusted_Dev iface = {
- &CreateRaw,
- &Initialize,
- &GetRingBuffer,
- &GetState,
- &Flush,
- &FlushSync,
- &CreateTransferBuffer,
- &DestroyTransferBuffer,
- &GetTransferBuffer,
- &FlushSyncFast,
- };
- return &iface;
-}
+ if (!CreateImplementation()) {
+ Destroy();
+ return false;
+ }
-PPB_Context3D_Impl* PPB_Context3D_Impl::AsPPB_Context3D_Impl() {
- return this;
+ return true;
}
bool PPB_Context3D_Impl::InitRaw(PP_Config3D_Dev config,
@@ -298,20 +294,6 @@ bool PPB_Context3D_Impl::InitRaw(PP_Config3D_Dev config,
return true;
}
-bool PPB_Context3D_Impl::Init(PP_Config3D_Dev config,
- PP_Resource share_context,
- const int32_t* attrib_list) {
- if (!InitRaw(config, share_context, attrib_list))
- return false;
-
- if (!CreateImplementation()) {
- Destroy();
- return false;
- }
-
- return true;
-}
-
bool PPB_Context3D_Impl::CreateImplementation() {
gpu::CommandBuffer* command_buffer = platform_context_->GetCommandBuffer();
DCHECK(command_buffer);
@@ -348,37 +330,15 @@ bool PPB_Context3D_Impl::CreateImplementation() {
return true;
}
-int32_t PPB_Context3D_Impl::BindSurfaces(PPB_Surface3D_Impl* draw,
- PPB_Surface3D_Impl* read) {
- // TODO(alokp): Support separate draw-read surfaces.
- DCHECK_EQ(draw, read);
- if (draw != read)
- return PP_GRAPHICS3DERROR_BAD_MATCH;
-
- if (draw == draw_surface_)
- return PP_OK;
-
- if (draw && draw->context())
- return PP_GRAPHICS3DERROR_BAD_ACCESS;
-
- if (draw_surface_)
- draw_surface_->BindToContext(NULL);
- if (draw && !draw->BindToContext(this))
- return PP_ERROR_NOMEMORY;
-
- draw_surface_ = draw;
- read_surface_ = read;
- return PP_OK;
-}
-
void PPB_Context3D_Impl::Destroy() {
if (draw_surface_)
draw_surface_->BindToContext(NULL);
gles2_impl_.reset();
- if (command_buffer() && transfer_buffer_id_ != 0) {
- command_buffer()->DestroyTransferBuffer(transfer_buffer_id_);
+ if (platform_context_.get() && transfer_buffer_id_ != 0) {
+ platform_context_->GetCommandBuffer()->DestroyTransferBuffer(
+ transfer_buffer_id_);
transfer_buffer_id_ = 0;
}
@@ -393,9 +353,5 @@ void PPB_Context3D_Impl::OnContextLost() {
read_surface_->OnContextLost();
}
-gpu::CommandBuffer *PPB_Context3D_Impl::command_buffer() {
- return platform_context_.get() ? platform_context_->GetCommandBuffer() : NULL;
-}
-
} // namespace ppapi
} // namespace webkit
diff --git a/webkit/plugins/ppapi/ppb_context_3d_impl.h b/webkit/plugins/ppapi/ppb_context_3d_impl.h
index 2b3e66e..f4660dd 100644
--- a/webkit/plugins/ppapi/ppb_context_3d_impl.h
+++ b/webkit/plugins/ppapi/ppb_context_3d_impl.h
@@ -7,7 +7,7 @@
#include "base/memory/scoped_callback_factory.h"
#include "base/memory/scoped_ptr.h"
-#include "ppapi/c/dev/ppb_context_3d_dev.h"
+#include "ppapi/thunk/ppb_context_3d_api.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/resource.h"
@@ -26,50 +26,81 @@ namespace ppapi {
class PPB_Surface3D_Impl;
-class PPB_Context3D_Impl : public Resource {
+class PPB_Context3D_Impl : public Resource,
+ public ::ppapi::thunk::PPB_Context3D_API {
public:
- explicit PPB_Context3D_Impl(PluginInstance* instance);
virtual ~PPB_Context3D_Impl();
- static const PPB_Context3D_Dev* GetInterface();
- static const PPB_Context3DTrusted_Dev* GetTrustedInterface();
-
- // Resource override.
- virtual PPB_Context3D_Impl* AsPPB_Context3D_Impl();
+ static PP_Resource Create(PP_Instance instance,
+ PP_Config3D_Dev config,
+ PP_Resource share_context,
+ const int32_t* attrib_list);
+ static PP_Resource CreateRaw(PP_Instance instance,
+ PP_Config3D_Dev config,
+ PP_Resource share_context,
+ const int32_t* attrib_list);
+
+ // ResourceObjectBase override.
+ virtual ::ppapi::thunk::PPB_Context3D_API* AsPPB_Context3D_API();
+
+ // PPB_Context3D_API implementation.
+ virtual int32_t GetAttrib(int32_t attribute, int32_t* value) OVERRIDE;
+ virtual int32_t BindSurfaces(PP_Resource draw, PP_Resource read) OVERRIDE;
+ virtual int32_t GetBoundSurfaces(PP_Resource* draw,
+ PP_Resource* read) OVERRIDE;
+ virtual PP_Bool InitializeTrusted(int32_t size) OVERRIDE;
+ virtual PP_Bool GetRingBuffer(int* shm_handle,
+ uint32_t* shm_size) OVERRIDE;
+ virtual PP_Context3DTrustedState GetState() OVERRIDE;
+ virtual PP_Bool Flush(int32_t put_offset) OVERRIDE;
+ virtual PP_Context3DTrustedState FlushSync(int32_t put_offset) OVERRIDE;
+ virtual int32_t CreateTransferBuffer(uint32_t size) OVERRIDE;
+ virtual PP_Bool DestroyTransferBuffer(int32_t id) OVERRIDE;
+ virtual PP_Bool GetTransferBuffer(int32_t id,
+ int* shm_handle,
+ uint32_t* shm_size) OVERRIDE;
+ virtual PP_Context3DTrustedState FlushSyncFast(
+ int32_t put_offset,
+ int32_t last_known_get) OVERRIDE;
+ virtual void* MapTexSubImage2DCHROMIUM(GLenum target,
+ GLint level,
+ GLint xoffset,
+ GLint yoffset,
+ GLsizei width,
+ GLsizei height,
+ GLenum format,
+ GLenum type,
+ GLenum access) OVERRIDE;
+ virtual void UnmapTexSubImage2DCHROMIUM(const void* mem) OVERRIDE;
- bool Init(PP_Config3D_Dev config,
- PP_Resource share_context,
- const int32_t* attrib_list);
- bool InitRaw(PP_Config3D_Dev config,
- PP_Resource share_context,
- const int32_t* attrib_list);
-
- PluginInstance* instance() {
- return instance_;
+ gpu::gles2::GLES2Implementation* gles2_impl() {
+ return gles2_impl_.get();
}
+ // Possibly NULL if initialization fails.
PluginDelegate::PlatformContext3D* platform_context() {
return platform_context_.get();
}
- gpu::gles2::GLES2Implementation* gles2_impl() {
- return gles2_impl_.get();
- }
-
- gpu::CommandBuffer* command_buffer();
+ private:
+ explicit PPB_Context3D_Impl(PluginInstance* instance);
- int32_t BindSurfaces(PPB_Surface3D_Impl* draw,
- PPB_Surface3D_Impl* read);
+ bool Init(PP_Config3D_Dev config,
+ PP_Resource share_context,
+ const int32_t* attrib_list);
+ bool InitRaw(PP_Config3D_Dev config,
+ PP_Resource share_context,
+ const int32_t* attrib_list);
- private:
- void Destroy();
bool CreateImplementation();
+ void Destroy();
void OnContextLost();
// Plugin instance this context is associated with.
PluginInstance* instance_;
// PluginDelegate's 3D Context. Responsible for providing the command buffer.
+ // Possibly NULL.
scoped_ptr<PluginDelegate::PlatformContext3D> platform_context_;
scoped_ptr<gpu::gles2::GLES2CmdHelper> helper_;
diff --git a/webkit/plugins/ppapi/ppb_directory_reader_impl.cc b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
index cba21d5..cb95b11 100644
--- a/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
+++ b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
@@ -73,11 +73,6 @@ PP_Resource PPB_DirectoryReader_Impl::Create(PP_Resource directory_ref) {
return reader->GetReference();
}
-PPB_DirectoryReader_Impl*
-PPB_DirectoryReader_Impl::AsPPB_DirectoryReader_Impl() {
- return this;
-}
-
PPB_DirectoryReader_API* PPB_DirectoryReader_Impl::AsPPB_DirectoryReader_API() {
return this;
}
diff --git a/webkit/plugins/ppapi/ppb_directory_reader_impl.h b/webkit/plugins/ppapi/ppb_directory_reader_impl.h
index 67be4a5..4c58f47 100644
--- a/webkit/plugins/ppapi/ppb_directory_reader_impl.h
+++ b/webkit/plugins/ppapi/ppb_directory_reader_impl.h
@@ -29,9 +29,6 @@ class PPB_DirectoryReader_Impl
static PP_Resource Create(PP_Resource directory_ref);
- // Resource overrides.
- virtual PPB_DirectoryReader_Impl* AsPPB_DirectoryReader_Impl() OVERRIDE;
-
// ResourceObjectBase overrides.
virtual ::ppapi::thunk::PPB_DirectoryReader_API* AsPPB_DirectoryReader_API()
OVERRIDE;
diff --git a/webkit/plugins/ppapi/ppb_flash_file_impl.cc b/webkit/plugins/ppapi/ppb_flash_file_impl.cc
index d285dff..bce105f 100644
--- a/webkit/plugins/ppapi/ppb_flash_file_impl.cc
+++ b/webkit/plugins/ppapi/ppb_flash_file_impl.cc
@@ -11,6 +11,7 @@
#include "ppapi/c/dev/pp_file_info_dev.h"
#include "ppapi/c/dev/ppb_file_io_dev.h"
#include "ppapi/c/private/ppb_flash_file.h"
+#include "ppapi/thunk/enter.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/file_path.h"
#include "webkit/plugins/ppapi/file_type_conversions.h"
@@ -24,6 +25,9 @@
#include "base/utf_string_conversions.h"
#endif
+using ppapi::thunk::EnterResource;
+using ppapi::thunk::PPB_FileRef_API;
+
namespace webkit {
namespace ppapi {
@@ -214,10 +218,10 @@ int32_t OpenFileRefFile(PP_Resource file_ref_id,
if (!PepperFileOpenFlagsToPlatformFileFlags(mode, &flags) || !file)
return PP_ERROR_BADARGUMENT;
- scoped_refptr<PPB_FileRef_Impl> file_ref(
- Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
- if (!file_ref)
+ EnterResource<PPB_FileRef_API> enter(file_ref_id, true);
+ if (enter.failed())
return PP_ERROR_BADRESOURCE;
+ PPB_FileRef_Impl* file_ref = static_cast<PPB_FileRef_Impl*>(enter.object());
PluginInstance* instance = file_ref->instance();
if (!instance)
@@ -234,10 +238,10 @@ int32_t OpenFileRefFile(PP_Resource file_ref_id,
int32_t QueryFileRefFile(PP_Resource file_ref_id,
PP_FileInfo_Dev* info) {
- scoped_refptr<PPB_FileRef_Impl> file_ref(
- Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
- if (!file_ref)
+ EnterResource<PPB_FileRef_API> enter(file_ref_id, true);
+ if (enter.failed())
return PP_ERROR_BADRESOURCE;
+ PPB_FileRef_Impl* file_ref = static_cast<PPB_FileRef_Impl*>(enter.object());
PluginInstance* instance = file_ref->instance();
if (!instance)
diff --git a/webkit/plugins/ppapi/ppb_flash_impl.cc b/webkit/plugins/ppapi/ppb_flash_impl.cc
index 0898da8..46f9cd91 100644
--- a/webkit/plugins/ppapi/ppb_flash_impl.cc
+++ b/webkit/plugins/ppapi/ppb_flash_impl.cc
@@ -10,6 +10,7 @@
#include "base/time.h"
#include "googleurl/src/gurl.h"
#include "ppapi/c/private/ppb_flash.h"
+#include "ppapi/thunk/enter.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
@@ -18,6 +19,9 @@
#include "webkit/plugins/ppapi/resource_tracker.h"
#include "webkit/plugins/ppapi/var.h"
+using ppapi::thunk::EnterResource;
+using ppapi::thunk::PPB_URLRequestInfo_API;
+
namespace webkit {
namespace ppapi {
@@ -48,10 +52,11 @@ PP_Var GetProxyForURL(PP_Instance pp_instance, const char* url) {
int32_t Navigate(PP_Resource request_id,
const char* target,
bool from_user_action) {
- scoped_refptr<PPB_URLRequestInfo_Impl> request(
- Resource::GetAs<PPB_URLRequestInfo_Impl>(request_id));
- if (!request)
+ EnterResource<PPB_URLRequestInfo_API> enter(request_id, true);
+ if (enter.failed())
return PP_ERROR_BADRESOURCE;
+ PPB_URLRequestInfo_Impl* request =
+ static_cast<PPB_URLRequestInfo_Impl*>(enter.object());
if (!target)
return PP_ERROR_BADARGUMENT;
diff --git a/webkit/plugins/ppapi/ppb_flash_impl_linux.cc b/webkit/plugins/ppapi/ppb_flash_impl_linux.cc
index bd554c7b..c698620 100644
--- a/webkit/plugins/ppapi/ppb_flash_impl_linux.cc
+++ b/webkit/plugins/ppapi/ppb_flash_impl_linux.cc
@@ -8,6 +8,7 @@
#include "ppapi/c/pp_point.h"
#include "ppapi/c/pp_rect.h"
#include "ppapi/c/dev/ppb_font_dev.h"
+#include "ppapi/thunk/enter.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/core/SkPaint.h"
@@ -17,6 +18,9 @@
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
#include "webkit/plugins/ppapi/var.h"
+using ppapi::thunk::EnterResource;
+using ppapi::thunk::PPB_ImageData_API;
+
namespace webkit {
namespace ppapi {
@@ -30,10 +34,12 @@ PP_Bool PPB_Flash_Impl::DrawGlyphs(PP_Instance,
uint32_t glyph_count,
const uint16_t glyph_indices[],
const PP_Point glyph_advances[]) {
- scoped_refptr<PPB_ImageData_Impl> image_resource(
- Resource::GetAs<PPB_ImageData_Impl>(pp_image_data));
- if (!image_resource.get())
+ EnterResource<PPB_ImageData_API> enter(pp_image_data, true);
+ if (enter.failed())
return PP_FALSE;
+ PPB_ImageData_Impl* image_resource =
+ static_cast<PPB_ImageData_Impl*>(enter.object());
+
ImageDataAutoMapper mapper(image_resource);
if (!mapper.is_valid())
return PP_FALSE;
diff --git a/webkit/plugins/ppapi/ppb_font_impl.cc b/webkit/plugins/ppapi/ppb_font_impl.cc
index 0da1b3a..b4c06e5 100644
--- a/webkit/plugins/ppapi/ppb_font_impl.cc
+++ b/webkit/plugins/ppapi/ppb_font_impl.cc
@@ -6,6 +6,7 @@
#include "ppapi/c/dev/ppb_font_dev.h"
#include "ppapi/shared_impl/ppapi_preferences.h"
+#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/thunk.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/plugin_module.h"
@@ -14,7 +15,9 @@
#include "webkit/plugins/ppapi/string.h"
#include "webkit/plugins/ppapi/var.h"
-using ::ppapi::WebKitForwarding;
+using ppapi::thunk::EnterResource;
+using ppapi::thunk::PPB_ImageData_API;
+using ppapi::WebKitForwarding;
namespace webkit {
namespace ppapi {
@@ -56,10 +59,6 @@ PPB_Font_Impl::~PPB_Font_Impl() {
return this;
}
-PPB_Font_Impl* PPB_Font_Impl::AsPPB_Font_Impl() {
- return this;
-}
-
PP_Bool PPB_Font_Impl::Describe(PP_FontDescription_Dev* description,
PP_FontMetrics_Dev* metrics) {
std::string face;
@@ -80,10 +79,12 @@ PP_Bool PPB_Font_Impl::DrawTextAt(PP_Resource image_data,
const PP_Rect* clip,
PP_Bool image_data_is_opaque) {
// Get and map the image data we're painting to.
- scoped_refptr<PPB_ImageData_Impl> image_resource(
- Resource::GetAs<PPB_ImageData_Impl>(image_data));
- if (!image_resource.get())
+ EnterResource<PPB_ImageData_API> enter(image_data, true);
+ if (enter.failed())
return PP_FALSE;
+ PPB_ImageData_Impl* image_resource =
+ static_cast<PPB_ImageData_Impl*>(enter.object());
+
ImageDataAutoMapper mapper(image_resource);
if (!mapper.is_valid())
return PP_FALSE;
diff --git a/webkit/plugins/ppapi/ppb_font_impl.h b/webkit/plugins/ppapi/ppb_font_impl.h
index 23416ef..4f1ffff 100644
--- a/webkit/plugins/ppapi/ppb_font_impl.h
+++ b/webkit/plugins/ppapi/ppb_font_impl.h
@@ -30,9 +30,6 @@ class PPB_Font_Impl : public Resource,
// ResourceObjectBase.
virtual ::ppapi::thunk::PPB_Font_API* AsPPB_Font_API() OVERRIDE;
- // Resource overrides.
- virtual PPB_Font_Impl* AsPPB_Font_Impl() OVERRIDE;
-
// PPB_Font implementation.
virtual PP_Bool Describe(PP_FontDescription_Dev* description,
PP_FontMetrics_Dev* metrics) OVERRIDE;
diff --git a/webkit/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.cc b/webkit/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.cc
deleted file mode 100644
index c6df8f8..0000000
--- a/webkit/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "webkit/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.h"
-
-#include "gpu/command_buffer/client/gles2_implementation.h"
-#include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h"
-#include "webkit/plugins/ppapi/ppb_context_3d_impl.h"
-
-namespace webkit {
-namespace ppapi {
-
-namespace {
-
-void* MapTexSubImage2DCHROMIUM(
- PP_Resource context_id,
- GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- GLenum access) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- return context->gles2_impl()->MapTexSubImage2DCHROMIUM(
- target, level, xoffset, yoffset, width, height, format, type, access);
-}
-
-void UnmapTexSubImage2DCHROMIUM(PP_Resource context_id, const void* mem) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->UnmapTexSubImage2DCHROMIUM(mem);
-}
-
-const struct PPB_GLESChromiumTextureMapping_Dev ppb_gles_chromium_extension = {
- &MapTexSubImage2DCHROMIUM,
- &UnmapTexSubImage2DCHROMIUM
-};
-
-} // namespace
-
-const PPB_GLESChromiumTextureMapping_Dev*
-PPB_GLESChromiumTextureMapping_Impl::GetInterface() {
- return &ppb_gles_chromium_extension;
-}
-
-} // namespace ppapi
-} // namespace webkit
-
diff --git a/webkit/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.h b/webkit/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.h
deleted file mode 100644
index ae592b4..0000000
--- a/webkit/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef WEBKIT_PLUGINS_PPAPI_PPB_GLES_CHROMIUM_TEXTURE_MAPPING_IMPL_H_
-#define WEBKIT_PLUGINS_PPAPI_PPB_GLES_CHROMIUM_TEXTURE_MAPPING_IMPL_H_
-
-struct PPB_GLESChromiumTextureMapping_Dev;
-
-namespace webkit {
-namespace ppapi {
-
-class PPB_GLESChromiumTextureMapping_Impl {
- public:
- static const PPB_GLESChromiumTextureMapping_Dev* GetInterface();
-};
-
-} // namespace ppapi
-} // namespace webkit
-
-#endif // WEBKIT_PLUGINS_PPAPI_PPB_GLES_CHROMIUM_TEXTURE_MAPPING_IMPL_H_
-
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index ff54442..b8f148a 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -15,6 +15,7 @@
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/ppb_graphics_2d.h"
#include "ppapi/cpp/common.h"
+#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/thunk.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/blit.h"
@@ -29,6 +30,9 @@
#include "base/mac/scoped_cftyperef.h"
#endif
+using ppapi::thunk::EnterResourceNoLock;
+using ppapi::thunk::PPB_ImageData_API;
+
namespace webkit {
namespace ppapi {
@@ -199,10 +203,11 @@ void PPB_Graphics2D_Impl::PaintImageData(PP_Resource image_data,
if (!top_left)
return;
- scoped_refptr<PPB_ImageData_Impl> image_resource(
- Resource::GetAs<PPB_ImageData_Impl>(image_data));
- if (!image_resource)
+ EnterResourceNoLock<PPB_ImageData_API> enter(image_data, true);
+ if (enter.failed())
return;
+ PPB_ImageData_Impl* image_resource =
+ static_cast<PPB_ImageData_Impl*>(enter.object());
QueuedOperation operation(QueuedOperation::PAINT);
operation.paint_image = image_resource;
@@ -253,10 +258,12 @@ void PPB_Graphics2D_Impl::Scroll(const PP_Rect* clip_rect,
}
void PPB_Graphics2D_Impl::ReplaceContents(PP_Resource image_data) {
- scoped_refptr<PPB_ImageData_Impl> image_resource(
- Resource::GetAs<PPB_ImageData_Impl>(image_data));
- if (!image_resource)
+ EnterResourceNoLock<PPB_ImageData_API> enter(image_data, true);
+ if (enter.failed())
return;
+ PPB_ImageData_Impl* image_resource =
+ static_cast<PPB_ImageData_Impl*>(enter.object());
+
if (!PPB_ImageData_Impl::IsImageDataFormatSupported(
image_resource->format()))
return;
@@ -335,10 +342,11 @@ int32_t PPB_Graphics2D_Impl::Flush(PP_CompletionCallback callback) {
bool PPB_Graphics2D_Impl::ReadImageData(PP_Resource image,
const PP_Point* top_left) {
// Get and validate the image object to paint into.
- scoped_refptr<PPB_ImageData_Impl> image_resource(
- Resource::GetAs<PPB_ImageData_Impl>(image));
- if (!image_resource)
+ EnterResourceNoLock<PPB_ImageData_API> enter(image, true);
+ if (enter.failed())
return false;
+ PPB_ImageData_Impl* image_resource =
+ static_cast<PPB_ImageData_Impl*>(enter.object());
if (!PPB_ImageData_Impl::IsImageDataFormatSupported(
image_resource->format()))
return false; // Must be in the right format.
@@ -369,7 +377,7 @@ bool PPB_Graphics2D_Impl::ReadImageData(PP_Resource image,
if (image_resource->format() != image_data_->format()) {
// Convert the image data if the format does not match.
- ConvertImageData(image_data_, src_irect, image_resource.get(), dest_rect);
+ ConvertImageData(image_data_, src_irect, image_resource, dest_rect);
} else {
skia::PlatformCanvas* dest_canvas = image_resource->mapped_canvas();
diff --git a/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc
index af98225..486c790 100644
--- a/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc
@@ -7,96 +7,49 @@
#include "base/logging.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
-#include "webkit/plugins/ppapi/common.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
+#include "webkit/plugins/ppapi/resource_tracker.h"
+
+using ppapi::thunk::PPB_Graphics3D_API;
namespace webkit {
namespace ppapi {
-namespace {
-
-int32_t GetConfigs(PP_Config3D_Dev* configs,
- int32_t config_size,
- int32_t* num_config) {
- // TODO(alokp): Implement me.
- return PP_ERROR_FAILED;
-}
-
-int32_t GetConfigAttribs(PP_Config3D_Dev config, int32_t* attrib_list) {
- // TODO(alokp): Implement me.
- return PP_ERROR_FAILED;
+PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PluginInstance* instance)
+ : Resource(instance) {
}
-PP_Var GetString(int32_t name) {
- // TODO(alokp): Implement me.
- return PP_MakeUndefined();
+PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() {
}
-PP_Resource Create(PP_Instance instance_id,
- PP_Config3D_Dev config,
- PP_Resource share_context,
- const int32_t* attrib_list) {
- // TODO(alokp): Support shared context.
- DCHECK_EQ(0, share_context);
- if (share_context != 0)
- return 0;
-
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
- if (!instance)
+// static
+PP_Resource PPB_Graphics3D_Impl::Create(PluginInstance* instance,
+ PP_Config3D_Dev config,
+ PP_Resource share_context,
+ const int32_t* attrib_list) {
+ scoped_refptr<PPB_Graphics3D_Impl> t(new PPB_Graphics3D_Impl(instance));
+ if (!t->Init(config, share_context, attrib_list))
return 0;
-
- scoped_refptr<PPB_Graphics3D_Impl> context(
- new PPB_Graphics3D_Impl(instance));
- if (!context->Init(config, share_context, attrib_list))
- return 0;
-
- return context->GetReference();
+ return t->GetReference();
}
-PP_Bool IsGraphics3D(PP_Resource resource) {
- return BoolToPPBool(!!Resource::GetAs<PPB_Graphics3D_Impl>(resource));
+PPB_Graphics3D_API* PPB_Graphics3D_Impl::AsPPB_Graphics3D_API() {
+ return this;
}
-int32_t GetAttribs(PP_Resource context, int32_t* attrib_list) {
+int32_t PPB_Graphics3D_Impl::GetAttribs(int32_t* attrib_list) {
// TODO(alokp): Implement me.
- return 0;
+ return PP_ERROR_FAILED;
}
-int32_t SetAttribs(PP_Resource context, int32_t* attrib_list) {
+int32_t PPB_Graphics3D_Impl::SetAttribs(int32_t* attrib_list) {
// TODO(alokp): Implement me.
- return 0;
+ return PP_ERROR_FAILED;
}
-int32_t SwapBuffers(PP_Resource context, PP_CompletionCallback callback) {
+int32_t PPB_Graphics3D_Impl::SwapBuffers(PP_CompletionCallback callback) {
// TODO(alokp): Implement me.
- return 0;
-}
-
-const PPB_Graphics3D_Dev ppb_graphics3d = {
- &GetConfigs,
- &GetConfigAttribs,
- &GetString,
- &Create,
- &IsGraphics3D,
- &GetAttribs,
- &SetAttribs,
- &SwapBuffers
-};
-
-} // namespace
-
-PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PluginInstance* instance)
- : Resource(instance) {
-}
-
-PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() {
-}
-
-const PPB_Graphics3D_Dev* PPB_Graphics3D_Impl::GetInterface() {
- return &ppb_graphics3d;
-}
-
-PPB_Graphics3D_Impl* PPB_Graphics3D_Impl::AsPPB_Graphics3D_Impl() {
- return this;
+ return PP_ERROR_FAILED;
}
bool PPB_Graphics3D_Impl::Init(PP_Config3D_Dev config,
diff --git a/webkit/plugins/ppapi/ppb_graphics_3d_impl.h b/webkit/plugins/ppapi/ppb_graphics_3d_impl.h
index b9dbc14..8b41297 100644
--- a/webkit/plugins/ppapi/ppb_graphics_3d_impl.h
+++ b/webkit/plugins/ppapi/ppb_graphics_3d_impl.h
@@ -5,27 +5,37 @@
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_
-#include "ppapi/c/dev/ppb_graphics_3d_dev.h"
+#include "ppapi/thunk/ppb_graphics_3d_api.h"
#include "webkit/plugins/ppapi/resource.h"
namespace webkit {
namespace ppapi {
-class PPB_Graphics3D_Impl : public Resource {
+class PPB_Graphics3D_Impl : public Resource,
+ public ::ppapi::thunk::PPB_Graphics3D_API {
public:
- explicit PPB_Graphics3D_Impl(PluginInstance* instance);
virtual ~PPB_Graphics3D_Impl();
- static const PPB_Graphics3D_Dev* GetInterface();
+ static PP_Resource Create(PluginInstance* instance,
+ PP_Config3D_Dev config,
+ PP_Resource share_context,
+ const int32_t* attrib_list);
+
+ // ResourceObjectBase override.
+ virtual ::ppapi::thunk::PPB_Graphics3D_API* AsPPB_Graphics3D_API() OVERRIDE;
+
+ // PPB_Graphics3D_API implementation.
+ virtual int32_t GetAttribs(int32_t* attrib_list) OVERRIDE;
+ virtual int32_t SetAttribs(int32_t* attrib_list) OVERRIDE;
+ virtual int32_t SwapBuffers(PP_CompletionCallback callback) OVERRIDE;
- // Resource override.
- virtual PPB_Graphics3D_Impl* AsPPB_Graphics3D_Impl();
+ private:
+ explicit PPB_Graphics3D_Impl(PluginInstance* instance);
bool Init(PP_Config3D_Dev config,
PP_Resource share_context,
const int32_t* attrib_list);
- private:
DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Impl);
};
diff --git a/webkit/plugins/ppapi/ppb_image_data_impl.cc b/webkit/plugins/ppapi/ppb_image_data_impl.cc
index 5f62f0d..4f40d01 100644
--- a/webkit/plugins/ppapi/ppb_image_data_impl.cc
+++ b/webkit/plugins/ppapi/ppb_image_data_impl.cc
@@ -38,10 +38,6 @@ PPB_ImageData_API* PPB_ImageData_Impl::AsPPB_ImageData_API() {
return this;
}
-PPB_ImageData_Impl* PPB_ImageData_Impl::AsPPB_ImageData_Impl() {
- return this;
-}
-
bool PPB_ImageData_Impl::Init(PP_ImageDataFormat format,
int width, int height,
bool init_to_zero) {
diff --git a/webkit/plugins/ppapi/ppb_image_data_impl.h b/webkit/plugins/ppapi/ppb_image_data_impl.h
index 9d498a1..436efb0 100644
--- a/webkit/plugins/ppapi/ppb_image_data_impl.h
+++ b/webkit/plugins/ppapi/ppb_image_data_impl.h
@@ -50,9 +50,6 @@ class PPB_ImageData_Impl : public Resource,
virtual ::ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() OVERRIDE;
- // Resource overrides.
- virtual PPB_ImageData_Impl* AsPPB_ImageData_Impl() OVERRIDE;
-
// PPB_ImageData_API implementation.
virtual PP_Bool Describe(PP_ImageDataDesc* desc) OVERRIDE;
virtual void* Map() OVERRIDE;
diff --git a/webkit/plugins/ppapi/ppb_layer_compositor_impl.cc b/webkit/plugins/ppapi/ppb_layer_compositor_impl.cc
index 93e3032..c8188ce 100644
--- a/webkit/plugins/ppapi/ppb_layer_compositor_impl.cc
+++ b/webkit/plugins/ppapi/ppb_layer_compositor_impl.cc
@@ -7,59 +7,11 @@
#include "ppapi/c/pp_errors.h"
#include "webkit/plugins/ppapi/common.h"
+using ppapi::thunk::PPB_LayerCompositor_API;
+
namespace webkit {
namespace ppapi {
-namespace {
-
-PP_Resource Create(PP_Instance instance) {
- return 0;
-}
-
-PP_Bool IsLayerCompositor(PP_Resource resource) {
- return PP_FALSE;
-}
-
-PP_Bool AddLayer(PP_Resource compositor, PP_Resource layer) {
- return PP_FALSE;
-}
-
-void RemoveLayer(PP_Resource compositor, PP_Resource layer) {
-}
-
-void SetZIndex(PP_Resource compositor, PP_Resource layer, int32_t index) {
-}
-
-void SetRect(PP_Resource compositor, PP_Resource layer,
- const struct PP_Rect* rect) {
-}
-
-void SetDisplay(PP_Resource compositor, PP_Resource layer,
- PP_Bool is_displayed) {
-}
-
-void MarkAsDirty(PP_Resource compositor, PP_Resource layer) {
-}
-
-int32_t SwapBuffers(PP_Resource compositor,
- struct PP_CompletionCallback callback) {
- return PP_ERROR_FAILED;
-}
-
-const PPB_LayerCompositor_Dev ppb_layercompositor = {
- &Create,
- &IsLayerCompositor,
- &AddLayer,
- &RemoveLayer,
- &SetZIndex,
- &SetRect,
- &SetDisplay,
- &MarkAsDirty,
- &SwapBuffers,
-};
-
-} // namespace
-
PPB_LayerCompositor_Impl::PPB_LayerCompositor_Impl(PluginInstance* instance)
: Resource(instance) {
}
@@ -67,16 +19,11 @@ PPB_LayerCompositor_Impl::PPB_LayerCompositor_Impl(PluginInstance* instance)
PPB_LayerCompositor_Impl::~PPB_LayerCompositor_Impl() {
}
-PPB_LayerCompositor_Impl*
-PPB_LayerCompositor_Impl::AsPPB_LayerCompositor_Impl() {
+PPB_LayerCompositor_API*
+PPB_LayerCompositor_Impl::AsPPB_LayerCompositor_API() {
return this;
}
-// static
-const PPB_LayerCompositor_Dev* PPB_LayerCompositor_Impl::GetInterface() {
- return &ppb_layercompositor;
-}
-
PP_Bool PPB_LayerCompositor_Impl::AddLayer(PP_Resource layer) {
return PP_FALSE;
}
@@ -88,7 +35,7 @@ void PPB_LayerCompositor_Impl::SetZIndex(PP_Resource layer, int32_t index) {
}
void PPB_LayerCompositor_Impl::SetRect(PP_Resource layer,
- const struct PP_Rect* rect) {
+ const PP_Rect* rect) {
}
void PPB_LayerCompositor_Impl::SetDisplay(PP_Resource layer,
@@ -98,8 +45,7 @@ void PPB_LayerCompositor_Impl::SetDisplay(PP_Resource layer,
void PPB_LayerCompositor_Impl::MarkAsDirty(PP_Resource layer) {
}
-int32_t PPB_LayerCompositor_Impl::SwapBuffers(
- struct PP_CompletionCallback callback) {
+int32_t PPB_LayerCompositor_Impl::SwapBuffers(PP_CompletionCallback callback) {
return PP_ERROR_FAILED;
}
diff --git a/webkit/plugins/ppapi/ppb_layer_compositor_impl.h b/webkit/plugins/ppapi/ppb_layer_compositor_impl.h
index 7d3a023..601cfa0 100644
--- a/webkit/plugins/ppapi/ppb_layer_compositor_impl.h
+++ b/webkit/plugins/ppapi/ppb_layer_compositor_impl.h
@@ -5,7 +5,7 @@
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_LAYER_COMPOSITOR_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_LAYER_COMPOSITOR_IMPL_H_
-#include "ppapi/c/dev/ppb_layer_compositor_dev.h"
+#include "ppapi/thunk/ppb_layer_compositor_api.h"
#include "webkit/plugins/ppapi/resource.h"
struct PP_Rect;
@@ -16,23 +16,26 @@ namespace ppapi {
class PluginInstance;
-class PPB_LayerCompositor_Impl : public Resource {
+class PPB_LayerCompositor_Impl
+ : public Resource,
+ public ::ppapi::thunk::PPB_LayerCompositor_API {
public:
explicit PPB_LayerCompositor_Impl(PluginInstance* instance);
virtual ~PPB_LayerCompositor_Impl();
static const PPB_LayerCompositor_Dev* GetInterface();
- // Resource override.
- virtual PPB_LayerCompositor_Impl* AsPPB_LayerCompositor_Impl();
-
- PP_Bool AddLayer(PP_Resource layer);
- void RemoveLayer(PP_Resource layer);
- void SetZIndex(PP_Resource layer, int32_t index);
- void SetRect(PP_Resource layer, const struct PP_Rect* rect);
- void SetDisplay(PP_Resource layer, PP_Bool is_displayed);
- void MarkAsDirty(PP_Resource layer);
- int32_t SwapBuffers(struct PP_CompletionCallback callback);
+ // ResourceObjectBase override.
+ virtual PPB_LayerCompositor_API* AsPPB_LayerCompositor_API();
+
+ // PPB_LayerCompositor_API implementation.
+ virtual PP_Bool AddLayer(PP_Resource layer) OVERRIDE;
+ virtual void RemoveLayer(PP_Resource layer) OVERRIDE;
+ virtual void SetZIndex(PP_Resource layer, int32_t index) OVERRIDE;
+ virtual void SetRect(PP_Resource layer, const PP_Rect* rect) OVERRIDE;
+ virtual void SetDisplay(PP_Resource layer, PP_Bool is_displayed) OVERRIDE;
+ virtual void MarkAsDirty(PP_Resource layer) OVERRIDE;
+ virtual int32_t SwapBuffers(PP_CompletionCallback callback) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(PPB_LayerCompositor_Impl);
diff --git a/webkit/plugins/ppapi/ppb_opengles_impl.cc b/webkit/plugins/ppapi/ppb_opengles_impl.cc
index df0ce19..9bd4e5c 100644
--- a/webkit/plugins/ppapi/ppb_opengles_impl.cc
+++ b/webkit/plugins/ppapi/ppb_opengles_impl.cc
@@ -2,1006 +2,758 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// This file is auto-generated. DO NOT EDIT!
+// This file is auto-generated from
+// gpu/command_buffer/build_gles2_cmd_buffer.py
+// DO NOT EDIT!
#include "webkit/plugins/ppapi/ppb_opengles_impl.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "ppapi/c/dev/ppb_opengles_dev.h"
+#include "ppapi/shared_impl/resource_object_base.h"
+#include "ppapi/shared_impl/tracker_base.h"
#include "webkit/plugins/ppapi/ppb_context_3d_impl.h"
+using ppapi::ResourceObjectBase;
+using ppapi::TrackerBase;
+
namespace webkit {
namespace ppapi {
namespace {
+gpu::gles2::GLES2Implementation* GetGLES(PP_Resource context) {
+ ResourceObjectBase* base = TrackerBase::Get()->GetResourceAPI(context);
+ DCHECK(base->AsPPB_Context3D_API());
+ return static_cast<PPB_Context3D_Impl*>(base)->gles2_impl();
+}
+
void ActiveTexture(PP_Resource context_id, GLenum texture) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->ActiveTexture(texture);
+ GetGLES(context_id)->ActiveTexture(texture);
}
void AttachShader(PP_Resource context_id, GLuint program, GLuint shader) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->AttachShader(program, shader);
+ GetGLES(context_id)->AttachShader(program, shader);
}
void BindAttribLocation(
PP_Resource context_id, GLuint program, GLuint index, const char* name) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->BindAttribLocation(program, index, name);
+ GetGLES(context_id)->BindAttribLocation(program, index, name);
}
void BindBuffer(PP_Resource context_id, GLenum target, GLuint buffer) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->BindBuffer(target, buffer);
+ GetGLES(context_id)->BindBuffer(target, buffer);
}
void BindFramebuffer(
PP_Resource context_id, GLenum target, GLuint framebuffer) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->BindFramebuffer(target, framebuffer);
+ GetGLES(context_id)->BindFramebuffer(target, framebuffer);
}
void BindRenderbuffer(
PP_Resource context_id, GLenum target, GLuint renderbuffer) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->BindRenderbuffer(target, renderbuffer);
+ GetGLES(context_id)->BindRenderbuffer(target, renderbuffer);
}
void BindTexture(PP_Resource context_id, GLenum target, GLuint texture) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->BindTexture(target, texture);
+ GetGLES(context_id)->BindTexture(target, texture);
}
void BlendColor(
PP_Resource context_id, GLclampf red, GLclampf green, GLclampf blue,
GLclampf alpha) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->BlendColor(red, green, blue, alpha);
+ GetGLES(context_id)->BlendColor(red, green, blue, alpha);
}
void BlendEquation(PP_Resource context_id, GLenum mode) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->BlendEquation(mode);
+ GetGLES(context_id)->BlendEquation(mode);
}
void BlendEquationSeparate(
PP_Resource context_id, GLenum modeRGB, GLenum modeAlpha) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->BlendEquationSeparate(modeRGB, modeAlpha);
+ GetGLES(context_id)->BlendEquationSeparate(modeRGB, modeAlpha);
}
void BlendFunc(PP_Resource context_id, GLenum sfactor, GLenum dfactor) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->BlendFunc(sfactor, dfactor);
+ GetGLES(context_id)->BlendFunc(sfactor, dfactor);
}
void BlendFuncSeparate(
PP_Resource context_id, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha,
GLenum dstAlpha) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
+ GetGLES(context_id)->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
}
void BufferData(
PP_Resource context_id, GLenum target, GLsizeiptr size, const void* data,
GLenum usage) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->BufferData(target, size, data, usage);
+ GetGLES(context_id)->BufferData(target, size, data, usage);
}
void BufferSubData(
PP_Resource context_id, GLenum target, GLintptr offset, GLsizeiptr size,
const void* data) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->BufferSubData(target, offset, size, data);
+ GetGLES(context_id)->BufferSubData(target, offset, size, data);
}
GLenum CheckFramebufferStatus(PP_Resource context_id, GLenum target) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- return context->gles2_impl()->CheckFramebufferStatus(target);
+ return GetGLES(context_id)->CheckFramebufferStatus(target);
}
void Clear(PP_Resource context_id, GLbitfield mask) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Clear(mask);
+ GetGLES(context_id)->Clear(mask);
}
void ClearColor(
PP_Resource context_id, GLclampf red, GLclampf green, GLclampf blue,
GLclampf alpha) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->ClearColor(red, green, blue, alpha);
+ GetGLES(context_id)->ClearColor(red, green, blue, alpha);
}
void ClearDepthf(PP_Resource context_id, GLclampf depth) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->ClearDepthf(depth);
+ GetGLES(context_id)->ClearDepthf(depth);
}
void ClearStencil(PP_Resource context_id, GLint s) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->ClearStencil(s);
+ GetGLES(context_id)->ClearStencil(s);
}
void ColorMask(
PP_Resource context_id, GLboolean red, GLboolean green, GLboolean blue,
GLboolean alpha) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->ColorMask(red, green, blue, alpha);
+ GetGLES(context_id)->ColorMask(red, green, blue, alpha);
}
void CompileShader(PP_Resource context_id, GLuint shader) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->CompileShader(shader);
+ GetGLES(context_id)->CompileShader(shader);
}
void CompressedTexImage2D(
PP_Resource context_id, GLenum target, GLint level, GLenum internalformat,
GLsizei width, GLsizei height, GLint border, GLsizei imageSize,
const void* data) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->CompressedTexImage2D(
- target, level, internalformat, width, height, border, imageSize, data);
+ GetGLES(
+ context_id)->CompressedTexImage2D(
+ target, level, internalformat, width, height, border, imageSize,
+ data);
}
void CompressedTexSubImage2D(
PP_Resource context_id, GLenum target, GLint level, GLint xoffset,
GLint yoffset, GLsizei width, GLsizei height, GLenum format,
GLsizei imageSize, const void* data) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->CompressedTexSubImage2D(
- target, level, xoffset, yoffset, width, height, format, imageSize, data);
+ GetGLES(
+ context_id)->CompressedTexSubImage2D(
+ target, level, xoffset, yoffset, width, height, format, imageSize,
+ data);
}
void CopyTexImage2D(
PP_Resource context_id, GLenum target, GLint level, GLenum internalformat,
GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->CopyTexImage2D(
- target, level, internalformat, x, y, width, height, border);
+ GetGLES(
+ context_id)->CopyTexImage2D(
+ target, level, internalformat, x, y, width, height, border);
}
void CopyTexSubImage2D(
PP_Resource context_id, GLenum target, GLint level, GLint xoffset,
GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->CopyTexSubImage2D(
- target, level, xoffset, yoffset, x, y, width, height);
+ GetGLES(
+ context_id)->CopyTexSubImage2D(
+ target, level, xoffset, yoffset, x, y, width, height);
}
GLuint CreateProgram(PP_Resource context_id) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- return context->gles2_impl()->CreateProgram();
+ return GetGLES(context_id)->CreateProgram();
}
GLuint CreateShader(PP_Resource context_id, GLenum type) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- return context->gles2_impl()->CreateShader(type);
+ return GetGLES(context_id)->CreateShader(type);
}
void CullFace(PP_Resource context_id, GLenum mode) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->CullFace(mode);
+ GetGLES(context_id)->CullFace(mode);
}
void DeleteBuffers(PP_Resource context_id, GLsizei n, const GLuint* buffers) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->DeleteBuffers(n, buffers);
+ GetGLES(context_id)->DeleteBuffers(n, buffers);
}
void DeleteFramebuffers(
PP_Resource context_id, GLsizei n, const GLuint* framebuffers) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->DeleteFramebuffers(n, framebuffers);
+ GetGLES(context_id)->DeleteFramebuffers(n, framebuffers);
}
void DeleteProgram(PP_Resource context_id, GLuint program) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->DeleteProgram(program);
+ GetGLES(context_id)->DeleteProgram(program);
}
void DeleteRenderbuffers(
PP_Resource context_id, GLsizei n, const GLuint* renderbuffers) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->DeleteRenderbuffers(n, renderbuffers);
+ GetGLES(context_id)->DeleteRenderbuffers(n, renderbuffers);
}
void DeleteShader(PP_Resource context_id, GLuint shader) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->DeleteShader(shader);
+ GetGLES(context_id)->DeleteShader(shader);
}
void DeleteTextures(
PP_Resource context_id, GLsizei n, const GLuint* textures) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->DeleteTextures(n, textures);
+ GetGLES(context_id)->DeleteTextures(n, textures);
}
void DepthFunc(PP_Resource context_id, GLenum func) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->DepthFunc(func);
+ GetGLES(context_id)->DepthFunc(func);
}
void DepthMask(PP_Resource context_id, GLboolean flag) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->DepthMask(flag);
+ GetGLES(context_id)->DepthMask(flag);
}
void DepthRangef(PP_Resource context_id, GLclampf zNear, GLclampf zFar) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->DepthRangef(zNear, zFar);
+ GetGLES(context_id)->DepthRangef(zNear, zFar);
}
void DetachShader(PP_Resource context_id, GLuint program, GLuint shader) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->DetachShader(program, shader);
+ GetGLES(context_id)->DetachShader(program, shader);
}
void Disable(PP_Resource context_id, GLenum cap) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Disable(cap);
+ GetGLES(context_id)->Disable(cap);
}
void DisableVertexAttribArray(PP_Resource context_id, GLuint index) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->DisableVertexAttribArray(index);
+ GetGLES(context_id)->DisableVertexAttribArray(index);
}
void DrawArrays(
PP_Resource context_id, GLenum mode, GLint first, GLsizei count) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->DrawArrays(mode, first, count);
+ GetGLES(context_id)->DrawArrays(mode, first, count);
}
void DrawElements(
PP_Resource context_id, GLenum mode, GLsizei count, GLenum type,
const void* indices) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->DrawElements(mode, count, type, indices);
+ GetGLES(context_id)->DrawElements(mode, count, type, indices);
}
void Enable(PP_Resource context_id, GLenum cap) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Enable(cap);
+ GetGLES(context_id)->Enable(cap);
}
void EnableVertexAttribArray(PP_Resource context_id, GLuint index) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->EnableVertexAttribArray(index);
+ GetGLES(context_id)->EnableVertexAttribArray(index);
}
void Finish(PP_Resource context_id) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Finish();
+ GetGLES(context_id)->Finish();
}
void Flush(PP_Resource context_id) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Flush();
+ GetGLES(context_id)->Flush();
}
void FramebufferRenderbuffer(
PP_Resource context_id, GLenum target, GLenum attachment,
GLenum renderbuffertarget, GLuint renderbuffer) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->FramebufferRenderbuffer(
- target, attachment, renderbuffertarget, renderbuffer);
+ GetGLES(
+ context_id)->FramebufferRenderbuffer(
+ target, attachment, renderbuffertarget, renderbuffer);
}
void FramebufferTexture2D(
PP_Resource context_id, GLenum target, GLenum attachment, GLenum textarget,
GLuint texture, GLint level) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->FramebufferTexture2D(
- target, attachment, textarget, texture, level);
+ GetGLES(
+ context_id)->FramebufferTexture2D(
+ target, attachment, textarget, texture, level);
}
void FrontFace(PP_Resource context_id, GLenum mode) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->FrontFace(mode);
+ GetGLES(context_id)->FrontFace(mode);
}
void GenBuffers(PP_Resource context_id, GLsizei n, GLuint* buffers) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GenBuffers(n, buffers);
+ GetGLES(context_id)->GenBuffers(n, buffers);
}
void GenerateMipmap(PP_Resource context_id, GLenum target) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GenerateMipmap(target);
+ GetGLES(context_id)->GenerateMipmap(target);
}
void GenFramebuffers(PP_Resource context_id, GLsizei n, GLuint* framebuffers) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GenFramebuffers(n, framebuffers);
+ GetGLES(context_id)->GenFramebuffers(n, framebuffers);
}
void GenRenderbuffers(
PP_Resource context_id, GLsizei n, GLuint* renderbuffers) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GenRenderbuffers(n, renderbuffers);
+ GetGLES(context_id)->GenRenderbuffers(n, renderbuffers);
}
void GenTextures(PP_Resource context_id, GLsizei n, GLuint* textures) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GenTextures(n, textures);
+ GetGLES(context_id)->GenTextures(n, textures);
}
void GetActiveAttrib(
PP_Resource context_id, GLuint program, GLuint index, GLsizei bufsize,
GLsizei* length, GLint* size, GLenum* type, char* name) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetActiveAttrib(
- program, index, bufsize, length, size, type, name);
+ GetGLES(
+ context_id)->GetActiveAttrib(
+ program, index, bufsize, length, size, type, name);
}
void GetActiveUniform(
PP_Resource context_id, GLuint program, GLuint index, GLsizei bufsize,
GLsizei* length, GLint* size, GLenum* type, char* name) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetActiveUniform(
- program, index, bufsize, length, size, type, name);
+ GetGLES(
+ context_id)->GetActiveUniform(
+ program, index, bufsize, length, size, type, name);
}
void GetAttachedShaders(
PP_Resource context_id, GLuint program, GLsizei maxcount, GLsizei* count,
GLuint* shaders) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetAttachedShaders(program, maxcount, count, shaders);
+ GetGLES(context_id)->GetAttachedShaders(program, maxcount, count, shaders);
}
GLint GetAttribLocation(
PP_Resource context_id, GLuint program, const char* name) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- return context->gles2_impl()->GetAttribLocation(program, name);
+ return GetGLES(context_id)->GetAttribLocation(program, name);
}
void GetBooleanv(PP_Resource context_id, GLenum pname, GLboolean* params) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetBooleanv(pname, params);
+ GetGLES(context_id)->GetBooleanv(pname, params);
}
void GetBufferParameteriv(
PP_Resource context_id, GLenum target, GLenum pname, GLint* params) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetBufferParameteriv(target, pname, params);
+ GetGLES(context_id)->GetBufferParameteriv(target, pname, params);
}
GLenum GetError(PP_Resource context_id) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- return context->gles2_impl()->GetError();
+ return GetGLES(context_id)->GetError();
}
void GetFloatv(PP_Resource context_id, GLenum pname, GLfloat* params) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetFloatv(pname, params);
+ GetGLES(context_id)->GetFloatv(pname, params);
}
void GetFramebufferAttachmentParameteriv(
PP_Resource context_id, GLenum target, GLenum attachment, GLenum pname,
GLint* params) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetFramebufferAttachmentParameteriv(
- target, attachment, pname, params);
+ GetGLES(
+ context_id)->GetFramebufferAttachmentParameteriv(
+ target, attachment, pname, params);
}
void GetIntegerv(PP_Resource context_id, GLenum pname, GLint* params) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetIntegerv(pname, params);
+ GetGLES(context_id)->GetIntegerv(pname, params);
}
void GetProgramiv(
PP_Resource context_id, GLuint program, GLenum pname, GLint* params) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetProgramiv(program, pname, params);
+ GetGLES(context_id)->GetProgramiv(program, pname, params);
}
void GetProgramInfoLog(
PP_Resource context_id, GLuint program, GLsizei bufsize, GLsizei* length,
char* infolog) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetProgramInfoLog(program, bufsize, length, infolog);
+ GetGLES(context_id)->GetProgramInfoLog(program, bufsize, length, infolog);
}
void GetRenderbufferParameteriv(
PP_Resource context_id, GLenum target, GLenum pname, GLint* params) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetRenderbufferParameteriv(target, pname, params);
+ GetGLES(context_id)->GetRenderbufferParameteriv(target, pname, params);
}
void GetShaderiv(
PP_Resource context_id, GLuint shader, GLenum pname, GLint* params) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetShaderiv(shader, pname, params);
+ GetGLES(context_id)->GetShaderiv(shader, pname, params);
}
void GetShaderInfoLog(
PP_Resource context_id, GLuint shader, GLsizei bufsize, GLsizei* length,
char* infolog) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetShaderInfoLog(shader, bufsize, length, infolog);
+ GetGLES(context_id)->GetShaderInfoLog(shader, bufsize, length, infolog);
}
void GetShaderPrecisionFormat(
PP_Resource context_id, GLenum shadertype, GLenum precisiontype,
GLint* range, GLint* precision) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetShaderPrecisionFormat(
- shadertype, precisiontype, range, precision);
+ GetGLES(
+ context_id)->GetShaderPrecisionFormat(
+ shadertype, precisiontype, range, precision);
}
void GetShaderSource(
PP_Resource context_id, GLuint shader, GLsizei bufsize, GLsizei* length,
char* source) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetShaderSource(shader, bufsize, length, source);
+ GetGLES(context_id)->GetShaderSource(shader, bufsize, length, source);
}
const GLubyte* GetString(PP_Resource context_id, GLenum name) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- return context->gles2_impl()->GetString(name);
+ return GetGLES(context_id)->GetString(name);
}
void GetTexParameterfv(
PP_Resource context_id, GLenum target, GLenum pname, GLfloat* params) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetTexParameterfv(target, pname, params);
+ GetGLES(context_id)->GetTexParameterfv(target, pname, params);
}
void GetTexParameteriv(
PP_Resource context_id, GLenum target, GLenum pname, GLint* params) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetTexParameteriv(target, pname, params);
+ GetGLES(context_id)->GetTexParameteriv(target, pname, params);
}
void GetUniformfv(
PP_Resource context_id, GLuint program, GLint location, GLfloat* params) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetUniformfv(program, location, params);
+ GetGLES(context_id)->GetUniformfv(program, location, params);
}
void GetUniformiv(
PP_Resource context_id, GLuint program, GLint location, GLint* params) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetUniformiv(program, location, params);
+ GetGLES(context_id)->GetUniformiv(program, location, params);
}
GLint GetUniformLocation(
PP_Resource context_id, GLuint program, const char* name) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- return context->gles2_impl()->GetUniformLocation(program, name);
+ return GetGLES(context_id)->GetUniformLocation(program, name);
}
void GetVertexAttribfv(
PP_Resource context_id, GLuint index, GLenum pname, GLfloat* params) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetVertexAttribfv(index, pname, params);
+ GetGLES(context_id)->GetVertexAttribfv(index, pname, params);
}
void GetVertexAttribiv(
PP_Resource context_id, GLuint index, GLenum pname, GLint* params) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetVertexAttribiv(index, pname, params);
+ GetGLES(context_id)->GetVertexAttribiv(index, pname, params);
}
void GetVertexAttribPointerv(
PP_Resource context_id, GLuint index, GLenum pname, void** pointer) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->GetVertexAttribPointerv(index, pname, pointer);
+ GetGLES(context_id)->GetVertexAttribPointerv(index, pname, pointer);
}
void Hint(PP_Resource context_id, GLenum target, GLenum mode) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Hint(target, mode);
+ GetGLES(context_id)->Hint(target, mode);
}
GLboolean IsBuffer(PP_Resource context_id, GLuint buffer) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- return context->gles2_impl()->IsBuffer(buffer);
+ return GetGLES(context_id)->IsBuffer(buffer);
}
GLboolean IsEnabled(PP_Resource context_id, GLenum cap) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- return context->gles2_impl()->IsEnabled(cap);
+ return GetGLES(context_id)->IsEnabled(cap);
}
GLboolean IsFramebuffer(PP_Resource context_id, GLuint framebuffer) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- return context->gles2_impl()->IsFramebuffer(framebuffer);
+ return GetGLES(context_id)->IsFramebuffer(framebuffer);
}
GLboolean IsProgram(PP_Resource context_id, GLuint program) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- return context->gles2_impl()->IsProgram(program);
+ return GetGLES(context_id)->IsProgram(program);
}
GLboolean IsRenderbuffer(PP_Resource context_id, GLuint renderbuffer) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- return context->gles2_impl()->IsRenderbuffer(renderbuffer);
+ return GetGLES(context_id)->IsRenderbuffer(renderbuffer);
}
GLboolean IsShader(PP_Resource context_id, GLuint shader) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- return context->gles2_impl()->IsShader(shader);
+ return GetGLES(context_id)->IsShader(shader);
}
GLboolean IsTexture(PP_Resource context_id, GLuint texture) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- return context->gles2_impl()->IsTexture(texture);
+ return GetGLES(context_id)->IsTexture(texture);
}
void LineWidth(PP_Resource context_id, GLfloat width) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->LineWidth(width);
+ GetGLES(context_id)->LineWidth(width);
}
void LinkProgram(PP_Resource context_id, GLuint program) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->LinkProgram(program);
+ GetGLES(context_id)->LinkProgram(program);
}
void PixelStorei(PP_Resource context_id, GLenum pname, GLint param) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->PixelStorei(pname, param);
+ GetGLES(context_id)->PixelStorei(pname, param);
}
void PolygonOffset(PP_Resource context_id, GLfloat factor, GLfloat units) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->PolygonOffset(factor, units);
+ GetGLES(context_id)->PolygonOffset(factor, units);
}
void ReadPixels(
PP_Resource context_id, GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type, void* pixels) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->ReadPixels(x, y, width, height, format, type, pixels);
+ GetGLES(context_id)->ReadPixels(x, y, width, height, format, type, pixels);
}
void ReleaseShaderCompiler(PP_Resource context_id) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->ReleaseShaderCompiler();
+ GetGLES(context_id)->ReleaseShaderCompiler();
}
void RenderbufferStorage(
PP_Resource context_id, GLenum target, GLenum internalformat, GLsizei width,
GLsizei height) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->RenderbufferStorage(
- target, internalformat, width, height);
+ GetGLES(
+ context_id)->RenderbufferStorage(target, internalformat, width, height);
}
void SampleCoverage(PP_Resource context_id, GLclampf value, GLboolean invert) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->SampleCoverage(value, invert);
+ GetGLES(context_id)->SampleCoverage(value, invert);
}
void Scissor(
PP_Resource context_id, GLint x, GLint y, GLsizei width, GLsizei height) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Scissor(x, y, width, height);
+ GetGLES(context_id)->Scissor(x, y, width, height);
}
void ShaderBinary(
PP_Resource context_id, GLsizei n, const GLuint* shaders,
GLenum binaryformat, const void* binary, GLsizei length) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->ShaderBinary(
- n, shaders, binaryformat, binary, length);
+ GetGLES(context_id)->ShaderBinary(n, shaders, binaryformat, binary, length);
}
void ShaderSource(
PP_Resource context_id, GLuint shader, GLsizei count, const char** str,
const GLint* length) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->ShaderSource(shader, count, str, length);
+ GetGLES(context_id)->ShaderSource(shader, count, str, length);
}
void StencilFunc(PP_Resource context_id, GLenum func, GLint ref, GLuint mask) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->StencilFunc(func, ref, mask);
+ GetGLES(context_id)->StencilFunc(func, ref, mask);
}
void StencilFuncSeparate(
PP_Resource context_id, GLenum face, GLenum func, GLint ref, GLuint mask) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->StencilFuncSeparate(face, func, ref, mask);
+ GetGLES(context_id)->StencilFuncSeparate(face, func, ref, mask);
}
void StencilMask(PP_Resource context_id, GLuint mask) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->StencilMask(mask);
+ GetGLES(context_id)->StencilMask(mask);
}
void StencilMaskSeparate(PP_Resource context_id, GLenum face, GLuint mask) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->StencilMaskSeparate(face, mask);
+ GetGLES(context_id)->StencilMaskSeparate(face, mask);
}
void StencilOp(
PP_Resource context_id, GLenum fail, GLenum zfail, GLenum zpass) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->StencilOp(fail, zfail, zpass);
+ GetGLES(context_id)->StencilOp(fail, zfail, zpass);
}
void StencilOpSeparate(
PP_Resource context_id, GLenum face, GLenum fail, GLenum zfail,
GLenum zpass) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->StencilOpSeparate(face, fail, zfail, zpass);
+ GetGLES(context_id)->StencilOpSeparate(face, fail, zfail, zpass);
}
void TexImage2D(
PP_Resource context_id, GLenum target, GLint level, GLint internalformat,
GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type,
const void* pixels) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->TexImage2D(
- target, level, internalformat, width, height, border, format, type,
- pixels);
+ GetGLES(
+ context_id)->TexImage2D(
+ target, level, internalformat, width, height, border, format, type,
+ pixels);
}
void TexParameterf(
PP_Resource context_id, GLenum target, GLenum pname, GLfloat param) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->TexParameterf(target, pname, param);
+ GetGLES(context_id)->TexParameterf(target, pname, param);
}
void TexParameterfv(
PP_Resource context_id, GLenum target, GLenum pname,
const GLfloat* params) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->TexParameterfv(target, pname, params);
+ GetGLES(context_id)->TexParameterfv(target, pname, params);
}
void TexParameteri(
PP_Resource context_id, GLenum target, GLenum pname, GLint param) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->TexParameteri(target, pname, param);
+ GetGLES(context_id)->TexParameteri(target, pname, param);
}
void TexParameteriv(
PP_Resource context_id, GLenum target, GLenum pname, const GLint* params) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->TexParameteriv(target, pname, params);
+ GetGLES(context_id)->TexParameteriv(target, pname, params);
}
void TexSubImage2D(
PP_Resource context_id, GLenum target, GLint level, GLint xoffset,
GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type,
const void* pixels) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->TexSubImage2D(
- target, level, xoffset, yoffset, width, height, format, type, pixels);
+ GetGLES(
+ context_id)->TexSubImage2D(
+ target, level, xoffset, yoffset, width, height, format, type,
+ pixels);
}
void Uniform1f(PP_Resource context_id, GLint location, GLfloat x) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Uniform1f(location, x);
+ GetGLES(context_id)->Uniform1f(location, x);
}
void Uniform1fv(
PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Uniform1fv(location, count, v);
+ GetGLES(context_id)->Uniform1fv(location, count, v);
}
void Uniform1i(PP_Resource context_id, GLint location, GLint x) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Uniform1i(location, x);
+ GetGLES(context_id)->Uniform1i(location, x);
}
void Uniform1iv(
PP_Resource context_id, GLint location, GLsizei count, const GLint* v) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Uniform1iv(location, count, v);
+ GetGLES(context_id)->Uniform1iv(location, count, v);
}
void Uniform2f(PP_Resource context_id, GLint location, GLfloat x, GLfloat y) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Uniform2f(location, x, y);
+ GetGLES(context_id)->Uniform2f(location, x, y);
}
void Uniform2fv(
PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Uniform2fv(location, count, v);
+ GetGLES(context_id)->Uniform2fv(location, count, v);
}
void Uniform2i(PP_Resource context_id, GLint location, GLint x, GLint y) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Uniform2i(location, x, y);
+ GetGLES(context_id)->Uniform2i(location, x, y);
}
void Uniform2iv(
PP_Resource context_id, GLint location, GLsizei count, const GLint* v) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Uniform2iv(location, count, v);
+ GetGLES(context_id)->Uniform2iv(location, count, v);
}
void Uniform3f(
PP_Resource context_id, GLint location, GLfloat x, GLfloat y, GLfloat z) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Uniform3f(location, x, y, z);
+ GetGLES(context_id)->Uniform3f(location, x, y, z);
}
void Uniform3fv(
PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Uniform3fv(location, count, v);
+ GetGLES(context_id)->Uniform3fv(location, count, v);
}
void Uniform3i(
PP_Resource context_id, GLint location, GLint x, GLint y, GLint z) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Uniform3i(location, x, y, z);
+ GetGLES(context_id)->Uniform3i(location, x, y, z);
}
void Uniform3iv(
PP_Resource context_id, GLint location, GLsizei count, const GLint* v) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Uniform3iv(location, count, v);
+ GetGLES(context_id)->Uniform3iv(location, count, v);
}
void Uniform4f(
PP_Resource context_id, GLint location, GLfloat x, GLfloat y, GLfloat z,
GLfloat w) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Uniform4f(location, x, y, z, w);
+ GetGLES(context_id)->Uniform4f(location, x, y, z, w);
}
void Uniform4fv(
PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Uniform4fv(location, count, v);
+ GetGLES(context_id)->Uniform4fv(location, count, v);
}
void Uniform4i(
PP_Resource context_id, GLint location, GLint x, GLint y, GLint z,
GLint w) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Uniform4i(location, x, y, z, w);
+ GetGLES(context_id)->Uniform4i(location, x, y, z, w);
}
void Uniform4iv(
PP_Resource context_id, GLint location, GLsizei count, const GLint* v) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Uniform4iv(location, count, v);
+ GetGLES(context_id)->Uniform4iv(location, count, v);
}
void UniformMatrix2fv(
PP_Resource context_id, GLint location, GLsizei count, GLboolean transpose,
const GLfloat* value) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->UniformMatrix2fv(location, count, transpose, value);
+ GetGLES(context_id)->UniformMatrix2fv(location, count, transpose, value);
}
void UniformMatrix3fv(
PP_Resource context_id, GLint location, GLsizei count, GLboolean transpose,
const GLfloat* value) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->UniformMatrix3fv(location, count, transpose, value);
+ GetGLES(context_id)->UniformMatrix3fv(location, count, transpose, value);
}
void UniformMatrix4fv(
PP_Resource context_id, GLint location, GLsizei count, GLboolean transpose,
const GLfloat* value) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->UniformMatrix4fv(location, count, transpose, value);
+ GetGLES(context_id)->UniformMatrix4fv(location, count, transpose, value);
}
void UseProgram(PP_Resource context_id, GLuint program) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->UseProgram(program);
+ GetGLES(context_id)->UseProgram(program);
}
void ValidateProgram(PP_Resource context_id, GLuint program) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->ValidateProgram(program);
+ GetGLES(context_id)->ValidateProgram(program);
}
void VertexAttrib1f(PP_Resource context_id, GLuint indx, GLfloat x) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->VertexAttrib1f(indx, x);
+ GetGLES(context_id)->VertexAttrib1f(indx, x);
}
void VertexAttrib1fv(
PP_Resource context_id, GLuint indx, const GLfloat* values) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->VertexAttrib1fv(indx, values);
+ GetGLES(context_id)->VertexAttrib1fv(indx, values);
}
void VertexAttrib2f(
PP_Resource context_id, GLuint indx, GLfloat x, GLfloat y) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->VertexAttrib2f(indx, x, y);
+ GetGLES(context_id)->VertexAttrib2f(indx, x, y);
}
void VertexAttrib2fv(
PP_Resource context_id, GLuint indx, const GLfloat* values) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->VertexAttrib2fv(indx, values);
+ GetGLES(context_id)->VertexAttrib2fv(indx, values);
}
void VertexAttrib3f(
PP_Resource context_id, GLuint indx, GLfloat x, GLfloat y, GLfloat z) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->VertexAttrib3f(indx, x, y, z);
+ GetGLES(context_id)->VertexAttrib3f(indx, x, y, z);
}
void VertexAttrib3fv(
PP_Resource context_id, GLuint indx, const GLfloat* values) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->VertexAttrib3fv(indx, values);
+ GetGLES(context_id)->VertexAttrib3fv(indx, values);
}
void VertexAttrib4f(
PP_Resource context_id, GLuint indx, GLfloat x, GLfloat y, GLfloat z,
GLfloat w) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->VertexAttrib4f(indx, x, y, z, w);
+ GetGLES(context_id)->VertexAttrib4f(indx, x, y, z, w);
}
void VertexAttrib4fv(
PP_Resource context_id, GLuint indx, const GLfloat* values) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->VertexAttrib4fv(indx, values);
+ GetGLES(context_id)->VertexAttrib4fv(indx, values);
}
void VertexAttribPointer(
PP_Resource context_id, GLuint indx, GLint size, GLenum type,
GLboolean normalized, GLsizei stride, const void* ptr) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->VertexAttribPointer(
- indx, size, type, normalized, stride, ptr);
+ GetGLES(
+ context_id)->VertexAttribPointer(
+ indx, size, type, normalized, stride, ptr);
}
void Viewport(
PP_Resource context_id, GLint x, GLint y, GLsizei width, GLsizei height) {
- scoped_refptr<PPB_Context3D_Impl> context =
- Resource::GetAs<PPB_Context3D_Impl>(context_id);
- context->gles2_impl()->Viewport(x, y, width, height);
+ GetGLES(context_id)->Viewport(x, y, width, height);
+}
+
+void SetLatchCHROMIUM(PP_Resource context_id, GLuint latch_id) {
+ GetGLES(context_id)->SetLatchCHROMIUM(latch_id);
+}
+
+void WaitLatchCHROMIUM(PP_Resource context_id, GLuint latch_id) {
+ GetGLES(context_id)->WaitLatchCHROMIUM(latch_id);
}
diff --git a/webkit/plugins/ppapi/ppb_proxy_impl.cc b/webkit/plugins/ppapi/ppb_proxy_impl.cc
index fc861af..1660b71 100644
--- a/webkit/plugins/ppapi/ppb_proxy_impl.cc
+++ b/webkit/plugins/ppapi/ppb_proxy_impl.cc
@@ -5,12 +5,17 @@
#include "webkit/plugins/ppapi/ppb_proxy_impl.h"
#include "ppapi/c/private/ppb_proxy_private.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_image_data_api.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
#include "webkit/plugins/ppapi/resource.h"
#include "webkit/plugins/ppapi/resource_tracker.h"
+using ppapi::thunk::EnterResource;
+using ppapi::thunk::PPB_URLLoader_API;
+
namespace webkit {
namespace ppapi {
@@ -37,11 +42,10 @@ void SetReserveInstanceIDCallback(PP_Module module,
}
int32_t GetURLLoaderBufferedBytes(PP_Resource url_loader) {
- scoped_refptr<PPB_URLLoader_Impl> loader(
- Resource::GetAs<PPB_URLLoader_Impl>(url_loader));
- if (!loader)
- return 0;
- return loader->buffer_size();
+ EnterResource<PPB_URLLoader_API> enter(url_loader, true);
+ if (enter.succeeded())
+ return static_cast<PPB_URLLoader_Impl*>(enter.object())->buffer_size();
+ return 0;
}
void AddRefModule(PP_Module module) {
diff --git a/webkit/plugins/ppapi/ppb_scrollbar_impl.cc b/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
index 5747fc2..1996bb8 100644
--- a/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
+++ b/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
@@ -166,33 +166,28 @@ void PPB_Scrollbar_Impl::ScrollBy(PP_ScrollBy_Dev unit, int32_t multiplier) {
scrollbar_->scroll(direction, granularity, fmultiplier);
}
-bool PPB_Scrollbar_Impl::Paint(const PP_Rect* rect, PPB_ImageData_Impl* image) {
- gfx::Rect gfx_rect(rect->point.x,
- rect->point.y,
- rect->size.width,
- rect->size.height);
+PP_Bool PPB_Scrollbar_Impl::HandleEvent(const PP_InputEvent* event) {
+ scoped_ptr<WebInputEvent> web_input_event(CreateWebInputEvent(*event));
+ if (!web_input_event.get())
+ return PP_FALSE;
+
+ return PP_FromBool(scrollbar_->handleInputEvent(*web_input_event.get()));
+}
+
+PP_Bool PPB_Scrollbar_Impl::PaintInternal(const gfx::Rect& rect,
+ PPB_ImageData_Impl* image) {
ImageDataAutoMapper mapper(image);
skia::PlatformCanvas* canvas = image->mapped_canvas();
if (!canvas)
- return false;
- scrollbar_->paint(webkit_glue::ToWebCanvas(canvas), gfx_rect);
+ return PP_FALSE;
+ scrollbar_->paint(webkit_glue::ToWebCanvas(canvas), rect);
#if defined(OS_WIN)
- if (base::win::GetVersion() == base::win::VERSION_XP) {
- skia::MakeOpaque(canvas, gfx_rect.x(), gfx_rect.y(),
- gfx_rect.width(), gfx_rect.height());
- }
+ if (base::win::GetVersion() == base::win::VERSION_XP)
+ skia::MakeOpaque(canvas, rect.x(), rect.y(), rect.width(), rect.height());
#endif
- return true;
-}
-
-bool PPB_Scrollbar_Impl::HandleEvent(const PP_InputEvent* event) {
- scoped_ptr<WebInputEvent> web_input_event(CreateWebInputEvent(*event));
- if (!web_input_event.get())
- return false;
-
- return scrollbar_->handleInputEvent(*web_input_event.get());
+ return PP_TRUE;
}
void PPB_Scrollbar_Impl::SetLocationInternal(const PP_Rect* location) {
diff --git a/webkit/plugins/ppapi/ppb_scrollbar_impl.h b/webkit/plugins/ppapi/ppb_scrollbar_impl.h
index 88c4308..6c1ca86 100644
--- a/webkit/plugins/ppapi/ppb_scrollbar_impl.h
+++ b/webkit/plugins/ppapi/ppb_scrollbar_impl.h
@@ -38,19 +38,22 @@ class PPB_Scrollbar_Impl : public PPB_Widget_Impl,
void SetTickMarks(const PP_Rect* tick_marks, uint32_t count);
void ScrollBy(PP_ScrollBy_Dev unit, int32_t multiplier);
- // PPB_Widget implementation.
- virtual bool Paint(const PP_Rect* rect, PPB_ImageData_Impl* image);
- virtual bool HandleEvent(const PP_InputEvent* event);
- virtual void SetLocationInternal(const PP_Rect* location);
+ // PPB_Widget public implementation.
+ virtual PP_Bool HandleEvent(const PP_InputEvent* event) OVERRIDE;
private:
+ // PPB_Widget private implementation.
+ virtual PP_Bool PaintInternal(const gfx::Rect& rect,
+ PPB_ImageData_Impl* image) OVERRIDE;
+ virtual void SetLocationInternal(const PP_Rect* location) OVERRIDE;
+
// WebKit::WebScrollbarClient implementation.
- virtual void valueChanged(WebKit::WebScrollbar* scrollbar);
+ virtual void valueChanged(WebKit::WebScrollbar* scrollbar) OVERRIDE;
virtual void invalidateScrollbarRect(WebKit::WebScrollbar* scrollbar,
- const WebKit::WebRect& rect);
+ const WebKit::WebRect& rect) OVERRIDE;
virtual void getTickmarks(
WebKit::WebScrollbar* scrollbar,
- WebKit::WebVector<WebKit::WebRect>* tick_marks) const;
+ WebKit::WebVector<WebKit::WebRect>* tick_marks) const OVERRIDE;
void NotifyInvalidate();
diff --git a/webkit/plugins/ppapi/ppb_surface_3d_impl.cc b/webkit/plugins/ppapi/ppb_surface_3d_impl.cc
index f250fcb..ad8e9b1 100644
--- a/webkit/plugins/ppapi/ppb_surface_3d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_surface_3d_impl.cc
@@ -14,14 +14,28 @@
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_context_3d_impl.h"
+using ppapi::thunk::PPB_Surface3D_API;
+
namespace webkit {
namespace ppapi {
-namespace {
+PPB_Surface3D_Impl::PPB_Surface3D_Impl(PluginInstance* instance)
+ : Resource(instance),
+ bound_to_instance_(false),
+ swap_initiated_(false),
+ swap_callback_(PP_BlockUntilComplete()),
+ context_(NULL) {
+}
+
+PPB_Surface3D_Impl::~PPB_Surface3D_Impl() {
+ if (context_)
+ context_->BindSurfaces(NULL, NULL);
+}
-PP_Resource Create(PP_Instance instance_id,
- PP_Config3D_Dev config,
- const int32_t* attrib_list) {
+// static
+PP_Resource PPB_Surface3D_Impl::Create(PP_Instance instance_id,
+ PP_Config3D_Dev config,
+ const int32_t* attrib_list) {
PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
if (!instance)
return 0;
@@ -30,64 +44,43 @@ PP_Resource Create(PP_Instance instance_id,
new PPB_Surface3D_Impl(instance));
if (!surface->Init(config, attrib_list))
return 0;
-
return surface->GetReference();
}
-PP_Bool IsSurface3D(PP_Resource resource) {
- return BoolToPPBool(!!Resource::GetAs<PPB_Surface3D_Impl>(resource));
+PPB_Surface3D_API* PPB_Surface3D_Impl::AsPPB_Surface3D_API() {
+ return this;
}
-int32_t SetAttrib(PP_Resource surface_id,
- int32_t attribute,
- int32_t value) {
+int32_t PPB_Surface3D_Impl::SetAttrib(int32_t attribute, int32_t value) {
// TODO(alokp): Implement me.
return 0;
}
-int32_t GetAttrib(PP_Resource surface_id,
- int32_t attribute,
- int32_t* value) {
+int32_t PPB_Surface3D_Impl::GetAttrib(int32_t attribute, int32_t* value) {
// TODO(alokp): Implement me.
return 0;
}
-int32_t SwapBuffers(PP_Resource surface_id,
- PP_CompletionCallback callback) {
- scoped_refptr<PPB_Surface3D_Impl> surface(
- Resource::GetAs<PPB_Surface3D_Impl>(surface_id));
- return surface->SwapBuffers(callback);
-}
-
-const PPB_Surface3D_Dev ppb_surface3d = {
- &Create,
- &IsSurface3D,
- &SetAttrib,
- &GetAttrib,
- &SwapBuffers
-};
-
-} // namespace
-
-PPB_Surface3D_Impl::PPB_Surface3D_Impl(PluginInstance* instance)
- : Resource(instance),
- bound_to_instance_(false),
- swap_initiated_(false),
- swap_callback_(PP_BlockUntilComplete()),
- context_(NULL) {
-}
+int32_t PPB_Surface3D_Impl::SwapBuffers(PP_CompletionCallback callback) {
+ if (!context_)
+ return PP_ERROR_FAILED;
-PPB_Surface3D_Impl::~PPB_Surface3D_Impl() {
- if (context_)
- context_->BindSurfaces(NULL, NULL);
-}
+ if (swap_callback_.func) {
+ // Already a pending SwapBuffers that hasn't returned yet.
+ return PP_ERROR_INPROGRESS;
+ }
-const PPB_Surface3D_Dev* PPB_Surface3D_Impl::GetInterface() {
- return &ppb_surface3d;
-}
+ if (!callback.func) {
+ // Blocking SwapBuffers isn't supported (since we have to be on the main
+ // thread).
+ return PP_ERROR_BADARGUMENT;
+ }
-PPB_Surface3D_Impl* PPB_Surface3D_Impl::AsPPB_Surface3D_Impl() {
- return this;
+ swap_callback_ = callback;
+ gpu::gles2::GLES2Implementation* impl = context_->gles2_impl();
+ if (impl)
+ context_->gles2_impl()->SwapBuffers();
+ return PP_OK_COMPLETIONPENDING;
}
bool PPB_Surface3D_Impl::Init(PP_Config3D_Dev config,
@@ -100,16 +93,14 @@ bool PPB_Surface3D_Impl::BindToInstance(bool bind) {
return true;
}
-bool PPB_Surface3D_Impl::BindToContext(
- PPB_Context3D_Impl* context) {
+bool PPB_Surface3D_Impl::BindToContext(PPB_Context3D_Impl* context) {
if (context == context_)
return true;
// Unbind from the current context.
- if (context_) {
+ if (context_ && context_->platform_context())
context_->platform_context()->SetSwapBuffersCallback(NULL);
- }
- if (context) {
+ if (context && context->platform_context()) {
// Resize the backing texture to the size of the instance when it is bound.
// TODO(alokp): This should be the responsibility of plugins.
gpu::gles2::GLES2Implementation* impl = context->gles2_impl();
@@ -125,29 +116,6 @@ bool PPB_Surface3D_Impl::BindToContext(
return true;
}
-int32_t PPB_Surface3D_Impl::SwapBuffers(PP_CompletionCallback callback) {
- if (!context_)
- return PP_ERROR_FAILED;
-
- if (swap_callback_.func) {
- // Already a pending SwapBuffers that hasn't returned yet.
- return PP_ERROR_INPROGRESS;
- }
-
- if (!callback.func) {
- // Blocking SwapBuffers isn't supported (since we have to be on the main
- // thread).
- return PP_ERROR_BADARGUMENT;
- }
-
- swap_callback_ = callback;
- gpu::gles2::GLES2Implementation* impl = context_->gles2_impl();
- if (impl) {
- context_->gles2_impl()->SwapBuffers();
- }
- return PP_OK_COMPLETIONPENDING;
-}
-
void PPB_Surface3D_Impl::ViewInitiatedPaint() {
}
diff --git a/webkit/plugins/ppapi/ppb_surface_3d_impl.h b/webkit/plugins/ppapi/ppb_surface_3d_impl.h
index e924e52..16b1c6f 100644
--- a/webkit/plugins/ppapi/ppb_surface_3d_impl.h
+++ b/webkit/plugins/ppapi/ppb_surface_3d_impl.h
@@ -6,7 +6,7 @@
#define WEBKIT_PLUGINS_PPAPI_PPB_SURFACE_3D_IMPL_H_
#include "base/callback.h"
-#include "ppapi/c/dev/ppb_surface_3d_dev.h"
+#include "ppapi/thunk/ppb_surface_3d_api.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/resource.h"
@@ -17,18 +17,24 @@ class Size;
namespace webkit {
namespace ppapi {
-class PPB_Surface3D_Impl : public Resource {
+class PPB_Context3D_Impl;
+
+class PPB_Surface3D_Impl : public Resource,
+ public ::ppapi::thunk::PPB_Surface3D_API {
public:
- explicit PPB_Surface3D_Impl(PluginInstance* instance);
virtual ~PPB_Surface3D_Impl();
- static const PPB_Surface3D_Dev* GetInterface();
+ static PP_Resource Create(PP_Instance instance_id,
+ PP_Config3D_Dev config,
+ const int32_t* attrib_list);
- // Resource override.
- virtual PPB_Surface3D_Impl* AsPPB_Surface3D_Impl();
+ // ResourceObjectBase override.
+ virtual ::ppapi::thunk::PPB_Surface3D_API* AsPPB_Surface3D_API() OVERRIDE;
- bool Init(PP_Config3D_Dev config,
- const int32_t* attrib_list);
+ // PPB_Surface3D_API implementation.
+ virtual int32_t SetAttrib(int32_t attribute, int32_t value) OVERRIDE;
+ virtual int32_t GetAttrib(int32_t attribute, int32_t* value) OVERRIDE;
+ virtual int32_t SwapBuffers(PP_CompletionCallback callback) OVERRIDE;
PPB_Context3D_Impl* context() const {
return context_;
@@ -46,13 +52,15 @@ class PPB_Surface3D_Impl : public Resource {
unsigned int GetBackingTextureId();
- int32_t SwapBuffers(PP_CompletionCallback callback);
-
void ViewInitiatedPaint();
void ViewFlushedPaint();
void OnContextLost();
private:
+ explicit PPB_Surface3D_Impl(PluginInstance* instance);
+
+ bool Init(PP_Config3D_Dev config, const int32_t* attrib_list);
+
// Called when SwapBuffers is complete.
void OnSwapBuffers();
void SendContextLost();
diff --git a/webkit/plugins/ppapi/ppb_transport_impl.cc b/webkit/plugins/ppapi/ppb_transport_impl.cc
index a37f299..54e0adf 100644
--- a/webkit/plugins/ppapi/ppb_transport_impl.cc
+++ b/webkit/plugins/ppapi/ppb_transport_impl.cc
@@ -17,6 +17,7 @@
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/var.h"
+using ppapi::thunk::PPB_Transport_API;
using webkit_glue::P2PTransport;
namespace webkit {
@@ -27,81 +28,6 @@ namespace {
const char kUdpProtocolName[] = "udp";
const char kTcpProtocolName[] = "tcp";
-PP_Resource CreateTransport(PP_Instance instance_id, const char* name,
- const char* proto) {
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
- if (!instance)
- return 0;
-
- scoped_refptr<PPB_Transport_Impl> t(new PPB_Transport_Impl(instance));
- if (!t->Init(name, proto))
- return 0;
-
- return t->GetReference();
-}
-
-PP_Bool IsTransport(PP_Resource resource) {
- return BoolToPPBool(Resource::GetAs<PPB_Transport_Impl>(resource) != NULL);
-}
-
-PP_Bool IsWritable(PP_Resource resource) {
- scoped_refptr<PPB_Transport_Impl> t(
- Resource::GetAs<PPB_Transport_Impl>(resource));
- return BoolToPPBool((t.get()) ? t->IsWritable() : false);
-}
-
-int32_t Connect(PP_Resource resource, PP_CompletionCallback callback) {
- scoped_refptr<PPB_Transport_Impl> t(
- Resource::GetAs<PPB_Transport_Impl>(resource));
- return (t.get()) ? t->Connect(callback) : PP_ERROR_BADRESOURCE;
-}
-
-int32_t GetNextAddress(PP_Resource resource, PP_Var* address,
- PP_CompletionCallback callback) {
- scoped_refptr<PPB_Transport_Impl> t(
- Resource::GetAs<PPB_Transport_Impl>(resource));
- return (t.get())? t->GetNextAddress(address, callback) : PP_ERROR_BADRESOURCE;
-}
-
-int32_t ReceiveRemoteAddress(PP_Resource resource, PP_Var address) {
- scoped_refptr<PPB_Transport_Impl> t(
- Resource::GetAs<PPB_Transport_Impl>(resource));
- return (t.get())? t->ReceiveRemoteAddress(address) : PP_ERROR_BADRESOURCE;
-}
-
-int32_t Recv(PP_Resource resource, void* data, uint32_t len,
- PP_CompletionCallback callback) {
- scoped_refptr<PPB_Transport_Impl> t(
- Resource::GetAs<PPB_Transport_Impl>(resource));
- return (t.get())? t->Recv(data, len, callback) : PP_ERROR_BADRESOURCE;
-}
-
-int32_t Send(PP_Resource resource, const void* data, uint32_t len,
- PP_CompletionCallback callback) {
- scoped_refptr<PPB_Transport_Impl> t(
- Resource::GetAs<PPB_Transport_Impl>(resource));
- return (t.get())? t->Send(data, len, callback) : PP_ERROR_BADRESOURCE;
-}
-
-// Disconnects from the remote peer.
-int32_t Close(PP_Resource resource) {
- scoped_refptr<PPB_Transport_Impl> t(
- Resource::GetAs<PPB_Transport_Impl>(resource));
- return (t.get())? t->Close() : PP_ERROR_BADRESOURCE;
-}
-
-const PPB_Transport_Dev ppb_transport = {
- &CreateTransport,
- &IsTransport,
- &IsWritable,
- &Connect,
- &GetNextAddress,
- &ReceiveRemoteAddress,
- &Recv,
- &Send,
- &Close,
-};
-
int MapNetError(int result) {
if (result > 0)
return result;
@@ -133,11 +59,17 @@ PPB_Transport_Impl::PPB_Transport_Impl(PluginInstance* instance)
PPB_Transport_Impl::~PPB_Transport_Impl() {
}
-const PPB_Transport_Dev* PPB_Transport_Impl::GetInterface() {
- return &ppb_transport;
+// static
+PP_Resource PPB_Transport_Impl::Create(PluginInstance* instance,
+ const char* name,
+ const char* proto) {
+ scoped_refptr<PPB_Transport_Impl> t(new PPB_Transport_Impl(instance));
+ if (!t->Init(name, proto))
+ return 0;
+ return t->GetReference();
}
-PPB_Transport_Impl* PPB_Transport_Impl::AsPPB_Transport_Impl() {
+PPB_Transport_API* PPB_Transport_Impl::AsPPB_Transport_API() {
return this;
}
@@ -157,11 +89,11 @@ bool PPB_Transport_Impl::Init(const char* name, const char* proto) {
return p2p_transport_.get() != NULL;
}
-bool PPB_Transport_Impl::IsWritable() const {
+PP_Bool PPB_Transport_Impl::IsWritable() {
if (!p2p_transport_.get())
- return false;
+ return PP_FALSE;
- return writable_;
+ return PP_FromBool(writable_);
}
int32_t PPB_Transport_Impl::Connect(PP_CompletionCallback callback) {
diff --git a/webkit/plugins/ppapi/ppb_transport_impl.h b/webkit/plugins/ppapi/ppb_transport_impl.h
index ca4818f..e7d9760 100644
--- a/webkit/plugins/ppapi/ppb_transport_impl.h
+++ b/webkit/plugins/ppapi/ppb_transport_impl.h
@@ -11,7 +11,7 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "net/base/completion_callback.h"
-#include "ppapi/c/dev/ppb_transport_dev.h"
+#include "ppapi/thunk/ppb_transport_api.h"
#include "webkit/glue/p2p_transport.h"
#include "webkit/plugins/ppapi/callbacks.h"
#include "webkit/plugins/ppapi/resource.h"
@@ -20,25 +20,29 @@ namespace webkit {
namespace ppapi {
class PPB_Transport_Impl : public Resource,
+ public ::ppapi::thunk::PPB_Transport_API,
public webkit_glue::P2PTransport::EventHandler {
public:
- static const PPB_Transport_Dev* GetInterface();
-
- explicit PPB_Transport_Impl(PluginInstance* instance);
virtual ~PPB_Transport_Impl();
- bool Init(const char* name, const char* proto);
-
- // Resource override.
- virtual PPB_Transport_Impl* AsPPB_Transport_Impl() OVERRIDE;
-
- bool IsWritable() const;
- int32_t Connect(PP_CompletionCallback cb);
- int32_t GetNextAddress(PP_Var* address, PP_CompletionCallback cb);
- int32_t ReceiveRemoteAddress(PP_Var address);
- int32_t Recv(void* data, uint32_t len, PP_CompletionCallback cb);
- int32_t Send(const void* data, uint32_t len, PP_CompletionCallback cb);
- int32_t Close();
+ static PP_Resource Create(PluginInstance* instance,
+ const char* name,
+ const char* proto);
+
+ // ResourceObjectBase override.
+ virtual ::ppapi::thunk::PPB_Transport_API* AsPPB_Transport_API() OVERRIDE;
+
+ // PPB_Transport_API implementation.
+ virtual PP_Bool IsWritable() OVERRIDE;
+ virtual int32_t Connect(PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t GetNextAddress(PP_Var* address,
+ PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t ReceiveRemoteAddress(PP_Var address) OVERRIDE;
+ virtual int32_t Recv(void* data, uint32_t len,
+ PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t Send(const void* data, uint32_t len,
+ PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t Close() OVERRIDE;
// webkit_glue::P2PTransport::EventHandler implementation.
virtual void OnCandidateReady(const std::string& address) OVERRIDE;
@@ -46,6 +50,10 @@ class PPB_Transport_Impl : public Resource,
virtual void OnError(int error) OVERRIDE;
private:
+ explicit PPB_Transport_Impl(PluginInstance* instance);
+
+ bool Init(const char* name, const char* proto);
+
void OnRead(int result);
void OnWritten(int result);
diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
index 6469fbe..d8afcbf 100644
--- a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
+++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
@@ -23,6 +23,9 @@
#include "webkit/plugins/ppapi/resource_tracker.h"
#include "webkit/plugins/ppapi/var.h"
+using ppapi::thunk::EnterResourceNoLock;
+using ppapi::thunk::PPB_Buffer_API;
+using ppapi::thunk::PPB_Context3D_API;
using ppapi::thunk::PPB_VideoDecoder_API;
namespace webkit {
@@ -121,11 +124,11 @@ int32_t PPB_VideoDecoder_Impl::Initialize(
if (!instance())
return PP_ERROR_FAILED;
- scoped_refptr<webkit::ppapi::PPB_Context3D_Impl> context3d =
- webkit::ppapi::Resource::GetAs<webkit::ppapi::PPB_Context3D_Impl>(
- context_id);
- if (!context3d)
+ EnterResourceNoLock<PPB_Context3D_API> enter(context_id, true);
+ if (enter.failed())
return PP_ERROR_BADRESOURCE;
+ PPB_Context3D_Impl* context3d =
+ static_cast<PPB_Context3D_Impl*>(enter.object());
int command_buffer_route_id =
context3d->platform_context()->GetCommandBufferRouteId();
@@ -156,8 +159,7 @@ int32_t PPB_VideoDecoder_Impl::Decode(
if (!platform_video_decoder_.get())
return PP_ERROR_BADRESOURCE;
- ::ppapi::thunk::EnterResourceNoLock< ::ppapi::thunk::PPB_Buffer_API>
- enter(bitstream_buffer->data, true);
+ EnterResourceNoLock<PPB_Buffer_API> enter(bitstream_buffer->data, true);
if (enter.failed())
return PP_ERROR_FAILED;
@@ -351,9 +353,12 @@ GLESBuffer::GLESBuffer(const PP_GLESBuffer_Dev& buffer)
SysmemBuffer::SysmemBuffer(const PP_SysmemBuffer_Dev& buffer)
: BaseBuffer(buffer.info) {
- scoped_refptr<webkit::ppapi::PPB_Buffer_Impl> pepper_buffer =
- webkit::ppapi::Resource::GetAs<webkit::ppapi::PPB_Buffer_Impl>(
- buffer.data);
+ // TODO(brettw) we should properly handle the errors here if the buffer
+ // isn't a valid image rather than CHECKing.
+ EnterResourceNoLock<PPB_Buffer_API> enter(buffer.data, true);
+ CHECK(enter.succeeded());
+ webkit::ppapi::PPB_Buffer_Impl* pepper_buffer =
+ static_cast<webkit::ppapi::PPB_Buffer_Impl*>(enter.object());
CHECK(pepper_buffer->IsMapped());
data_ = pepper_buffer->Map();
}
diff --git a/webkit/plugins/ppapi/ppb_widget_impl.cc b/webkit/plugins/ppapi/ppb_widget_impl.cc
index 896ba5f..91bfea1 100644
--- a/webkit/plugins/ppapi/ppb_widget_impl.cc
+++ b/webkit/plugins/ppapi/ppb_widget_impl.cc
@@ -4,70 +4,19 @@
#include "webkit/plugins/ppapi/ppb_widget_impl.h"
-#include "base/logging.h"
-#include "ppapi/c/dev/ppb_widget_dev.h"
#include "ppapi/c/dev/ppp_widget_dev.h"
-#include "ppapi/c/pp_completion_callback.h"
-#include "ppapi/c/pp_errors.h"
-#include "webkit/plugins/ppapi/common.h"
+#include "ppapi/thunk/enter.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/plugin_module.h"
+using ppapi::thunk::EnterResourceNoLock;
+using ppapi::thunk::PPB_ImageData_API;
+using ppapi::thunk::PPB_Widget_API;
+
namespace webkit {
namespace ppapi {
-namespace {
-
-PP_Bool IsWidget(PP_Resource resource) {
- return BoolToPPBool(!!Resource::GetAs<PPB_Widget_Impl>(resource));
-}
-
-PP_Bool Paint(PP_Resource resource,
- const PP_Rect* rect,
- PP_Resource image_id) {
- scoped_refptr<PPB_Widget_Impl> widget(
- Resource::GetAs<PPB_Widget_Impl>(resource));
- if (!widget)
- return PP_FALSE;
-
- scoped_refptr<PPB_ImageData_Impl> image(
- Resource::GetAs<PPB_ImageData_Impl>(image_id));
- if (!image)
- return PP_FALSE;
-
- return BoolToPPBool(widget->Paint(rect, image));
-}
-
-PP_Bool HandleEvent(PP_Resource resource, const PP_InputEvent* event) {
- scoped_refptr<PPB_Widget_Impl> widget(
- Resource::GetAs<PPB_Widget_Impl>(resource));
- return BoolToPPBool(widget && widget->HandleEvent(event));
-}
-
-PP_Bool GetLocation(PP_Resource resource, PP_Rect* location) {
- scoped_refptr<PPB_Widget_Impl> widget(
- Resource::GetAs<PPB_Widget_Impl>(resource));
- return BoolToPPBool(widget && widget->GetLocation(location));
-}
-
-void SetLocation(PP_Resource resource, const PP_Rect* location) {
- scoped_refptr<PPB_Widget_Impl> widget(
- Resource::GetAs<PPB_Widget_Impl>(resource));
- if (widget)
- widget->SetLocation(location);
-}
-
-const PPB_Widget_Dev ppb_widget = {
- &IsWidget,
- &Paint,
- &HandleEvent,
- &GetLocation,
- &SetLocation,
-};
-
-} // namespace
-
PPB_Widget_Impl::PPB_Widget_Impl(PluginInstance* instance)
: Resource(instance) {
memset(&location_, 0, sizeof(location_));
@@ -76,18 +25,22 @@ PPB_Widget_Impl::PPB_Widget_Impl(PluginInstance* instance)
PPB_Widget_Impl::~PPB_Widget_Impl() {
}
-// static
-const PPB_Widget_Dev* PPB_Widget_Impl::GetInterface() {
- return &ppb_widget;
+PPB_Widget_API* PPB_Widget_Impl::AsPPB_Widget_API() {
+ return this;
}
-PPB_Widget_Impl* PPB_Widget_Impl::AsPPB_Widget_Impl() {
- return this;
+PP_Bool PPB_Widget_Impl::Paint(const PP_Rect* rect, PP_Resource image_id) {
+ EnterResourceNoLock<PPB_ImageData_API> enter(image_id, true);
+ if (enter.failed())
+ return PP_FALSE;
+ return PaintInternal(gfx::Rect(rect->point.x, rect->point.y,
+ rect->size.width, rect->size.height),
+ static_cast<PPB_ImageData_Impl*>(enter.object()));
}
-bool PPB_Widget_Impl::GetLocation(PP_Rect* location) {
+PP_Bool PPB_Widget_Impl::GetLocation(PP_Rect* location) {
*location = location_;
- return true;
+ return PP_TRUE;
}
void PPB_Widget_Impl::SetLocation(const PP_Rect* location) {
diff --git a/webkit/plugins/ppapi/ppb_widget_impl.h b/webkit/plugins/ppapi/ppb_widget_impl.h
index 5a1aa72..2cdc333 100644
--- a/webkit/plugins/ppapi/ppb_widget_impl.h
+++ b/webkit/plugins/ppapi/ppb_widget_impl.h
@@ -8,40 +8,45 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "ppapi/c/pp_rect.h"
+#include "ppapi/thunk/ppb_widget_api.h"
#include "webkit/plugins/ppapi/resource.h"
struct PPB_Widget_Dev;
struct PP_InputEvent;
+namespace gfx {
+class Rect;
+}
+
namespace webkit {
namespace ppapi {
-class PPB_ImageData_Impla;
+class PPB_ImageData_Impl;
class PluginInstance;
-class PPB_Widget_Impl : public Resource {
+class PPB_Widget_Impl : public Resource,
+ public ::ppapi::thunk::PPB_Widget_API {
public:
explicit PPB_Widget_Impl(PluginInstance* instance);
virtual ~PPB_Widget_Impl();
- // Returns a pointer to the interface implementing PPB_Widget that is
- // exposed to the plugin.
- static const PPB_Widget_Dev* GetInterface();
-
- // Resource overrides.
- virtual PPB_Widget_Impl* AsPPB_Widget_Impl();
+ // ResourceObjectBase overrides.
+ virtual ::ppapi::thunk::PPB_Widget_API* AsPPB_Widget_API() OVERRIDE;
- // PPB_Widget implementation.
- virtual bool Paint(const PP_Rect* rect, PPB_ImageData_Impl* image) = 0;
- virtual bool HandleEvent(const PP_InputEvent* event) = 0;
- bool GetLocation(PP_Rect* location);
- void SetLocation(const PP_Rect* location);
+ // PPB_WidgetAPI implementation.
+ virtual PP_Bool Paint(const PP_Rect* rect, PP_Resource ) OVERRIDE;
+ virtual PP_Bool HandleEvent(const PP_InputEvent* event) = 0;
+ virtual PP_Bool GetLocation(PP_Rect* location) OVERRIDE;
+ virtual void SetLocation(const PP_Rect* location) OVERRIDE;
// Notifies the plugin instance that the given rect needs to be repainted.
void Invalidate(const PP_Rect* dirty);
protected:
+ virtual PP_Bool PaintInternal(const gfx::Rect& rect,
+ PPB_ImageData_Impl* image) = 0;
virtual void SetLocationInternal(const PP_Rect* location) = 0;
+
PP_Rect location() const { return location_; }
private:
diff --git a/webkit/plugins/ppapi/resource.h b/webkit/plugins/ppapi/resource.h
index 0d0b151..54af4c1 100644
--- a/webkit/plugins/ppapi/resource.h
+++ b/webkit/plugins/ppapi/resource.h
@@ -14,35 +14,11 @@
namespace webkit {
namespace ppapi {
-// If you inherit from resource, make sure you add the class name here.
+// Support the old way of doing resource casts for those resources that have
+// not been converted to the new system.
#define FOR_ALL_RESOURCES(F) \
F(MockResource) \
- F(PPB_AudioConfig_Impl) \
- F(PPB_Audio_Impl) \
- F(PPB_Broker_Impl) \
- F(PPB_Buffer_Impl) \
- F(PPB_Context3D_Impl) \
- F(PPB_DirectoryReader_Impl) \
- F(PPB_FileChooser_Impl) \
- F(PPB_FileIO_Impl) \
- F(PPB_FileRef_Impl) \
- F(PPB_FileSystem_Impl) \
- F(PPB_Flash_Menu_Impl) \
- F(PPB_Flash_NetConnector_Impl) \
- F(PPB_Font_Impl) \
- F(PPB_Graphics2D_Impl) \
- F(PPB_Graphics3D_Impl) \
- F(PPB_ImageData_Impl) \
- F(PPB_LayerCompositor_Impl) \
- F(PPB_Scrollbar_Impl) \
- F(PPB_Surface3D_Impl) \
- F(PPB_Transport_Impl) \
- F(PPB_URLLoader_Impl) \
- F(PPB_URLRequestInfo_Impl) \
- F(PPB_URLResponseInfo_Impl) \
- F(PPB_VideoDecoder_Impl) \
- F(PPB_VideoLayer_Impl) \
- F(PPB_Widget_Impl)
+ F(PPB_Scrollbar_Impl)
// Forward declaration of Resource classes.
#define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE;
diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc
index fe9588e..fd67df5 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.cc
+++ b/webkit/plugins/ppapi/resource_creation_impl.cc
@@ -10,6 +10,7 @@
#include "webkit/plugins/ppapi/ppb_audio_impl.h"
#include "webkit/plugins/ppapi/ppb_broker_impl.h"
#include "webkit/plugins/ppapi/ppb_buffer_impl.h"
+#include "webkit/plugins/ppapi/ppb_context_3d_impl.h"
#include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
#include "webkit/plugins/ppapi/ppb_file_chooser_impl.h"
#include "webkit/plugins/ppapi/ppb_file_io_impl.h"
@@ -19,8 +20,10 @@
#include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h"
#include "webkit/plugins/ppapi/ppb_font_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_surface_3d_impl.h"
+#include "webkit/plugins/ppapi/ppb_transport_impl.h"
#include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
#include "webkit/plugins/ppapi/ppb_url_request_info_impl.h"
#include "webkit/plugins/ppapi/ppb_video_decoder_impl.h"
@@ -87,6 +90,24 @@ PP_Resource ResourceCreationImpl::CreateBuffer(PP_Instance instance,
return PPB_Buffer_Impl::Create(instance, size);
}
+PP_Resource ResourceCreationImpl::CreateContext3D(
+ PP_Instance instance,
+ PP_Config3D_Dev config,
+ PP_Resource share_context,
+ const int32_t* attrib_list) {
+ return PPB_Context3D_Impl::Create(instance, config, share_context,
+ attrib_list);
+}
+
+PP_Resource ResourceCreationImpl::CreateContext3DRaw(
+ PP_Instance instance,
+ PP_Config3D_Dev config,
+ PP_Resource share_context,
+ const int32_t* attrib_list) {
+ return PPB_Context3D_Impl::CreateRaw(instance, config, share_context,
+ attrib_list);
+}
+
PP_Resource ResourceCreationImpl::CreateDirectoryReader(
PP_Resource directory_ref) {
return PPB_DirectoryReader_Impl::Create(directory_ref);
@@ -155,6 +176,15 @@ PP_Resource ResourceCreationImpl::CreateGraphics2D(
return graphics_2d->GetReference();
}
+PP_Resource ResourceCreationImpl::CreateGraphics3D(
+ PP_Instance instance,
+ PP_Config3D_Dev config,
+ PP_Resource share_context,
+ const int32_t* attrib_list) {
+ return PPB_Graphics3D_Impl::Create(instance_, config, share_context,
+ attrib_list);
+}
+
PP_Resource ResourceCreationImpl::CreateImageData(PP_Instance pp_instance,
PP_ImageDataFormat format,
const PP_Size& size,
@@ -177,6 +207,12 @@ PP_Resource ResourceCreationImpl::CreateSurface3D(
return 0;
}
+PP_Resource ResourceCreationImpl::CreateTransport(PP_Instance instance,
+ const char* name,
+ const char* proto) {
+ return PPB_Transport_Impl::Create(instance_, name, proto);
+}
+
PP_Resource ResourceCreationImpl::CreateURLLoader(PP_Instance instance) {
return PPB_URLLoader_Impl::Create(instance);
}
diff --git a/webkit/plugins/ppapi/resource_creation_impl.h b/webkit/plugins/ppapi/resource_creation_impl.h
index 7d39a7e1..9f78f39 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.h
+++ b/webkit/plugins/ppapi/resource_creation_impl.h
@@ -36,6 +36,14 @@ class ResourceCreationImpl : public ::ppapi::FunctionGroupBase,
virtual PP_Resource CreateBroker(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateBuffer(PP_Instance instance,
uint32_t size) OVERRIDE;
+ virtual PP_Resource CreateContext3D(PP_Instance instance,
+ PP_Config3D_Dev config,
+ PP_Resource share_context,
+ const int32_t* attrib_list) OVERRIDE;
+ virtual PP_Resource CreateContext3DRaw(PP_Instance instance,
+ PP_Config3D_Dev config,
+ PP_Resource share_context,
+ const int32_t* attrib_list) OVERRIDE;
virtual PP_Resource CreateDirectoryReader(PP_Resource directory_ref) OVERRIDE;
virtual PP_Resource CreateFileChooser(
PP_Instance instance,
@@ -54,6 +62,10 @@ class ResourceCreationImpl : public ::ppapi::FunctionGroupBase,
virtual PP_Resource CreateGraphics2D(PP_Instance pp_instance,
const PP_Size& size,
PP_Bool is_always_opaque) OVERRIDE;
+ virtual PP_Resource CreateGraphics3D(PP_Instance instance,
+ PP_Config3D_Dev config,
+ PP_Resource share_context,
+ const int32_t* attrib_list) OVERRIDE;
virtual PP_Resource CreateImageData(PP_Instance instance,
PP_ImageDataFormat format,
const PP_Size& size,
@@ -61,6 +73,9 @@ class ResourceCreationImpl : public ::ppapi::FunctionGroupBase,
virtual PP_Resource CreateSurface3D(PP_Instance instance,
PP_Config3D_Dev config,
const int32_t* attrib_list) OVERRIDE;
+ virtual PP_Resource CreateTransport(PP_Instance instance,
+ const char* name,
+ const char* proto) OVERRIDE;
virtual PP_Resource CreateURLLoader(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateURLRequestInfo(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateVideoDecoder(PP_Instance instance) OVERRIDE;