1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
// 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 cc {
PassOwnPtr<CCRenderPass> CCRenderPass::create(Id id, IntRect outputRect, const WebKit::WebTransformationMatrix& transformToRootTarget)
{
return adoptPtr(new CCRenderPass(id, outputRect, transformToRootTarget));
}
CCRenderPass::CCRenderPass(Id id, IntRect outputRect, const WebKit::WebTransformationMatrix& transformToRootTarget)
: m_id(id)
, m_transformToRootTarget(transformToRootTarget)
, m_outputRect(outputRect)
, m_hasTransparentBackground(true)
, m_hasOcclusionFromOutsideTargetSurface(false)
{
ASSERT(id.layerId > 0);
ASSERT(id.index >= 0);
}
PassOwnPtr<CCRenderPass> CCRenderPass::copy(Id newId) const
{
ASSERT(newId != m_id);
OwnPtr<CCRenderPass> copyPass(create(newId, m_outputRect, m_transformToRootTarget));
copyPass->setDamageRect(m_damageRect);
copyPass->setHasTransparentBackground(m_hasTransparentBackground);
copyPass->setHasOcclusionFromOutsideTargetSurface(m_hasOcclusionFromOutsideTargetSurface);
copyPass->setFilters(m_filters);
copyPass->setBackgroundFilters(m_backgroundFilters);
return copyPass.release();
}
void CCRenderPass::appendQuadsForLayer(CCLayerImpl* layer, CCOcclusionTrackerImpl* occlusionTracker, CCAppendQuadsData& appendQuadsData)
{
const bool forSurface = false;
CCQuadCuller quadCuller(m_quadList, m_sharedQuadStateList, layer, occlusionTracker, layer->hasDebugBorders(), forSurface);
layer->appendQuads(quadCuller, appendQuadsData);
}
void CCRenderPass::appendQuadsForRenderSurfaceLayer(CCLayerImpl* layer, const CCRenderPass* contributingRenderPass, CCOcclusionTrackerImpl* occlusionTracker, CCAppendQuadsData& appendQuadsData)
{
const bool forSurface = true;
CCQuadCuller quadCuller(m_quadList, m_sharedQuadStateList, layer, occlusionTracker, layer->hasDebugBorders(), forSurface);
bool isReplica = false;
layer->renderSurface()->appendQuads(quadCuller, appendQuadsData, isReplica, contributingRenderPass->id());
// Add replica after the surface so that it appears below the surface.
if (layer->hasReplica()) {
isReplica = true;
layer->renderSurface()->appendQuads(quadCuller, appendQuadsData, isReplica, contributingRenderPass->id());
}
}
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<WebCore::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, cc::IntRect(fillRects[i]));
// Skip the quad culler and just append the quads directly to avoid occlusion checks.
m_quadList.append(CCSolidColorDrawQuad::create(sharedQuadState, layerRect, screenBackgroundColor));
}
}
}
|