OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 return command_line.HasSwitch(switches::kInProcessPlugins); | 129 return command_line.HasSwitch(switches::kInProcessPlugins); |
130 #else | 130 #else |
131 return command_line.HasSwitch(switches::kInProcessPlugins) || | 131 return command_line.HasSwitch(switches::kInProcessPlugins) || |
132 command_line.HasSwitch(switches::kSingleProcess); | 132 command_line.HasSwitch(switches::kSingleProcess); |
133 #endif | 133 #endif |
134 } | 134 } |
135 | 135 |
136 // ----------------------------------------------------------------------------- | 136 // ----------------------------------------------------------------------------- |
137 // Platform specific code for dealing with bitmap transport... | 137 // Platform specific code for dealing with bitmap transport... |
138 | 138 |
139 // ----------------------------------------------------------------------------- | |
140 // Create a platform canvas object which renders into the given transport | |
141 // memory. | |
142 // ----------------------------------------------------------------------------- | |
143 static skia::PlatformCanvas* CanvasFromTransportDIB( | |
144 TransportDIB* dib, const gfx::Rect& rect) { | |
145 #if defined(OS_WIN) | |
146 return new skia::PlatformCanvas(rect.width(), rect.height(), true, | |
147 dib->handle()); | |
148 #elif defined(OS_LINUX) || defined(OS_MACOSX) | |
149 return new skia::PlatformCanvas(rect.width(), rect.height(), true, | |
150 reinterpret_cast<uint8_t*>(dib->memory())); | |
151 #endif | |
152 } | |
153 | |
154 TransportDIB* RenderProcess::CreateTransportDIB(size_t size) { | 139 TransportDIB* RenderProcess::CreateTransportDIB(size_t size) { |
155 #if defined(OS_WIN) || defined(OS_LINUX) | 140 #if defined(OS_WIN) || defined(OS_LINUX) |
156 // Windows and Linux create transport DIBs inside the renderer | 141 // Windows and Linux create transport DIBs inside the renderer |
157 return TransportDIB::Create(size, sequence_number_++); | 142 return TransportDIB::Create(size, sequence_number_++); |
158 #elif defined(OS_MACOSX) // defined(OS_WIN) || defined(OS_LINUX) | 143 #elif defined(OS_MACOSX) // defined(OS_WIN) || defined(OS_LINUX) |
159 // Mac creates transport DIBs in the browser, so we need to do a sync IPC to | 144 // Mac creates transport DIBs in the browser, so we need to do a sync IPC to |
160 // get one. | 145 // get one. |
161 TransportDIB::Handle handle; | 146 TransportDIB::Handle handle; |
162 IPC::Message* msg = new ViewHostMsg_AllocTransportDIB(size, &handle); | 147 IPC::Message* msg = new ViewHostMsg_AllocTransportDIB(size, &handle); |
163 if (!child_thread()->Send(msg)) | 148 if (!child_thread()->Send(msg)) |
(...skipping 25 matching lines...) Expand all Loading... |
189 TransportDIB** memory, const gfx::Rect& rect) { | 174 TransportDIB** memory, const gfx::Rect& rect) { |
190 const size_t stride = skia::PlatformCanvas::StrideForWidth(rect.width()); | 175 const size_t stride = skia::PlatformCanvas::StrideForWidth(rect.width()); |
191 const size_t size = stride * rect.height(); | 176 const size_t size = stride * rect.height(); |
192 | 177 |
193 if (!GetTransportDIBFromCache(memory, size)) { | 178 if (!GetTransportDIBFromCache(memory, size)) { |
194 *memory = CreateTransportDIB(size); | 179 *memory = CreateTransportDIB(size); |
195 if (!*memory) | 180 if (!*memory) |
196 return false; | 181 return false; |
197 } | 182 } |
198 | 183 |
199 return CanvasFromTransportDIB(*memory, rect); | 184 return (*memory)->GetPlatformCanvas(rect.width(), rect.height()); |
200 } | 185 } |
201 | 186 |
202 void RenderProcess::ReleaseTransportDIB(TransportDIB* mem) { | 187 void RenderProcess::ReleaseTransportDIB(TransportDIB* mem) { |
203 if (PutSharedMemInCache(mem)) { | 188 if (PutSharedMemInCache(mem)) { |
204 shared_mem_cache_cleaner_.Reset(); | 189 shared_mem_cache_cleaner_.Reset(); |
205 return; | 190 return; |
206 } | 191 } |
207 | 192 |
208 FreeTransportDIB(mem); | 193 FreeTransportDIB(mem); |
209 } | 194 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 } | 246 } |
262 | 247 |
263 void RenderProcess::ClearTransportDIBCache() { | 248 void RenderProcess::ClearTransportDIBCache() { |
264 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { | 249 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { |
265 if (shared_mem_cache_[i]) { | 250 if (shared_mem_cache_[i]) { |
266 FreeTransportDIB(shared_mem_cache_[i]); | 251 FreeTransportDIB(shared_mem_cache_[i]); |
267 shared_mem_cache_[i] = NULL; | 252 shared_mem_cache_[i] = NULL; |
268 } | 253 } |
269 } | 254 } |
270 } | 255 } |
OLD | NEW |