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

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

Issue 10879050: Revert 139366 - [OSX/Pepper] Don't have browser cache shmem ref behind ImageData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« 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"
10 #include "content/common/view_messages.h" 8 #include "content/common/view_messages.h"
11 #include "content/renderer/render_thread_impl.h" 9 #include "content/renderer/render_thread_impl.h"
12 #include "ui/surface/transport_dib.h" 10 #include "ui/surface/transport_dib.h"
13 11
14 namespace content { 12 namespace content {
15 13
16 PepperPlatformImage2DImpl::PepperPlatformImage2DImpl(int width, 14 PepperPlatformImage2DImpl::PepperPlatformImage2DImpl(int width,
17 int height, 15 int height,
18 TransportDIB* dib) 16 TransportDIB* dib)
19 : width_(width), 17 : width_(width),
20 height_(height), 18 height_(height),
21 dib_(dib) { 19 dib_(dib) {
22 } 20 }
23 21
22 // On Mac, we have to tell the browser to free the transport DIB.
24 PepperPlatformImage2DImpl::~PepperPlatformImage2DImpl() { 23 PepperPlatformImage2DImpl::~PepperPlatformImage2DImpl() {
24 #if defined(OS_MACOSX)
25 if (dib_.get()) {
26 RenderThreadImpl::current()->Send(
27 new ViewHostMsg_FreeTransportDIB(dib_->id()));
28 }
29 #endif
25 } 30 }
26 31
27 // static 32 // static
28 PepperPlatformImage2DImpl* PepperPlatformImage2DImpl::Create(int width, 33 PepperPlatformImage2DImpl* PepperPlatformImage2DImpl::Create(int width,
29 int height) { 34 int height) {
30 uint32 buffer_size = width * height * 4; 35 uint32 buffer_size = width * height * 4;
31 UMA_HISTOGRAM_COUNTS("Plugin.PepperImage2DSize", buffer_size);
32 36
33 // Allocate the transport DIB and the PlatformCanvas pointing to it. 37 // Allocate the transport DIB and the PlatformCanvas pointing to it.
34 #if defined(OS_MACOSX) 38 #if defined(OS_MACOSX)
35 // On the Mac, shared memory has to be created in the browser in order to 39 // On the Mac, shared memory has to be created in the browser in order to
36 // work in the sandbox. Do this by sending a message to the browser 40 // work in the sandbox. Do this by sending a message to the browser
37 // requesting a TransportDIB (see also 41 // requesting a TransportDIB (see also
38 // chrome/renderer/webplugin_delegate_proxy.cc, method 42 // chrome/renderer/webplugin_delegate_proxy.cc, method
39 // WebPluginDelegateProxy::CreateBitmap() for similar code). 43 // WebPluginDelegateProxy::CreateBitmap() for similar code). The TransportDIB
44 // is cached in the browser, and is freed (in typical cases) by the
45 // PepperPlatformImage2DImpl's destructor.
40 TransportDIB::Handle dib_handle; 46 TransportDIB::Handle dib_handle;
41 IPC::Message* msg = new ViewHostMsg_AllocTransportDIB(buffer_size, 47 IPC::Message* msg = new ViewHostMsg_AllocTransportDIB(buffer_size,
42 false, 48 true,
43 &dib_handle); 49 &dib_handle);
44 if (!RenderThreadImpl::current()->Send(msg)) 50 if (!RenderThreadImpl::current()->Send(msg))
45 return NULL; 51 return NULL;
46 if (!TransportDIB::is_valid_handle(dib_handle)) 52 if (!TransportDIB::is_valid_handle(dib_handle))
47 return NULL; 53 return NULL;
48 54
49 TransportDIB* dib = TransportDIB::Map(dib_handle); 55 TransportDIB* dib = TransportDIB::Map(dib_handle);
50 #else 56 #else
51 static int next_dib_id = 0; 57 static int next_dib_id = 0;
52 TransportDIB* dib = TransportDIB::Create(buffer_size, next_dib_id++); 58 TransportDIB* dib = TransportDIB::Create(buffer_size, next_dib_id++);
(...skipping 18 matching lines...) Expand all
71 #elif defined(OS_POSIX) 77 #elif defined(OS_POSIX)
72 return static_cast<intptr_t>(dib_->handle()); 78 return static_cast<intptr_t>(dib_->handle());
73 #endif 79 #endif
74 } 80 }
75 81
76 TransportDIB* PepperPlatformImage2DImpl::GetTransportDIB() const { 82 TransportDIB* PepperPlatformImage2DImpl::GetTransportDIB() const {
77 return dib_.get(); 83 return dib_.get();
78 } 84 }
79 85
80 } // namespace content 86 } // 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