summaryrefslogtreecommitdiffstats
path: root/cc/CCRenderPass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cc/CCRenderPass.cpp')
-rw-r--r--cc/CCRenderPass.cpp92
1 files changed, 92 insertions, 0 deletions
diff --git a/cc/CCRenderPass.cpp b/cc/CCRenderPass.cpp
new file mode 100644
index 0000000..2ab855f
--- /dev/null
+++ b/cc/CCRenderPass.cpp
@@ -0,0 +1,92 @@
+// Copyright 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+
+#include "CCRenderPass.h"
+
+#include "CCLayerImpl.h"
+#include "CCMathUtil.h"
+#include "CCOcclusionTracker.h"
+#include "CCQuadCuller.h"
+#include "CCSharedQuadState.h"
+#include "CCSolidColorDrawQuad.h"
+
+using WebKit::WebTransformationMatrix;
+
+namespace WebCore {
+
+PassOwnPtr<CCRenderPass> CCRenderPass::create(int id, IntRect outputRect, const WebKit::WebTransformationMatrix& transformToRootTarget)
+{
+ return adoptPtr(new CCRenderPass(id, outputRect, transformToRootTarget));
+}
+
+CCRenderPass::CCRenderPass(int id, IntRect outputRect, const WebKit::WebTransformationMatrix& transformToRootTarget)
+ : m_id(id)
+ , m_transformToRootTarget(transformToRootTarget)
+ , m_outputRect(outputRect)
+ , m_hasTransparentBackground(true)
+ , m_hasOcclusionFromOutsideTargetSurface(false)
+{
+ ASSERT(id > 0);
+}
+
+void CCRenderPass::appendQuadsForLayer(CCLayerImpl* layer, CCOcclusionTrackerImpl* occlusionTracker, bool& hadMissingTiles)
+{
+ const bool forSurface = false;
+ CCQuadCuller quadCuller(m_quadList, m_sharedQuadStateList, layer, occlusionTracker, layer->hasDebugBorders(), forSurface);
+
+ layer->appendQuads(quadCuller, hadMissingTiles);
+
+ m_hasOcclusionFromOutsideTargetSurface |= quadCuller.hasOcclusionFromOutsideTargetSurface();
+}
+
+void CCRenderPass::appendQuadsForRenderSurfaceLayer(CCLayerImpl* layer, const CCRenderPass* contributingRenderPass, CCOcclusionTrackerImpl* occlusionTracker)
+{
+ const bool forSurface = true;
+ CCQuadCuller quadCuller(m_quadList, m_sharedQuadStateList, layer, occlusionTracker, layer->hasDebugBorders(), forSurface);
+
+ bool isReplica = false;
+ layer->renderSurface()->appendQuads(quadCuller, isReplica, contributingRenderPass->id());
+
+ // Add replica after the surface so that it appears below the surface.
+ if (layer->hasReplica()) {
+ isReplica = true;
+ layer->renderSurface()->appendQuads(quadCuller, isReplica, contributingRenderPass->id());
+ }
+
+ m_hasOcclusionFromOutsideTargetSurface |= quadCuller.hasOcclusionFromOutsideTargetSurface();
+}
+
+void CCRenderPass::appendQuadsToFillScreen(CCLayerImpl* rootLayer, SkColor screenBackgroundColor, const CCOcclusionTrackerImpl& occlusionTracker)
+{
+ if (!rootLayer || !screenBackgroundColor)
+ return;
+
+ Region fillRegion = occlusionTracker.computeVisibleRegionInScreen();
+ if (fillRegion.isEmpty())
+ return;
+
+ bool forSurface = false;
+ CCQuadCuller quadCuller(m_quadList, m_sharedQuadStateList, rootLayer, &occlusionTracker, rootLayer->hasDebugBorders(), forSurface);
+
+ // Manually create the quad state for the gutter quads, as the root layer
+ // doesn't have any bounds and so can't generate this itself.
+ // FIXME: Make the gutter quads generated by the solid color layer (make it smarter about generating quads to fill unoccluded areas).
+ IntRect rootTargetRect = rootLayer->renderSurface()->contentRect();
+ float opacity = 1;
+ bool opaque = true;
+ CCSharedQuadState* sharedQuadState = quadCuller.useSharedQuadState(CCSharedQuadState::create(rootLayer->drawTransform(), rootTargetRect, rootTargetRect, opacity, opaque));
+ ASSERT(rootLayer->screenSpaceTransform().isInvertible());
+ WebTransformationMatrix transformToLayerSpace = rootLayer->screenSpaceTransform().inverse();
+ Vector<IntRect> fillRects = fillRegion.rects();
+ for (size_t i = 0; i < fillRects.size(); ++i) {
+ // The root layer transform is composed of translations and scales only, no perspective, so mapping is sufficient.
+ IntRect layerRect = CCMathUtil::mapClippedRect(transformToLayerSpace, fillRects[i]);
+ // Skip the quad culler and just append the quads directly to avoid occlusion checks.
+ m_quadList.append(CCSolidColorDrawQuad::create(sharedQuadState, layerRect, screenBackgroundColor));
+ }
+}
+
+}