OLD | NEW |
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 #ifndef UI_SURFACE_TRANSPORT_DIB_H_ | 5 #ifndef UI_SURFACE_TRANSPORT_DIB_H_ |
6 #define UI_SURFACE_TRANSPORT_DIB_H_ | 6 #define UI_SURFACE_TRANSPORT_DIB_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "ui/surface/surface_export.h" | 9 #include "ui/surface/surface_export.h" |
10 | 10 |
11 #if !defined(TOOLKIT_GTK) | 11 #if !defined(TOOLKIT_GTK) |
12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
13 #endif | 13 #endif |
14 | 14 |
15 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
16 #include <windows.h> | 16 #include <windows.h> |
17 #elif defined(TOOLKIT_GTK) | 17 #elif defined(TOOLKIT_GTK) |
18 #include "ui/base/x/x11_util.h" | 18 #include "ui/base/x/x11_util.h" |
| 19 #include "ui/gfx/x/x11_types.h" |
19 #endif | 20 #endif |
20 | 21 |
21 class SkCanvas; | 22 class SkCanvas; |
22 | 23 |
23 // ----------------------------------------------------------------------------- | 24 // ----------------------------------------------------------------------------- |
24 // A TransportDIB is a block of memory that is used to transport pixels | 25 // A TransportDIB is a block of memory that is used to transport pixels |
25 // between processes: from the renderer process to the browser, and | 26 // between processes: from the renderer process to the browser, and |
26 // between renderer and plugin processes. | 27 // between renderer and plugin processes. |
27 // ----------------------------------------------------------------------------- | 28 // ----------------------------------------------------------------------------- |
28 class SURFACE_EXPORT TransportDIB { | 29 class SURFACE_EXPORT TransportDIB { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 // on the wire. | 183 // on the wire. |
183 Id id() const; | 184 Id id() const; |
184 | 185 |
185 // Return a handle to the underlying shared memory. This can be sent over the | 186 // Return a handle to the underlying shared memory. This can be sent over the |
186 // wire to give this transport DIB to another process. | 187 // wire to give this transport DIB to another process. |
187 Handle handle() const; | 188 Handle handle() const; |
188 | 189 |
189 #if defined(TOOLKIT_GTK) | 190 #if defined(TOOLKIT_GTK) |
190 // Map the shared memory into the X server and return an id for the shared | 191 // Map the shared memory into the X server and return an id for the shared |
191 // segment. | 192 // segment. |
192 XID MapToX(Display* connection); | 193 XID MapToX(XDisplay* connection); |
193 | 194 |
194 void IncreaseInFlightCounter() { inflight_counter_++; } | 195 void IncreaseInFlightCounter() { inflight_counter_++; } |
195 // Decreases the inflight counter, and deletes the transport DIB if it is | 196 // Decreases the inflight counter, and deletes the transport DIB if it is |
196 // detached. | 197 // detached. |
197 void DecreaseInFlightCounter(); | 198 void DecreaseInFlightCounter(); |
198 | 199 |
199 // Deletes this transport DIB and detaches the shared memory once the | 200 // Deletes this transport DIB and detaches the shared memory once the |
200 // |inflight_counter_| is zero. | 201 // |inflight_counter_| is zero. |
201 void Detach(); | 202 void Detach(); |
202 #endif | 203 #endif |
203 | 204 |
204 private: | 205 private: |
205 TransportDIB(); | 206 TransportDIB(); |
206 | 207 |
207 // Verifies that the dib can hold a canvas of the requested dimensions. | 208 // Verifies that the dib can hold a canvas of the requested dimensions. |
208 bool VerifyCanvasSize(int w, int h); | 209 bool VerifyCanvasSize(int w, int h); |
209 | 210 |
210 #if defined(TOOLKIT_GTK) | 211 #if defined(TOOLKIT_GTK) |
211 Id key_; // SysV shared memory id | 212 Id key_; // SysV shared memory id |
212 void* address_; // mapped address | 213 void* address_; // mapped address |
213 XSharedMemoryId x_shm_; // X id for the shared segment | 214 XSharedMemoryId x_shm_; // X id for the shared segment |
214 Display* display_; // connection to the X server | 215 XDisplay* display_; // connection to the X server |
215 size_t inflight_counter_; // How many requests to the X server are in flight | 216 size_t inflight_counter_; // How many requests to the X server are in flight |
216 bool detached_; // If true, delete the transport DIB when it is idle | 217 bool detached_; // If true, delete the transport DIB when it is idle |
217 #else | 218 #else |
218 explicit TransportDIB(base::SharedMemoryHandle dib); | 219 explicit TransportDIB(base::SharedMemoryHandle dib); |
219 base::SharedMemory shared_memory_; | 220 base::SharedMemory shared_memory_; |
220 uint32 sequence_num_; | 221 uint32 sequence_num_; |
221 #endif | 222 #endif |
222 size_t size_; // length, in bytes | 223 size_t size_; // length, in bytes |
223 | 224 |
224 DISALLOW_COPY_AND_ASSIGN(TransportDIB); | 225 DISALLOW_COPY_AND_ASSIGN(TransportDIB); |
225 }; | 226 }; |
226 | 227 |
227 #endif // UI_SURFACE_TRANSPORT_DIB_H_ | 228 #endif // UI_SURFACE_TRANSPORT_DIB_H_ |
OLD | NEW |