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

Side by Side Diff: ui/surface/transport_dib.h

Issue 13985039: Rationalize linux vs x11 in ui (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix review / try issues Created 7 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 | Annotate | Revision Log
« no previous file with comments | « ui/gl/gl_surface_x11.cc ('k') | ui/surface/transport_dib_posix.cc » ('j') | 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 #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) || (defined(OS_LINUX) && defined(USE_AURA)) 17 #elif defined(TOOLKIT_GTK) || \
18 (defined(OS_LINUX) && defined(USE_AURA) && defined(USE_X11))
18 #include "ui/base/x/x11_util.h" 19 #include "ui/base/x/x11_util.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 // -----------------------------------------------------------------------------
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // Returns a default, invalid handle, that is meant to indicate a missing 74 // Returns a default, invalid handle, that is meant to indicate a missing
74 // Transport DIB. 75 // Transport DIB.
75 static Handle DefaultHandleValue() { return NULL; } 76 static Handle DefaultHandleValue() { return NULL; }
76 77
77 // Returns a value that is ONLY USEFUL FOR TESTS WHERE IT WON'T BE 78 // Returns a value that is ONLY USEFUL FOR TESTS WHERE IT WON'T BE
78 // ACTUALLY USED AS A REAL HANDLE. 79 // ACTUALLY USED AS A REAL HANDLE.
79 static Handle GetFakeHandleForTest() { 80 static Handle GetFakeHandleForTest() {
80 static int fake_handle = 10; 81 static int fake_handle = 10;
81 return reinterpret_cast<Handle>(fake_handle++); 82 return reinterpret_cast<Handle>(fake_handle++);
82 } 83 }
83 #elif defined(TOOLKIT_GTK) || (defined(OS_LINUX) && defined(USE_AURA)) 84 #elif defined(TOOLKIT_GTK) || \
85 (defined(OS_LINUX) && defined(USE_AURA) && defined(USE_X11))
84 typedef int Handle; // These two ints are SysV IPC shared memory keys 86 typedef int Handle; // These two ints are SysV IPC shared memory keys
85 struct Id { 87 struct Id {
86 // Ensure that default initialized Ids are invalid. 88 // Ensure that default initialized Ids are invalid.
87 Id() : shmkey(-1) { 89 Id() : shmkey(-1) {
88 } 90 }
89 91
90 bool operator<(const Id& other) const { 92 bool operator<(const Id& other) const {
91 return shmkey < other.shmkey; 93 return shmkey < other.shmkey;
92 } 94 }
93 95
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 size_t size() const { return size_; } 181 size_t size() const { return size_; }
180 182
181 // Return the identifier which can be used to refer to this shared memory 183 // Return the identifier which can be used to refer to this shared memory
182 // on the wire. 184 // on the wire.
183 Id id() const; 185 Id id() const;
184 186
185 // Return a handle to the underlying shared memory. This can be sent over the 187 // Return a handle to the underlying shared memory. This can be sent over the
186 // wire to give this transport DIB to another process. 188 // wire to give this transport DIB to another process.
187 Handle handle() const; 189 Handle handle() const;
188 190
189 #if defined(TOOLKIT_GTK) || (defined(OS_LINUX) && defined(USE_AURA)) 191 #if defined(TOOLKIT_GTK) || \
192 (defined(OS_LINUX) && defined(USE_AURA) && defined(USE_X11))
190 // Map the shared memory into the X server and return an id for the shared 193 // Map the shared memory into the X server and return an id for the shared
191 // segment. 194 // segment.
192 XID MapToX(Display* connection); 195 XID MapToX(Display* connection);
193 196
194 void IncreaseInFlightCounter() { inflight_counter_++; } 197 void IncreaseInFlightCounter() { inflight_counter_++; }
195 // Decreases the inflight counter, and deletes the transport DIB if it is 198 // Decreases the inflight counter, and deletes the transport DIB if it is
196 // detached. 199 // detached.
197 void DecreaseInFlightCounter(); 200 void DecreaseInFlightCounter();
198 201
199 // Deletes this transport DIB and detaches the shared memory once the 202 // Deletes this transport DIB and detaches the shared memory once the
200 // |inflight_counter_| is zero. 203 // |inflight_counter_| is zero.
201 void Detach(); 204 void Detach();
202 #endif 205 #endif
203 206
204 private: 207 private:
205 TransportDIB(); 208 TransportDIB();
206 209
207 // Verifies that the dib can hold a canvas of the requested dimensions. 210 // Verifies that the dib can hold a canvas of the requested dimensions.
208 bool VerifyCanvasSize(int w, int h); 211 bool VerifyCanvasSize(int w, int h);
209 212
210 #if defined(TOOLKIT_GTK) || (defined(OS_LINUX) && defined(USE_AURA)) 213 #if defined(TOOLKIT_GTK) || \
214 (defined(OS_LINUX) && defined(USE_AURA) && defined(USE_X11))
211 Id key_; // SysV shared memory id 215 Id key_; // SysV shared memory id
212 void* address_; // mapped address 216 void* address_; // mapped address
213 XSharedMemoryId x_shm_; // X id for the shared segment 217 XSharedMemoryId x_shm_; // X id for the shared segment
214 Display* display_; // connection to the X server 218 Display* display_; // connection to the X server
215 size_t inflight_counter_; // How many requests to the X server are in flight 219 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 220 bool detached_; // If true, delete the transport DIB when it is idle
217 #else 221 #else
218 explicit TransportDIB(base::SharedMemoryHandle dib); 222 explicit TransportDIB(base::SharedMemoryHandle dib);
219 base::SharedMemory shared_memory_; 223 base::SharedMemory shared_memory_;
220 uint32 sequence_num_; 224 uint32 sequence_num_;
221 #endif 225 #endif
222 size_t size_; // length, in bytes 226 size_t size_; // length, in bytes
223 227
224 DISALLOW_COPY_AND_ASSIGN(TransportDIB); 228 DISALLOW_COPY_AND_ASSIGN(TransportDIB);
225 }; 229 };
226 230
227 #endif // UI_SURFACE_TRANSPORT_DIB_H_ 231 #endif // UI_SURFACE_TRANSPORT_DIB_H_
OLDNEW
« no previous file with comments | « ui/gl/gl_surface_x11.cc ('k') | ui/surface/transport_dib_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698