Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1505)

Side by Side Diff: cc/render_surface_impl.cc

Issue 11189043: cc: Rename cc classes and members to match filenames (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #include "CCRenderSurface.h" 7 #include "CCRenderSurface.h"
8 8
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "CCDamageTracker.h" 10 #include "CCDamageTracker.h"
(...skipping 14 matching lines...) Expand all
25 25
26 static const int debugSurfaceBorderWidth = 2; 26 static const int debugSurfaceBorderWidth = 2;
27 static const int debugSurfaceBorderAlpha = 100; 27 static const int debugSurfaceBorderAlpha = 100;
28 static const int debugSurfaceBorderColorRed = 0; 28 static const int debugSurfaceBorderColorRed = 0;
29 static const int debugSurfaceBorderColorGreen = 0; 29 static const int debugSurfaceBorderColorGreen = 0;
30 static const int debugSurfaceBorderColorBlue = 255; 30 static const int debugSurfaceBorderColorBlue = 255;
31 static const int debugReplicaBorderColorRed = 160; 31 static const int debugReplicaBorderColorRed = 160;
32 static const int debugReplicaBorderColorGreen = 0; 32 static const int debugReplicaBorderColorGreen = 0;
33 static const int debugReplicaBorderColorBlue = 255; 33 static const int debugReplicaBorderColorBlue = 255;
34 34
35 CCRenderSurface::CCRenderSurface(CCLayerImpl* owningLayer) 35 RenderSurfaceImpl::RenderSurfaceImpl(LayerImpl* owningLayer)
36 : m_owningLayer(owningLayer) 36 : m_owningLayer(owningLayer)
37 , m_surfacePropertyChanged(false) 37 , m_surfacePropertyChanged(false)
38 , m_drawOpacity(1) 38 , m_drawOpacity(1)
39 , m_drawOpacityIsAnimating(false) 39 , m_drawOpacityIsAnimating(false)
40 , m_targetSurfaceTransformsAreAnimating(false) 40 , m_targetSurfaceTransformsAreAnimating(false)
41 , m_screenSpaceTransformsAreAnimating(false) 41 , m_screenSpaceTransformsAreAnimating(false)
42 , m_nearestAncestorThatMovesPixels(0) 42 , m_nearestAncestorThatMovesPixels(0)
43 , m_targetRenderSurfaceLayerIndexHistory(0) 43 , m_targetRenderSurfaceLayerIndexHistory(0)
44 , m_currentLayerIndexHistory(0) 44 , m_currentLayerIndexHistory(0)
45 { 45 {
46 m_damageTracker = CCDamageTracker::create(); 46 m_damageTracker = DamageTracker::create();
47 } 47 }
48 48
49 CCRenderSurface::~CCRenderSurface() 49 RenderSurfaceImpl::~RenderSurfaceImpl()
50 { 50 {
51 } 51 }
52 52
53 FloatRect CCRenderSurface::drawableContentRect() const 53 FloatRect RenderSurfaceImpl::drawableContentRect() const
54 { 54 {
55 FloatRect drawableContentRect = CCMathUtil::mapClippedRect(m_drawTransform, m_contentRect); 55 FloatRect drawableContentRect = MathUtil::mapClippedRect(m_drawTransform, m_ contentRect);
56 if (m_owningLayer->hasReplica()) 56 if (m_owningLayer->hasReplica())
57 drawableContentRect.unite(CCMathUtil::mapClippedRect(m_replicaDrawTransf orm, m_contentRect)); 57 drawableContentRect.unite(MathUtil::mapClippedRect(m_replicaDrawTransfor m, m_contentRect));
58 58
59 return drawableContentRect; 59 return drawableContentRect;
60 } 60 }
61 61
62 std::string CCRenderSurface::name() const 62 std::string RenderSurfaceImpl::name() const
63 { 63 {
64 return base::StringPrintf("RenderSurface(id=%i,owner=%s)", m_owningLayer->id (), m_owningLayer->debugName().data()); 64 return base::StringPrintf("RenderSurfaceImpl(id=%i,owner=%s)", m_owningLayer ->id(), m_owningLayer->debugName().data());
65 } 65 }
66 66
67 static std::string indentString(int indent) 67 static std::string indentString(int indent)
68 { 68 {
69 std::string str; 69 std::string str;
70 for (int i = 0; i != indent; ++i) 70 for (int i = 0; i != indent; ++i)
71 str.append(" "); 71 str.append(" ");
72 return str; 72 return str;
73 } 73 }
74 74
75 void CCRenderSurface::dumpSurface(std::string* str, int indent) const 75 void RenderSurfaceImpl::dumpSurface(std::string* str, int indent) const
76 { 76 {
77 std::string indentStr = indentString(indent); 77 std::string indentStr = indentString(indent);
78 str->append(indentStr); 78 str->append(indentStr);
79 base::StringAppendF(str, "%s\n", name().data()); 79 base::StringAppendF(str, "%s\n", name().data());
80 80
81 indentStr.append(" "); 81 indentStr.append(" ");
82 str->append(indentStr); 82 str->append(indentStr);
83 base::StringAppendF(str, "contentRect: (%d, %d, %d, %d)\n", m_contentRect.x( ), m_contentRect.y(), m_contentRect.width(), m_contentRect.height()); 83 base::StringAppendF(str, "contentRect: (%d, %d, %d, %d)\n", m_contentRect.x( ), m_contentRect.y(), m_contentRect.width(), m_contentRect.height());
84 84
85 str->append(indentStr); 85 str->append(indentStr);
86 base::StringAppendF(str, "drawTransform: %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f\n", 86 base::StringAppendF(str, "drawTransform: %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f\n",
87 m_drawTransform.m11(), m_drawTransform.m12(), m_drawTransform.m13(), m_d rawTransform.m14(), 87 m_drawTransform.m11(), m_drawTransform.m12(), m_drawTransform.m13(), m_d rawTransform.m14(),
88 m_drawTransform.m21(), m_drawTransform.m22(), m_drawTransform.m23(), m_d rawTransform.m24(), 88 m_drawTransform.m21(), m_drawTransform.m22(), m_drawTransform.m23(), m_d rawTransform.m24(),
89 m_drawTransform.m31(), m_drawTransform.m32(), m_drawTransform.m33(), m_d rawTransform.m34(), 89 m_drawTransform.m31(), m_drawTransform.m32(), m_drawTransform.m33(), m_d rawTransform.m34(),
90 m_drawTransform.m41(), m_drawTransform.m42(), m_drawTransform.m43(), m_d rawTransform.m44()); 90 m_drawTransform.m41(), m_drawTransform.m42(), m_drawTransform.m43(), m_d rawTransform.m44());
91 91
92 str->append(indentStr); 92 str->append(indentStr);
93 base::StringAppendF(str, "damageRect is pos(%f, %f), size(%f, %f)\n", 93 base::StringAppendF(str, "damageRect is pos(%f, %f), size(%f, %f)\n",
94 m_damageTracker->currentDamageRect().x(), m_damageTracker->currentDamage Rect().y(), 94 m_damageTracker->currentDamageRect().x(), m_damageTracker->currentDamage Rect().y(),
95 m_damageTracker->currentDamageRect().width(), m_damageTracker->currentDa mageRect().height()); 95 m_damageTracker->currentDamageRect().width(), m_damageTracker->currentDa mageRect().height());
96 } 96 }
97 97
98 int CCRenderSurface::owningLayerId() const 98 int RenderSurfaceImpl::owningLayerId() const
99 { 99 {
100 return m_owningLayer ? m_owningLayer->id() : 0; 100 return m_owningLayer ? m_owningLayer->id() : 0;
101 } 101 }
102 102
103 103
104 void CCRenderSurface::setClipRect(const IntRect& clipRect) 104 void RenderSurfaceImpl::setClipRect(const IntRect& clipRect)
105 { 105 {
106 if (m_clipRect == clipRect) 106 if (m_clipRect == clipRect)
107 return; 107 return;
108 108
109 m_surfacePropertyChanged = true; 109 m_surfacePropertyChanged = true;
110 m_clipRect = clipRect; 110 m_clipRect = clipRect;
111 } 111 }
112 112
113 bool CCRenderSurface::contentsChanged() const 113 bool RenderSurfaceImpl::contentsChanged() const
114 { 114 {
115 return !m_damageTracker->currentDamageRect().isEmpty(); 115 return !m_damageTracker->currentDamageRect().isEmpty();
116 } 116 }
117 117
118 void CCRenderSurface::setContentRect(const IntRect& contentRect) 118 void RenderSurfaceImpl::setContentRect(const IntRect& contentRect)
119 { 119 {
120 if (m_contentRect == contentRect) 120 if (m_contentRect == contentRect)
121 return; 121 return;
122 122
123 m_surfacePropertyChanged = true; 123 m_surfacePropertyChanged = true;
124 m_contentRect = contentRect; 124 m_contentRect = contentRect;
125 } 125 }
126 126
127 bool CCRenderSurface::surfacePropertyChanged() const 127 bool RenderSurfaceImpl::surfacePropertyChanged() const
128 { 128 {
129 // Surface property changes are tracked as follows: 129 // Surface property changes are tracked as follows:
130 // 130 //
131 // - m_surfacePropertyChanged is flagged when the clipRect or contentRect ch ange. As 131 // - m_surfacePropertyChanged is flagged when the clipRect or contentRect ch ange. As
132 // of now, these are the only two properties that can be affected by desce ndant layers. 132 // of now, these are the only two properties that can be affected by desce ndant layers.
133 // 133 //
134 // - all other property changes come from the owning layer (or some ancestor layer 134 // - all other property changes come from the owning layer (or some ancestor layer
135 // that propagates its change to the owning layer). 135 // that propagates its change to the owning layer).
136 // 136 //
137 ASSERT(m_owningLayer); 137 ASSERT(m_owningLayer);
138 return m_surfacePropertyChanged || m_owningLayer->layerPropertyChanged(); 138 return m_surfacePropertyChanged || m_owningLayer->layerPropertyChanged();
139 } 139 }
140 140
141 bool CCRenderSurface::surfacePropertyChangedOnlyFromDescendant() const 141 bool RenderSurfaceImpl::surfacePropertyChangedOnlyFromDescendant() const
142 { 142 {
143 return m_surfacePropertyChanged && !m_owningLayer->layerPropertyChanged(); 143 return m_surfacePropertyChanged && !m_owningLayer->layerPropertyChanged();
144 } 144 }
145 145
146 void CCRenderSurface::addContributingDelegatedRenderPassLayer(CCLayerImpl* layer ) 146 void RenderSurfaceImpl::addContributingDelegatedRenderPassLayer(LayerImpl* layer )
147 { 147 {
148 ASSERT(std::find(m_layerList.begin(), m_layerList.end(), layer) != m_layerLi st.end()); 148 ASSERT(std::find(m_layerList.begin(), m_layerList.end(), layer) != m_layerLi st.end());
149 CCDelegatedRendererLayerImpl* delegatedRendererLayer = static_cast<CCDelegat edRendererLayerImpl*>(layer); 149 DelegatedRendererLayerImpl* delegatedRendererLayer = static_cast<DelegatedRe ndererLayerImpl*>(layer);
150 m_contributingDelegatedRenderPassLayerList.push_back(delegatedRendererLayer) ; 150 m_contributingDelegatedRenderPassLayerList.push_back(delegatedRendererLayer) ;
151 } 151 }
152 152
153 void CCRenderSurface::clearLayerLists() 153 void RenderSurfaceImpl::clearLayerLists()
154 { 154 {
155 m_layerList.clear(); 155 m_layerList.clear();
156 m_contributingDelegatedRenderPassLayerList.clear(); 156 m_contributingDelegatedRenderPassLayerList.clear();
157 } 157 }
158 158
159 static inline IntRect computeClippedRectInTarget(const CCLayerImpl* owningLayer) 159 static inline IntRect computeClippedRectInTarget(const LayerImpl* owningLayer)
160 { 160 {
161 ASSERT(owningLayer->parent()); 161 ASSERT(owningLayer->parent());
162 162
163 const CCLayerImpl* renderTarget = owningLayer->parent()->renderTarget(); 163 const LayerImpl* renderTarget = owningLayer->parent()->renderTarget();
164 const CCRenderSurface* self = owningLayer->renderSurface(); 164 const RenderSurfaceImpl* self = owningLayer->renderSurface();
165 165
166 IntRect clippedRectInTarget = self->clipRect(); 166 IntRect clippedRectInTarget = self->clipRect();
167 if (owningLayer->backgroundFilters().hasFilterThatMovesPixels()) { 167 if (owningLayer->backgroundFilters().hasFilterThatMovesPixels()) {
168 // If the layer has background filters that move pixels, we cannot sciss or as tightly. 168 // If the layer has background filters that move pixels, we cannot sciss or as tightly.
169 // FIXME: this should be able to be a tighter scissor, perhaps expanded by the filter outsets? 169 // FIXME: this should be able to be a tighter scissor, perhaps expanded by the filter outsets?
170 clippedRectInTarget = renderTarget->renderSurface()->contentRect(); 170 clippedRectInTarget = renderTarget->renderSurface()->contentRect();
171 } else if (clippedRectInTarget.isEmpty()) { 171 } else if (clippedRectInTarget.isEmpty()) {
172 // For surfaces, empty clipRect means that the surface does not clip any thing. 172 // For surfaces, empty clipRect means that the surface does not clip any thing.
173 clippedRectInTarget = enclosingIntRect(intersection(renderTarget->render Surface()->contentRect(), self->drawableContentRect())); 173 clippedRectInTarget = enclosingIntRect(intersection(renderTarget->render Surface()->contentRect(), self->drawableContentRect()));
174 } else 174 } else
175 clippedRectInTarget.intersect(enclosingIntRect(self->drawableContentRect ())); 175 clippedRectInTarget.intersect(enclosingIntRect(self->drawableContentRect ()));
176 return clippedRectInTarget; 176 return clippedRectInTarget;
177 } 177 }
178 178
179 CCRenderPass::Id CCRenderSurface::renderPassId() 179 RenderPass::Id RenderSurfaceImpl::renderPassId()
180 { 180 {
181 int layerId = m_owningLayer->id(); 181 int layerId = m_owningLayer->id();
182 int subId = 0; 182 int subId = 0;
183 ASSERT(layerId > 0); 183 ASSERT(layerId > 0);
184 return CCRenderPass::Id(layerId, subId); 184 return RenderPass::Id(layerId, subId);
185 } 185 }
186 186
187 void CCRenderSurface::appendRenderPasses(CCRenderPassSink& passSink) 187 void RenderSurfaceImpl::appendRenderPasses(RenderPassSink& passSink)
188 { 188 {
189 for (size_t i = 0; i < m_contributingDelegatedRenderPassLayerList.size(); ++ i) 189 for (size_t i = 0; i < m_contributingDelegatedRenderPassLayerList.size(); ++ i)
190 m_contributingDelegatedRenderPassLayerList[i]->appendContributingRenderP asses(passSink); 190 m_contributingDelegatedRenderPassLayerList[i]->appendContributingRenderP asses(passSink);
191 191
192 scoped_ptr<CCRenderPass> pass = CCRenderPass::create(renderPassId(), m_conte ntRect, m_screenSpaceTransform); 192 scoped_ptr<RenderPass> pass = RenderPass::create(renderPassId(), m_contentRe ct, m_screenSpaceTransform);
193 pass->setDamageRect(m_damageTracker->currentDamageRect()); 193 pass->setDamageRect(m_damageTracker->currentDamageRect());
194 pass->setFilters(m_owningLayer->filters()); 194 pass->setFilters(m_owningLayer->filters());
195 pass->setBackgroundFilters(m_owningLayer->backgroundFilters()); 195 pass->setBackgroundFilters(m_owningLayer->backgroundFilters());
196 passSink.appendRenderPass(pass.Pass()); 196 passSink.appendRenderPass(pass.Pass());
197 } 197 }
198 198
199 void CCRenderSurface::appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appen dQuadsData, bool forReplica, CCRenderPass::Id renderPassId) 199 void RenderSurfaceImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQ uadsData, bool forReplica, RenderPass::Id renderPassId)
200 { 200 {
201 ASSERT(!forReplica || m_owningLayer->hasReplica()); 201 ASSERT(!forReplica || m_owningLayer->hasReplica());
202 202
203 IntRect clippedRectInTarget = computeClippedRectInTarget(m_owningLayer); 203 IntRect clippedRectInTarget = computeClippedRectInTarget(m_owningLayer);
204 bool isOpaque = false; 204 bool isOpaque = false;
205 const WebTransformationMatrix& drawTransform = forReplica ? m_replicaDrawTra nsform : m_drawTransform; 205 const WebTransformationMatrix& drawTransform = forReplica ? m_replicaDrawTra nsform : m_drawTransform;
206 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(CCSharedQua dState::create(drawTransform, m_contentRect, clippedRectInTarget, m_drawOpacity, isOpaque).Pass()); 206 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(SharedQuadSta te::create(drawTransform, m_contentRect, clippedRectInTarget, m_drawOpacity, isO paque).Pass());
207 207
208 if (m_owningLayer->hasDebugBorders()) { 208 if (m_owningLayer->hasDebugBorders()) {
209 int red = forReplica ? debugReplicaBorderColorRed : debugSurfaceBorderCo lorRed; 209 int red = forReplica ? debugReplicaBorderColorRed : debugSurfaceBorderCo lorRed;
210 int green = forReplica ? debugReplicaBorderColorGreen : debugSurfaceBor derColorGreen; 210 int green = forReplica ? debugReplicaBorderColorGreen : debugSurfaceBor derColorGreen;
211 int blue = forReplica ? debugReplicaBorderColorBlue : debugSurfaceBorder ColorBlue; 211 int blue = forReplica ? debugReplicaBorderColorBlue : debugSurfaceBorder ColorBlue;
212 SkColor color = SkColorSetARGB(debugSurfaceBorderAlpha, red, green, blue ); 212 SkColor color = SkColorSetARGB(debugSurfaceBorderAlpha, red, green, blue );
213 quadSink.append(CCDebugBorderDrawQuad::create(sharedQuadState, contentRe ct(), color, debugSurfaceBorderWidth).PassAs<CCDrawQuad>(), appendQuadsData); 213 quadSink.append(DebugBorderDrawQuad::create(sharedQuadState, contentRect (), color, debugSurfaceBorderWidth).PassAs<DrawQuad>(), appendQuadsData);
214 } 214 }
215 215
216 // FIXME: By using the same RenderSurface for both the content and its refle ction, 216 // FIXME: By using the same RenderSurfaceImpl for both the content and its r eflection,
217 // it's currently not possible to apply a separate mask to the reflection la yer 217 // it's currently not possible to apply a separate mask to the reflection la yer
218 // or correctly handle opacity in reflections (opacity must be applied after drawing 218 // or correctly handle opacity in reflections (opacity must be applied after drawing
219 // both the layer and its reflection). The solution is to introduce yet anot her RenderSurface 219 // both the layer and its reflection). The solution is to introduce yet anot her RenderSurfaceImpl
220 // to draw the layer and its reflection in. For now we only apply a separate reflection 220 // to draw the layer and its reflection in. For now we only apply a separate reflection
221 // mask if the contents don't have a mask of their own. 221 // mask if the contents don't have a mask of their own.
222 CCLayerImpl* maskLayer = m_owningLayer->maskLayer(); 222 LayerImpl* maskLayer = m_owningLayer->maskLayer();
223 if (maskLayer && (!maskLayer->drawsContent() || maskLayer->bounds().isEmpty( ))) 223 if (maskLayer && (!maskLayer->drawsContent() || maskLayer->bounds().isEmpty( )))
224 maskLayer = 0; 224 maskLayer = 0;
225 225
226 if (!maskLayer && forReplica) { 226 if (!maskLayer && forReplica) {
227 maskLayer = m_owningLayer->replicaLayer()->maskLayer(); 227 maskLayer = m_owningLayer->replicaLayer()->maskLayer();
228 if (maskLayer && (!maskLayer->drawsContent() || maskLayer->bounds().isEm pty())) 228 if (maskLayer && (!maskLayer->drawsContent() || maskLayer->bounds().isEm pty()))
229 maskLayer = 0; 229 maskLayer = 0;
230 } 230 }
231 231
232 float maskTexCoordScaleX = 1; 232 float maskTexCoordScaleX = 1;
233 float maskTexCoordScaleY = 1; 233 float maskTexCoordScaleY = 1;
234 float maskTexCoordOffsetX = 1; 234 float maskTexCoordOffsetX = 1;
235 float maskTexCoordOffsetY = 1; 235 float maskTexCoordOffsetY = 1;
236 if (maskLayer) { 236 if (maskLayer) {
237 maskTexCoordScaleX = static_cast<float>(contentRect().width()) / maskLay er->contentBounds().width(); 237 maskTexCoordScaleX = static_cast<float>(contentRect().width()) / maskLay er->contentBounds().width();
238 maskTexCoordScaleY = static_cast<float>(contentRect().height()) / maskLa yer->contentBounds().height(); 238 maskTexCoordScaleY = static_cast<float>(contentRect().height()) / maskLa yer->contentBounds().height();
239 maskTexCoordOffsetX = static_cast<float>(contentRect().x()) / contentRec t().width() * maskTexCoordScaleX; 239 maskTexCoordOffsetX = static_cast<float>(contentRect().x()) / contentRec t().width() * maskTexCoordScaleX;
240 maskTexCoordOffsetY = static_cast<float>(contentRect().y()) / contentRec t().height() * maskTexCoordScaleY; 240 maskTexCoordOffsetY = static_cast<float>(contentRect().y()) / contentRec t().height() * maskTexCoordScaleY;
241 } 241 }
242 242
243 CCResourceProvider::ResourceId maskResourceId = maskLayer ? maskLayer->conte ntsResourceId() : 0; 243 ResourceProvider::ResourceId maskResourceId = maskLayer ? maskLayer->content sResourceId() : 0;
244 IntRect contentsChangedSinceLastFrame = contentsChanged() ? m_contentRect : IntRect(); 244 IntRect contentsChangedSinceLastFrame = contentsChanged() ? m_contentRect : IntRect();
245 245
246 quadSink.append(CCRenderPassDrawQuad::create(sharedQuadState, contentRect(), renderPassId, forReplica, maskResourceId, contentsChangedSinceLastFrame, 246 quadSink.append(RenderPassDrawQuad::create(sharedQuadState, contentRect(), r enderPassId, forReplica, maskResourceId, contentsChangedSinceLastFrame,
247 maskTexCoordScaleX, maskTexCoor dScaleY, maskTexCoordOffsetX, maskTexCoordOffsetY).PassAs<CCDrawQuad>(), appendQ uadsData); 247 maskTexCoordScaleX, maskTexCoor dScaleY, maskTexCoordOffsetX, maskTexCoordOffsetY).PassAs<DrawQuad>(), appendQua dsData);
248 } 248 }
249 249
250 } 250 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698