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

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

Issue 13886018: Add a factory and defines for native Linux surfaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Get {base,ui,aura}_unittests working with native linux surface 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
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
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // Returns a default, invalid handle, that is meant to indicate a missing 103 // Returns a default, invalid handle, that is meant to indicate a missing
104 // Transport DIB. 104 // Transport DIB.
105 static Handle DefaultHandleValue() { return -1; } 105 static Handle DefaultHandleValue() { return -1; }
106 106
107 // Returns a value that is ONLY USEFUL FOR TESTS WHERE IT WON'T BE 107 // Returns a value that is ONLY USEFUL FOR TESTS WHERE IT WON'T BE
108 // ACTUALLY USED AS A REAL HANDLE. 108 // ACTUALLY USED AS A REAL HANDLE.
109 static Handle GetFakeHandleForTest() { 109 static Handle GetFakeHandleForTest() {
110 static int fake_handle = 10; 110 static int fake_handle = 10;
111 return fake_handle++; 111 return fake_handle++;
112 } 112 }
113 #elif defined(USE_NATIVE_SURFACE_LINUX)
114 typedef int Handle;
115 typedef int Id;
116 // Returns a default, invalid handle, that is meant to indicate a missing
117 // Transport DIB.
118 static Handle DefaultHandleValue() { return -1; }
119
120 // Returns a value that is ONLY USEFUL FOR TESTS WHERE IT WON'T BE
121 // ACTUALLY USED AS A REAL HANDLE.
122 static Handle GetFakeHandleForTest() {
123 static int fake_handle = 10;
124 return fake_handle++;
125 }
113 #else // OS_POSIX 126 #else // OS_POSIX
114 typedef base::SharedMemoryHandle Handle; 127 typedef base::SharedMemoryHandle Handle;
115 // On POSIX, the inode number of the backing file is used as an id. 128 // On POSIX, the inode number of the backing file is used as an id.
116 #if defined(OS_ANDROID) 129 #if defined(OS_ANDROID)
117 typedef base::SharedMemoryHandle Id; 130 typedef base::SharedMemoryHandle Id;
118 #else 131 #else
119 typedef base::SharedMemoryId Id; 132 typedef base::SharedMemoryId Id;
120 #endif 133 #endif
121 134
122 // Returns a default, invalid handle, that is meant to indicate a missing 135 // Returns a default, invalid handle, that is meant to indicate a missing
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 #if defined(TOOLKIT_GTK) || \ 204 #if defined(TOOLKIT_GTK) || \
192 (defined(OS_LINUX) && defined(USE_AURA) && defined(USE_X11)) 205 (defined(OS_LINUX) && defined(USE_AURA) && defined(USE_X11))
193 // Map the shared memory into the X server and return an id for the shared 206 // Map the shared memory into the X server and return an id for the shared
194 // segment. 207 // segment.
195 XID MapToX(Display* connection); 208 XID MapToX(Display* connection);
196 209
197 void IncreaseInFlightCounter() { inflight_counter_++; } 210 void IncreaseInFlightCounter() { inflight_counter_++; }
198 // Decreases the inflight counter, and deletes the transport DIB if it is 211 // Decreases the inflight counter, and deletes the transport DIB if it is
199 // detached. 212 // detached.
200 void DecreaseInFlightCounter(); 213 void DecreaseInFlightCounter();
214 #endif
201 215
216 #if defined(TOOLKIT_GTK) || \
217 (defined(OS_LINUX) && defined(USE_AURA) && defined(USE_X11)) || \
218 defined(USE_NATIVE_SURFACE_LINUX)
202 // Deletes this transport DIB and detaches the shared memory once the 219 // Deletes this transport DIB and detaches the shared memory once the
203 // |inflight_counter_| is zero. 220 // |inflight_counter_| is zero.
204 void Detach(); 221 void Detach();
205 #endif 222 #endif
206 223
207 private: 224 private:
208 TransportDIB(); 225 TransportDIB();
209 226
210 // Verifies that the dib can hold a canvas of the requested dimensions. 227 // Verifies that the dib can hold a canvas of the requested dimensions.
211 bool VerifyCanvasSize(int w, int h); 228 bool VerifyCanvasSize(int w, int h);
(...skipping 10 matching lines...) Expand all
222 explicit TransportDIB(base::SharedMemoryHandle dib); 239 explicit TransportDIB(base::SharedMemoryHandle dib);
223 base::SharedMemory shared_memory_; 240 base::SharedMemory shared_memory_;
224 uint32 sequence_num_; 241 uint32 sequence_num_;
225 #endif 242 #endif
226 size_t size_; // length, in bytes 243 size_t size_; // length, in bytes
227 244
228 DISALLOW_COPY_AND_ASSIGN(TransportDIB); 245 DISALLOW_COPY_AND_ASSIGN(TransportDIB);
229 }; 246 };
230 247
231 #endif // UI_SURFACE_TRANSPORT_DIB_H_ 248 #endif // UI_SURFACE_TRANSPORT_DIB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698