| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "CCResourceProvider.h" | 7 #include "CCResourceProvider.h" |
| 8 #ifdef LOG | 8 #ifdef LOG |
| 9 #undef LOG | 9 #undef LOG |
| 10 #endif | 10 #endif |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 { | 62 { |
| 63 ASSERT(CCProxy::isImplThread()); | 63 ASSERT(CCProxy::isImplThread()); |
| 64 return m_context->context3D(); | 64 return m_context->context3D(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool CCResourceProvider::inUseByConsumer(ResourceId id) | 67 bool CCResourceProvider::inUseByConsumer(ResourceId id) |
| 68 { | 68 { |
| 69 ASSERT(CCProxy::isImplThread()); | 69 ASSERT(CCProxy::isImplThread()); |
| 70 ResourceMap::iterator it = m_resources.find(id); | 70 ResourceMap::iterator it = m_resources.find(id); |
| 71 ASSERT(it != m_resources.end()); | 71 ASSERT(it != m_resources.end()); |
| 72 return !!it->second.lockForReadCount || it->second.exported; | 72 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 73 Resource* resource = &it->value; |
| 74 #else |
| 75 Resource* resource = &it->second; |
| 76 #endif |
| 77 return !!resource->lockForReadCount || resource->exported; |
| 73 } | 78 } |
| 74 | 79 |
| 75 CCResourceProvider::ResourceId CCResourceProvider::createResource(int pool, cons
t IntSize& size, GC3Denum format, TextureUsageHint hint) | 80 CCResourceProvider::ResourceId CCResourceProvider::createResource(int pool, cons
t IntSize& size, GC3Denum format, TextureUsageHint hint) |
| 76 { | 81 { |
| 77 switch (m_defaultResourceType) { | 82 switch (m_defaultResourceType) { |
| 78 case GLTexture: | 83 case GLTexture: |
| 79 return createGLTexture(pool, size, format, hint); | 84 return createGLTexture(pool, size, format, hint); |
| 80 case Bitmap: | 85 case Bitmap: |
| 81 ASSERT(format == GraphicsContext3D::RGBA); | 86 ASSERT(format == GraphicsContext3D::RGBA); |
| 82 return createBitmap(pool, size); | 87 return createBitmap(pool, size); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 resource.external = true; | 138 resource.external = true; |
| 134 m_resources.add(id, resource); | 139 m_resources.add(id, resource); |
| 135 return id; | 140 return id; |
| 136 } | 141 } |
| 137 | 142 |
| 138 void CCResourceProvider::deleteResource(ResourceId id) | 143 void CCResourceProvider::deleteResource(ResourceId id) |
| 139 { | 144 { |
| 140 ASSERT(CCProxy::isImplThread()); | 145 ASSERT(CCProxy::isImplThread()); |
| 141 ResourceMap::iterator it = m_resources.find(id); | 146 ResourceMap::iterator it = m_resources.find(id); |
| 142 ASSERT(it != m_resources.end()); | 147 ASSERT(it != m_resources.end()); |
| 143 ASSERT(!it->second.lockedForWrite); | 148 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 144 ASSERT(!it->second.lockForReadCount); | 149 Resource* resource = &it->value; |
| 150 #else |
| 151 Resource* resource = &it->second; |
| 152 #endif |
| 153 ASSERT(!resource->lockedForWrite); |
| 154 ASSERT(!resource->lockForReadCount); |
| 145 | 155 |
| 146 if (it->second.glId && !it->second.external) { | 156 if (resource->glId && !resource->external) { |
| 147 WebGraphicsContext3D* context3d = m_context->context3D(); | 157 WebGraphicsContext3D* context3d = m_context->context3D(); |
| 148 ASSERT(context3d); | 158 ASSERT(context3d); |
| 149 GLC(context3d, context3d->deleteTexture(it->second.glId)); | 159 GLC(context3d, context3d->deleteTexture(resource->glId)); |
| 150 } | 160 } |
| 151 if (it->second.pixels) | 161 if (resource->pixels) |
| 152 delete it->second.pixels; | 162 delete resource->pixels; |
| 153 | 163 |
| 154 m_resources.remove(it); | 164 m_resources.remove(it); |
| 155 } | 165 } |
| 156 | 166 |
| 157 void CCResourceProvider::deleteOwnedResources(int pool) | 167 void CCResourceProvider::deleteOwnedResources(int pool) |
| 158 { | 168 { |
| 159 ASSERT(CCProxy::isImplThread()); | 169 ASSERT(CCProxy::isImplThread()); |
| 160 ResourceIdArray toDelete; | 170 ResourceIdArray toDelete; |
| 161 for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.end()
; ++it) { | 171 for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.end()
; ++it) { |
| 172 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 173 if (it->value.pool == pool && !it->value.external) |
| 174 toDelete.append(it->key); |
| 175 #else |
| 162 if (it->second.pool == pool && !it->second.external) | 176 if (it->second.pool == pool && !it->second.external) |
| 163 toDelete.append(it->first); | 177 toDelete.append(it->first); |
| 178 #endif |
| 164 } | 179 } |
| 165 for (ResourceIdArray::iterator it = toDelete.begin(); it != toDelete.end();
++it) | 180 for (ResourceIdArray::iterator it = toDelete.begin(); it != toDelete.end();
++it) |
| 166 deleteResource(*it); | 181 deleteResource(*it); |
| 167 } | 182 } |
| 168 | 183 |
| 169 CCResourceProvider::ResourceType CCResourceProvider::resourceType(ResourceId id) | 184 CCResourceProvider::ResourceType CCResourceProvider::resourceType(ResourceId id) |
| 170 { | 185 { |
| 171 ResourceMap::iterator it = m_resources.find(id); | 186 ResourceMap::iterator it = m_resources.find(id); |
| 172 ASSERT(it != m_resources.end()); | 187 ASSERT(it != m_resources.end()); |
| 173 return it->second.type; | 188 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 189 Resource* resource = &it->value; |
| 190 #else |
| 191 Resource* resource = &it->second; |
| 192 #endif |
| 193 return resource->type; |
| 174 } | 194 } |
| 175 | 195 |
| 176 void CCResourceProvider::upload(ResourceId id, const uint8_t* image, const IntRe
ct& imageRect, const IntRect& sourceRect, const IntSize& destOffset) | 196 void CCResourceProvider::upload(ResourceId id, const uint8_t* image, const IntRe
ct& imageRect, const IntRect& sourceRect, const IntSize& destOffset) |
| 177 { | 197 { |
| 178 ASSERT(CCProxy::isImplThread()); | 198 ASSERT(CCProxy::isImplThread()); |
| 179 ResourceMap::iterator it = m_resources.find(id); | 199 ResourceMap::iterator it = m_resources.find(id); |
| 180 ASSERT(it != m_resources.end()); | 200 ASSERT(it != m_resources.end()); |
| 181 ASSERT(!it->second.lockedForWrite); | 201 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 182 ASSERT(!it->second.lockForReadCount); | 202 Resource* resource = &it->value; |
| 183 ASSERT(!it->second.external); | 203 #else |
| 204 Resource* resource = &it->second; |
| 205 #endif |
| 206 ASSERT(!resource->lockedForWrite); |
| 207 ASSERT(!resource->lockForReadCount); |
| 208 ASSERT(!resource->external); |
| 184 | 209 |
| 185 if (it->second.glId) { | 210 if (resource->glId) { |
| 186 WebGraphicsContext3D* context3d = m_context->context3D(); | 211 WebGraphicsContext3D* context3d = m_context->context3D(); |
| 187 ASSERT(context3d); | 212 ASSERT(context3d); |
| 188 ASSERT(m_texSubImage.get()); | 213 ASSERT(m_texSubImage.get()); |
| 189 context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, it->second.glId); | 214 context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, resource->glId); |
| 190 m_texSubImage->upload(image, imageRect, sourceRect, destOffset, it->seco
nd.format, context3d); | 215 m_texSubImage->upload(image, imageRect, sourceRect, destOffset, resource
->format, context3d); |
| 191 } | 216 } |
| 192 | 217 |
| 193 if (it->second.pixels) { | 218 if (resource->pixels) { |
| 194 SkBitmap srcFull; | 219 SkBitmap srcFull; |
| 195 srcFull.setConfig(SkBitmap::kARGB_8888_Config, imageRect.width(), imageR
ect.height()); | 220 srcFull.setConfig(SkBitmap::kARGB_8888_Config, imageRect.width(), imageR
ect.height()); |
| 196 srcFull.setPixels(const_cast<uint8_t*>(image)); | 221 srcFull.setPixels(const_cast<uint8_t*>(image)); |
| 197 SkBitmap srcSubset; | 222 SkBitmap srcSubset; |
| 198 SkIRect skSourceRect = SkIRect::MakeXYWH(sourceRect.x(), sourceRect.y(),
sourceRect.width(), sourceRect.height()); | 223 SkIRect skSourceRect = SkIRect::MakeXYWH(sourceRect.x(), sourceRect.y(),
sourceRect.width(), sourceRect.height()); |
| 199 skSourceRect.offset(-imageRect.x(), -imageRect.y()); | 224 skSourceRect.offset(-imageRect.x(), -imageRect.y()); |
| 200 srcFull.extractSubset(&srcSubset, skSourceRect); | 225 srcFull.extractSubset(&srcSubset, skSourceRect); |
| 201 | 226 |
| 202 ScopedWriteLockSoftware lock(this, id); | 227 ScopedWriteLockSoftware lock(this, id); |
| 203 SkCanvas* dest = lock.skCanvas(); | 228 SkCanvas* dest = lock.skCanvas(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 222 | 247 |
| 223 context3d->shallowFlushCHROMIUM(); | 248 context3d->shallowFlushCHROMIUM(); |
| 224 return true; | 249 return true; |
| 225 } | 250 } |
| 226 | 251 |
| 227 const CCResourceProvider::Resource* CCResourceProvider::lockForRead(ResourceId i
d) | 252 const CCResourceProvider::Resource* CCResourceProvider::lockForRead(ResourceId i
d) |
| 228 { | 253 { |
| 229 ASSERT(CCProxy::isImplThread()); | 254 ASSERT(CCProxy::isImplThread()); |
| 230 ResourceMap::iterator it = m_resources.find(id); | 255 ResourceMap::iterator it = m_resources.find(id); |
| 231 ASSERT(it != m_resources.end()); | 256 ASSERT(it != m_resources.end()); |
| 232 ASSERT(!it->second.lockedForWrite); | 257 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 233 it->second.lockForReadCount++; | 258 Resource* resource = &it->value; |
| 234 return &it->second; | 259 #else |
| 260 Resource* resource = &it->second; |
| 261 #endif |
| 262 ASSERT(!resource->lockedForWrite); |
| 263 resource->lockForReadCount++; |
| 264 return resource; |
| 235 } | 265 } |
| 236 | 266 |
| 237 void CCResourceProvider::unlockForRead(ResourceId id) | 267 void CCResourceProvider::unlockForRead(ResourceId id) |
| 238 { | 268 { |
| 239 ASSERT(CCProxy::isImplThread()); | 269 ASSERT(CCProxy::isImplThread()); |
| 240 ResourceMap::iterator it = m_resources.find(id); | 270 ResourceMap::iterator it = m_resources.find(id); |
| 241 ASSERT(it != m_resources.end()); | 271 ASSERT(it != m_resources.end()); |
| 242 ASSERT(it->second.lockForReadCount > 0); | 272 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 243 it->second.lockForReadCount--; | 273 Resource* resource = &it->value; |
| 274 #else |
| 275 Resource* resource = &it->second; |
| 276 #endif |
| 277 ASSERT(resource->lockForReadCount > 0); |
| 278 resource->lockForReadCount--; |
| 244 } | 279 } |
| 245 | 280 |
| 246 const CCResourceProvider::Resource* CCResourceProvider::lockForWrite(ResourceId
id) | 281 const CCResourceProvider::Resource* CCResourceProvider::lockForWrite(ResourceId
id) |
| 247 { | 282 { |
| 248 ASSERT(CCProxy::isImplThread()); | 283 ASSERT(CCProxy::isImplThread()); |
| 249 ResourceMap::iterator it = m_resources.find(id); | 284 ResourceMap::iterator it = m_resources.find(id); |
| 250 ASSERT(it != m_resources.end()); | 285 ASSERT(it != m_resources.end()); |
| 251 ASSERT(!it->second.lockedForWrite); | 286 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 252 ASSERT(!it->second.lockForReadCount); | 287 Resource* resource = &it->value; |
| 253 ASSERT(!it->second.external); | 288 #else |
| 254 it->second.lockedForWrite = true; | 289 Resource* resource = &it->second; |
| 255 return &it->second; | 290 #endif |
| 291 ASSERT(!resource->lockedForWrite); |
| 292 ASSERT(!resource->lockForReadCount); |
| 293 ASSERT(!resource->external); |
| 294 resource->lockedForWrite = true; |
| 295 return resource; |
| 256 } | 296 } |
| 257 | 297 |
| 258 void CCResourceProvider::unlockForWrite(ResourceId id) | 298 void CCResourceProvider::unlockForWrite(ResourceId id) |
| 259 { | 299 { |
| 260 ASSERT(CCProxy::isImplThread()); | 300 ASSERT(CCProxy::isImplThread()); |
| 261 ResourceMap::iterator it = m_resources.find(id); | 301 ResourceMap::iterator it = m_resources.find(id); |
| 262 ASSERT(it != m_resources.end()); | 302 ASSERT(it != m_resources.end()); |
| 263 ASSERT(it->second.lockedForWrite); | 303 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 264 ASSERT(!it->second.external); | 304 Resource* resource = &it->value; |
| 265 it->second.lockedForWrite = false; | 305 #else |
| 306 Resource* resource = &it->second; |
| 307 #endif |
| 308 ASSERT(resource->lockedForWrite); |
| 309 ASSERT(!resource->external); |
| 310 resource->lockedForWrite = false; |
| 266 } | 311 } |
| 267 | 312 |
| 268 CCResourceProvider::ScopedReadLockGL::ScopedReadLockGL(CCResourceProvider* resou
rceProvider, CCResourceProvider::ResourceId resourceId) | 313 CCResourceProvider::ScopedReadLockGL::ScopedReadLockGL(CCResourceProvider* resou
rceProvider, CCResourceProvider::ResourceId resourceId) |
| 269 : m_resourceProvider(resourceProvider) | 314 : m_resourceProvider(resourceProvider) |
| 270 , m_resourceId(resourceId) | 315 , m_resourceId(resourceId) |
| 271 , m_textureId(resourceProvider->lockForRead(resourceId)->glId) | 316 , m_textureId(resourceProvider->lockForRead(resourceId)->glId) |
| 272 { | 317 { |
| 273 ASSERT(m_textureId); | 318 ASSERT(m_textureId); |
| 274 } | 319 } |
| 275 | 320 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 int child = m_nextChild++; | 422 int child = m_nextChild++; |
| 378 m_children.add(child, childInfo); | 423 m_children.add(child, childInfo); |
| 379 return child; | 424 return child; |
| 380 } | 425 } |
| 381 | 426 |
| 382 void CCResourceProvider::destroyChild(int child) | 427 void CCResourceProvider::destroyChild(int child) |
| 383 { | 428 { |
| 384 ASSERT(CCProxy::isImplThread()); | 429 ASSERT(CCProxy::isImplThread()); |
| 385 ChildMap::iterator it = m_children.find(child); | 430 ChildMap::iterator it = m_children.find(child); |
| 386 ASSERT(it != m_children.end()); | 431 ASSERT(it != m_children.end()); |
| 432 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 433 deleteOwnedResources(it->value.pool); |
| 434 #else |
| 387 deleteOwnedResources(it->second.pool); | 435 deleteOwnedResources(it->second.pool); |
| 436 #endif |
| 388 m_children.remove(it); | 437 m_children.remove(it); |
| 389 trimMailboxDeque(); | 438 trimMailboxDeque(); |
| 390 } | 439 } |
| 391 | 440 |
| 392 const CCResourceProvider::ResourceIdMap& CCResourceProvider::getChildToParentMap
(int child) const | 441 const CCResourceProvider::ResourceIdMap& CCResourceProvider::getChildToParentMap
(int child) const |
| 393 { | 442 { |
| 394 ASSERT(CCProxy::isImplThread()); | 443 ASSERT(CCProxy::isImplThread()); |
| 395 ChildMap::const_iterator it = m_children.find(child); | 444 ChildMap::const_iterator it = m_children.find(child); |
| 396 ASSERT(it != m_children.end()); | 445 ASSERT(it != m_children.end()); |
| 446 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 447 return it->value.childToParentMap; |
| 448 #else |
| 397 return it->second.childToParentMap; | 449 return it->second.childToParentMap; |
| 450 #endif |
| 398 } | 451 } |
| 399 | 452 |
| 400 CCResourceProvider::TransferableResourceList CCResourceProvider::prepareSendToPa
rent(const ResourceIdArray& resources) | 453 CCResourceProvider::TransferableResourceList CCResourceProvider::prepareSendToPa
rent(const ResourceIdArray& resources) |
| 401 { | 454 { |
| 402 ASSERT(CCProxy::isImplThread()); | 455 ASSERT(CCProxy::isImplThread()); |
| 403 TransferableResourceList list; | 456 TransferableResourceList list; |
| 404 list.syncPoint = 0; | 457 list.syncPoint = 0; |
| 405 WebGraphicsContext3D* context3d = m_context->context3D(); | 458 WebGraphicsContext3D* context3d = m_context->context3D(); |
| 406 if (!context3d || !context3d->makeContextCurrent()) { | 459 if (!context3d || !context3d->makeContextCurrent()) { |
| 407 // FIXME: Implement this path for software compositing. | 460 // FIXME: Implement this path for software compositing. |
| 408 return list; | 461 return list; |
| 409 } | 462 } |
| 410 for (ResourceIdArray::const_iterator it = resources.begin(); it != resources
.end(); ++it) { | 463 for (ResourceIdArray::const_iterator it = resources.begin(); it != resources
.end(); ++it) { |
| 411 TransferableResource resource; | 464 TransferableResource resource; |
| 412 if (transferResource(context3d, *it, &resource)) { | 465 if (transferResource(context3d, *it, &resource)) { |
| 466 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 467 m_resources.find(*it)->value.exported = true; |
| 468 #else |
| 413 m_resources.find(*it)->second.exported = true; | 469 m_resources.find(*it)->second.exported = true; |
| 470 #endif |
| 414 list.resources.append(resource); | 471 list.resources.append(resource); |
| 415 } | 472 } |
| 416 } | 473 } |
| 417 if (list.resources.size()) | 474 if (list.resources.size()) |
| 418 list.syncPoint = context3d->insertSyncPoint(); | 475 list.syncPoint = context3d->insertSyncPoint(); |
| 419 return list; | 476 return list; |
| 420 } | 477 } |
| 421 | 478 |
| 422 CCResourceProvider::TransferableResourceList CCResourceProvider::prepareSendToCh
ild(int child, const ResourceIdArray& resources) | 479 CCResourceProvider::TransferableResourceList CCResourceProvider::prepareSendToCh
ild(int child, const ResourceIdArray& resources) |
| 423 { | 480 { |
| 424 ASSERT(CCProxy::isImplThread()); | 481 ASSERT(CCProxy::isImplThread()); |
| 425 TransferableResourceList list; | 482 TransferableResourceList list; |
| 426 list.syncPoint = 0; | 483 list.syncPoint = 0; |
| 427 WebGraphicsContext3D* context3d = m_context->context3D(); | 484 WebGraphicsContext3D* context3d = m_context->context3D(); |
| 428 if (!context3d || !context3d->makeContextCurrent()) { | 485 if (!context3d || !context3d->makeContextCurrent()) { |
| 429 // FIXME: Implement this path for software compositing. | 486 // FIXME: Implement this path for software compositing. |
| 430 return list; | 487 return list; |
| 431 } | 488 } |
| 489 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 490 Child& childInfo = m_children.find(child)->value; |
| 491 #else |
| 432 Child& childInfo = m_children.find(child)->second; | 492 Child& childInfo = m_children.find(child)->second; |
| 493 #endif |
| 433 for (ResourceIdArray::const_iterator it = resources.begin(); it != resources
.end(); ++it) { | 494 for (ResourceIdArray::const_iterator it = resources.begin(); it != resources
.end(); ++it) { |
| 434 TransferableResource resource; | 495 TransferableResource resource; |
| 435 if (!transferResource(context3d, *it, &resource)) | 496 if (!transferResource(context3d, *it, &resource)) |
| 436 ASSERT_NOT_REACHED(); | 497 ASSERT_NOT_REACHED(); |
| 437 resource.id = childInfo.parentToChildMap.get(*it); | 498 resource.id = childInfo.parentToChildMap.get(*it); |
| 438 childInfo.parentToChildMap.remove(*it); | 499 childInfo.parentToChildMap.remove(*it); |
| 439 childInfo.childToParentMap.remove(resource.id); | 500 childInfo.childToParentMap.remove(resource.id); |
| 440 list.resources.append(resource); | 501 list.resources.append(resource); |
| 441 deleteResource(*it); | 502 deleteResource(*it); |
| 442 } | 503 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 455 } | 516 } |
| 456 if (resources.syncPoint) { | 517 if (resources.syncPoint) { |
| 457 // NOTE: If the parent is a browser and the child a renderer, the parent | 518 // NOTE: If the parent is a browser and the child a renderer, the parent |
| 458 // is not supposed to have its context wait, because that could induce | 519 // is not supposed to have its context wait, because that could induce |
| 459 // deadlocks and/or security issues. The caller is responsible for | 520 // deadlocks and/or security issues. The caller is responsible for |
| 460 // waiting asynchronously, and resetting syncPoint before calling this. | 521 // waiting asynchronously, and resetting syncPoint before calling this. |
| 461 // However if the parent is a renderer (e.g. browser tag), it may be ok | 522 // However if the parent is a renderer (e.g. browser tag), it may be ok |
| 462 // (and is simpler) to wait. | 523 // (and is simpler) to wait. |
| 463 GLC(context3d, context3d->waitSyncPoint(resources.syncPoint)); | 524 GLC(context3d, context3d->waitSyncPoint(resources.syncPoint)); |
| 464 } | 525 } |
| 526 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 527 Child& childInfo = m_children.find(child)->value; |
| 528 #else |
| 465 Child& childInfo = m_children.find(child)->second; | 529 Child& childInfo = m_children.find(child)->second; |
| 530 #endif |
| 466 for (Vector<TransferableResource>::const_iterator it = resources.resources.b
egin(); it != resources.resources.end(); ++it) { | 531 for (Vector<TransferableResource>::const_iterator it = resources.resources.b
egin(); it != resources.resources.end(); ++it) { |
| 467 unsigned textureId; | 532 unsigned textureId; |
| 468 GLC(context3d, textureId = context3d->createTexture()); | 533 GLC(context3d, textureId = context3d->createTexture()); |
| 469 GLC(context3d, context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, tex
tureId)); | 534 GLC(context3d, context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, tex
tureId)); |
| 470 GLC(context3d, context3d->consumeTextureCHROMIUM(GraphicsContext3D::TEXT
URE_2D, it->mailbox.name)); | 535 GLC(context3d, context3d->consumeTextureCHROMIUM(GraphicsContext3D::TEXT
URE_2D, it->mailbox.name)); |
| 471 ResourceId id = m_nextId++; | 536 ResourceId id = m_nextId++; |
| 472 Resource resource(textureId, childInfo.pool, it->size, it->format); | 537 Resource resource(textureId, childInfo.pool, it->size, it->format); |
| 473 m_resources.add(id, resource); | 538 m_resources.add(id, resource); |
| 474 m_mailboxes.append(it->mailbox); | 539 m_mailboxes.append(it->mailbox); |
| 475 childInfo.parentToChildMap.add(id, it->id); | 540 childInfo.parentToChildMap.add(id, it->id); |
| 476 childInfo.childToParentMap.add(it->id, id); | 541 childInfo.childToParentMap.add(it->id, id); |
| 477 } | 542 } |
| 478 } | 543 } |
| 479 | 544 |
| 480 void CCResourceProvider::receiveFromParent(const TransferableResourceList& resou
rces) | 545 void CCResourceProvider::receiveFromParent(const TransferableResourceList& resou
rces) |
| 481 { | 546 { |
| 482 ASSERT(CCProxy::isImplThread()); | 547 ASSERT(CCProxy::isImplThread()); |
| 483 WebGraphicsContext3D* context3d = m_context->context3D(); | 548 WebGraphicsContext3D* context3d = m_context->context3D(); |
| 484 if (!context3d || !context3d->makeContextCurrent()) { | 549 if (!context3d || !context3d->makeContextCurrent()) { |
| 485 // FIXME: Implement this path for software compositing. | 550 // FIXME: Implement this path for software compositing. |
| 486 return; | 551 return; |
| 487 } | 552 } |
| 488 if (resources.syncPoint) | 553 if (resources.syncPoint) |
| 489 GLC(context3d, context3d->waitSyncPoint(resources.syncPoint)); | 554 GLC(context3d, context3d->waitSyncPoint(resources.syncPoint)); |
| 490 for (Vector<TransferableResource>::const_iterator it = resources.resources.b
egin(); it != resources.resources.end(); ++it) { | 555 for (Vector<TransferableResource>::const_iterator it = resources.resources.b
egin(); it != resources.resources.end(); ++it) { |
| 491 Resource& resource = m_resources.find(it->id)->second; | 556 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 492 ASSERT(resource.exported); | 557 Resource* resource = &m_resources.find(it->id)->value; |
| 493 resource.exported = false; | 558 #else |
| 494 GLC(context3d, context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, res
ource.glId)); | 559 Resource* resource = &m_resources.find(it->id)->second; |
| 560 #endif |
| 561 ASSERT(resource->exported); |
| 562 resource->exported = false; |
| 563 GLC(context3d, context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, res
ource->glId)); |
| 495 GLC(context3d, context3d->consumeTextureCHROMIUM(GraphicsContext3D::TEXT
URE_2D, it->mailbox.name)); | 564 GLC(context3d, context3d->consumeTextureCHROMIUM(GraphicsContext3D::TEXT
URE_2D, it->mailbox.name)); |
| 496 m_mailboxes.append(it->mailbox); | 565 m_mailboxes.append(it->mailbox); |
| 497 } | 566 } |
| 498 } | 567 } |
| 499 | 568 |
| 500 bool CCResourceProvider::transferResource(WebGraphicsContext3D* context, Resourc
eId id, TransferableResource* resource) | 569 bool CCResourceProvider::transferResource(WebGraphicsContext3D* context, Resourc
eId id, TransferableResource* resource) |
| 501 { | 570 { |
| 502 ASSERT(CCProxy::isImplThread()); | 571 ASSERT(CCProxy::isImplThread()); |
| 503 ResourceMap::const_iterator it = m_resources.find(id); | 572 ResourceMap::const_iterator it = m_resources.find(id); |
| 504 ASSERT(it != m_resources.end()); | 573 ASSERT(it != m_resources.end()); |
| 505 ASSERT(!it->second.lockedForWrite); | 574 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 506 ASSERT(!it->second.lockForReadCount); | 575 const Resource* source = &it->value; |
| 507 ASSERT(!it->second.external); | 576 #else |
| 508 if (it->second.exported) | 577 const Resource* source = &it->second; |
| 578 #endif |
| 579 ASSERT(!source->lockedForWrite); |
| 580 ASSERT(!source->lockForReadCount); |
| 581 ASSERT(!source->external); |
| 582 if (source->exported) |
| 509 return false; | 583 return false; |
| 510 resource->id = id; | 584 resource->id = id; |
| 511 resource->format = it->second.format; | 585 resource->format = source->format; |
| 512 resource->size = it->second.size; | 586 resource->size = source->size; |
| 513 if (!m_mailboxes.isEmpty()) | 587 if (!m_mailboxes.isEmpty()) |
| 514 resource->mailbox = m_mailboxes.takeFirst(); | 588 resource->mailbox = m_mailboxes.takeFirst(); |
| 515 else | 589 else |
| 516 GLC(context, context->genMailboxCHROMIUM(resource->mailbox.name)); | 590 GLC(context, context->genMailboxCHROMIUM(resource->mailbox.name)); |
| 517 GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, it->second.
glId)); | 591 GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, source->glI
d)); |
| 518 GLC(context, context->produceTextureCHROMIUM(GraphicsContext3D::TEXTURE_2D,
resource->mailbox.name)); | 592 GLC(context, context->produceTextureCHROMIUM(GraphicsContext3D::TEXTURE_2D,
resource->mailbox.name)); |
| 519 return true; | 593 return true; |
| 520 } | 594 } |
| 521 | 595 |
| 522 void CCResourceProvider::trimMailboxDeque() | 596 void CCResourceProvider::trimMailboxDeque() |
| 523 { | 597 { |
| 524 // Trim the mailbox deque to the maximum number of resources we may need to | 598 // Trim the mailbox deque to the maximum number of resources we may need to |
| 525 // send. | 599 // send. |
| 526 // If we have a parent, any non-external resource not already transfered is | 600 // If we have a parent, any non-external resource not already transfered is |
| 527 // eligible to be sent to the parent. Otherwise, all resources belonging to | 601 // eligible to be sent to the parent. Otherwise, all resources belonging to |
| 528 // a child might need to be sent back to the child. | 602 // a child might need to be sent back to the child. |
| 529 size_t maxMailboxCount = 0; | 603 size_t maxMailboxCount = 0; |
| 530 if (m_context->capabilities().hasParentCompositor) { | 604 if (m_context->capabilities().hasParentCompositor) { |
| 531 for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.e
nd(); ++it) { | 605 for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.e
nd(); ++it) { |
| 606 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 607 if (!it->value.exported && !it->value.external) |
| 608 #else |
| 532 if (!it->second.exported && !it->second.external) | 609 if (!it->second.exported && !it->second.external) |
| 610 #endif |
| 533 ++maxMailboxCount; | 611 ++maxMailboxCount; |
| 534 } | 612 } |
| 535 } else { | 613 } else { |
| 536 HashSet<int> childPoolSet; | 614 HashSet<int> childPoolSet; |
| 537 for (ChildMap::iterator it = m_children.begin(); it != m_children.end();
++it) | 615 for (ChildMap::iterator it = m_children.begin(); it != m_children.end();
++it) |
| 616 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 617 childPoolSet.add(it->value.pool); |
| 618 #else |
| 538 childPoolSet.add(it->second.pool); | 619 childPoolSet.add(it->second.pool); |
| 620 #endif |
| 539 for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.e
nd(); ++it) { | 621 for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.e
nd(); ++it) { |
| 622 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
| 623 if (childPoolSet.contains(it->value.pool)) |
| 624 #else |
| 540 if (childPoolSet.contains(it->second.pool)) | 625 if (childPoolSet.contains(it->second.pool)) |
| 626 #endif |
| 541 ++maxMailboxCount; | 627 ++maxMailboxCount; |
| 542 } | 628 } |
| 543 } | 629 } |
| 544 while (m_mailboxes.size() > maxMailboxCount) | 630 while (m_mailboxes.size() > maxMailboxCount) |
| 545 m_mailboxes.removeFirst(); | 631 m_mailboxes.removeFirst(); |
| 546 } | 632 } |
| 547 | 633 |
| 548 } | 634 } |
| OLD | NEW |