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

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

Issue 6665029: Adds a TransportDIB::Id value that is explicitly invalid and use it when compositing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mebbe this one compiles? Created 9 years, 9 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 APP_SURFACE_TRANSPORT_DIB_H_ 5 #ifndef APP_SURFACE_TRANSPORT_DIB_H_
6 #define APP_SURFACE_TRANSPORT_DIB_H_ 6 #define APP_SURFACE_TRANSPORT_DIB_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 10
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 static Handle DefaultHandleValue() { return Handle(); } 88 static Handle DefaultHandleValue() { return Handle(); }
89 89
90 // Returns a value that is ONLY USEFUL FOR TESTS WHERE IT WON'T BE 90 // Returns a value that is ONLY USEFUL FOR TESTS WHERE IT WON'T BE
91 // ACTUALLY USED AS A REAL HANDLE. 91 // ACTUALLY USED AS A REAL HANDLE.
92 static Handle GetFakeHandleForTest() { 92 static Handle GetFakeHandleForTest() {
93 static int fake_handle = 10; 93 static int fake_handle = 10;
94 return Handle(fake_handle++, false); 94 return Handle(fake_handle++, false);
95 } 95 }
96 #elif defined(USE_X11) 96 #elif defined(USE_X11)
97 typedef int Handle; // These two ints are SysV IPC shared memory keys 97 typedef int Handle; // These two ints are SysV IPC shared memory keys
98 typedef int Id; 98 struct Id {
99 // Ensure that default initialized Ids are invalid.
100 Id() : shmkey(-1) {
101 }
102
103 bool operator< (const Id& other) const {
brettw 2011/03/24 23:54:34 I think normal style would be no space afer the <
104 return shmkey < other.shmkey;
105 }
106
107 int shmkey;
108 };
99 109
100 // Returns a default, invalid handle, that is meant to indicate a missing 110 // Returns a default, invalid handle, that is meant to indicate a missing
101 // Transport DIB. 111 // Transport DIB.
102 static Handle DefaultHandleValue() { return -1; } 112 static Handle DefaultHandleValue() { return -1; }
103 113
104 // Returns a value that is ONLY USEFUL FOR TESTS WHERE IT WON'T BE 114 // Returns a value that is ONLY USEFUL FOR TESTS WHERE IT WON'T BE
105 // ACTUALLY USED AS A REAL HANDLE. 115 // ACTUALLY USED AS A REAL HANDLE.
106 static Handle GetFakeHandleForTest() { 116 static Handle GetFakeHandleForTest() {
107 static int fake_handle = 10; 117 static int fake_handle = 10;
108 return fake_handle++; 118 return fake_handle++;
(...skipping 13 matching lines...) Expand all
122 132
123 // Map the referenced transport DIB. The caller owns the returned object. 133 // Map the referenced transport DIB. The caller owns the returned object.
124 // Returns NULL on failure. 134 // Returns NULL on failure.
125 static TransportDIB* Map(Handle transport_dib); 135 static TransportDIB* Map(Handle transport_dib);
126 136
127 // Create a new |TransportDIB| with a handle to the shared memory. This 137 // Create a new |TransportDIB| with a handle to the shared memory. This
128 // always returns a valid pointer. The DIB is not mapped. 138 // always returns a valid pointer. The DIB is not mapped.
129 static TransportDIB* CreateWithHandle(Handle handle); 139 static TransportDIB* CreateWithHandle(Handle handle);
130 140
131 // Returns true if the handle is valid. 141 // Returns true if the handle is valid.
132 static bool is_valid(Handle dib); 142 static bool is_valid_handle(Handle dib);
143
144 // Returns true if the ID refers to a valid dib.
145 static bool is_valid_id(Id id);
133 146
134 // Returns a canvas using the memory of this TransportDIB. The returned 147 // Returns a canvas using the memory of this TransportDIB. The returned
135 // pointer will be owned by the caller. The bitmap will be of the given size, 148 // pointer will be owned by the caller. The bitmap will be of the given size,
136 // which should fit inside this memory. 149 // which should fit inside this memory.
137 // 150 //
138 // On POSIX, this |TransportDIB| will be mapped if not already. On Windows, 151 // On POSIX, this |TransportDIB| will be mapped if not already. On Windows,
139 // this |TransportDIB| will NOT be mapped and should not be mapped prior, 152 // this |TransportDIB| will NOT be mapped and should not be mapped prior,
140 // because PlatformCanvas will map the file internally. 153 // because PlatformCanvas will map the file internally.
141 // 154 //
142 // Will return NULL on allocation failure. This could be because the image 155 // Will return NULL on allocation failure. This could be because the image
(...skipping 26 matching lines...) Expand all
169 XID MapToX(Display* connection); 182 XID MapToX(Display* connection);
170 #endif 183 #endif
171 184
172 private: 185 private:
173 TransportDIB(); 186 TransportDIB();
174 #if defined(OS_WIN) || defined(OS_MACOSX) 187 #if defined(OS_WIN) || defined(OS_MACOSX)
175 explicit TransportDIB(base::SharedMemoryHandle dib); 188 explicit TransportDIB(base::SharedMemoryHandle dib);
176 base::SharedMemory shared_memory_; 189 base::SharedMemory shared_memory_;
177 uint32 sequence_num_; 190 uint32 sequence_num_;
178 #elif defined(USE_X11) 191 #elif defined(USE_X11)
179 int key_; // SysV shared memory id 192 Id key_; // SysV shared memory id
180 void* address_; // mapped address 193 void* address_; // mapped address
181 XSharedMemoryId x_shm_; // X id for the shared segment 194 XSharedMemoryId x_shm_; // X id for the shared segment
182 Display* display_; // connection to the X server 195 Display* display_; // connection to the X server
183 #endif 196 #endif
184 size_t size_; // length, in bytes 197 size_t size_; // length, in bytes
185 198
186 DISALLOW_COPY_AND_ASSIGN(TransportDIB); 199 DISALLOW_COPY_AND_ASSIGN(TransportDIB);
187 }; 200 };
188 201
189 #endif // APP_SURFACE_TRANSPORT_DIB_H_ 202 #endif // APP_SURFACE_TRANSPORT_DIB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698