diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-18 17:47:49 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-18 17:47:49 +0000 |
commit | de9cfbce825a56e003bf0140ac83a3211c72ad9f (patch) | |
tree | 5d04897da40a06dbaffdfce61493ce7193700b11 | |
parent | 377b4cc93ed0ca53988f5cc23026fb1ca3c6d838 (diff) | |
download | chromium_src-de9cfbce825a56e003bf0140ac83a3211c72ad9f.zip chromium_src-de9cfbce825a56e003bf0140ac83a3211c72ad9f.tar.gz chromium_src-de9cfbce825a56e003bf0140ac83a3211c72ad9f.tar.bz2 |
Pull latest ppapi for initial testing support, implement checks so the tests pass in Chrome. Mostly, this involves better error checking.
The most substantial change is that I made TransportDIB able to return NULL on failure to make a PlatformCanvas, which we run into when makeing too large of a canvas from a plugin. I checked all the callers of this function to make sure they all handled the problem (many already did).
TEST=pulls Pepper test
BUG=-none
Review URL: http://codereview.chromium.org/2101004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47526 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | DEPS | 2 | ||||
-rw-r--r-- | app/surface/transport_dib.h | 3 | ||||
-rw-r--r-- | app/surface/transport_dib_linux.cc | 7 | ||||
-rw-r--r-- | app/surface/transport_dib_mac.cc | 7 | ||||
-rw-r--r-- | app/surface/transport_dib_win.cc | 6 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.cc | 2 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_image_data.cc | 9 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_instance.h | 4 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_resource.h | 3 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_resource_tracker.h | 3 |
10 files changed, 33 insertions, 13 deletions
@@ -143,7 +143,7 @@ deps = { Var("ffmpeg_revision"), "src/third_party/ppapi": - "http://ppapi.googlecode.com/svn/trunk@38", + "http://ppapi.googlecode.com/svn/trunk@39", } diff --git a/app/surface/transport_dib.h b/app/surface/transport_dib.h index 44fb6a9..ffa10e4 100644 --- a/app/surface/transport_dib.h +++ b/app/surface/transport_dib.h @@ -131,6 +131,9 @@ class TransportDIB { // Returns a canvas using the memory of this TransportDIB. The returned // pointer will be owned by the caller. The bitmap will be of the given size, // which should fit inside this memory. + // + // Will return NULL on allocation failure. This could be because the image + // is too large to map into the current process' address space. skia::PlatformCanvas* GetPlatformCanvas(int w, int h); // Return a pointer to the shared memory diff --git a/app/surface/transport_dib_linux.cc b/app/surface/transport_dib_linux.cc index 6c41a0c..26cad3f 100644 --- a/app/surface/transport_dib_linux.cc +++ b/app/surface/transport_dib_linux.cc @@ -10,6 +10,7 @@ #include "app/surface/transport_dib.h" #include "app/x11_util.h" #include "base/logging.h" +#include "base/scoped_ptr.h" #include "gfx/size.h" #include "skia/ext/platform_canvas.h" @@ -86,8 +87,10 @@ bool TransportDIB::is_valid(Handle dib) { } skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { - return new skia::PlatformCanvas(w, h, true, - reinterpret_cast<uint8_t*>(memory())); + scoped_ptr<skia::PlatformCanvas> canvas(new skia::PlatformCanvas); + if (!canvas->initialize(w, h, true, reinterpret_cast<uint8_t*>(memory()))) + return NULL; + return canvas.release(); } void* TransportDIB::memory() const { diff --git a/app/surface/transport_dib_mac.cc b/app/surface/transport_dib_mac.cc index cc56ab6..ef1d242 100644 --- a/app/surface/transport_dib_mac.cc +++ b/app/surface/transport_dib_mac.cc @@ -8,6 +8,7 @@ #include <sys/stat.h> #include "base/eintr_wrapper.h" +#include "base/scoped_ptr.h" #include "base/shared_memory.h" #include "skia/ext/platform_canvas.h" @@ -60,8 +61,10 @@ bool TransportDIB::is_valid(Handle dib) { } skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { - return new skia::PlatformCanvas(w, h, true, - reinterpret_cast<uint8_t*>(memory())); + scoped_ptr<skia::PlatformCanvas> canvas(new skia::PlatformCanvas); + if (!canvas->initialize(w, h, true, reinterpret_cast<uint8_t*>(memory()))) + return NULL; + return canvas.release(); } void* TransportDIB::memory() const { diff --git a/app/surface/transport_dib_win.cc b/app/surface/transport_dib_win.cc index 2a92fb1..9246f24 100644 --- a/app/surface/transport_dib_win.cc +++ b/app/surface/transport_dib_win.cc @@ -7,6 +7,7 @@ #include "app/surface/transport_dib.h" #include "base/logging.h" +#include "base/scoped_ptr.h" #include "base/sys_info.h" #include "skia/ext/platform_canvas.h" @@ -65,7 +66,10 @@ bool TransportDIB::is_valid(Handle dib) { } skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { - return new skia::PlatformCanvas(w, h, true, handle()); + scoped_ptr<skia::PlatformCanvas> canvas(new skia::PlatformCanvas); + if (!canvas->initialize(w, h, true, handle())) + return NULL; + return canvas.release(); } void* TransportDIB::memory() const { diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index a545b03..18532f9 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -700,7 +700,7 @@ bool WebPluginDelegateProxy::CreateSharedBitmap( #endif canvas->reset((*memory)->GetPlatformCanvas(plugin_rect_.width(), plugin_rect_.height())); - return true; + return !!canvas->get(); } #if defined(OS_MACOSX) diff --git a/webkit/glue/plugins/pepper_image_data.cc b/webkit/glue/plugins/pepper_image_data.cc index cf86437..ba6ebd7 100644 --- a/webkit/glue/plugins/pepper_image_data.cc +++ b/webkit/glue/plugins/pepper_image_data.cc @@ -5,6 +5,7 @@ #include "webkit/glue/plugins/pepper_image_data.h" #include <algorithm> +#include <limits> #include "base/logging.h" #include "base/scoped_ptr.h" @@ -107,6 +108,14 @@ bool ImageData::Init(PP_ImageDataFormat format, bool init_to_zero) { // TODO(brettw) this should be called only on the main thread! // TODO(brettw) use init_to_zero when we implement caching. + if (format != PP_IMAGEDATAFORMAT_BGRA_PREMUL) + return false; // Only support this one format for now. + if (width <= 0 || height <= 0) + return false; + if (static_cast<int64>(width) * static_cast<int64>(height) >= + std::numeric_limits<int32>::max()) + return false; // Prevent overflow of signed 32-bit ints. + platform_image_.reset( module()->GetSomeInstance()->delegate()->CreateImage2D(width, height)); width_ = width; diff --git a/webkit/glue/plugins/pepper_plugin_instance.h b/webkit/glue/plugins/pepper_plugin_instance.h index b81ad09..3286928 100644 --- a/webkit/glue/plugins/pepper_plugin_instance.h +++ b/webkit/glue/plugins/pepper_plugin_instance.h @@ -10,10 +10,10 @@ #include "base/basictypes.h" #include "base/ref_counted.h" +#include "third_party/ppapi/c/pp_instance.h" +#include "third_party/ppapi/c/pp_resource.h" #include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h" -typedef struct _pp_Instance PP_Instance; -typedef struct _pp_Resource PP_Resource; typedef struct _pp_Var PP_Var; typedef struct _ppb_Instance PPB_Instance; typedef struct _ppp_Instance PPP_Instance; diff --git a/webkit/glue/plugins/pepper_resource.h b/webkit/glue/plugins/pepper_resource.h index 6cf1e28..e70ff4a 100644 --- a/webkit/glue/plugins/pepper_resource.h +++ b/webkit/glue/plugins/pepper_resource.h @@ -7,8 +7,7 @@ #include "base/basictypes.h" #include "base/ref_counted.h" - -typedef struct _pp_Resource PP_Resource; +#include "third_party/ppapi/c/pp_resource.h" namespace pepper { diff --git a/webkit/glue/plugins/pepper_resource_tracker.h b/webkit/glue/plugins/pepper_resource_tracker.h index f24afc2..b3a67bd 100644 --- a/webkit/glue/plugins/pepper_resource_tracker.h +++ b/webkit/glue/plugins/pepper_resource_tracker.h @@ -12,8 +12,7 @@ #include "base/lock.h" #include "base/ref_counted.h" #include "base/singleton.h" - -typedef struct _pp_Resource PP_Resource; +#include "third_party/ppapi/c/pp_resource.h" namespace pepper { |