OLD | NEW |
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // | 117 // |
118 // The sequence number is used to uniquely identify the transport DIB. It | 118 // The sequence number is used to uniquely identify the transport DIB. It |
119 // should be unique for all transport DIBs ever created in the same | 119 // should be unique for all transport DIBs ever created in the same |
120 // renderer. | 120 // renderer. |
121 static TransportDIB* Create(size_t size, uint32 sequence_num); | 121 static TransportDIB* Create(size_t size, uint32 sequence_num); |
122 | 122 |
123 // Map the referenced transport DIB. The caller owns the returned object. | 123 // Map the referenced transport DIB. The caller owns the returned object. |
124 // Returns NULL on failure. | 124 // Returns NULL on failure. |
125 static TransportDIB* Map(Handle transport_dib); | 125 static TransportDIB* Map(Handle transport_dib); |
126 | 126 |
| 127 // Create a new |TransportDIB| with a handle to the shared memory. This |
| 128 // always returns a valid pointer. The DIB is not mapped. |
| 129 static TransportDIB* CreateWithHandle(Handle handle); |
| 130 |
127 // Returns true if the handle is valid. | 131 // Returns true if the handle is valid. |
128 static bool is_valid(Handle dib); | 132 static bool is_valid(Handle dib); |
129 | 133 |
130 // Returns a canvas using the memory of this TransportDIB. The returned | 134 // Returns a canvas using the memory of this TransportDIB. The returned |
131 // pointer will be owned by the caller. The bitmap will be of the given size, | 135 // pointer will be owned by the caller. The bitmap will be of the given size, |
132 // which should fit inside this memory. | 136 // which should fit inside this memory. |
133 // | 137 // |
| 138 // 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, |
| 140 // because PlatformCanvas will map the file internally. |
| 141 // |
134 // Will return NULL on allocation failure. This could be because the image | 142 // Will return NULL on allocation failure. This could be because the image |
135 // is too large to map into the current process' address space. | 143 // is too large to map into the current process' address space. |
136 skia::PlatformCanvas* GetPlatformCanvas(int w, int h); | 144 skia::PlatformCanvas* GetPlatformCanvas(int w, int h); |
137 | 145 |
138 // Return a pointer to the shared memory | 146 // Map the DIB into the current process if it is not already. This is used to |
| 147 // map a DIB that has already been created. Returns true if the DIB is mapped. |
| 148 bool Map(); |
| 149 |
| 150 // Return a pointer to the shared memory. |
139 void* memory() const; | 151 void* memory() const; |
140 | 152 |
141 // Return the maximum size of the shared memory. This is not the amount of | 153 // Return the maximum size of the shared memory. This is not the amount of |
142 // data which is valid, you have to know that via other means, this is simply | 154 // data which is valid, you have to know that via other means, this is simply |
143 // the maximum amount that /could/ be valid. | 155 // the maximum amount that /could/ be valid. |
144 size_t size() const { return size_; } | 156 size_t size() const { return size_; } |
145 | 157 |
146 // Return the identifier which can be used to refer to this shared memory | 158 // Return the identifier which can be used to refer to this shared memory |
147 // on the wire. | 159 // on the wire. |
148 Id id() const; | 160 Id id() const; |
(...skipping 19 matching lines...) Expand all Loading... |
168 void* address_; // mapped address | 180 void* address_; // mapped address |
169 XSharedMemoryId x_shm_; // X id for the shared segment | 181 XSharedMemoryId x_shm_; // X id for the shared segment |
170 Display* display_; // connection to the X server | 182 Display* display_; // connection to the X server |
171 #endif | 183 #endif |
172 size_t size_; // length, in bytes | 184 size_t size_; // length, in bytes |
173 | 185 |
174 DISALLOW_COPY_AND_ASSIGN(TransportDIB); | 186 DISALLOW_COPY_AND_ASSIGN(TransportDIB); |
175 }; | 187 }; |
176 | 188 |
177 #endif // APP_SURFACE_TRANSPORT_DIB_H_ | 189 #endif // APP_SURFACE_TRANSPORT_DIB_H_ |
OLD | NEW |