summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/pepper_devices.cc
diff options
context:
space:
mode:
authordspringer@google.com <dspringer@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-07 20:40:11 +0000
committerdspringer@google.com <dspringer@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-07 20:40:11 +0000
commit248e1623b3943775a94ca3cee125f02788549e3e (patch)
tree49d06e69f1e3fdd73ce15f4baa33884fec5e7b4a /chrome/renderer/pepper_devices.cc
parent0415cac329cb7d21e474746100d78e8c142f130a (diff)
downloadchromium_src-248e1623b3943775a94ca3cee125f02788549e3e.zip
chromium_src-248e1623b3943775a94ca3cee125f02788549e3e.tar.gz
chromium_src-248e1623b3943775a94ca3cee125f02788549e3e.tar.bz2
Fix Pepper 2D device init on Mac, so that it work with NaCl modules as well as
with trusted Pepper plugins. The shared memory was not being used to create the skia bitmap due to a missing mmap() call. Adding this call (via TransportDIB::Map()) generates the right shared mem region. Note: this is an interim fix. Really, the browser should make the TransportDIB as it does onthe Mac for the GPU plugin. BUG=40701 TEST=Run any Pepper 2D application as a .nexe Review URL: http://codereview.chromium.org/1542016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43873 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/pepper_devices.cc')
-rw-r--r--chrome/renderer/pepper_devices.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/chrome/renderer/pepper_devices.cc b/chrome/renderer/pepper_devices.cc
index 494884c..72027eb 100644
--- a/chrome/renderer/pepper_devices.cc
+++ b/chrome/renderer/pepper_devices.cc
@@ -29,9 +29,26 @@ NPError Graphics2DDeviceContext::Initialize(
uint32 buffer_size = width * height * kBytesPerPixel;
// Allocate the transport DIB and the PlatformCanvas pointing to it.
+#if defined(OS_MACOSX)
+ // On the Mac, there is no clean way to create a TransportDIB::Handle and
+ // then Map() it. Using TransportDIB::Create() followed by
+ // TransportDIB::Map() will leak a TransportDIB object (you can't Create()
+ // then Map(), then delete because the file descriptor used by the underlying
+ // shared memory object gets closed.) Work around this issue by creating
+ // a SharedMemory object then pass that into TransportDIB::Map().
+ scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory());
+ if (!shared_memory->Create(L"", false /* read write */,
+ false /* do not open existing */, buffer_size)) {
+ return NPERR_OUT_OF_MEMORY_ERROR;
+ }
+ TransportDIB::Handle dib_handle;
+ shared_memory->GiveToProcess(0 /* pid, not needed */, &dib_handle);
+ transport_dib_.reset(TransportDIB::Map(dib_handle));
+#else
transport_dib_.reset(TransportDIB::Create(buffer_size, ++next_buffer_id_));
if (!transport_dib_.get())
return NPERR_OUT_OF_MEMORY_ERROR;
+#endif // defined(OS_MACOSX)
canvas_.reset(transport_dib_->GetPlatformCanvas(width, height));
if (!canvas_.get())
return NPERR_OUT_OF_MEMORY_ERROR;