Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: content/renderer/pepper/pepper_platform_image_2d_impl.cc

Issue 10424007: [OSX/Pepper] Don't have browser cache shmem ref behind ImageData. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/pepper/pepper_platform_image_2d_impl.h" 5 #include "content/renderer/pepper/pepper_platform_image_2d_impl.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8
9 #include "base/metrics/histogram.h"
8 #include "content/common/view_messages.h" 10 #include "content/common/view_messages.h"
9 #include "content/renderer/render_thread_impl.h" 11 #include "content/renderer/render_thread_impl.h"
10 #include "ui/surface/transport_dib.h" 12 #include "ui/surface/transport_dib.h"
11 13
12 namespace content { 14 namespace content {
13 15
14 PepperPlatformImage2DImpl::PepperPlatformImage2DImpl(int width, 16 PepperPlatformImage2DImpl::PepperPlatformImage2DImpl(int width,
15 int height, 17 int height,
16 TransportDIB* dib) 18 TransportDIB* dib)
17 : width_(width), 19 : width_(width),
18 height_(height), 20 height_(height),
19 dib_(dib) { 21 dib_(dib) {
20 } 22 }
21 23
22 // On Mac, we have to tell the browser to free the transport DIB.
23 PepperPlatformImage2DImpl::~PepperPlatformImage2DImpl() { 24 PepperPlatformImage2DImpl::~PepperPlatformImage2DImpl() {
24 #if defined(OS_MACOSX)
25 if (dib_.get()) {
26 RenderThreadImpl::current()->Send(
27 new ViewHostMsg_FreeTransportDIB(dib_->id()));
28 }
29 #endif
30 } 25 }
31 26
32 // static 27 // static
33 PepperPlatformImage2DImpl* PepperPlatformImage2DImpl::Create(int width, 28 PepperPlatformImage2DImpl* PepperPlatformImage2DImpl::Create(int width,
34 int height) { 29 int height) {
35 uint32 buffer_size = width * height * 4; 30 uint32 buffer_size = width * height * 4;
31 UMA_HISTOGRAM_COUNTS("Plugin.PepperImage2DSize", buffer_size);
36 32
37 // Allocate the transport DIB and the PlatformCanvas pointing to it. 33 // Allocate the transport DIB and the PlatformCanvas pointing to it.
38 #if defined(OS_MACOSX) 34 #if defined(OS_MACOSX)
39 // On the Mac, shared memory has to be created in the browser in order to 35 // On the Mac, shared memory has to be created in the browser in order to
40 // work in the sandbox. Do this by sending a message to the browser 36 // work in the sandbox. Do this by sending a message to the browser
41 // requesting a TransportDIB (see also 37 // requesting a TransportDIB (see also
42 // chrome/renderer/webplugin_delegate_proxy.cc, method 38 // chrome/renderer/webplugin_delegate_proxy.cc, method
43 // WebPluginDelegateProxy::CreateBitmap() for similar code). The TransportDIB 39 // WebPluginDelegateProxy::CreateBitmap() for similar code).
44 // is cached in the browser, and is freed (in typical cases) by the
45 // PepperPlatformImage2DImpl's destructor.
46 TransportDIB::Handle dib_handle; 40 TransportDIB::Handle dib_handle;
47 IPC::Message* msg = new ViewHostMsg_AllocTransportDIB(buffer_size, 41 IPC::Message* msg = new ViewHostMsg_AllocTransportDIB(buffer_size,
48 true, 42 false,
49 &dib_handle); 43 &dib_handle);
50 if (!RenderThreadImpl::current()->Send(msg)) 44 if (!RenderThreadImpl::current()->Send(msg))
51 return NULL; 45 return NULL;
52 if (!TransportDIB::is_valid_handle(dib_handle)) 46 if (!TransportDIB::is_valid_handle(dib_handle))
53 return NULL; 47 return NULL;
54 48
55 TransportDIB* dib = TransportDIB::Map(dib_handle); 49 TransportDIB* dib = TransportDIB::Map(dib_handle);
56 #else 50 #else
57 static int next_dib_id = 0; 51 static int next_dib_id = 0;
58 TransportDIB* dib = TransportDIB::Create(buffer_size, next_dib_id++); 52 TransportDIB* dib = TransportDIB::Create(buffer_size, next_dib_id++);
(...skipping 18 matching lines...) Expand all
77 #elif defined(OS_POSIX) 71 #elif defined(OS_POSIX)
78 return static_cast<intptr_t>(dib_->handle()); 72 return static_cast<intptr_t>(dib_->handle());
79 #endif 73 #endif
80 } 74 }
81 75
82 TransportDIB* PepperPlatformImage2DImpl::GetTransportDIB() const { 76 TransportDIB* PepperPlatformImage2DImpl::GetTransportDIB() const {
83 return dib_.get(); 77 return dib_.get();
84 } 78 }
85 79
86 } // namespace content 80 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698