limit compositing when graphics layers requires too much tile memory.
authorSeojin Kim <seojin.kim@samsung.com>
Tue, 11 Sep 2012 09:56:50 +0000 (18:56 +0900)
committerJungJik Lee <jungjik.lee@samsung.com>
Tue, 11 Sep 2012 11:04:04 +0000 (20:04 +0900)
Change-Id: If6b66c13913f64db40347bd2d8c0b45f17091d58

Source/WTF/wtf/Platform.h
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h

index 8522d88..78af182 100755 (executable)
 #define ENABLE_TIZEN_WEBKIT2_DEBUG_BORDERS 1 /* Hyowon Kim(hw1008.kim@samsung.com) : Renders a border around composited Render Layers to help debug and study layer compositing. */
 #define ENABLE_TIZEN_WEBKIT2_TILED_AC 1 /* Youngtaeck Song(youngtaeck.song@samsung.com) : Tiling with Acceletated compositing for Tizen */
 #define ENABLE_TIZEN_WEBKIT2_TILED_AC_UPDATE_ONLY_VIEWPORT_AFTER_ZOOM 1 /* JungJik Lee(jungjik.lee@samsung.com) : WK2 Update the viewport area after zooming. */
+#define ENABLE_TIZEN_WEBKIT2_TILED_AC_LIMIT_COMPOSITING 1 /* Seojin Kim(seojin.kim@samsung.com) : limit compositing */
 #define ENABLE_TIZEN_WEB_LAYER_TREE_RENDERER_FUNCTION_NAME_BUG_FIX 1 /* YongGeol Jung(yg48.jung@samsung.com) : Fix wrong function name of WebLayerTreeRenderer */
 #define ENABLE_TIZEN_ONESHOT_DRAWING_SYNCHRONIZATION 1 /* Hyowon Kim(hw1008.kim@samsung.com) : Fix layer flickering */
 #define ENABLE_TIZEN_DONT_USE_TEXTURE_MAPPER_TEXTURE_POOL 1 /* Seojin Kim(seojin.kim@samsung.com) : TextureMapper texture pool has no shrink mechanism currently, and leads to OOM finally */
index d49ecb8..012f0ce 100644 (file)
@@ -196,6 +196,9 @@ RenderLayerCompositor::RenderLayerCompositor(RenderView* renderView)
     , m_obligatoryBackingAreaMegaPixels(0)
     , m_secondaryBackingAreaMegaPixels(0)
 #endif
+#if ENABLE(TIZEN_WEBKIT2_TILED_AC_LIMIT_COMPOSITING)
+    , m_compositingAllowed(true)
+#endif
 {
 }
 
@@ -352,6 +355,30 @@ bool RenderLayerCompositor::hasAnyAdditionalCompositedLayers(const RenderLayer*
     return m_compositedLayerCount > (rootLayer->isComposited() ? 1 : 0);
 }
 
+#if ENABLE(TIZEN_WEBKIT2_TILED_AC_LIMIT_COMPOSITING)
+void RenderLayerCompositor::countLayersWhichWillBeComposited(RenderLayer* layer, int& count)
+{
+    if (!layer)
+        return;
+
+    if (needsToBeComposited(layer))
+        count++;
+
+    for (RenderLayer* currLayer = layer->firstChild(); currLayer; currLayer = currLayer->nextSibling())
+        countLayersWhichWillBeComposited(currLayer, count);
+}
+
+void RenderLayerCompositor::disallowCompositingIfNeeded()
+{
+    m_compositingAllowed = true;
+
+    int willBeCompositedLayersCount = 0;
+    countLayersWhichWillBeComposited(rootRenderLayer(), willBeCompositedLayersCount);
+    if (willBeCompositedLayersCount > 100)
+        m_compositingAllowed = false;
+}
+#endif
+
 void RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType updateType, RenderLayer* updateRoot)
 {
     m_updateCompositingLayersTimer.stop();
@@ -366,6 +393,10 @@ void RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType update
     if (!m_reevaluateCompositingAfterLayout && !m_compositing)
         return;
 
+#if ENABLE(TIZEN_WEBKIT2_TILED_AC_LIMIT_COMPOSITING)
+    disallowCompositingIfNeeded();
+#endif
+
     AnimationUpdateBlock animationUpdateBlock(m_renderView->frameView()->frame()->animation());
 
     bool checkForHierarchyUpdate = m_reevaluateCompositingAfterLayout;
@@ -443,6 +474,9 @@ void RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType update
 
         // Host the document layer in the RenderView's root layer.
         if (isFullUpdate) {
+#if ENABLE(TIZEN_WEBKIT2_TILED_AC_LIMIT_COMPOSITING)
+            ensureRootLayer();
+#endif
             // Even when childList is empty, don't drop out of compositing mode if there are
             // composited layers that we didn't hit in our traversal (e.g. because of visibility:hidden).
             if (childList.isEmpty() && !hasAnyAdditionalCompositedLayers(updateRoot))
@@ -455,7 +489,7 @@ void RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType update
         // most of the time, geometry is updated via RenderLayer::styleChanged().
         updateLayerTreeGeometry(updateRoot, 0);
     }
-    
+
 #if !LOG_DISABLED
     if (compositingLogEnabled() && isFullUpdate && (needHierarchyUpdate || needGeometryUpdate)) {
         double endTime = currentTime();
@@ -1489,6 +1523,9 @@ bool RenderLayerCompositor::requiresCompositingLayer(const RenderLayer* layer) c
 
 bool RenderLayerCompositor::canBeComposited(const RenderLayer* layer) const
 {
+#if ENABLE(TIZEN_WEBKIT2_TILED_AC_LIMIT_COMPOSITING)
+    if (!m_compositingAllowed) return false;
+#endif
     // FIXME: We disable accelerated compositing for elements in a RenderFlowThread as it doesn't work properly.
     // See http://webkit.org/b/84900 to re-enable it.
     return m_hasAcceleratedCompositing && layer->isSelfPaintingLayer() && !layer->renderer()->inRenderFlowThread();
index c7c6340..ad3141f 100644 (file)
@@ -223,6 +223,11 @@ public:
     void unregisterAllScrollingLayers();
 #endif
 
+#if ENABLE(TIZEN_WEBKIT2_TILED_AC_LIMIT_COMPOSITING)
+    void countLayersWhichWillBeComposited(RenderLayer* layer, int& count);
+    void disallowCompositingIfNeeded();
+#endif
+
 private:
     class OverlapMap;
 
@@ -352,6 +357,9 @@ private:
     bool m_compositingLayersNeedRebuild;
     bool m_flushingLayers;
     bool m_forceCompositingMode;
+#if ENABLE(TIZEN_WEBKIT2_TILED_AC_LIMIT_COMPOSITING)
+    bool m_compositingAllowed;
+#endif
 
     RootLayerAttachment m_rootLayerAttachment;