Chromium Code Reviews| 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) | |
| 239 { | |
| 240 DCHECK(m_threadChecker.CalledOnValidThread()); | |
| 241 | |
| 242 const int8* name = reinterpret_cast<const int8*>(mailbox.c_str()); | |
|
piman
2012/12/20 02:14:21
nit: .data() instead of c_str() to avoid forcing a
danakj
2012/12/20 02:16:19
how come you need reinterpret_cast to do this? wha
alexst (slow to review)
2012/12/21 14:15:21
Done.
alexst (slow to review)
2012/12/21 14:15:21
consumeTextureCHROMIUM expects signed data both, c
| |
| 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->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER , GL_LINEAR)); | |
| 249 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER , GL_LINEAR)); | |
| 250 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL _CLAMP_TO_EDGE)); | |
| 251 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL _CLAMP_TO_EDGE)); | |
|
piman
2012/12/20 02:14:21
nit: we shouldn't have to set the tex parameters,
alexst (slow to review)
2012/12/21 14:15:21
Done.
| |
| 252 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, name)); | |
| 253 GLC(context3d, context3d->flush()); | |
|
danakj
2012/12/20 02:16:19
how come the flush is needed?
alexst (slow to review)
2012/12/21 14:15:21
Backing texture for the mailbox is in a different
| |
| 254 | |
| 255 ResourceId id = m_nextId++; | |
| 256 Resource resource(textureId, gfx::Size(), 0, GL_LINEAR); | |
|
piman
2012/12/20 02:14:21
We probably want to pass all the info so that thes
alexst (slow to review)
2012/12/21 14:15:21
I only know the size but not the format from swapB
| |
| 257 resource.external = true; | |
| 258 resource.mailbox.setName(name); | |
| 259 m_resources[id] = resource; | |
| 260 return id; | |
| 261 } | |
| 262 | |
| 238 void ResourceProvider::deleteResource(ResourceId id) | 263 void ResourceProvider::deleteResource(ResourceId id) |
| 239 { | 264 { |
| 240 DCHECK(m_threadChecker.CalledOnValidThread()); | 265 DCHECK(m_threadChecker.CalledOnValidThread()); |
| 241 ResourceMap::iterator it = m_resources.find(id); | 266 ResourceMap::iterator it = m_resources.find(id); |
| 242 CHECK(it != m_resources.end()); | 267 CHECK(it != m_resources.end()); |
| 243 Resource* resource = &it->second; | 268 Resource* resource = &it->second; |
| 244 DCHECK(!resource->lockedForWrite); | 269 DCHECK(!resource->lockedForWrite); |
| 245 DCHECK(!resource->lockForReadCount); | 270 DCHECK(!resource->lockForReadCount); |
| 246 DCHECK(!resource->markedForDeletion); | 271 DCHECK(!resource->markedForDeletion); |
| 247 | 272 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 263 if (resource->glUploadQueryId) { | 288 if (resource->glUploadQueryId) { |
| 264 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); | 289 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); |
| 265 DCHECK(context3d); | 290 DCHECK(context3d); |
| 266 GLC(context3d, context3d->deleteQueryEXT(resource->glUploadQueryId)); | 291 GLC(context3d, context3d->deleteQueryEXT(resource->glUploadQueryId)); |
| 267 } | 292 } |
| 268 if (resource->glPixelBufferId) { | 293 if (resource->glPixelBufferId) { |
| 269 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); | 294 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); |
| 270 DCHECK(context3d); | 295 DCHECK(context3d); |
| 271 GLC(context3d, context3d->deleteBuffer(resource->glPixelBufferId)); | 296 GLC(context3d, context3d->deleteBuffer(resource->glPixelBufferId)); |
| 272 } | 297 } |
| 298 if (!resource->mailbox.isZero()) { | |
|
piman
2012/12/20 02:14:21
This is not quite right, since we will have a mail
alexst (slow to review)
2012/12/21 14:15:21
Done.
| |
| 299 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); | |
| 300 DCHECK(context3d); | |
| 301 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId)); | |
| 302 GLC(context3d, context3d->produceTextureCHROMIUM(GL_TEXTURE_2D, resource ->mailbox.name)); | |
| 303 GLC(context3d, context3d->deleteTexture(resource->glId)); | |
| 304 } | |
| 273 if (resource->pixels) | 305 if (resource->pixels) |
| 274 delete[] resource->pixels; | 306 delete[] resource->pixels; |
| 275 if (resource->pixelBuffer) | 307 if (resource->pixelBuffer) |
| 276 delete[] resource->pixelBuffer; | 308 delete[] resource->pixelBuffer; |
| 277 | 309 |
| 278 m_resources.erase(it); | 310 m_resources.erase(it); |
| 279 } | 311 } |
| 280 | 312 |
| 281 ResourceProvider::ResourceType ResourceProvider::resourceType(ResourceId id) | 313 ResourceProvider::ResourceType ResourceProvider::resourceType(ResourceId id) |
| 282 { | 314 { |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 950 return false; | 982 return false; |
| 951 } | 983 } |
| 952 | 984 |
| 953 resource->pendingSetPixels = false; | 985 resource->pendingSetPixels = false; |
| 954 unlockForWrite(id); | 986 unlockForWrite(id); |
| 955 | 987 |
| 956 return true; | 988 return true; |
| 957 } | 989 } |
| 958 | 990 |
| 959 } // namespace cc | 991 } // namespace cc |
| OLD | NEW |