Index: cc/DelegatedRendererLayerChromium.cpp |
diff --git a/cc/DelegatedRendererLayerChromium.cpp b/cc/DelegatedRendererLayerChromium.cpp |
index 8b7a710d3b2edc812ae2a7ca3fd18c3750084475..041a7c5b17c0aba6db0a3af58c3de00717f6e699 100644 |
--- a/cc/DelegatedRendererLayerChromium.cpp |
+++ b/cc/DelegatedRendererLayerChromium.cpp |
@@ -3,12 +3,83 @@ |
// found in the LICENSE file. |
#include "config.h" |
-#include "DelegatedRendererLayerChromium.h" |
+#include "cc/DelegatedRendererLayerChromium.h" |
-#include "CCDelegatedRendererLayerImpl.h" |
+#include "cc/CCDelegatedRendererLayerImpl.h" |
+#include "cc/CCLayerTreeHostImpl.h" |
+#include "cc/CCCheckerboardDrawQuad.h" |
+#include "cc/CCDebugBorderDrawQuad.h" |
+#include "cc/CCRenderPass.h" |
+#include "cc/CCRenderPassDrawQuad.h" |
+#include "cc/CCResourceProvider.h" |
+#include "cc/CCSolidColorDrawQuad.h" |
+#include "cc/CCTextureDrawQuad.h" |
+#include "cc/CCTileDrawQuad.h" |
+#include "cc/CCYUVVideoDrawQuad.h" |
namespace cc { |
+namespace { |
+ |
+void FixResourcesInDrawQuad(const CCDrawQuad* quad, const CCResourceProvider::ResourceIdMap& map, std::set<unsigned>* resources) { |
+ switch (quad->material()) { |
+ case CCDrawQuad::Invalid: |
+ //NOTREACHED(); |
+ break; |
+ case CCDrawQuad::Checkerboard: |
+ case CCDrawQuad::DebugBorder: |
+ case CCDrawQuad::SolidColor: |
+ break; |
+ case CCDrawQuad::IOSurfaceContent: |
+ // TODO(piman): convert to CCTextureDrawQuad? |
+ //NOTIMPLEMENTED(); |
+ break; |
+ case CCDrawQuad::RenderPass: { |
+ CCRenderPassDrawQuad* materialQuad = const_cast<CCRenderPassDrawQuad*>(CCRenderPassDrawQuad::materialCast(quad)); |
+ unsigned newResourceId = map.get(materialQuad->maskResourceId()); |
+ materialQuad->setMaskResourceId(newResourceId); |
+ resources->insert(newResourceId); |
+ break; |
+ } |
+ case CCDrawQuad::TextureContent: { |
+ CCTextureDrawQuad* materialQuad = const_cast<CCTextureDrawQuad*>(CCTextureDrawQuad::materialCast(quad)); |
+ unsigned newResourceId = map.get(materialQuad->resourceId()); |
+ materialQuad->setResourceId(newResourceId); |
+ resources->insert(newResourceId); |
+ break; |
+ } |
+ case CCDrawQuad::TiledContent: { |
+ CCTileDrawQuad* materialQuad = const_cast<CCTileDrawQuad*>(CCTileDrawQuad::materialCast(quad)); |
+ unsigned newResourceId = map.get(materialQuad->resourceId()); |
+ materialQuad->setResourceId(newResourceId); |
+ resources->insert(newResourceId); |
+ break; |
+ } |
+ case CCDrawQuad::YUVVideoContent: { |
+ // TODO |
+ /* |
+ const CCYUVVideoDrawQuad* yuvQuad = CCYUVVideoDrawQuad::materialCast(quad); |
+ resources->insert(yuvQuad->yPlane().resourceId); |
+ resources->insert(yuvQuad->uPlane().resourceId); |
+ resources->insert(yuvQuad->vPlane().resourceId); |
+ */ |
+ break; |
+ } |
+ case CCDrawQuad::StreamVideoContent: |
+ // TODO(piman): convert to CCTextureDrawQuad? |
+ //NOTIMPLEMENTED(); |
+ break; |
+ } |
+} |
+ |
+void FixResourcesInRenderPass(CCRenderPass* pass, const CCResourceProvider::ResourceIdMap& map, std::set<unsigned>* resources) { |
+ const CCQuadList& quadList = pass->quadList(); |
+ for (CCQuadList::const_iterator it = quadList.begin(); it != quadList.end(); ++it) |
+ FixResourcesInDrawQuad(*it, map, resources); |
+} |
+ |
+} // anonymous namespace |
+ |
PassRefPtr<DelegatedRendererLayerChromium> DelegatedRendererLayerChromium::create() |
{ |
return adoptRef(new DelegatedRendererLayerChromium()); |
@@ -16,9 +87,11 @@ PassRefPtr<DelegatedRendererLayerChromium> DelegatedRendererLayerChromium::creat |
DelegatedRendererLayerChromium::DelegatedRendererLayerChromium() |
: LayerChromium() |
+ , m_new(false) |
{ |
setIsDrawable(true); |
setMasksToBounds(true); |
+ m_recyclingResources.sync_point = 0; |
} |
DelegatedRendererLayerChromium::~DelegatedRendererLayerChromium() |
@@ -30,4 +103,64 @@ PassOwnPtr<CCLayerImpl> DelegatedRendererLayerChromium::createCCLayerImpl() |
return CCDelegatedRendererLayerImpl::create(m_layerId); |
} |
+void DelegatedRendererLayerChromium::pushPropertiesTo(CCLayerImpl* layer) |
+{ |
+ LayerChromium::pushPropertiesTo(layer); |
+ if (m_new) { |
+ typedef std::set<unsigned> ResourceSet; |
+ CCDelegatedRendererLayerImpl* delegatedRendererLayer = static_cast<CCDelegatedRendererLayerImpl*>(layer); |
+ CCResourceProvider* resourceProvider = layer->layerTreeHostImpl()->resourceProvider(); |
+ |
+ int childId = delegatedRendererLayer->childId(); |
+ if (!childId) { |
+ delegatedRendererLayer->createChild(); |
+ childId = delegatedRendererLayer->childId(); |
+ } |
+ resourceProvider->receiveFromChild(childId, m_frame.resources); |
+ m_frame.resources.sync_point = 0; |
+ m_frame.resources.resources.clear(); |
+ const CCResourceProvider::ResourceIdMap& map = resourceProvider->getChildToParentMap(childId); |
+ |
+ ResourceSet oldResources; |
+ oldResources.swap(m_currentResources); |
+ ScopedPtrVector<CCRenderPass> passes; |
+ for (size_t i = 0; i < m_frame.render_passes.size(); ++i) { |
+ scoped_ptr<CCRenderPass> pass(m_frame.render_passes[i]); |
+ FixResourcesInRenderPass(pass.get(), map, &m_currentResources); |
+ passes.append(pass.Pass()); |
+ } |
+ delegatedRendererLayer->setRenderPasses(passes); |
+ m_frame.render_passes.clear(); |
+ |
+ if (childId) { |
+ CCResourceProvider::ResourceIdArray array; |
+ for (ResourceSet::iterator it = oldResources.begin(); it != oldResources.end(); ++it) { |
+ if (m_currentResources.find(*it) == m_currentResources.end()) |
+ array.append(*it); |
+ } |
+ cc::TransferableResourceList recycle; |
+ recycle.sync_point = 0; |
+ resourceProvider->prepareSendToChild(childId, array, &recycle); |
+ if (recycle.sync_point) |
+ m_recyclingResources.sync_point = recycle.sync_point; |
+ m_recyclingResources.resources.insert(m_recyclingResources.resources.end(), recycle.resources.begin(), recycle.resources.end()); |
+ } |
+ m_new = false; |
+ } |
+} |
+ |
+void DelegatedRendererLayerChromium::setFrameData(const CompositorFrame& frame) |
+{ |
+ m_new = true; |
+ m_frame = frame; |
+ setNeedsCommit(); |
+} |
+ |
+void DelegatedRendererLayerChromium::getRecycledResources(TransferableResourceList* list) |
+{ |
+ std::swap(*list, m_recyclingResources); |
+ m_recyclingResources.sync_point = 0; |
+ m_recyclingResources.resources.clear(); |
+} |
+ |
} |