summaryrefslogtreecommitdiffstats
path: root/o3d/gpu_plugin
diff options
context:
space:
mode:
authorapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-02 18:16:07 +0000
committerapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-02 18:16:07 +0000
commitcdec6ce6b720d9fffb7ef2a7999a3166e7c3dd26 (patch)
tree598f7d7944161c224413f704b843dfd7d8216c53 /o3d/gpu_plugin
parentbfe4c158cd0372fa7a602997f65b42a92645aaf3 (diff)
downloadchromium_src-cdec6ce6b720d9fffb7ef2a7999a3166e7c3dd26.zip
chromium_src-cdec6ce6b720d9fffb7ef2a7999a3166e7c3dd26.tar.gz
chromium_src-cdec6ce6b720d9fffb7ef2a7999a3166e7c3dd26.tar.bz2
Replaced SharedMemory::Map method with NPN_MapMemory.
Moved responsibility for mapping ring buffer into GPUProcessor. Removed SharedMemory::SetInt32 and SetFloat. Implemented GetWindowNPObject in WebKitNHPBrowser. TEST=none BUG=none Review URL: http://codereview.chromium.org/246069 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27867 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/gpu_plugin')
-rw-r--r--o3d/gpu_plugin/command_buffer.cc20
-rw-r--r--o3d/gpu_plugin/command_buffer.h7
-rw-r--r--o3d/gpu_plugin/command_buffer_mock.h4
-rw-r--r--o3d/gpu_plugin/command_buffer_unittest.cc24
-rw-r--r--o3d/gpu_plugin/gpu_plugin.gyp22
-rw-r--r--o3d/gpu_plugin/gpu_plugin.h3
-rw-r--r--o3d/gpu_plugin/gpu_plugin_object.cc4
-rw-r--r--o3d/gpu_plugin/gpu_plugin_object.h5
-rw-r--r--o3d/gpu_plugin/gpu_plugin_object_unittest.cc11
-rw-r--r--o3d/gpu_plugin/gpu_processor.cc31
-rw-r--r--o3d/gpu_plugin/gpu_processor.h3
-rw-r--r--o3d/gpu_plugin/gpu_processor_unittest.cc24
-rw-r--r--o3d/gpu_plugin/gpu_processor_win.cc37
-rw-r--r--o3d/gpu_plugin/np_utils/np_browser.cc12
-rw-r--r--o3d/gpu_plugin/np_utils/np_browser.h4
-rw-r--r--o3d/gpu_plugin/np_utils/np_browser_mock.h7
-rw-r--r--o3d/gpu_plugin/np_utils/np_browser_stub.cc8
-rw-r--r--o3d/gpu_plugin/np_utils/np_browser_stub.h3
-rw-r--r--o3d/gpu_plugin/np_utils/np_headers.h6
-rw-r--r--o3d/gpu_plugin/np_utils/webkit_browser.h9
-rw-r--r--o3d/gpu_plugin/system_services/shared_memory.cc75
-rw-r--r--o3d/gpu_plugin/system_services/shared_memory.h31
-rw-r--r--o3d/gpu_plugin/system_services/shared_memory_mock.h3
-rw-r--r--o3d/gpu_plugin/system_services/shared_memory_public.h35
-rw-r--r--o3d/gpu_plugin/system_services/shared_memory_unittest.cc139
25 files changed, 203 insertions, 324 deletions
diff --git a/o3d/gpu_plugin/command_buffer.cc b/o3d/gpu_plugin/command_buffer.cc
index c499866..293235ce 100644
--- a/o3d/gpu_plugin/command_buffer.cc
+++ b/o3d/gpu_plugin/command_buffer.cc
@@ -29,7 +29,7 @@ bool CommandBuffer::Initialize(int32 size) {
if (num_bytes / sizeof(int32) != size)
return false;
- if (shared_memory_.Get())
+ if (ring_buffer_.Get())
return false;
NPObjectPointer<NPObject> window = NPObjectPointer<NPObject>::FromReturned(
@@ -47,22 +47,12 @@ bool CommandBuffer::Initialize(int32 size) {
return false;
}
- NPObjectPointer<NPObject> result;
if (!NPInvoke(npp_, system, "createSharedMemory", num_bytes,
- &result)) {
+ &ring_buffer_)) {
return false;
}
- // TODO(spatrick): validate NPClass before assuming a CHRSharedMemory is
- // returned.
- shared_memory_ = NPObjectPointer<CHRSharedMemory>(
- static_cast<CHRSharedMemory*>(result.Get()));
- if (!shared_memory_.Get())
- return false;
-
- bool mapped;
- if (!NPInvoke(npp_, shared_memory_, "map", &mapped) || !mapped) {
- shared_memory_ = NPObjectPointer<CHRSharedMemory>();
+ if (!ring_buffer_.Get()) {
return false;
}
@@ -70,8 +60,8 @@ bool CommandBuffer::Initialize(int32 size) {
return true;
}
-NPObjectPointer<CHRSharedMemory> CommandBuffer::GetRingBuffer() {
- return shared_memory_;
+NPObjectPointer<NPObject> CommandBuffer::GetRingBuffer() {
+ return ring_buffer_;
}
int32 CommandBuffer::GetSize() {
diff --git a/o3d/gpu_plugin/command_buffer.h b/o3d/gpu_plugin/command_buffer.h
index 6565470..65d5343 100644
--- a/o3d/gpu_plugin/command_buffer.h
+++ b/o3d/gpu_plugin/command_buffer.h
@@ -12,7 +12,6 @@
#include "base/task.h"
#include "o3d/gpu_plugin/np_utils/default_np_object.h"
#include "o3d/gpu_plugin/np_utils/np_dispatcher.h"
-#include "o3d/gpu_plugin/system_services/shared_memory_public.h"
namespace o3d {
namespace gpu_plugin {
@@ -28,7 +27,7 @@ class CommandBuffer : public DefaultNPObject<NPObject> {
virtual bool Initialize(int32 size);
// Gets the shared memory ring buffer object for the command buffer.
- virtual NPObjectPointer<CHRSharedMemory> GetRingBuffer();
+ virtual NPObjectPointer<NPObject> GetRingBuffer();
virtual int32 GetSize();
@@ -108,7 +107,7 @@ class CommandBuffer : public DefaultNPObject<NPObject> {
NP_UTILS_BEGIN_DISPATCHER_CHAIN(CommandBuffer, DefaultNPObject<NPObject>)
NP_UTILS_DISPATCHER(Initialize, bool(int32 size))
- NP_UTILS_DISPATCHER(GetRingBuffer, NPObjectPointer<CHRSharedMemory>())
+ NP_UTILS_DISPATCHER(GetRingBuffer, NPObjectPointer<NPObject>())
NP_UTILS_DISPATCHER(GetSize, int32())
NP_UTILS_DISPATCHER(SyncOffsets, int32(int32 get_offset))
NP_UTILS_DISPATCHER(GetGetOffset, int32());
@@ -124,7 +123,7 @@ class CommandBuffer : public DefaultNPObject<NPObject> {
private:
NPP npp_;
- NPObjectPointer<CHRSharedMemory> shared_memory_;
+ NPObjectPointer<NPObject> ring_buffer_;
int32 size_;
int32 get_offset_;
int32 put_offset_;
diff --git a/o3d/gpu_plugin/command_buffer_mock.h b/o3d/gpu_plugin/command_buffer_mock.h
index 31e1d63..6592546 100644
--- a/o3d/gpu_plugin/command_buffer_mock.h
+++ b/o3d/gpu_plugin/command_buffer_mock.h
@@ -17,13 +17,13 @@ class MockCommandBuffer : public CommandBuffer {
public:
explicit MockCommandBuffer(NPP npp) : CommandBuffer(npp) {
ON_CALL(*this, GetRingBuffer())
- .WillByDefault(testing::Return(NPObjectPointer<CHRSharedMemory>()));
+ .WillByDefault(testing::Return(NPObjectPointer<NPObject>()));
ON_CALL(*this, GetRegisteredObject(testing::_))
.WillByDefault(testing::Return(NPObjectPointer<NPObject>()));
}
MOCK_METHOD1(Initialize, bool(int32 size));
- MOCK_METHOD0(GetRingBuffer, NPObjectPointer<CHRSharedMemory>());
+ MOCK_METHOD0(GetRingBuffer, NPObjectPointer<NPObject>());
MOCK_METHOD0(GetSize, int32());
MOCK_METHOD1(SyncOffsets, int32(int32 put_offset));
MOCK_METHOD0(GetGetOffset, int32());
diff --git a/o3d/gpu_plugin/command_buffer_unittest.cc b/o3d/gpu_plugin/command_buffer_unittest.cc
index e9c720f..8a542d3 100644
--- a/o3d/gpu_plugin/command_buffer_unittest.cc
+++ b/o3d/gpu_plugin/command_buffer_unittest.cc
@@ -73,9 +73,6 @@ TEST_F(CommandBufferTest, InitializesCommandBuffer) {
EXPECT_CALL(*system_object_.Get(), CreateSharedMemory(1024))
.WillOnce(Return(expected_shared_memory));
- EXPECT_CALL(*expected_shared_memory.Get(), Map())
- .WillOnce(Return(true));
-
EXPECT_TRUE(command_buffer_->Initialize(256));
EXPECT_EQ(expected_shared_memory, command_buffer_->GetRingBuffer());
@@ -100,24 +97,6 @@ TEST_F(CommandBufferTest, InitializeFailsIfCannotCreateSharedMemory) {
command_buffer_->GetRingBuffer());
}
-TEST_F(CommandBufferTest, InitializeFailsIfCannotMapSharedMemory) {
- EXPECT_CALL(mock_browser_, GetWindowNPObject(NULL))
- .WillOnce(Return(window_object_.ToReturned()));
-
- NPObjectPointer<MockSharedMemory> expected_shared_memory =
- NPCreateObject<StrictMock<MockSharedMemory> >(NULL);
-
- EXPECT_CALL(*system_object_.Get(), CreateSharedMemory(1024))
- .WillOnce(Return(expected_shared_memory));
-
- EXPECT_CALL(*expected_shared_memory.Get(), Map())
- .WillOnce(Return(false));
-
- EXPECT_FALSE(command_buffer_->Initialize(256));
- EXPECT_EQ(NPObjectPointer<NPObject>(),
- command_buffer_->GetRingBuffer());
-}
-
TEST_F(CommandBufferTest, GetAndPutOffsetsDefaultToZero) {
EXPECT_EQ(0, command_buffer_->GetGetOffset());
EXPECT_EQ(0, command_buffer_->GetPutOffset());
@@ -138,9 +117,6 @@ TEST_F(CommandBufferTest, CanSyncGetAndPutOffset) {
EXPECT_CALL(*system_object_.Get(), CreateSharedMemory(1024))
.WillOnce(Return(expected_shared_memory));
- EXPECT_CALL(*expected_shared_memory.Get(), Map())
- .WillOnce(Return(true));
-
EXPECT_TRUE(command_buffer_->Initialize(256));
StrictMock<MockCallback>* put_offset_change_callback =
diff --git a/o3d/gpu_plugin/gpu_plugin.gyp b/o3d/gpu_plugin/gpu_plugin.gyp
index 5402197..3edc4a3 100644
--- a/o3d/gpu_plugin/gpu_plugin.gyp
+++ b/o3d/gpu_plugin/gpu_plugin.gyp
@@ -15,7 +15,8 @@
],
'include_dirs': [
'../..',
-
+ '../../third_party/npapi',
+
# Chrome NPAPI header dir appears before the O3D one so it takes
# priority. TODO(apatrick): one set of NPAPI headers.
'../../third_party/npapi/bindings',
@@ -23,6 +24,8 @@
],
'direct_dependent_settings': {
'include_dirs': [
+ '../../third_party/npapi',
+
# Chrome NPAPI header dir appears before the O3D one so it takes
# priority. TODO(apatrick): one set of NPAPI headers.
'../../third_party/npapi/bindings',
@@ -62,7 +65,7 @@
'target_name': 'np_utils_unittests',
'type': 'executable',
'dependencies': [
- 'gpu_plugin',
+ 'np_utils',
'../../testing/gmock.gyp:gmock',
'../../testing/gmock.gyp:gmockmain',
'../../testing/gtest.gyp:gtest',
@@ -90,7 +93,22 @@
'include_dirs': [
'../..',
'../../third_party/npapi',
+
+ # Chrome NPAPI header dir appears before the O3D one so it takes
+ # priority. TODO(apatrick): one set of NPAPI headers.
+ '../../third_party/npapi/bindings',
+ '../../third_party/npapi/include',
],
+ 'direct_dependent_settings': {
+ 'include_dirs': [
+ '../../third_party/npapi',
+
+ # Chrome NPAPI header dir appears before the O3D one so it takes
+ # priority. TODO(apatrick): one set of NPAPI headers.
+ '../../third_party/npapi/bindings',
+ '../../third_party/npapi/include',
+ ],
+ },
'sources': [
'system_services/shared_memory.cc',
'system_services/shared_memory.h',
diff --git a/o3d/gpu_plugin/gpu_plugin.h b/o3d/gpu_plugin/gpu_plugin.h
index 748a69e..a8fa9ef 100644
--- a/o3d/gpu_plugin/gpu_plugin.h
+++ b/o3d/gpu_plugin/gpu_plugin.h
@@ -5,8 +5,7 @@
#ifndef O3D_GPU_PLUGIN_GPU_PLUGIN_H_
#define O3D_GPU_PLUGIN_GPU_PLUGIN_H_
-#include "third_party/npapi/bindings/npapi.h"
-#include "third_party/npapi/bindings/npruntime.h"
+#include "o3d/gpu_plugin/np_utils/np_headers.h"
typedef struct _NPPluginFuncs NPPluginFuncs;
typedef struct _NPNetscapeFuncs NPNetscapeFuncs;
diff --git a/o3d/gpu_plugin/gpu_plugin_object.cc b/o3d/gpu_plugin/gpu_plugin_object.cc
index 60e3414..d9a1959 100644
--- a/o3d/gpu_plugin/gpu_plugin_object.cc
+++ b/o3d/gpu_plugin/gpu_plugin_object.cc
@@ -12,10 +12,6 @@
namespace o3d {
namespace gpu_plugin {
-namespace {
-const int32 kCommandBufferSize = 1024;
-} // namespace anonymous
-
const NPUTF8 GPUPluginObject::kPluginType[] =
"application/vnd.google.chrome.gpu-plugin";
diff --git a/o3d/gpu_plugin/gpu_plugin_object.h b/o3d/gpu_plugin/gpu_plugin_object.h
index 127ee8d..00c4b85 100644
--- a/o3d/gpu_plugin/gpu_plugin_object.h
+++ b/o3d/gpu_plugin/gpu_plugin_object.h
@@ -12,10 +12,9 @@
#include "o3d/gpu_plugin/command_buffer.h"
#include "o3d/gpu_plugin/np_utils/default_np_object.h"
#include "o3d/gpu_plugin/np_utils/np_dispatcher.h"
+#include "o3d/gpu_plugin/np_utils/np_headers.h"
#include "o3d/gpu_plugin/np_utils/np_plugin_object.h"
#include "o3d/gpu_plugin/np_utils/np_utils.h"
-#include "third_party/npapi/bindings/npapi.h"
-#include "third_party/npapi/bindings/npruntime.h"
namespace o3d {
namespace gpu_plugin {
@@ -26,6 +25,8 @@ class GPUProcessor;
class GPUPluginObject : public DefaultNPObject<NPObject>,
public PluginObject {
public:
+ static const int32 kCommandBufferSize = 1024 * 1024;
+
static const NPUTF8 kPluginType[];
explicit GPUPluginObject(NPP npp);
diff --git a/o3d/gpu_plugin/gpu_plugin_object_unittest.cc b/o3d/gpu_plugin/gpu_plugin_object_unittest.cc
index f87f3c4..efe38b2 100644
--- a/o3d/gpu_plugin/gpu_plugin_object_unittest.cc
+++ b/o3d/gpu_plugin/gpu_plugin_object_unittest.cc
@@ -9,7 +9,12 @@
#include "o3d/gpu_plugin/np_utils/np_object_pointer.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/gmock/include/gmock/gmock.h"
+
+#if defined(O3D_IN_CHROME)
#include "webkit/glue/plugins/nphostapi.h"
+#else
+#include "npupp.h"
+#endif
using testing::_;
using testing::DoAll;
@@ -111,7 +116,8 @@ TEST_F(GPUPluginObjectTest, OpenCommandBufferReturnsInitializedCommandBuffer) {
NPGetClass<CommandBuffer>()))
.WillOnce(Return(command_buffer.ToReturned()));
- EXPECT_CALL(*command_buffer.Get(), Initialize(1024))
+ EXPECT_CALL(*command_buffer.Get(),
+ Initialize(GPUPluginObject::kCommandBufferSize))
.WillOnce(Return(true));
EXPECT_CALL(*command_buffer.Get(), SetPutOffsetChangeCallback(NotNull()));
@@ -140,7 +146,8 @@ TEST_F(GPUPluginObjectTest, OpenCommandBufferReturnsNullIfCannotInitialize) {
NPGetClass<CommandBuffer>()))
.WillOnce(Return(command_buffer.ToReturned()));
- EXPECT_CALL(*command_buffer.Get(), Initialize(1024))
+ EXPECT_CALL(*command_buffer.Get(),
+ Initialize(GPUPluginObject::kCommandBufferSize))
.WillOnce(Return(false));
EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo",
diff --git a/o3d/gpu_plugin/gpu_processor.cc b/o3d/gpu_plugin/gpu_processor.cc
index bb74617..b757a37 100644
--- a/o3d/gpu_plugin/gpu_processor.cc
+++ b/o3d/gpu_plugin/gpu_processor.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "o3d/gpu_plugin/gpu_processor.h"
-#include "o3d/gpu_plugin/system_services/shared_memory_public.h"
namespace o3d {
namespace gpu_plugin {
@@ -48,29 +47,23 @@ void GPUProcessor::ProcessCommands() {
}
void *GPUProcessor::GetSharedMemoryAddress(unsigned int shm_id) {
- // TODO(apatrick): Verify that the NPClass is in fact shared memory before
- // accessing the members.
- NPObjectPointer<CHRSharedMemory> shared_memory(static_cast<CHRSharedMemory*>(
- command_buffer_->GetRegisteredObject(static_cast<int32>(shm_id)).Get()));
+ NPObjectPointer<NPObject> shared_memory =
+ command_buffer_->GetRegisteredObject(static_cast<int32>(shm_id));
- // Return address if shared memory is already mapped to this process.
- if (shared_memory->ptr)
- return shared_memory->ptr;
-
- // If the call fails or returns false then ptr will still be NULL.
- bool result;
- NPInvoke(npp_, shared_memory, "map", &result);
-
- return shared_memory->ptr;
+ size_t size;
+ return NPBrowser::get()->MapMemory(npp_, shared_memory.Get(), &size);
}
+// TODO(apatrick): Consolidate this with the above and return both the address
+// and size.
size_t GPUProcessor::GetSharedMemorySize(unsigned int shm_id) {
- // TODO(apatrick): Verify that the NPClass is in fact shared memory before
- // accessing the members.
- NPObjectPointer<CHRSharedMemory> shared_memory(static_cast<CHRSharedMemory*>(
- command_buffer_->GetRegisteredObject(static_cast<int32>(shm_id)).Get()));
+ NPObjectPointer<NPObject> shared_memory =
+ command_buffer_->GetRegisteredObject(static_cast<int32>(shm_id));
+
+ size_t size;
+ NPBrowser::get()->MapMemory(npp_, shared_memory.Get(), &size);
- return shared_memory->size;
+ return size;
}
void GPUProcessor::set_token(unsigned int token) {
diff --git a/o3d/gpu_plugin/gpu_processor.h b/o3d/gpu_plugin/gpu_processor.h
index fd87b98..246b277 100644
--- a/o3d/gpu_plugin/gpu_processor.h
+++ b/o3d/gpu_plugin/gpu_processor.h
@@ -5,6 +5,8 @@
#ifndef O3D_GPU_PLUGIN_GPU_PROCESSOR_H_
#define O3D_GPU_PLUGIN_GPU_PROCESSOR_H_
+#include "base/scoped_ptr.h"
+#include "base/shared_memory.h"
#include "o3d/command_buffer/service/cross/cmd_buffer_engine.h"
#include "o3d/command_buffer/service/cross/cmd_parser.h"
#include "o3d/command_buffer/service/cross/gapi_decoder.h"
@@ -64,6 +66,7 @@ class GPUProcessor : public base::RefCountedThreadSafe<GPUProcessor>,
private:
NPP npp_;
NPObjectPointer<CommandBuffer> command_buffer_;
+ scoped_ptr<base::SharedMemory> mapped_ring_buffer_;
int commands_per_update_;
#if defined(OS_WIN)
diff --git a/o3d/gpu_plugin/gpu_processor_unittest.cc b/o3d/gpu_plugin/gpu_processor_unittest.cc
index 7447bb8..d06a382 100644
--- a/o3d/gpu_plugin/gpu_processor_unittest.cc
+++ b/o3d/gpu_plugin/gpu_processor_unittest.cc
@@ -8,7 +8,7 @@
#include "o3d/command_buffer/service/cross/mocks.h"
#include "o3d/gpu_plugin/command_buffer_mock.h"
#include "o3d/gpu_plugin/gpu_processor.h"
-#include "o3d/gpu_plugin/np_utils/np_browser_stub.h"
+#include "o3d/gpu_plugin/np_utils/np_browser_mock.h"
#include "o3d/gpu_plugin/np_utils/np_object_pointer.h"
#include "o3d/gpu_plugin/system_services/shared_memory_mock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -16,6 +16,7 @@
using testing::_;
using testing::DoAll;
+using testing::Invoke;
using testing::NiceMock;
using testing::Return;
using testing::SetArgumentPointee;
@@ -28,10 +29,17 @@ class GPUProcessorTest : public testing::Test {
protected:
virtual void SetUp() {
shared_memory_ = NPCreateObject<NiceMock<MockSharedMemory> >(NULL);
- shared_memory_->ptr = buffer_;
- shared_memory_->size = sizeof(buffer_);
memset(buffer_, 0, sizeof(buffer_));
+ ON_CALL(mock_browser_, MapMemory(NULL, shared_memory_.Get(), _))
+ .WillByDefault(DoAll(SetArgumentPointee<2>(sizeof(buffer_)),
+ Return(buffer_)));
+
+ // Don't mock PluginThreadAsyncCall. Have it schedule the task.
+ ON_CALL(mock_browser_, PluginThreadAsyncCall(_, _, _))
+ .WillByDefault(Invoke(&mock_browser_,
+ &MockNPBrowser::ConcretePluginThreadAsyncCall));
+
command_buffer_ = NPCreateObject<MockCommandBuffer>(NULL);
ON_CALL(*command_buffer_.Get(), GetRingBuffer())
.WillByDefault(Return(shared_memory_));
@@ -69,7 +77,7 @@ class GPUProcessorTest : public testing::Test {
base::AtExitManager at_exit_manager;
MessageLoop message_loop;
- StubNPBrowser stub_browser_;
+ MockNPBrowser mock_browser_;
NPObjectPointer<MockCommandBuffer> command_buffer_;
NPObjectPointer<NiceMock<MockSharedMemory> > shared_memory_;
int32 buffer_[1024 / sizeof(int32)];
@@ -281,11 +289,9 @@ TEST_F(GPUProcessorTest, GetAddressOfSharedMemoryMapsMemoryIfUnmapped) {
EXPECT_CALL(*command_buffer_.Get(), GetRegisteredObject(7))
.WillOnce(Return(shared_memory_));
- shared_memory_->ptr = NULL;
-
- EXPECT_CALL(*shared_memory_.Get(), Map())
- .WillOnce(DoAll(SetPointee(&shared_memory_->ptr, &buffer_[0]),
- Return(true)));
+ EXPECT_CALL(mock_browser_, MapMemory(NULL, shared_memory_.Get(), _))
+ .WillOnce(DoAll(SetArgumentPointee<2>(sizeof(buffer_)),
+ Return(buffer_)));
EXPECT_EQ(&buffer_[0], processor_->GetSharedMemoryAddress(7));
}
diff --git a/o3d/gpu_plugin/gpu_processor_win.cc b/o3d/gpu_plugin/gpu_processor_win.cc
index acd667f..30f963f 100644
--- a/o3d/gpu_plugin/gpu_processor_win.cc
+++ b/o3d/gpu_plugin/gpu_processor_win.cc
@@ -15,23 +15,8 @@ GPUProcessor::GPUProcessor(NPP npp,
command_buffer_(command_buffer),
commands_per_update_(100) {
gapi_.reset(new command_buffer::GAPID3D9);
-
decoder_.reset(new command_buffer::GAPIDecoder(gapi_.get()));
-
- NPObjectPointer<CHRSharedMemory> ring_buffer =
- command_buffer->GetRingBuffer();
-
- if (ring_buffer.Get()) {
- parser_.reset(new command_buffer::CommandParser(ring_buffer->ptr,
- ring_buffer->size,
- 0,
- ring_buffer->size,
- 0,
- decoder_.get()));
- } else {
- parser_.reset(new command_buffer::CommandParser(NULL, 0, 0, 0, 0,
- decoder_.get()));
- }
+ decoder_->set_engine(this);
}
GPUProcessor::GPUProcessor(NPP npp,
@@ -52,6 +37,26 @@ bool GPUProcessor::Initialize(HWND handle) {
// Cannot reinitialize.
DCHECK(gapi_->hwnd() == NULL);
+ // Map the ring buffer and create the parser.
+ NPObjectPointer<NPObject> ring_buffer =
+ command_buffer_->GetRingBuffer();
+
+ if (ring_buffer.Get()) {
+ size_t size;
+ void* ptr = NPBrowser::get()->MapMemory(npp_,
+ ring_buffer.Get(),
+ &size);
+ if (ptr == NULL) {
+ return false;
+ }
+
+ parser_.reset(new command_buffer::CommandParser(ptr, size, 0, size, 0,
+ decoder_.get()));
+ } else {
+ parser_.reset(new command_buffer::CommandParser(NULL, 0, 0, 0, 0,
+ decoder_.get()));
+ }
+
// Initialize GAPI immediately if the window handle is valid.
if (handle) {
gapi_->set_hwnd(handle);
diff --git a/o3d/gpu_plugin/np_utils/np_browser.cc b/o3d/gpu_plugin/np_utils/np_browser.cc
index c86104d..f6f8189 100644
--- a/o3d/gpu_plugin/np_utils/np_browser.cc
+++ b/o3d/gpu_plugin/np_utils/np_browser.cc
@@ -5,6 +5,12 @@
#include "o3d/gpu_plugin/np_utils/np_browser.h"
#include "base/logging.h"
+#if defined(O3D_IN_CHROME)
+#include "webkit/glue/plugins/nphostapi.h"
+#else
+#include "npupp.h"
+#endif
+
namespace o3d {
namespace gpu_plugin {
@@ -109,5 +115,11 @@ void NPBrowser::PluginThreadAsyncCall(NPP npp,
netscape_funcs_->pluginthreadasynccall(npp, callback, data);
}
+void* NPBrowser::MapMemory(NPP npp,
+ NPObject* object,
+ size_t* size) {
+ return netscape_funcs_->mapmemory(npp, object, size);
+}
+
} // namespace gpu_plugin
} // namespace o3d
diff --git a/o3d/gpu_plugin/np_utils/np_browser.h b/o3d/gpu_plugin/np_utils/np_browser.h
index dc50d81..04429d4 100644
--- a/o3d/gpu_plugin/np_utils/np_browser.h
+++ b/o3d/gpu_plugin/np_utils/np_browser.h
@@ -76,6 +76,10 @@ class NPBrowser {
PluginThreadAsyncCallProc callback,
void* data);
+ virtual void* MapMemory(NPP npp,
+ NPObject* object,
+ size_t* size);
+
private:
static NPBrowser* browser_;
NPBrowser* previous_browser_;
diff --git a/o3d/gpu_plugin/np_utils/np_browser_mock.h b/o3d/gpu_plugin/np_utils/np_browser_mock.h
index 4cfe25d..e638809 100644
--- a/o3d/gpu_plugin/np_utils/np_browser_mock.h
+++ b/o3d/gpu_plugin/np_utils/np_browser_mock.h
@@ -29,10 +29,17 @@ class MockNPBrowser : public StubNPBrowser {
&MockNPBrowser::ConcreteCreateObject));
}
+ void ConcretePluginThreadAsyncCall(NPP npp,
+ PluginThreadAsyncCallProc callback,
+ void* data) {
+ return StubNPBrowser::PluginThreadAsyncCall(npp, callback, data);
+ }
+
MOCK_METHOD2(CreateObject, NPObject*(NPP npp, const NPClass* cl));
MOCK_METHOD1(GetWindowNPObject, NPObject*(NPP cpp));
MOCK_METHOD3(PluginThreadAsyncCall,
void(NPP npp, PluginThreadAsyncCallProc callback, void* data));
+ MOCK_METHOD3(MapMemory, void*(NPP npp, NPObject* object, size_t* size));
};
} // namespace gpu_plugin
diff --git a/o3d/gpu_plugin/np_utils/np_browser_stub.cc b/o3d/gpu_plugin/np_utils/np_browser_stub.cc
index 7e27a2b..d6d3e87 100644
--- a/o3d/gpu_plugin/np_utils/np_browser_stub.cc
+++ b/o3d/gpu_plugin/np_utils/np_browser_stub.cc
@@ -112,5 +112,13 @@ void StubNPBrowser::PluginThreadAsyncCall(
MessageLoop::current()->PostTask(FROM_HERE,
NewRunnableFunction(callback, data));
}
+
+void* StubNPBrowser::MapMemory(NPP npp,
+ NPObject* object,
+ size_t* size) {
+ *size = 0;
+ return NULL;
+}
+
} // namespace gpu_plugin
} // namespace o3d
diff --git a/o3d/gpu_plugin/np_utils/np_browser_stub.h b/o3d/gpu_plugin/np_utils/np_browser_stub.h
index b5c9cff..ce4908c 100644
--- a/o3d/gpu_plugin/np_utils/np_browser_stub.h
+++ b/o3d/gpu_plugin/np_utils/np_browser_stub.h
@@ -68,6 +68,9 @@ class StubNPBrowser : public NPBrowser {
virtual void PluginThreadAsyncCall(NPP npp,
PluginThreadAsyncCallProc callback,
void* data);
+ virtual void* MapMemory(NPP npp,
+ NPObject* object,
+ size_t* size);
private:
DISALLOW_COPY_AND_ASSIGN(StubNPBrowser);
diff --git a/o3d/gpu_plugin/np_utils/np_headers.h b/o3d/gpu_plugin/np_utils/np_headers.h
index 49e496c..6a2a3c6 100644
--- a/o3d/gpu_plugin/np_utils/np_headers.h
+++ b/o3d/gpu_plugin/np_utils/np_headers.h
@@ -16,10 +16,4 @@
#undef utf8characters
#undef utf8length
-#if defined(O3D_IN_CHROME)
-#include "webkit/glue/plugins/nphostapi.h"
-#else
-#include "npupp.h"
-#endif
-
#endif // O3D_GPU_PLUGIN_NP_UTILS_NP_HEADERS_H_
diff --git a/o3d/gpu_plugin/np_utils/webkit_browser.h b/o3d/gpu_plugin/np_utils/webkit_browser.h
index 70e0782..86cfa3e 100644
--- a/o3d/gpu_plugin/np_utils/webkit_browser.h
+++ b/o3d/gpu_plugin/np_utils/webkit_browser.h
@@ -99,7 +99,14 @@ class WebKitBrowser : public NPBrowser {
}
virtual NPObject* GetWindowNPObject(NPP npp) {
- return NULL;
+ NPObject* window;
+ if (NPERR_NO_ERROR == NPN_GetValue(npp,
+ NPNVWindowNPObject,
+ &window)) {
+ return window;
+ } else {
+ return NULL;
+ }
}
private:
diff --git a/o3d/gpu_plugin/system_services/shared_memory.cc b/o3d/gpu_plugin/system_services/shared_memory.cc
index 9600111..dbe7f7c 100644
--- a/o3d/gpu_plugin/system_services/shared_memory.cc
+++ b/o3d/gpu_plugin/system_services/shared_memory.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "o3d/gpu_plugin/np_utils/np_class.h"
#include "o3d/gpu_plugin/system_services/shared_memory.h"
namespace o3d {
@@ -10,77 +11,55 @@ namespace gpu_plugin {
SharedMemory::SharedMemory(NPP npp)
: npp_(npp),
shared_memory_(NULL) {
- handle = NULL;
- ptr = NULL;
- size = 0;
}
SharedMemory::~SharedMemory() {
- if (shared_memory_) {
- delete shared_memory_;
- }
-}
-
-void SharedMemory::Initialize(base::SharedMemory* shared_memory, int32 size) {
- DCHECK(shared_memory);
- shared_memory_ = shared_memory;
- this->handle = shared_memory->handle();
- this->size = size;
}
bool SharedMemory::Initialize(int32 size) {
if (size < 0)
return false;
- if (shared_memory_)
+ if (shared_memory_.get())
return false;
- shared_memory_ = new base::SharedMemory();
+ shared_memory_.reset(new base::SharedMemory());
if (!shared_memory_->Create(std::wstring(), false, false, size)) {
- delete shared_memory_;
- shared_memory_ = NULL;
+ shared_memory_.reset();
return false;
}
- handle = shared_memory_->handle();
- this->size = size;
return true;
}
-bool SharedMemory::Map() {
- if (!shared_memory_)
- return false;
-
- if (!shared_memory_->memory()) {
- if (!shared_memory_->Map(shared_memory_->max_size()))
- return false;
-
- ptr = shared_memory_->memory();
- }
-
- return true;
+int32 SharedMemory::GetSize() {
+ return shared_memory_.get() ? shared_memory_->max_size() : 0;
}
-bool SharedMemory::SetInt32(int32 offset, int32 value) {
- if (!ptr)
- return false;
+} // namespace gpu_plugin
+} // namespace o3d
- if (offset < 0 || offset * sizeof(value) >= size)
- return false;
+void* NPN_MapMemory(NPP npp, NPObject* object, size_t* size) {
+ *size = 0;
- reinterpret_cast<int32*>(ptr)[offset] = value;
- return true;
-}
+ // Check that the object really is shared memory.
+ if (object->_class !=
+ o3d::gpu_plugin::NPGetClass<o3d::gpu_plugin::SharedMemory>()) {
+ return NULL;
+ }
-bool SharedMemory::SetFloat(int32 offset, float value) {
- if (!ptr)
- return false;
+ o3d::gpu_plugin::SharedMemory* shared_memory_object =
+ static_cast<o3d::gpu_plugin::SharedMemory*>(object);
+ base::SharedMemory* shared_memory =
+ shared_memory_object->shared_memory();
+ if (!shared_memory) {
+ return NULL;
+ }
- if (offset < 0 || offset * sizeof(value) >= size)
- return false;
+ if (!shared_memory->memory()) {
+ shared_memory->Map(shared_memory->max_size());
+ }
- reinterpret_cast<float*>(ptr)[offset] = value;
- return true;
+ *size = shared_memory->max_size();
+ return shared_memory->memory();
}
-} // namespace gpu_plugin
-} // namespace o3d
diff --git a/o3d/gpu_plugin/system_services/shared_memory.h b/o3d/gpu_plugin/system_services/shared_memory.h
index 7d72544..1ee7df4 100644
--- a/o3d/gpu_plugin/system_services/shared_memory.h
+++ b/o3d/gpu_plugin/system_services/shared_memory.h
@@ -5,61 +5,44 @@
#ifndef O3D_GPU_PLUGIN_SYSTEM_SERVICES_SHARED_MEMORY_H_
#define O3D_GPU_PLUGIN_SYSTEM_SERVICES_SHARED_MEMORY_H_
+#include "base/scoped_ptr.h"
#include "base/shared_memory.h"
#include "o3d/gpu_plugin/np_utils/default_np_object.h"
#include "o3d/gpu_plugin/np_utils/np_dispatcher.h"
#include "o3d/gpu_plugin/np_utils/np_object_pointer.h"
-#include "o3d/gpu_plugin/system_services/shared_memory_public.h"
#include "third_party/npapi/bindings/npruntime.h"
namespace o3d {
namespace gpu_plugin {
// An NPObject holding a shared memory handle.
-class SharedMemory : public DefaultNPObject<CHRSharedMemory> {
+class SharedMemory : public DefaultNPObject<NPObject> {
public:
explicit SharedMemory(NPP npp);
~SharedMemory();
- // Initialize from an existing base::SharedMemory. Takes ownership of the
- // base::SharedMemory.
- void Initialize(base::SharedMemory* shared_memory, int32 size);
-
virtual bool Initialize(int32 size);
- virtual int32 GetSize() {
- return size;
- }
-
- virtual bool Map();
-
- // This is a temporary function to allow me to drive the command buffer from
- // JavaScript for the purposes of testing.
- bool SetInt32(int32 offset, int32 value);
-
- // This is a temporary function to allow me to drive the command buffer from
- // JavaScript for the purposes of testing.
- bool SetFloat(int32 offset, float value);
+ virtual int32 GetSize();
base::SharedMemory* shared_memory() const {
- return shared_memory_;
+ return shared_memory_.get();
}
NP_UTILS_BEGIN_DISPATCHER_CHAIN(SharedMemory, DefaultNPObject<NPObject>)
NP_UTILS_DISPATCHER(Initialize, bool(int32 size));
NP_UTILS_DISPATCHER(GetSize, int32())
- NP_UTILS_DISPATCHER(Map, bool())
- NP_UTILS_DISPATCHER(SetInt32, bool(int32 offset, int32 value));
- NP_UTILS_DISPATCHER(SetFloat, bool(int32 offset, float value));
NP_UTILS_END_DISPATCHER_CHAIN
private:
NPP npp_;
- base::SharedMemory* shared_memory_;
+ scoped_ptr<base::SharedMemory> shared_memory_;
DISALLOW_COPY_AND_ASSIGN(SharedMemory);
};
} // namespace gpu_plugin
} // namespace o3d
+void* NPN_MapMemory(NPP npp, NPObject* object, size_t* size);
+
#endif // O3D_GPU_PLUGIN_SYSTEM_SERVICES_SHARED_MEMORY_H_
diff --git a/o3d/gpu_plugin/system_services/shared_memory_mock.h b/o3d/gpu_plugin/system_services/shared_memory_mock.h
index de3f93d..435174c 100644
--- a/o3d/gpu_plugin/system_services/shared_memory_mock.h
+++ b/o3d/gpu_plugin/system_services/shared_memory_mock.h
@@ -16,9 +16,8 @@ class MockSharedMemory : public SharedMemory {
explicit MockSharedMemory(NPP npp) : SharedMemory(npp) {
}
- MOCK_METHOD1(Initialize, bool(int32));
+ MOCK_METHOD1(Initialize, bool(int32 size));
MOCK_METHOD0(GetSize, int32());
- MOCK_METHOD0(Map, bool());
private:
DISALLOW_COPY_AND_ASSIGN(MockSharedMemory);
diff --git a/o3d/gpu_plugin/system_services/shared_memory_public.h b/o3d/gpu_plugin/system_services/shared_memory_public.h
deleted file mode 100644
index f6598ed..0000000
--- a/o3d/gpu_plugin/system_services/shared_memory_public.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2006-2008 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 O3D_GPU_PLUGIN_SYSTEM_SERVICES_SHARED_MEMORY_PUBLIC_H_
-#define O3D_GPU_PLUGIN_SYSTEM_SERVICES_SHARED_MEMORY_PUBLIC_H_
-
-// Mapped memory range. Size is zero and pointer is null until object is
-// mapped. Each process needs to separately map the object. It is safe to
-// map an already mapped object.
-
-// Deliberately not including a directory name because Chromium and O3D put
-// these headers in different directories.
-#include "npruntime.h"
-
-#if defined(__cplusplus)
-
-struct CHRSharedMemory : NPObject {
- size_t size;
- void* ptr;
- void* handle;
-};
-
-#else
-
-typedef struct _CHRSharedMemory {
- NPObject object;
- size_t size;
- void* ptr;
- void* handle;
-} CHRSharedMemory;
-
-#endif
-
-#endif // O3D_GPU_PLUGIN_SYSTEM_SERVICES_SHARED_MEMORY_PUBLIC_H_
diff --git a/o3d/gpu_plugin/system_services/shared_memory_unittest.cc b/o3d/gpu_plugin/system_services/shared_memory_unittest.cc
index d6eea84..0c56f98 100644
--- a/o3d/gpu_plugin/system_services/shared_memory_unittest.cc
+++ b/o3d/gpu_plugin/system_services/shared_memory_unittest.cc
@@ -27,33 +27,34 @@ class SharedMemoryTest : public testing::Test {
NPObjectPointer<SharedMemory> shared_memory_;
};
-TEST_F(SharedMemoryTest, MemoryIsNotMappedBeforeInitialization) {
- EXPECT_TRUE(NULL == shared_memory_->handle);
- EXPECT_TRUE(NULL == shared_memory_->ptr);
- EXPECT_EQ(0, shared_memory_->size);
+TEST_F(SharedMemoryTest, SizeIsaZeroBeforeInitialization) {
EXPECT_EQ(0, shared_memory_->GetSize());
}
TEST_F(SharedMemoryTest, InitializesAndReturnsMappedMemory) {
EXPECT_TRUE(shared_memory_->Initialize(65536));
- EXPECT_TRUE(NULL != shared_memory_->handle);
- EXPECT_TRUE(NULL == shared_memory_->ptr);
- EXPECT_EQ(65536, shared_memory_->size);
EXPECT_EQ(65536, shared_memory_->GetSize());
- EXPECT_TRUE(shared_memory_->Map());
- ASSERT_TRUE(NULL != shared_memory_->ptr);
- EXPECT_EQ(65536, shared_memory_->size);
+ size_t size;
+ int8* ptr = static_cast<int8*>(NPN_MapMemory(NULL,
+ shared_memory_.Get(),
+ &size));
+ ASSERT_TRUE(NULL != ptr);
+ EXPECT_EQ(65536, size);
// Test that memory can be written to.
- int8* ptr = static_cast<int8*>(shared_memory_->ptr);
for (int i = 0; i < 65536; ++i) {
ptr[i] = 7;
}
}
TEST_F(SharedMemoryTest, MapFailsBeforeInitialization) {
- EXPECT_FALSE(shared_memory_->Map());
+ size_t size = 7;
+ int8* ptr = static_cast<int8*>(NPN_MapMemory(NULL,
+ shared_memory_.Get(),
+ &size));
+ EXPECT_TRUE(NULL == ptr);
+ EXPECT_EQ(0, size);
}
TEST_F(SharedMemoryTest, InitializeFailsForNegativeSize) {
@@ -65,14 +66,18 @@ TEST_F(SharedMemoryTest, SecondCallToInitializeFails) {
EXPECT_FALSE(shared_memory_->Initialize(65536));
}
-TEST_F(SharedMemoryTest, InitializeRoundsUpToPageSizeButReportsRequestedSize) {
+TEST_F(SharedMemoryTest, InitializeRoundsUpToPageSize) {
EXPECT_TRUE(shared_memory_->Initialize(7));
+ EXPECT_EQ(7, shared_memory_->GetSize());
- EXPECT_TRUE(shared_memory_->Map());
- EXPECT_EQ(7, shared_memory_->size);
+ size_t size;
+ int8* ptr = static_cast<int8*>(NPN_MapMemory(NULL,
+ shared_memory_.Get(),
+ &size));
+ ASSERT_TRUE(NULL != ptr);
+ EXPECT_EQ(7, size);
// Test that memory can be written to.
- int8* ptr = static_cast<int8*>(shared_memory_->ptr);
for (int i = 0; i < 7; ++i) {
ptr[i] = 7;
}
@@ -81,99 +86,19 @@ TEST_F(SharedMemoryTest, InitializeRoundsUpToPageSizeButReportsRequestedSize) {
TEST_F(SharedMemoryTest, SecondMapDoesNothing) {
EXPECT_TRUE(shared_memory_->Initialize(65536));
- EXPECT_TRUE(shared_memory_->Map());
- ASSERT_TRUE(NULL != shared_memory_->handle);
- ASSERT_TRUE(NULL != shared_memory_->ptr);
- EXPECT_EQ(65536, shared_memory_->size);
+ size_t size1;
+ int8* ptr1 = static_cast<int8*>(NPN_MapMemory(NULL,
+ shared_memory_.Get(),
+ &size1));
- void* handle = shared_memory_->handle;
- void* ptr = shared_memory_->ptr;
- EXPECT_TRUE(shared_memory_->Map());
- ASSERT_EQ(ptr, shared_memory_->ptr);
- EXPECT_EQ(65536, shared_memory_->size);
-}
-
-TEST_F(SharedMemoryTest, CanInitializeWithHandle) {
- base::SharedMemory* temp_shared_memory = new base::SharedMemory;
- EXPECT_TRUE(temp_shared_memory->Create(std::wstring(), false, false, 65536));
-
- shared_memory_->Initialize(temp_shared_memory, 65536);
- EXPECT_TRUE(NULL != shared_memory_->handle);
- EXPECT_TRUE(NULL == shared_memory_->ptr);
- EXPECT_EQ(65536, shared_memory_->size);
-
- EXPECT_TRUE(shared_memory_->Map());
- EXPECT_TRUE(NULL != shared_memory_->handle);
- EXPECT_TRUE(NULL != shared_memory_->ptr);
- EXPECT_EQ(65536, shared_memory_->size);
-}
-
-TEST_F(SharedMemoryTest, CanSetInt32) {
- base::SharedMemory* temp_shared_memory = new base::SharedMemory;
- EXPECT_TRUE(temp_shared_memory->Create(std::wstring(), false, false, 65536));
-
- shared_memory_->Initialize(temp_shared_memory, 65536);
- EXPECT_TRUE(shared_memory_->Map());
-
- EXPECT_TRUE(shared_memory_->SetInt32(1, 7));
- EXPECT_EQ(7, static_cast<int32*>(shared_memory_->ptr)[1]);
-
- EXPECT_TRUE(shared_memory_->SetInt32(1, 8));
- EXPECT_EQ(8, static_cast<int32*>(shared_memory_->ptr)[1]);
-}
-
-TEST_F(SharedMemoryTest, FailsIfSetInt32CalledBeforeMap) {
- base::SharedMemory* temp_shared_memory = new base::SharedMemory;
- EXPECT_TRUE(temp_shared_memory->Create(std::wstring(), false, false, 65536));
-
- shared_memory_->Initialize(temp_shared_memory, 65536);
-
- EXPECT_FALSE(shared_memory_->SetInt32(1, 7));
-}
-
-TEST_F(SharedMemoryTest, FailsIfSetInt32OffsetIsOutOfRange) {
- base::SharedMemory* temp_shared_memory = new base::SharedMemory;
- EXPECT_TRUE(temp_shared_memory->Create(std::wstring(), false, false, 65536));
-
- shared_memory_->Initialize(temp_shared_memory, 65536);
- EXPECT_TRUE(shared_memory_->Map());
-
- EXPECT_FALSE(shared_memory_->SetInt32(-1, 7));
- EXPECT_FALSE(shared_memory_->SetInt32(16384, 7));
-}
-
-TEST_F(SharedMemoryTest, CanSetFloat) {
- base::SharedMemory* temp_shared_memory = new base::SharedMemory;
- EXPECT_TRUE(temp_shared_memory->Create(std::wstring(), false, false, 65536));
-
- shared_memory_->Initialize(temp_shared_memory, 65536);
- EXPECT_TRUE(shared_memory_->Map());
-
- EXPECT_TRUE(shared_memory_->SetFloat(1, 7));
- EXPECT_EQ(7, static_cast<float*>(shared_memory_->ptr)[1]);
-
- EXPECT_TRUE(shared_memory_->SetFloat(1, 8));
- EXPECT_EQ(8, static_cast<float*>(shared_memory_->ptr)[1]);
-}
-
-TEST_F(SharedMemoryTest, FailsIfSetFloatCalledBeforeMap) {
- base::SharedMemory* temp_shared_memory = new base::SharedMemory;
- EXPECT_TRUE(temp_shared_memory->Create(std::wstring(), false, false, 65536));
-
- shared_memory_->Initialize(temp_shared_memory, 65536);
-
- EXPECT_FALSE(shared_memory_->SetFloat(1, 7));
-}
-
-TEST_F(SharedMemoryTest, FailsIfSetFloatOffsetIsOutOfRange) {
- base::SharedMemory* temp_shared_memory = new base::SharedMemory;
- EXPECT_TRUE(temp_shared_memory->Create(std::wstring(), false, false, 65536));
-
- shared_memory_->Initialize(temp_shared_memory, 65536);
- EXPECT_TRUE(shared_memory_->Map());
+ size_t size2;
+ int8* ptr2 = static_cast<int8*>(NPN_MapMemory(NULL,
+ shared_memory_.Get(),
+ &size2));
- EXPECT_FALSE(shared_memory_->SetFloat(-1, 7));
- EXPECT_FALSE(shared_memory_->SetFloat(16384, 7));
+ EXPECT_EQ(ptr1, ptr2);
+ EXPECT_EQ(65536, size1);
+ EXPECT_EQ(65536, size2);
}
} // namespace gpu_plugin