summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorten Johan Sorvig <morten.sorvig@nokia.com>2010-03-30 13:23:31 +0200
committerMorten Johan Sorvig <morten.sorvig@nokia.com>2010-03-30 13:23:31 +0200
commitfa67538c197c977386d23666749fd72ebbfebcd4 (patch)
tree86902415e1559b849dc074f1cc3f8878ea928a00
parent1e7862d7748fddc25c624cbe44bf01f89cd3cb38 (diff)
Remove more pepper sample code.
-rw-r--r--src/gui/pepper/pepper.pri1
-rw-r--r--src/gui/pepper/plugin_object.cc49
-rw-r--r--src/gui/pepper/plugin_object.h1
-rw-r--r--src/gui/pepper/test_object.cc226
4 files changed, 3 insertions, 274 deletions
diff --git a/src/gui/pepper/pepper.pri b/src/gui/pepper/pepper.pri
index 5844f66db0..b26dad3d5a 100644
--- a/src/gui/pepper/pepper.pri
+++ b/src/gui/pepper/pepper.pri
@@ -3,7 +3,6 @@ INCLUDEDIR =+ $$PWD
DEPENDIR += $$PWD
SOURCES += $$PWD/event_handler.cc \
$$PWD/plugin_object.cc \
- $$PWD/test_object.cc \
$$PWD/main.cc \
$$PWD/peppermain.cpp
diff --git a/src/gui/pepper/plugin_object.cc b/src/gui/pepper/plugin_object.cc
index 1f65a214a7..1922368e3e 100644
--- a/src/gui/pepper/plugin_object.cc
+++ b/src/gui/pepper/plugin_object.cc
@@ -226,27 +226,6 @@ void FlushCallback(NPP , NPDeviceContext* ,
NPExtensions* extensions = NULL;
-// Sine wave similar to one from simple_sources.cc
-// F is the desired frequency (e.g. 200), T is sample type (e.g. int16)
-template <int F, typename T> void SineWaveCallback(
- NPDeviceContextAudio *context) {
-
- const size_t n_samples = context->config.sampleFrameCount;
- const size_t n_channels = context->config.outputChannelMap;
- const double th = 2 * 3.141592653589 * F / context->config.sampleRate;
- // store time value to avoid clicks on buffer boundries
- intptr_t t = (intptr_t)context->config.userData;
-
- T* buf = reinterpret_cast<T*>(context->outBuffer);
- for (size_t sample = 0; sample < n_samples; ++sample) {
- T value = static_cast<T>(sin(th * t++) * std::numeric_limits<T>::max());
- for (size_t channel = 0; channel < n_channels; ++channel) {
- *buf++ = value;
- }
- }
- context->config.userData = reinterpret_cast<void *>(t);
-}
-
const int32 kCommandBufferSize = 1024 * 1024;
} // namespace
@@ -256,16 +235,14 @@ const int32 kCommandBufferSize = 1024 * 1024;
PluginObject::PluginObject(NPP npp)
: npp_(npp),
- test_object_(browser->createobject(npp, GetTestClass())),
- device2d_(NULL),
- deviceaudio_(NULL) {
- memset(&context_audio_, 0, sizeof(context_audio_));
+ //test_object_(browser->createobject(npp, GetTestClass())),
+ device2d_(NULL) {
plugin_object = this;
}
PluginObject::~PluginObject() {
- browser->releaseobject(test_object_);
+ // browser->releaseobject(test_object_);
plugin_object = 0;
}
@@ -282,13 +259,8 @@ void PluginObject::New(NPMIMEType pluginType,
if (!extensions) {
browser->getvalue(npp_, NPNVPepperExtensions,
reinterpret_cast<void*>(&extensions));
- // CHECK(extensions);
}
device2d_ = extensions->acquireDevice(npp_, NPPepper2DDevice);
- // CHECK(device2d_);
-
- // deviceaudio_ = extensions->acquireDevice(npp_, NPPepperAudioDevice);
- // CHECK(deviceaudio_);
}
void PluginObject::SetWindow(const NPWindow& window) {
@@ -310,21 +282,6 @@ void PluginObject::SetWindow(const NPWindow& window) {
qt_nacl_setup();
qtSetupDone = true;
}
-
-#if 0
- // testing any field would do
- if (!context_audio_.config.callback) {
- NPDeviceContextAudioConfig cfg;
- cfg.sampleRate = 44100;
- cfg.sampleType = NPAudioSampleTypeInt16;
- cfg.outputChannelMap = NPAudioChannelStereo;
- cfg.inputChannelMap = NPAudioChannelNone;
- cfg.sampleFrameCount = 2048;
- cfg.flags = 0;
- cfg.callback = &SineWaveCallback<200, int16>;
- deviceaudio_->initializeContext(npp_, &cfg, &context_audio_);
- }
-#endif
}
diff --git a/src/gui/pepper/plugin_object.h b/src/gui/pepper/plugin_object.h
index 0e7cd83b23..470465bdbe 100644
--- a/src/gui/pepper/plugin_object.h
+++ b/src/gui/pepper/plugin_object.h
@@ -50,7 +50,6 @@ class PluginObject {
DISALLOW_IMPLICIT_CONSTRUCTORS(PluginObject);
- bool InitializeCommandBuffer();
NPObject header_;
NPP npp_;
diff --git a/src/gui/pepper/test_object.cc b/src/gui/pepper/test_object.cc
deleted file mode 100644
index 66971cfac7..0000000000
--- a/src/gui/pepper/test_object.cc
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_object.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "plugin_object.h"
-
-static bool testEnumerate(NPObject*, NPIdentifier **value, uint32_t *count);
-static bool testHasMethod(NPObject*, NPIdentifier name);
-static bool testInvoke(NPObject* header,
- NPIdentifier name,
- const NPVariant* args,
- uint32_t argCount,
- NPVariant* result);
-static bool testInvokeDefault(NPObject*,
- const NPVariant *args,
- uint32_t argCount,
- NPVariant *result);
-static bool testHasProperty(NPObject*, NPIdentifier name);
-static bool testGetProperty(NPObject*, NPIdentifier name, NPVariant *variant);
-static NPObject *testAllocate(NPP npp, NPClass *theClass);
-static void testDeallocate(NPObject* obj);
-static bool testConstruct(NPObject* npobj,
- const NPVariant* args,
- uint32_t argCount,
- NPVariant* result);
-
-static NPClass testClass = {
- NP_CLASS_STRUCT_VERSION,
- testAllocate,
- testDeallocate,
- 0,
- testHasMethod,
- testInvoke,
- testInvokeDefault,
- testHasProperty,
- testGetProperty,
- 0,
- 0,
- testEnumerate,
- testConstruct
-};
-
-NPClass* GetTestClass() {
- return &testClass;
-}
-
-int testObjectCount = 0;
-
-int GetTestObjectCount() {
- return testObjectCount;
-}
-
-static bool identifiersInitialized = false;
-
-#define NUM_ENUMERABLE_TEST_IDENTIFIERS 4
-#define NUM_TEST_IDENTIFIERS 5
-
-#define ID_PROPERTY_FOO 0
-#define ID_PROPERTY_BAR 1
-#define ID_PROPERTY_TEST_OBJECT 2
-#define ID_PROPERTY_REF_COUNT 3
-#define ID_PROPERTY_OBJECT_POINTER 4
-
-static NPIdentifier testIdentifiers[NUM_TEST_IDENTIFIERS];
-static const NPUTF8 *testIdentifierNames[NUM_TEST_IDENTIFIERS] = {
- "foo",
- "bar",
- "testObject",
- "refCount",
- "objectPointer",
-};
-
-#define ID_THROW_EXCEPTION_METHOD 0
-#define NUM_METHOD_IDENTIFIERS 1
-
-static NPIdentifier testMethodIdentifiers[NUM_METHOD_IDENTIFIERS];
-static const NPUTF8 *testMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
- "throwException",
-};
-
-static void initializeIdentifiers(void) {
- browser->getstringidentifiers(testIdentifierNames,
- NUM_TEST_IDENTIFIERS,
- testIdentifiers);
- browser->getstringidentifiers(testMethodIdentifierNames,
- NUM_METHOD_IDENTIFIERS,
- testMethodIdentifiers);
-}
-
-static NPObject *testAllocate(NPP npp, NPClass *theClass) {
- TestObject *newInstance =
- static_cast<TestObject*>(malloc(sizeof(TestObject)));
- newInstance->test_object = NULL;
- ++testObjectCount;
-
- if (!identifiersInitialized) {
- identifiersInitialized = true;
- initializeIdentifiers();
- }
-
- return reinterpret_cast<NPObject*>(newInstance);
-}
-
-static void testDeallocate(NPObject *obj) {
- TestObject *testObject = reinterpret_cast<TestObject*>(obj);
- if (testObject->test_object)
- browser->releaseobject(testObject->test_object);
- --testObjectCount;
- free(obj);
-}
-
-static bool testHasMethod(NPObject*, NPIdentifier name) {
- for (unsigned i = 0; i < NUM_METHOD_IDENTIFIERS; i++) {
- if (testMethodIdentifiers[i] == name)
- return true;
- }
- return false;
-}
-
-static bool testInvoke(NPObject* header,
- NPIdentifier name,
- const NPVariant* args,
- uint32_t argCount,
- NPVariant* result) {
- if (name == testMethodIdentifiers[ID_THROW_EXCEPTION_METHOD]) {
- browser->setexception(header, "test object throwException SUCCESS");
- return true;
- }
- return false;
-}
-
-static bool testInvokeDefault(NPObject *obj,
- const NPVariant *args,
- uint32_t argCount,
- NPVariant *result) {
- INT32_TO_NPVARIANT(2, *result);
- return true;
-}
-
-static bool testHasProperty(NPObject*, NPIdentifier name) {
- for (unsigned i = 0; i < NUM_TEST_IDENTIFIERS; i++) {
- if (testIdentifiers[i] == name)
- return true;
- }
- return false;
-}
-
-static bool testGetProperty(NPObject *obj,
- NPIdentifier name,
- NPVariant *variant) {
- if (name == testIdentifiers[ID_PROPERTY_FOO]) {
- const size_t kFooLength = 4;
- char* mem = static_cast<char*>(browser->memalloc(kFooLength));
- snprintf(mem, kFooLength, "foo");
- STRINGZ_TO_NPVARIANT(mem, *variant);
- return true;
- } else if (name == testIdentifiers[ID_PROPERTY_BAR]) {
- BOOLEAN_TO_NPVARIANT(true, *variant);
- return true;
- } else if (name == testIdentifiers[ID_PROPERTY_TEST_OBJECT]) {
- TestObject* testObject = reinterpret_cast<TestObject*>(obj);
- if (testObject->test_object == NULL)
- testObject->test_object = browser->createobject(NULL, &testClass);
- browser->retainobject(testObject->test_object);
- OBJECT_TO_NPVARIANT(testObject->test_object, *variant);
- return true;
- } else if (name == testIdentifiers[ID_PROPERTY_REF_COUNT]) {
- INT32_TO_NPVARIANT(obj->referenceCount, *variant);
- return true;
- } else if (name == testIdentifiers[ID_PROPERTY_OBJECT_POINTER]) {
- int32_t objectPointer =
- static_cast<int32_t>(reinterpret_cast<uintptr_t>(obj));
- INT32_TO_NPVARIANT(objectPointer, *variant);
- return true;
- }
- return false;
-}
-
-static bool testEnumerate(NPObject *npobj,
- NPIdentifier **value,
- uint32_t *count) {
- *count = NUM_ENUMERABLE_TEST_IDENTIFIERS;
- const size_t kTotalSize = *count * sizeof(NPIdentifier);
-
- *value = reinterpret_cast<NPIdentifier*>(browser->memalloc(kTotalSize));
- memcpy(*value, testIdentifiers, kTotalSize);
-
- return true;
-}
-
-static bool testConstruct(NPObject* npobj,
- const NPVariant* args,
- uint32_t argCount,
- NPVariant* result) {
- browser->retainobject(npobj);
-
- // Just return the same object.
- OBJECT_TO_NPVARIANT(npobj, *result);
- return true;
-}