OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <objidl.h> | 9 #include <objidl.h> |
10 #include <mlang.h> | 10 #include <mlang.h> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // log important leaked objects | 79 // log important leaked objects |
80 webkit_glue::CheckForLeaks(); | 80 webkit_glue::CheckForLeaks(); |
81 #endif | 81 #endif |
82 | 82 |
83 GetShutDownEvent()->Signal(); | 83 GetShutDownEvent()->Signal(); |
84 ClearTransportDIBCache(); | 84 ClearTransportDIBCache(); |
85 } | 85 } |
86 | 86 |
87 bool RenderProcessImpl::InProcessPlugins() { | 87 bool RenderProcessImpl::InProcessPlugins() { |
88 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 88 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
89 #if defined(OS_LINUX) | 89 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
90 // Plugin processes require a UI message loop, and the Linux message loop | 90 // Plugin processes require a UI message loop, and the Linux message loop |
91 // implementation only allows one UI loop per process. | 91 // implementation only allows one UI loop per process. |
92 if (command_line.HasSwitch(switches::kInProcessPlugins)) | 92 if (command_line.HasSwitch(switches::kInProcessPlugins)) |
93 NOTIMPLEMENTED() << ": in process plugins not supported on Linux"; | 93 NOTIMPLEMENTED() << ": in process plugins not supported on Linux"; |
94 return command_line.HasSwitch(switches::kInProcessPlugins); | 94 return command_line.HasSwitch(switches::kInProcessPlugins); |
95 #else | 95 #else |
96 return command_line.HasSwitch(switches::kInProcessPlugins) || | 96 return command_line.HasSwitch(switches::kInProcessPlugins) || |
97 command_line.HasSwitch(switches::kSingleProcess); | 97 command_line.HasSwitch(switches::kSingleProcess); |
98 #endif | 98 #endif |
99 } | 99 } |
100 | 100 |
101 // ----------------------------------------------------------------------------- | 101 // ----------------------------------------------------------------------------- |
102 // Platform specific code for dealing with bitmap transport... | 102 // Platform specific code for dealing with bitmap transport... |
103 | 103 |
104 TransportDIB* RenderProcessImpl::CreateTransportDIB(size_t size) { | 104 TransportDIB* RenderProcessImpl::CreateTransportDIB(size_t size) { |
105 #if defined(OS_WIN) || defined(OS_LINUX) | 105 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_OPENBSD) |
106 // Windows and Linux create transport DIBs inside the renderer | 106 // Windows and Linux create transport DIBs inside the renderer |
107 return TransportDIB::Create(size, transport_dib_next_sequence_number_++); | 107 return TransportDIB::Create(size, transport_dib_next_sequence_number_++); |
108 #elif defined(OS_MACOSX) // defined(OS_WIN) || defined(OS_LINUX) | 108 #elif defined(OS_MACOSX) |
109 // Mac creates transport DIBs in the browser, so we need to do a sync IPC to | 109 // Mac creates transport DIBs in the browser, so we need to do a sync IPC to |
110 // get one. The TransportDIB is cached in the browser. | 110 // get one. The TransportDIB is cached in the browser. |
111 TransportDIB::Handle handle; | 111 TransportDIB::Handle handle; |
112 IPC::Message* msg = new ViewHostMsg_AllocTransportDIB(size, true, &handle); | 112 IPC::Message* msg = new ViewHostMsg_AllocTransportDIB(size, true, &handle); |
113 if (!main_thread()->Send(msg)) | 113 if (!main_thread()->Send(msg)) |
114 return NULL; | 114 return NULL; |
115 if (handle.fd < 0) | 115 if (handle.fd < 0) |
116 return NULL; | 116 return NULL; |
117 return TransportDIB::Map(handle); | 117 return TransportDIB::Map(handle); |
118 #endif // defined(OS_MACOSX) | 118 #endif // defined(OS_MACOSX) |
(...skipping 14 matching lines...) Expand all Loading... |
133 } | 133 } |
134 | 134 |
135 // ----------------------------------------------------------------------------- | 135 // ----------------------------------------------------------------------------- |
136 | 136 |
137 | 137 |
138 skia::PlatformCanvas* RenderProcessImpl::GetDrawingCanvas( | 138 skia::PlatformCanvas* RenderProcessImpl::GetDrawingCanvas( |
139 TransportDIB** memory, const gfx::Rect& rect) { | 139 TransportDIB** memory, const gfx::Rect& rect) { |
140 int width = rect.width(); | 140 int width = rect.width(); |
141 int height = rect.height(); | 141 int height = rect.height(); |
142 const size_t stride = skia::PlatformCanvas::StrideForWidth(rect.width()); | 142 const size_t stride = skia::PlatformCanvas::StrideForWidth(rect.width()); |
143 #if defined(OS_LINUX) | 143 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
144 const size_t max_size = base::SysInfo::MaxSharedMemorySize(); | 144 const size_t max_size = base::SysInfo::MaxSharedMemorySize(); |
145 #else | 145 #else |
146 const size_t max_size = 0; | 146 const size_t max_size = 0; |
147 #endif | 147 #endif |
148 | 148 |
149 // If the requested size is too big, reduce the height. Ideally we might like | 149 // If the requested size is too big, reduce the height. Ideally we might like |
150 // to reduce the width as well to make the size reduction more "balanced", but | 150 // to reduce the width as well to make the size reduction more "balanced", but |
151 // it rarely comes up in practice. | 151 // it rarely comes up in practice. |
152 if ((max_size != 0) && (height * stride > max_size)) | 152 if ((max_size != 0) && (height * stride > max_size)) |
153 height = max_size / stride; | 153 height = max_size / stride; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 } | 229 } |
230 | 230 |
231 void RenderProcessImpl::ClearTransportDIBCache() { | 231 void RenderProcessImpl::ClearTransportDIBCache() { |
232 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { | 232 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { |
233 if (shared_mem_cache_[i]) { | 233 if (shared_mem_cache_[i]) { |
234 FreeTransportDIB(shared_mem_cache_[i]); | 234 FreeTransportDIB(shared_mem_cache_[i]); |
235 shared_mem_cache_[i] = NULL; | 235 shared_mem_cache_[i] = NULL; |
236 } | 236 } |
237 } | 237 } |
238 } | 238 } |
OLD | NEW |