OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "cc/resource_provider.h" | 5 #include "cc/resource_provider.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 | 8 |
9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL _CLAMP_TO_EDGE)); | 228 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL _CLAMP_TO_EDGE)); |
229 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL _CLAMP_TO_EDGE)); | 229 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL _CLAMP_TO_EDGE)); |
230 | 230 |
231 ResourceId id = m_nextId++; | 231 ResourceId id = m_nextId++; |
232 Resource resource(textureId, gfx::Size(), 0, GL_LINEAR); | 232 Resource resource(textureId, gfx::Size(), 0, GL_LINEAR); |
233 resource.external = true; | 233 resource.external = true; |
234 m_resources[id] = resource; | 234 m_resources[id] = resource; |
235 return id; | 235 return id; |
236 } | 236 } |
237 | 237 |
238 ResourceProvider::ResourceId ResourceProvider::createResourceFromTextureMailbox( const std::string& mailbox, const base::Callback<void(unsigned)>& releaseCallbac k) | |
239 { | |
240 DCHECK(m_threadChecker.CalledOnValidThread()); | |
241 | |
242 const int8* name = reinterpret_cast<const int8*>(mailbox.data()); | |
243 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); | |
244 DCHECK(context3d); | |
245 unsigned textureId; | |
246 GLC(context3d, textureId = context3d->createTexture()); | |
247 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); | |
248 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, name)); | |
249 GLC(context3d, context3d->flush()); | |
250 | |
251 ResourceId id = m_nextId++; | |
252 Resource resource(textureId, gfx::Size(), 0, GL_LINEAR); | |
253 resource.external = true; | |
254 resource.mailbox.setName(name); | |
255 resource.mailbox.releaseCallback = releaseCallback; | |
256 m_resources[id] = resource; | |
257 return id; | |
258 } | |
259 | |
238 void ResourceProvider::deleteResource(ResourceId id) | 260 void ResourceProvider::deleteResource(ResourceId id) |
239 { | 261 { |
240 DCHECK(m_threadChecker.CalledOnValidThread()); | 262 DCHECK(m_threadChecker.CalledOnValidThread()); |
241 ResourceMap::iterator it = m_resources.find(id); | 263 ResourceMap::iterator it = m_resources.find(id); |
242 CHECK(it != m_resources.end()); | 264 CHECK(it != m_resources.end()); |
243 Resource* resource = &it->second; | 265 Resource* resource = &it->second; |
244 DCHECK(!resource->lockedForWrite); | 266 DCHECK(!resource->lockedForWrite); |
245 DCHECK(!resource->lockForReadCount); | 267 DCHECK(!resource->lockForReadCount); |
246 DCHECK(!resource->markedForDeletion); | 268 DCHECK(!resource->markedForDeletion); |
247 | 269 |
(...skipping 15 matching lines...) Expand all Loading... | |
263 if (resource->glUploadQueryId) { | 285 if (resource->glUploadQueryId) { |
264 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); | 286 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); |
265 DCHECK(context3d); | 287 DCHECK(context3d); |
266 GLC(context3d, context3d->deleteQueryEXT(resource->glUploadQueryId)); | 288 GLC(context3d, context3d->deleteQueryEXT(resource->glUploadQueryId)); |
267 } | 289 } |
268 if (resource->glPixelBufferId) { | 290 if (resource->glPixelBufferId) { |
269 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); | 291 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); |
270 DCHECK(context3d); | 292 DCHECK(context3d); |
271 GLC(context3d, context3d->deleteBuffer(resource->glPixelBufferId)); | 293 GLC(context3d, context3d->deleteBuffer(resource->glPixelBufferId)); |
272 } | 294 } |
295 if (!resource->mailbox.isZero() && resource->external) { | |
danakj
2013/01/02 16:17:22
Should this be just if (!mailbox.IsZero) {}
and t
alexst (slow to review)
2013/01/02 19:31:35
I was addressing an earlier comment below so we on
| |
296 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); | |
297 DCHECK(context3d); | |
298 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId)); | |
299 GLC(context3d, context3d->produceTextureCHROMIUM(GL_TEXTURE_2D, resource ->mailbox.name)); | |
300 GLC(context3d, context3d->deleteTexture(resource->glId)); | |
301 if (!resource->mailbox.releaseCallback.is_null()) { | |
302 unsigned syncPoint = 0; | |
303 GLC(context3d, syncPoint = context3d->insertSyncPoint()); | |
304 resource->mailbox.releaseCallback.Run(syncPoint); | |
305 } | |
306 } | |
273 if (resource->pixels) | 307 if (resource->pixels) |
274 delete[] resource->pixels; | 308 delete[] resource->pixels; |
275 if (resource->pixelBuffer) | 309 if (resource->pixelBuffer) |
276 delete[] resource->pixelBuffer; | 310 delete[] resource->pixelBuffer; |
277 | 311 |
278 m_resources.erase(it); | 312 m_resources.erase(it); |
279 } | 313 } |
280 | 314 |
281 ResourceProvider::ResourceType ResourceProvider::resourceType(ResourceId id) | 315 ResourceProvider::ResourceType ResourceProvider::resourceType(ResourceId id) |
282 { | 316 { |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
950 return false; | 984 return false; |
951 } | 985 } |
952 | 986 |
953 resource->pendingSetPixels = false; | 987 resource->pendingSetPixels = false; |
954 unlockForWrite(id); | 988 unlockForWrite(id); |
955 | 989 |
956 return true; | 990 return true; |
957 } | 991 } |
958 | 992 |
959 } // namespace cc | 993 } // namespace cc |
OLD | NEW |