Index: cc/CCDelegatedRendererLayerImpl.cpp |
diff --git a/cc/CCDelegatedRendererLayerImpl.cpp b/cc/CCDelegatedRendererLayerImpl.cpp |
index 02d569835fe8aaafb6ea89ada2c206aa0f277e4b..eed9843a031d9a1c3463810073126b1b9852f6b9 100644 |
--- a/cc/CCDelegatedRendererLayerImpl.cpp |
+++ b/cc/CCDelegatedRendererLayerImpl.cpp |
@@ -7,8 +7,9 @@ |
#include "CCDelegatedRendererLayerImpl.h" |
#include "CCAppendQuadsData.h" |
-#include "CCQuadSink.h" |
+#include "CCLayerTreeHostImpl.h" |
#include "CCMathUtil.h" |
+#include "CCQuadSink.h" |
#include "CCRenderPassDrawQuad.h" |
#include "CCRenderPassSink.h" |
@@ -16,12 +17,14 @@ namespace cc { |
CCDelegatedRendererLayerImpl::CCDelegatedRendererLayerImpl(int id) |
: CCLayerImpl(id) |
+ , m_childId(0) |
{ |
} |
CCDelegatedRendererLayerImpl::~CCDelegatedRendererLayerImpl() |
{ |
clearRenderPasses(); |
+ clearChild(); |
} |
bool CCDelegatedRendererLayerImpl::descendantDrawsContent() |
@@ -69,9 +72,29 @@ void CCDelegatedRendererLayerImpl::clearRenderPasses() |
m_renderPassesInDrawOrder.clear(); |
} |
+void CCDelegatedRendererLayerImpl::clearChild() |
+{ |
+ if (!m_childId) |
+ return; |
+ CCResourceProvider* resourceProvider = layerTreeHostImpl()->resourceProvider(); |
+ resourceProvider->destroyChild(m_childId); |
+ m_childId = 0; |
+} |
+ |
void CCDelegatedRendererLayerImpl::didLoseContext() |
{ |
clearRenderPasses(); |
+ clearChild(); |
+} |
+ |
+static int pool = 3; |
+ |
+void CCDelegatedRendererLayerImpl::createChild() |
+{ |
+ if (!m_childId) { |
+ CCResourceProvider* resourceProvider = layerTreeHostImpl()->resourceProvider(); |
+ m_childId = resourceProvider->createChild(pool++); |
+ } |
} |
static inline int indexToId(int index) { return index + 1; } |