summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-07 05:33:20 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-07 05:33:20 +0000
commit7ca87c2179917c73feae2f6183d2536dd6690623 (patch)
treee4bf36cdd3bb3045f82d1d921f760d70b7dc73d5 /ppapi
parent187c54919b3af4cd6dec23d9ea3c1547417fe7be (diff)
downloadchromium_src-7ca87c2179917c73feae2f6183d2536dd6690623.zip
chromium_src-7ca87c2179917c73feae2f6183d2536dd6690623.tar.gz
chromium_src-7ca87c2179917c73feae2f6183d2536dd6690623.tar.bz2
Add an instance parameter to var objects, audio, and the 2D API. This replaces the module in most cases.
This will be used in the proxy to multiplex one plugin across multiple renderer processes. We need the instance in the proxy to know which process to send it to. I added a deprecated var object creation function for native client, which depends on the module and this is very difficult to change. Because it doesn't have the multiplexing requirements, this is fine for now. TEST=ppapi ui tests BUG=none Review URL: http://codereview.chromium.org/6085009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70721 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/c/dev/ppb_audio_config_dev.h6
-rw-r--r--ppapi/c/dev/ppb_var_deprecated.h12
-rw-r--r--ppapi/c/ppb_graphics_2d.h11
-rw-r--r--ppapi/c/ppb_image_data.h7
-rw-r--r--ppapi/cpp/dev/audio_config_dev.cc6
-rw-r--r--ppapi/cpp/dev/audio_config_dev.h5
-rw-r--r--ppapi/cpp/dev/audio_dev.cc4
-rw-r--r--ppapi/cpp/dev/audio_dev.h2
-rw-r--r--ppapi/cpp/graphics_2d.cc7
-rw-r--r--ppapi/cpp/graphics_2d.h3
-rw-r--r--ppapi/cpp/image_data.cc5
-rw-r--r--ppapi/cpp/image_data.h4
-rw-r--r--ppapi/cpp/paint_manager.cc2
-rw-r--r--ppapi/cpp/var.cc5
-rw-r--r--ppapi/cpp/var.h12
-rw-r--r--ppapi/example/example.cc15
-rw-r--r--ppapi/tests/test_buffer.cc2
-rw-r--r--ppapi/tests/test_case.cc2
-rw-r--r--ppapi/tests/test_graphics_2d.cc58
-rw-r--r--ppapi/tests/test_image_data.cc25
20 files changed, 118 insertions, 75 deletions
diff --git a/ppapi/c/dev/ppb_audio_config_dev.h b/ppapi/c/dev/ppb_audio_config_dev.h
index cf0df7b..0a1be2a 100644
--- a/ppapi/c/dev/ppb_audio_config_dev.h
+++ b/ppapi/c/dev/ppb_audio_config_dev.h
@@ -6,12 +6,12 @@
#define PPAPI_C_DEV_PPB_AUDIO_CONFIG_DEV_H_
#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_macros.h"
-#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
-#define PPB_AUDIO_CONFIG_DEV_INTERFACE "PPB_AudioConfig(Dev);0.3"
+#define PPB_AUDIO_CONFIG_DEV_INTERFACE "PPB_AudioConfig(Dev);0.4"
enum {
PP_AUDIOMINSAMPLEFRAMECOUNT = 64,
@@ -52,7 +52,7 @@ struct PPB_AudioConfig_Dev {
* buffer16[2 * (sample_frame_count - 1) + 1] is the last right channel sample
* Data will always be in the native endian format of the platform.
*/
- PP_Resource (*CreateStereo16Bit)(PP_Module module,
+ PP_Resource (*CreateStereo16Bit)(PP_Instance instance,
PP_AudioSampleRate_Dev sample_rate,
uint32_t sample_frame_count);
diff --git a/ppapi/c/dev/ppb_var_deprecated.h b/ppapi/c/dev/ppb_var_deprecated.h
index dd3f8bc..7b5af31 100644
--- a/ppapi/c/dev/ppb_var_deprecated.h
+++ b/ppapi/c/dev/ppb_var_deprecated.h
@@ -6,13 +6,14 @@
#define PPAPI_C_PPB_VAR_DEPRECATED_H_
#include "ppapi/c/dev/deprecated_bool.h"
+#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_var.h"
struct PPP_Class_Deprecated;
-#define PPB_VAR_DEPRECATED_INTERFACE "PPB_Var(Deprecated);0.2"
+#define PPB_VAR_DEPRECATED_INTERFACE "PPB_Var(Deprecated);0.3"
/**
* @file
@@ -231,9 +232,16 @@ struct PPB_Var_Deprecated {
* return CreateObject(&point_class, new Point(x, y));
* }</pre>
*/
- struct PP_Var (*CreateObject)(PP_Module module,
+ struct PP_Var (*CreateObject)(PP_Instance instance,
const struct PPP_Class_Deprecated* object_class,
void* object_data);
+
+ // Like CreateObject but takes a module. This will be deleted when all callers
+ // can be changed to use the PP_Instance CreateObject one.
+ struct PP_Var (*CreateObjectWithModuleDeprecated)(
+ PP_Module module,
+ const struct PPP_Class_Deprecated* object_class,
+ void* object_data);
};
/**
diff --git a/ppapi/c/ppb_graphics_2d.h b/ppapi/c/ppb_graphics_2d.h
index 6daa16f..8a166a7 100644
--- a/ppapi/c/ppb_graphics_2d.h
+++ b/ppapi/c/ppb_graphics_2d.h
@@ -6,6 +6,7 @@
#define PPAPI_C_PPB_GRAPHICS_2D_H_
#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
@@ -15,7 +16,7 @@ struct PP_Point;
struct PP_Rect;
struct PP_Size;
-#define PPB_GRAPHICS_2D_INTERFACE "PPB_Graphics2D;0.2"
+#define PPB_GRAPHICS_2D_INTERFACE "PPB_Graphics2D;0.3"
/**
* @file
@@ -28,10 +29,8 @@ struct PP_Size;
/** {PENDING: describe PPB_Graphics2D. */
struct PPB_Graphics2D {
/**
- * The returned graphics context will not be bound to any plugin instance on
- * creation (call BindGraphics on the plugin instance to do that. The
- * graphics context has a lifetime that can exceed that of the given plugin
- * instance.
+ * The returned graphics context will not be bound to the plugin instance on
+ * creation (call BindGraphics on the plugin instance to do that).
*
* Set the is_always_opaque flag if you know that you will be painting only
* opaque data to this context. This will disable blending when compositing
@@ -45,7 +44,7 @@ struct PPB_Graphics2D {
*
* If you aren't sure, it is always correct to specify that it it not opaque.
*/
- PP_Resource (*Create)(PP_Module module,
+ PP_Resource (*Create)(PP_Instance instance,
const struct PP_Size* size,
PP_Bool is_always_opaque);
diff --git a/ppapi/c/ppb_image_data.h b/ppapi/c/ppb_image_data.h
index e1fe5d0..27fbbc0 100644
--- a/ppapi/c/ppb_image_data.h
+++ b/ppapi/c/ppb_image_data.h
@@ -6,6 +6,7 @@
#define PPAPI_C_PPB_IMAGE_DATA_H_
#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_macros.h"
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
@@ -31,7 +32,7 @@ struct PP_ImageDataDesc {
};
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_ImageDataDesc, 16);
-#define PPB_IMAGEDATA_INTERFACE "PPB_ImageData;0.2"
+#define PPB_IMAGEDATA_INTERFACE "PPB_ImageData;0.3"
/**
* @file
@@ -58,7 +59,7 @@ struct PPB_ImageData {
/**
* Allocates an image data resource with the given format and size. The
* return value will have a nonzero ID on success, or zero on failure.
- * Failure means the module handle, image size, or format was invalid.
+ * Failure means the instance, image size, or format was invalid.
*
* Set the init_to_zero flag if you want the bitmap initialized to
* transparent during the creation process. If this flag is not set, the
@@ -69,7 +70,7 @@ struct PPB_ImageData {
* memory, but may contain data from a previous image produced by the same
* plugin if the bitmap was cached and re-used.
*/
- PP_Resource (*Create)(PP_Module module,
+ PP_Resource (*Create)(PP_Instance instance,
PP_ImageDataFormat format,
const struct PP_Size* size,
PP_Bool init_to_zero);
diff --git a/ppapi/cpp/dev/audio_config_dev.cc b/ppapi/cpp/dev/audio_config_dev.cc
index c8f8f3a..754a78f 100644
--- a/ppapi/cpp/dev/audio_config_dev.cc
+++ b/ppapi/cpp/dev/audio_config_dev.cc
@@ -4,6 +4,7 @@
#include "ppapi/cpp/dev/audio_config_dev.h"
+#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
@@ -22,14 +23,15 @@ AudioConfig_Dev::AudioConfig_Dev()
sample_frame_count_(0) {
}
-AudioConfig_Dev::AudioConfig_Dev(PP_AudioSampleRate_Dev sample_rate,
+AudioConfig_Dev::AudioConfig_Dev(Instance* instance,
+ PP_AudioSampleRate_Dev sample_rate,
uint32_t sample_frame_count)
: sample_rate_(sample_rate),
sample_frame_count_(sample_frame_count) {
if (has_interface<PPB_AudioConfig_Dev>()) {
PassRefFromConstructor(
get_interface<PPB_AudioConfig_Dev>()->CreateStereo16Bit(
- Module::Get()->pp_module(), sample_rate, sample_frame_count));
+ instance->pp_instance(), sample_rate, sample_frame_count));
}
}
diff --git a/ppapi/cpp/dev/audio_config_dev.h b/ppapi/cpp/dev/audio_config_dev.h
index 1229156..6b0f1f2 100644
--- a/ppapi/cpp/dev/audio_config_dev.h
+++ b/ppapi/cpp/dev/audio_config_dev.h
@@ -11,6 +11,8 @@
namespace pp {
+class Instance;
+
// Typical usage:
//
// // Create an audio config with a supported frame count.
@@ -34,7 +36,8 @@ class AudioConfig_Dev : public Resource {
// semple frame count.
//
// See PPB_AudioConfigDev.CreateStereo16Bit for more.
- AudioConfig_Dev(PP_AudioSampleRate_Dev sample_rate,
+ AudioConfig_Dev(Instance* instance,
+ PP_AudioSampleRate_Dev sample_rate,
uint32_t sample_frame_count);
// Returns a supported frame count for use in the constructor.
diff --git a/ppapi/cpp/dev/audio_dev.cc b/ppapi/cpp/dev/audio_dev.cc
index 850d4d1..b80d196 100644
--- a/ppapi/cpp/dev/audio_dev.cc
+++ b/ppapi/cpp/dev/audio_dev.cc
@@ -16,14 +16,14 @@ template <> const char* interface_name<PPB_Audio_Dev>() {
} // namespace
-Audio_Dev::Audio_Dev(const Instance& instance,
+Audio_Dev::Audio_Dev(Instance* instance,
const AudioConfig_Dev& config,
PPB_Audio_Callback callback,
void* user_data)
: config_(config) {
if (has_interface<PPB_Audio_Dev>()) {
PassRefFromConstructor(get_interface<PPB_Audio_Dev>()->Create(
- instance.pp_instance(), config.pp_resource(), callback, user_data));
+ instance->pp_instance(), config.pp_resource(), callback, user_data));
}
}
diff --git a/ppapi/cpp/dev/audio_dev.h b/ppapi/cpp/dev/audio_dev.h
index 983e53c..a355cb6 100644
--- a/ppapi/cpp/dev/audio_dev.h
+++ b/ppapi/cpp/dev/audio_dev.h
@@ -17,7 +17,7 @@ namespace pp {
class Audio_Dev : public Resource {
public:
Audio_Dev() {}
- Audio_Dev(const Instance& instance,
+ Audio_Dev(Instance* instance,
const AudioConfig_Dev& config,
PPB_Audio_Callback callback,
void* user_data);
diff --git a/ppapi/cpp/graphics_2d.cc b/ppapi/cpp/graphics_2d.cc
index edd5c33..0db5862 100644
--- a/ppapi/cpp/graphics_2d.cc
+++ b/ppapi/cpp/graphics_2d.cc
@@ -9,6 +9,7 @@
#include "ppapi/cpp/common.h"
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/image_data.h"
+#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
#include "ppapi/cpp/point.h"
@@ -32,12 +33,14 @@ Graphics2D::Graphics2D(const Graphics2D& other)
size_(other.size_) {
}
-Graphics2D::Graphics2D(const Size& size, bool is_always_opaque)
+Graphics2D::Graphics2D(Instance* instance,
+ const Size& size,
+ bool is_always_opaque)
: Resource() {
if (!has_interface<PPB_Graphics2D>())
return;
PassRefFromConstructor(get_interface<PPB_Graphics2D>()->Create(
- Module::Get()->pp_module(),
+ instance->pp_instance(),
&size.pp_size(),
BoolToPPBool(is_always_opaque)));
if (!is_null()) {
diff --git a/ppapi/cpp/graphics_2d.h b/ppapi/cpp/graphics_2d.h
index 39bcb5e..9d498e1 100644
--- a/ppapi/cpp/graphics_2d.h
+++ b/ppapi/cpp/graphics_2d.h
@@ -13,6 +13,7 @@ namespace pp {
class CompletionCallback;
class ImageData;
+class Instance;
class Point;
class Rect;
@@ -27,7 +28,7 @@ class Graphics2D : public Resource {
// Allocates a new 2D graphics context with the given size in the browser,
// resulting object will be is_null() if the allocation failed.
- Graphics2D(const Size& size, bool is_always_opaque);
+ Graphics2D(Instance* instance, const Size& size, bool is_always_opaque);
virtual ~Graphics2D();
diff --git a/ppapi/cpp/image_data.cc b/ppapi/cpp/image_data.cc
index e43263b..33178a6 100644
--- a/ppapi/cpp/image_data.cc
+++ b/ppapi/cpp/image_data.cc
@@ -43,7 +43,8 @@ ImageData::ImageData(PassRef, PP_Resource resource)
PassRefAndInitData(resource);
}
-ImageData::ImageData(PP_ImageDataFormat format,
+ImageData::ImageData(Instance* instance,
+ PP_ImageDataFormat format,
const Size& size,
bool init_to_zero)
: data_(NULL) {
@@ -53,7 +54,7 @@ ImageData::ImageData(PP_ImageDataFormat format,
return;
PassRefAndInitData(get_interface<PPB_ImageData>()->Create(
- Module::Get()->pp_module(), format, &size.pp_size(),
+ instance->pp_instance(), format, &size.pp_size(),
BoolToPPBool(init_to_zero)));
}
diff --git a/ppapi/cpp/image_data.h b/ppapi/cpp/image_data.h
index 25f9156..673bcfc 100644
--- a/ppapi/cpp/image_data.h
+++ b/ppapi/cpp/image_data.h
@@ -12,6 +12,7 @@
namespace pp {
+class Instance;
class Plugin;
class ImageData : public Resource {
@@ -28,7 +29,8 @@ class ImageData : public Resource {
// Allocates a new ImageData in the browser with the given parameters. The
// resulting object will be is_null() if the allocation failed.
- ImageData(PP_ImageDataFormat format,
+ ImageData(Instance* instance,
+ PP_ImageDataFormat format,
const Size& size,
bool init_to_zero);
diff --git a/ppapi/cpp/paint_manager.cc b/ppapi/cpp/paint_manager.cc
index a20cd0c..a555c52 100644
--- a/ppapi/cpp/paint_manager.cc
+++ b/ppapi/cpp/paint_manager.cc
@@ -56,7 +56,7 @@ void PaintManager::SetSize(const Size& new_size) {
if (new_size == graphics_.size())
return;
- graphics_ = Graphics2D(new_size, is_always_opaque_);
+ graphics_ = Graphics2D(instance_, new_size, is_always_opaque_);
if (graphics_.is_null())
return;
instance_->BindGraphics(graphics_);
diff --git a/ppapi/cpp/var.cc b/ppapi/cpp/var.cc
index 58ff30a..43bc869 100644
--- a/ppapi/cpp/var.cc
+++ b/ppapi/cpp/var.cc
@@ -12,6 +12,7 @@
#include "ppapi/c/pp_var.h"
#include "ppapi/c/dev/ppb_var_deprecated.h"
#include "ppapi/cpp/common.h"
+#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/logging.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
@@ -92,10 +93,10 @@ Var::Var(const std::string& utf8_str) {
needs_release_ = (var_.type == PP_VARTYPE_STRING);
}
-Var::Var(ScriptableObject* object) {
+Var::Var(Instance* instance, ScriptableObject* object) {
if (has_interface<PPB_Var_Deprecated>()) {
var_ = get_interface<PPB_Var_Deprecated>()->CreateObject(
- Module::Get()->pp_module(), object->GetClass(), object);
+ instance->pp_instance(), object->GetClass(), object);
needs_release_ = true;
} else {
var_.type = PP_VARTYPE_NULL;
diff --git a/ppapi/cpp/var.h b/ppapi/cpp/var.h
index 9109fef..0fdd5f5 100644
--- a/ppapi/cpp/var.h
+++ b/ppapi/cpp/var.h
@@ -8,10 +8,13 @@
#include <string>
#include <vector>
+#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_var.h"
namespace pp {
+class Instance;
+
namespace deprecated {
class ScriptableObject;
}
@@ -49,7 +52,14 @@ class Var {
}
// Takes ownership of the given pointer.
- Var(deprecated::ScriptableObject* object);
+ Var(Instance* instance, deprecated::ScriptableObject* object);
+
+ // TODO(brettw) erase this! This is a temporary hack to keep the build
+ // going while we land the nacl side of this change. Calling this function
+ // will crash rather than break the compile.
+ Var(deprecated::ScriptableObject* /* object */) {
+ *(int*)0 = 3;
+ }
Var(const Var& other);
diff --git a/ppapi/example/example.cc b/ppapi/example/example.cc
index ab5a248..e875a4b 100644
--- a/ppapi/example/example.cc
+++ b/ppapi/example/example.cc
@@ -44,6 +44,8 @@ void FillRect(pp::ImageData* image, int left, int top, int width, int height,
class MyScriptableObject : public pp::deprecated::ScriptableObject {
public:
+ explicit MyScriptableObject(pp::Instance* instance) : instance_(instance) {}
+
virtual bool HasMethod(const pp::Var& method, pp::Var* exception) {
return method.AsString() == "toString";
}
@@ -56,7 +58,7 @@ class MyScriptableObject : public pp::deprecated::ScriptableObject {
virtual pp::Var GetProperty(const pp::Var& name, pp::Var* exception) {
if (name.is_string() && name.AsString() == "blah")
- return new MyScriptableObject();
+ return pp::Var(instance_, new MyScriptableObject(instance_));
return pp::Var();
}
@@ -72,6 +74,9 @@ class MyScriptableObject : public pp::deprecated::ScriptableObject {
return pp::Var("hello world");
return pp::Var();
}
+
+ private:
+ pp::Instance* instance_;
};
class MyFetcherClient {
@@ -191,11 +196,11 @@ class MyInstance : public pp::Instance, public MyFetcherClient {
}
virtual pp::Var GetInstanceObject() {
- return new MyScriptableObject();
+ return pp::Var(this, new MyScriptableObject(this));
}
pp::ImageData PaintImage(int width, int height) {
- pp::ImageData image(PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::ImageData image(this, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
pp::Size(width, height), false);
if (image.is_null()) {
printf("Couldn't allocate the image data\n");
@@ -240,7 +245,7 @@ class MyInstance : public pp::Instance, public MyFetcherClient {
width_ = position.size().width();
height_ = position.size().height();
- device_context_ = pp::Graphics2D(pp::Size(width_, height_), false);
+ device_context_ = pp::Graphics2D(this, pp::Size(width_, height_), false);
if (!BindGraphics(device_context_)) {
printf("Couldn't bind the device context\n");
return;
@@ -348,7 +353,7 @@ class MyInstance : public pp::Instance, public MyFetcherClient {
pp::Var doc = window.GetProperty("document");
pp::Var body = doc.GetProperty("body");
- pp::Var obj(new MyScriptableObject());
+ pp::Var obj(this, new MyScriptableObject(this));
// Our object should have its toString method called.
Log("Testing MyScriptableObject::toString():");
diff --git a/ppapi/tests/test_buffer.cc b/ppapi/tests/test_buffer.cc
index bcef727..9f1dc4b 100644
--- a/ppapi/tests/test_buffer.cc
+++ b/ppapi/tests/test_buffer.cc
@@ -59,7 +59,7 @@ std::string TestBuffer::TestIsBuffer() {
// Make another resource type and test it.
const int w = 16, h = 16;
- pp::Graphics2D device(pp::Size(w, h), true);
+ pp::Graphics2D device(instance_, pp::Size(w, h), true);
if (device.is_null())
return "Couldn't create device context";
if (buffer_interface_->IsBuffer(device.pp_resource()))
diff --git a/ppapi/tests/test_case.cc b/ppapi/tests/test_case.cc
index 20a7f5f..20e45d1 100644
--- a/ppapi/tests/test_case.cc
+++ b/ppapi/tests/test_case.cc
@@ -29,7 +29,7 @@ pp::Var TestCase::GetTestObject() {
if (test_object_.is_undefined()) {
pp::deprecated::ScriptableObject* so = CreateTestObject();
if (so)
- test_object_ = pp::Var(so); // Takes ownership.
+ test_object_ = pp::Var(instance_, so); // Takes ownership.
}
return test_object_;
}
diff --git a/ppapi/tests/test_graphics_2d.cc b/ppapi/tests/test_graphics_2d.cc
index 1ba8f7f..d57ce48 100644
--- a/ppapi/tests/test_graphics_2d.cc
+++ b/ppapi/tests/test_graphics_2d.cc
@@ -77,7 +77,7 @@ bool TestGraphics2D::ReadImageData(const pp::Graphics2D& dc,
bool TestGraphics2D::IsDCUniformColor(const pp::Graphics2D& dc,
uint32_t color) const {
- pp::ImageData readback(PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::ImageData readback(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
dc.size(), false);
if (readback.is_null())
return false;
@@ -166,7 +166,7 @@ bool TestGraphics2D::IsSquareInDC(const pp::Graphics2D& dc,
uint32_t background_color,
const pp::Rect& square,
uint32_t square_color) const {
- pp::ImageData readback(PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::ImageData readback(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
dc.size(), false);
if (readback.is_null())
return false;
@@ -179,7 +179,8 @@ bool TestGraphics2D::IsSquareInDC(const pp::Graphics2D& dc,
// a crash since the browser don't return a value.
std::string TestGraphics2D::TestInvalidResource() {
pp::Graphics2D null_context;
- pp::ImageData image(PP_IMAGEDATAFORMAT_BGRA_PREMUL, pp::Size(16, 16), true);
+ pp::ImageData image(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::Size(16, 16), true);
// Describe.
PP_Size size;
@@ -237,11 +238,11 @@ std::string TestGraphics2D::TestInvalidResource() {
}
std::string TestGraphics2D::TestInvalidSize() {
- pp::Graphics2D a(pp::Size(16, 0), false);
+ pp::Graphics2D a(instance_, pp::Size(16, 0), false);
if (!a.is_null())
return "0 height accepted";
- pp::Graphics2D b(pp::Size(0, 16), false);
+ pp::Graphics2D b(instance_, pp::Size(0, 16), false);
if (!b.is_null())
return "0 width accepted";
@@ -261,7 +262,7 @@ std::string TestGraphics2D::TestInvalidSize() {
}
std::string TestGraphics2D::TestHumongous() {
- pp::Graphics2D a(pp::Size(100000, 100000), false);
+ pp::Graphics2D a(instance_, pp::Size(100000, 100000), false);
if (!a.is_null())
return "Humongous device created";
return "";
@@ -269,13 +270,14 @@ std::string TestGraphics2D::TestHumongous() {
std::string TestGraphics2D::TestInitToZero() {
const int w = 15, h = 17;
- pp::Graphics2D dc(pp::Size(w, h), false);
+ pp::Graphics2D dc(instance_, pp::Size(w, h), false);
if (dc.is_null())
return "Failure creating a boring device";
// Make an image with nonzero data in it (so we can test that zeros were
// actually read versus ReadImageData being a NOP).
- pp::ImageData image(PP_IMAGEDATAFORMAT_BGRA_PREMUL, pp::Size(w, h), true);
+ pp::ImageData image(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::Size(w, h), true);
if (image.is_null())
return "Failure to allocate an image";
memset(image.data(), 0xFF, image.stride() * image.size().height() * 4);
@@ -291,7 +293,7 @@ std::string TestGraphics2D::TestInitToZero() {
std::string TestGraphics2D::TestDescribe() {
const int w = 15, h = 17;
- pp::Graphics2D dc(pp::Size(w, h), false);
+ pp::Graphics2D dc(instance_, pp::Size(w, h), false);
if (dc.is_null())
return "Failure creating a boring device";
@@ -310,7 +312,7 @@ std::string TestGraphics2D::TestDescribe() {
std::string TestGraphics2D::TestPaint() {
const int w = 15, h = 17;
- pp::Graphics2D dc(pp::Size(w, h), false);
+ pp::Graphics2D dc(instance_, pp::Size(w, h), false);
if (dc.is_null())
return "Failure creating a boring device";
@@ -320,8 +322,8 @@ std::string TestGraphics2D::TestPaint() {
// Fill the backing store with white.
const uint32_t background_color = 0xFFFFFFFF;
- pp::ImageData background(PP_IMAGEDATAFORMAT_BGRA_PREMUL, pp::Size(w, h),
- false);
+ pp::ImageData background(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::Size(w, h), false);
FillRectInImage(&background, pp::Rect(0, 0, w, h), background_color);
dc.PaintImageData(background, pp::Point(0, 0));
if (!FlushAndWaitForDone(&dc))
@@ -329,8 +331,8 @@ std::string TestGraphics2D::TestPaint() {
// Make an image to paint with that's opaque white and enqueue a paint.
const int fill_w = 2, fill_h = 3;
- pp::ImageData fill(PP_IMAGEDATAFORMAT_BGRA_PREMUL, pp::Size(fill_w, fill_h),
- true);
+ pp::ImageData fill(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::Size(fill_w, fill_h), true);
if (fill.is_null())
return "Failure to allocate fill image";
FillRectInImage(&fill, pp::Rect(fill.size()), background_color);
@@ -371,7 +373,8 @@ std::string TestGraphics2D::TestPaint() {
return "Partially offscreen paint failed.";
// Now repaint that top left pixel by doing a subset of the source image.
- pp::ImageData subset(PP_IMAGEDATAFORMAT_BGRA_PREMUL, pp::Size(w, h), false);
+ pp::ImageData subset(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::Size(w, h), false);
uint32_t subset_color = 0x80808080;
const int subset_x = 2, subset_y = 1;
*subset.GetAddr32(pp::Point(subset_x, subset_y)) = subset_color;
@@ -388,7 +391,7 @@ std::string TestGraphics2D::TestPaint() {
std::string TestGraphics2D::TestScroll() {
const int w = 115, h = 117;
- pp::Graphics2D dc(pp::Size(w, h), false);
+ pp::Graphics2D dc(instance_, pp::Size(w, h), false);
if (dc.is_null())
return "Failure creating a boring device.";
@@ -397,7 +400,7 @@ std::string TestGraphics2D::TestScroll() {
return "Bad initial color.";
const int image_w = 15, image_h = 23;
- pp::ImageData test_image(PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::ImageData test_image(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
pp::Size(image_w, image_h), false);
FillImageWithGradient(&test_image);
@@ -418,7 +421,7 @@ std::string TestGraphics2D::TestScroll() {
image_x += dx;
image_y += dy;
- pp::ImageData readback(PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::ImageData readback(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
pp::Size(image_w, image_h), false);
if (!ReadImageData(dc, &readback, pp::Point(image_x, image_y)))
return "TC1, Couldn't read back image data.";
@@ -450,12 +453,12 @@ std::string TestGraphics2D::TestScroll() {
std::string TestGraphics2D::TestReplace() {
const int w = 15, h = 17;
- pp::Graphics2D dc(pp::Size(w, h), false);
+ pp::Graphics2D dc(instance_, pp::Size(w, h), false);
if (dc.is_null())
return "Failure creating a boring device";
// Replacing with a different size image should fail.
- pp::ImageData weird_size(PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::ImageData weird_size(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
pp::Size(w - 1, h), true);
if (weird_size.is_null())
return "Failure allocating the weird sized image";
@@ -463,8 +466,8 @@ std::string TestGraphics2D::TestReplace() {
// Fill the background with blue but don't flush yet.
const int32_t background_color = 0xFF0000FF;
- pp::ImageData background(PP_IMAGEDATAFORMAT_BGRA_PREMUL, pp::Size(w, h),
- true);
+ pp::ImageData background(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::Size(w, h), true);
if (background.is_null())
return "Failure to allocate background image";
FillRectInImage(&background, pp::Rect(0, 0, w, h), background_color);
@@ -472,7 +475,8 @@ std::string TestGraphics2D::TestReplace() {
// Replace with a green background but don't flush yet.
const int32_t swapped_color = 0xFF0000FF;
- pp::ImageData swapped(PP_IMAGEDATAFORMAT_BGRA_PREMUL, pp::Size(w, h), true);
+ pp::ImageData swapped(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::Size(w, h), true);
if (swapped.is_null())
return "Failure to allocate swapped image";
FillRectInImage(&swapped, pp::Rect(0, 0, w, h), swapped_color);
@@ -505,13 +509,13 @@ std::string TestGraphics2D::TestFlush() {
// Tests that synchronous flushes (NULL callback) fail on the main thread
// (which is the current one).
const int w = 15, h = 17;
- pp::Graphics2D dc(pp::Size(w, h), false);
+ pp::Graphics2D dc(instance_, pp::Size(w, h), false);
if (dc.is_null())
return "Failure creating a boring device";
// Fill the background with blue but don't flush yet.
- pp::ImageData background(PP_IMAGEDATAFORMAT_BGRA_PREMUL, pp::Size(w, h),
- true);
+ pp::ImageData background(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::Size(w, h), true);
if (background.is_null())
return "Failure to allocate background image";
dc.PaintImageData(background, pp::Point(0, 0));
@@ -522,7 +526,7 @@ std::string TestGraphics2D::TestFlush() {
// Test flushing with no operations still issues a callback.
// (This may also hang if the browser never issues the callback).
- pp::Graphics2D dc_nopaints(pp::Size(w, h), false);
+ pp::Graphics2D dc_nopaints(instance_, pp::Size(w, h), false);
if (dc.is_null())
return "Failure creating the nopaint device";
if (!FlushAndWaitForDone(&dc_nopaints))
diff --git a/ppapi/tests/test_image_data.cc b/ppapi/tests/test_image_data.cc
index 6300264..b841e4e 100644
--- a/ppapi/tests/test_image_data.cc
+++ b/ppapi/tests/test_image_data.cc
@@ -27,13 +27,13 @@ void TestImageData::RunTest() {
}
std::string TestImageData::TestInvalidFormat() {
- pp::ImageData a(static_cast<PP_ImageDataFormat>(1337), pp::Size(16, 16),
- true);
+ pp::ImageData a(instance_, static_cast<PP_ImageDataFormat>(1337),
+ pp::Size(16, 16), true);
if (!a.is_null())
return "Crazy image data format accepted";
- pp::ImageData b(static_cast<PP_ImageDataFormat>(-1), pp::Size(16, 16),
- true);
+ pp::ImageData b(instance_, static_cast<PP_ImageDataFormat>(-1),
+ pp::Size(16, 16), true);
if (!b.is_null())
return "Negative image data format accepted";
@@ -41,16 +41,17 @@ std::string TestImageData::TestInvalidFormat() {
}
std::string TestImageData::TestInvalidSize() {
- pp::ImageData zero_size(PP_IMAGEDATAFORMAT_BGRA_PREMUL, pp::Size(0, 0), true);
+ pp::ImageData zero_size(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::Size(0, 0), true);
if (!zero_size.is_null())
return "Zero width and height accepted";
- pp::ImageData zero_height(PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::ImageData zero_height(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
pp::Size(16, 0), true);
if (!zero_height.is_null())
return "Zero height accepted";
- pp::ImageData zero_width(PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::ImageData zero_width(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
pp::Size(0, 16), true);
if (!zero_width.is_null())
return "Zero width accepted";
@@ -79,7 +80,7 @@ std::string TestImageData::TestInvalidSize() {
}
std::string TestImageData::TestHugeSize() {
- pp::ImageData huge_size(PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::ImageData huge_size(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
pp::Size(100000000, 100000000), true);
if (!huge_size.is_null())
return "31-bit overflow size accepted";
@@ -89,7 +90,8 @@ std::string TestImageData::TestHugeSize() {
std::string TestImageData::TestInitToZero() {
const int w = 5;
const int h = 6;
- pp::ImageData img(PP_IMAGEDATAFORMAT_BGRA_PREMUL, pp::Size(w, h), true);
+ pp::ImageData img(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::Size(w, h), true);
if (img.is_null())
return "Could not create bitmap";
@@ -122,14 +124,15 @@ std::string TestImageData::TestIsImageData() {
// Make another resource type and test it.
const int w = 16, h = 16;
- pp::Graphics2D device(pp::Size(w, h), true);
+ pp::Graphics2D device(instance_, pp::Size(w, h), true);
if (device.is_null())
return "Couldn't create device context";
if (image_data_interface_->IsImageData(device.pp_resource()))
return "Device context was reported as an image";
// Make a valid image resource.
- pp::ImageData img(PP_IMAGEDATAFORMAT_BGRA_PREMUL, pp::Size(w, h), true);
+ pp::ImageData img(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::Size(w, h), true);
if (img.is_null())
return "Couldn't create image data";
if (!image_data_interface_->IsImageData(img.pp_resource()))