Index: cc/CCResourceProvider.cpp |
diff --git a/cc/CCResourceProvider.cpp b/cc/CCResourceProvider.cpp |
index 54918c43d52f47a833353a89515d743d3a41d082..42caa1452c43ab2b059444ea8cc5d7a15ea0a0b7 100644 |
--- a/cc/CCResourceProvider.cpp |
+++ b/cc/CCResourceProvider.cpp |
@@ -14,6 +14,7 @@ |
#include "base/debug/alias.h" |
#include "base/string_split.h" |
#include "base/string_util.h" |
+#include "cc/transferable_resource.h" |
#include "CCProxy.h" |
#include "CCRendererGL.h" // For the GLC() macro. |
#include "Extensions3DChromium.h" |
@@ -50,14 +51,6 @@ static bool isTextureFormatSupportedForStorage(GC3Denum format) |
return (format == GraphicsContext3D::RGBA || format == Extensions3D::BGRA_EXT); |
} |
-CCResourceProvider::TransferableResourceList::TransferableResourceList() |
-{ |
-} |
- |
-CCResourceProvider::TransferableResourceList::~TransferableResourceList() |
-{ |
-} |
- |
CCResourceProvider::Resource::Resource() |
: glId(0) |
, pixels(0) |
@@ -66,7 +59,7 @@ CCResourceProvider::Resource::Resource() |
, lockedForWrite(false) |
, external(false) |
, exported(false) |
- , markedForDeletion(false) |
+ , deleted(false) |
, size() |
, format(0) |
, type(static_cast<ResourceType>(0)) |
@@ -81,7 +74,7 @@ CCResourceProvider::Resource::Resource(unsigned textureId, int pool, const IntSi |
, lockedForWrite(false) |
, external(false) |
, exported(false) |
- , markedForDeletion(false) |
+ , deleted(false) |
, size(size) |
, format(format) |
, type(GLTexture) |
@@ -96,7 +89,7 @@ CCResourceProvider::Resource::Resource(uint8_t* pixels, int pool, const IntSize& |
, lockedForWrite(false) |
, external(false) |
, exported(false) |
- , markedForDeletion(false) |
+ , deleted(false) |
, size(size) |
, format(format) |
, type(Bitmap) |
@@ -222,10 +215,10 @@ void CCResourceProvider::deleteResource(ResourceId id) |
#endif |
ASSERT(!resource->lockedForWrite); |
ASSERT(!resource->lockForReadCount); |
- ASSERT(!resource->markedForDeletion); |
+ ASSERT(!resource->deleted); |
if (resource->exported) { |
- resource->markedForDeletion = true; |
+ resource->deleted = true; |
return; |
} else |
deleteResourceInternal(it); |
@@ -255,10 +248,10 @@ void CCResourceProvider::deleteOwnedResources(int pool) |
ResourceIdArray toDelete; |
for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.end(); ++it) { |
#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
- if (it->value.pool == pool && !it->value.external && !it->value.markedForDeletion) |
+ if (it->value.pool == pool && !it->value.external && !it->value.deleted) |
toDelete.append(it->key); |
#else |
- if (it->second.pool == pool && !it->second.external && !it->value.markedForDeletion) |
+ if (it->second.pool == pool && !it->second.external && !it->value.deleted) |
toDelete.append(it->first); |
#endif |
} |
@@ -546,15 +539,15 @@ const CCResourceProvider::ResourceIdMap& CCResourceProvider::getChildToParentMap |
#endif |
} |
-CCResourceProvider::TransferableResourceList CCResourceProvider::prepareSendToParent(const ResourceIdArray& resources) |
+void CCResourceProvider::prepareSendToParent(const ResourceIdArray& resources, TransferableResourceList* list) |
{ |
ASSERT(CCProxy::isImplThread()); |
- TransferableResourceList list; |
- list.syncPoint = 0; |
+ list->sync_point = 0; |
+ list->resources.clear(); |
WebGraphicsContext3D* context3d = m_context->context3D(); |
if (!context3d || !context3d->makeContextCurrent()) { |
// FIXME: Implement this path for software compositing. |
- return list; |
+ return; |
} |
for (ResourceIdArray::const_iterator it = resources.begin(); it != resources.end(); ++it) { |
TransferableResource resource; |
@@ -564,23 +557,22 @@ CCResourceProvider::TransferableResourceList CCResourceProvider::prepareSendToPa |
#else |
m_resources.find(*it)->second.exported = true; |
#endif |
- list.resources.append(resource); |
+ list->resources.push_back(resource); |
} |
} |
- if (list.resources.size()) |
- list.syncPoint = context3d->insertSyncPoint(); |
- return list; |
+ if (list->resources.size()) |
+ list->sync_point = context3d->insertSyncPoint(); |
} |
-CCResourceProvider::TransferableResourceList CCResourceProvider::prepareSendToChild(int child, const ResourceIdArray& resources) |
+void CCResourceProvider::prepareSendToChild(int child, const ResourceIdArray& resources, TransferableResourceList* list) |
{ |
ASSERT(CCProxy::isImplThread()); |
- TransferableResourceList list; |
- list.syncPoint = 0; |
+ list->sync_point = 0; |
+ list->resources.clear(); |
WebGraphicsContext3D* context3d = m_context->context3D(); |
if (!context3d || !context3d->makeContextCurrent()) { |
// FIXME: Implement this path for software compositing. |
- return list; |
+ return; |
} |
#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
Child& childInfo = m_children.find(child)->value; |
@@ -594,12 +586,11 @@ CCResourceProvider::TransferableResourceList CCResourceProvider::prepareSendToCh |
resource.id = childInfo.parentToChildMap.get(*it); |
childInfo.parentToChildMap.remove(*it); |
childInfo.childToParentMap.remove(resource.id); |
- list.resources.append(resource); |
+ list->resources.push_back(resource); |
deleteResource(*it); |
} |
- if (list.resources.size()) |
- list.syncPoint = context3d->insertSyncPoint(); |
- return list; |
+ if (list->resources.size()) |
+ list->sync_point = context3d->insertSyncPoint(); |
} |
void CCResourceProvider::receiveFromChild(int child, const TransferableResourceList& resources) |
@@ -610,27 +601,27 @@ void CCResourceProvider::receiveFromChild(int child, const TransferableResourceL |
// FIXME: Implement this path for software compositing. |
return; |
} |
- if (resources.syncPoint) { |
+ if (resources.sync_point) { |
// NOTE: If the parent is a browser and the child a renderer, the parent |
// is not supposed to have its context wait, because that could induce |
// deadlocks and/or security issues. The caller is responsible for |
- // waiting asynchronously, and resetting syncPoint before calling this. |
+ // waiting asynchronously, and resetting sync_point before calling this. |
// However if the parent is a renderer (e.g. browser tag), it may be ok |
// (and is simpler) to wait. |
- GLC(context3d, context3d->waitSyncPoint(resources.syncPoint)); |
+ GLC(context3d, context3d->waitSyncPoint(resources.sync_point)); |
} |
#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
Child& childInfo = m_children.find(child)->value; |
#else |
Child& childInfo = m_children.find(child)->second; |
#endif |
- for (Vector<TransferableResource>::const_iterator it = resources.resources.begin(); it != resources.resources.end(); ++it) { |
+ for (std::vector<TransferableResource>::const_iterator it = resources.resources.begin(); it != resources.resources.end(); ++it) { |
unsigned textureId; |
GLC(context3d, textureId = context3d->createTexture()); |
GLC(context3d, context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId)); |
GLC(context3d, context3d->consumeTextureCHROMIUM(GraphicsContext3D::TEXTURE_2D, it->mailbox.name)); |
ResourceId id = m_nextId++; |
- Resource resource(textureId, childInfo.pool, it->size, it->format); |
+ Resource resource(textureId, childInfo.pool, IntSize(it->size.width(), it->size.height()), it->format); |
m_resources.add(id, resource); |
m_mailboxes.append(it->mailbox); |
childInfo.parentToChildMap.add(id, it->id); |
@@ -646,9 +637,9 @@ void CCResourceProvider::receiveFromParent(const TransferableResourceList& resou |
// FIXME: Implement this path for software compositing. |
return; |
} |
- if (resources.syncPoint) |
- GLC(context3d, context3d->waitSyncPoint(resources.syncPoint)); |
- for (Vector<TransferableResource>::const_iterator it = resources.resources.begin(); it != resources.resources.end(); ++it) { |
+ if (resources.sync_point) |
+ GLC(context3d, context3d->waitSyncPoint(resources.sync_point)); |
+ for (std::vector<TransferableResource>::const_iterator it = resources.resources.begin(); it != resources.resources.end(); ++it) { |
ResourceMap::iterator mapIterator = m_resources.find(it->id); |
ASSERT(mapIterator != m_resources.end()); |
#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
@@ -661,7 +652,7 @@ void CCResourceProvider::receiveFromParent(const TransferableResourceList& resou |
GLC(context3d, context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, resource->glId)); |
GLC(context3d, context3d->consumeTextureCHROMIUM(GraphicsContext3D::TEXTURE_2D, it->mailbox.name)); |
m_mailboxes.append(it->mailbox); |
- if (resource->markedForDeletion) |
+ if (resource->deleted) |
deleteResourceInternal(mapIterator); |
} |
} |
@@ -683,7 +674,7 @@ bool CCResourceProvider::transferResource(WebGraphicsContext3D* context, Resourc |
return false; |
resource->id = id; |
resource->format = source->format; |
- resource->size = source->size; |
+ resource->size = gfx::Size(source->size.height(), source->size.width()); |
if (!m_mailboxes.isEmpty()) |
resource->mailbox = m_mailboxes.takeFirst(); |
else |