OLD | NEW |
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 "cc/render_surface_impl.h" | 5 #include "cc/render_surface_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
11 #include "cc/damage_tracker.h" | 11 #include "cc/damage_tracker.h" |
12 #include "cc/debug_border_draw_quad.h" | 12 #include "cc/debug_border_draw_quad.h" |
| 13 #include "cc/debug_colors.h" |
13 #include "cc/delegated_renderer_layer_impl.h" | 14 #include "cc/delegated_renderer_layer_impl.h" |
14 #include "cc/layer_impl.h" | 15 #include "cc/layer_impl.h" |
15 #include "cc/math_util.h" | 16 #include "cc/math_util.h" |
16 #include "cc/quad_sink.h" | 17 #include "cc/quad_sink.h" |
17 #include "cc/render_pass.h" | 18 #include "cc/render_pass.h" |
18 #include "cc/render_pass_draw_quad.h" | 19 #include "cc/render_pass_draw_quad.h" |
19 #include "cc/render_pass_sink.h" | 20 #include "cc/render_pass_sink.h" |
20 #include "cc/shared_quad_state.h" | 21 #include "cc/shared_quad_state.h" |
21 #include "ui/gfx/rect_conversions.h" | 22 #include "ui/gfx/rect_conversions.h" |
22 #include <public/WebTransformationMatrix.h> | 23 #include <public/WebTransformationMatrix.h> |
23 | 24 |
24 using WebKit::WebTransformationMatrix; | 25 using WebKit::WebTransformationMatrix; |
25 | 26 |
26 namespace cc { | 27 namespace cc { |
27 | 28 |
28 static const int debugSurfaceBorderWidth = 2; | |
29 static const int debugSurfaceBorderAlpha = 100; | |
30 static const int debugSurfaceBorderColorRed = 0; | |
31 static const int debugSurfaceBorderColorGreen = 0; | |
32 static const int debugSurfaceBorderColorBlue = 255; | |
33 static const int debugReplicaBorderColorRed = 160; | |
34 static const int debugReplicaBorderColorGreen = 0; | |
35 static const int debugReplicaBorderColorBlue = 255; | |
36 | |
37 RenderSurfaceImpl::RenderSurfaceImpl(LayerImpl* owningLayer) | 29 RenderSurfaceImpl::RenderSurfaceImpl(LayerImpl* owningLayer) |
38 : m_owningLayer(owningLayer) | 30 : m_owningLayer(owningLayer) |
39 , m_surfacePropertyChanged(false) | 31 , m_surfacePropertyChanged(false) |
40 , m_drawOpacity(1) | 32 , m_drawOpacity(1) |
41 , m_drawOpacityIsAnimating(false) | 33 , m_drawOpacityIsAnimating(false) |
42 , m_targetSurfaceTransformsAreAnimating(false) | 34 , m_targetSurfaceTransformsAreAnimating(false) |
43 , m_screenSpaceTransformsAreAnimating(false) | 35 , m_screenSpaceTransformsAreAnimating(false) |
44 , m_nearestAncestorThatMovesPixels(0) | 36 , m_nearestAncestorThatMovesPixels(0) |
45 , m_targetRenderSurfaceLayerIndexHistory(0) | 37 , m_targetRenderSurfaceLayerIndexHistory(0) |
46 , m_currentLayerIndexHistory(0) | 38 , m_currentLayerIndexHistory(0) |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 void RenderSurfaceImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQ
uadsData, bool forReplica, RenderPass::Id renderPassId) | 195 void RenderSurfaceImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQ
uadsData, bool forReplica, RenderPass::Id renderPassId) |
204 { | 196 { |
205 DCHECK(!forReplica || m_owningLayer->hasReplica()); | 197 DCHECK(!forReplica || m_owningLayer->hasReplica()); |
206 | 198 |
207 gfx::Rect clippedRectInTarget = computeClippedRectInTarget(m_owningLayer); | 199 gfx::Rect clippedRectInTarget = computeClippedRectInTarget(m_owningLayer); |
208 bool isOpaque = false; | 200 bool isOpaque = false; |
209 const WebTransformationMatrix& drawTransform = forReplica ? m_replicaDrawTra
nsform : m_drawTransform; | 201 const WebTransformationMatrix& drawTransform = forReplica ? m_replicaDrawTra
nsform : m_drawTransform; |
210 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(SharedQuadSta
te::create(drawTransform, m_contentRect, clippedRectInTarget, m_drawOpacity, isO
paque).Pass()); | 202 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(SharedQuadSta
te::create(drawTransform, m_contentRect, clippedRectInTarget, m_drawOpacity, isO
paque).Pass()); |
211 | 203 |
212 if (m_owningLayer->showDebugBorders()) { | 204 if (m_owningLayer->showDebugBorders()) { |
213 int red = forReplica ? debugReplicaBorderColorRed : debugSurfaceBorderCo
lorRed; | 205 SkColor color = forReplica ? DebugColors::SurfaceReplicaBorderColor() :
DebugColors::SurfaceBorderColor(); |
214 int green = forReplica ? debugReplicaBorderColorGreen : debugSurfaceBor
derColorGreen; | 206 float width = forReplica ? DebugColors::SurfaceReplicaBorderWidth(m_owni
ngLayer->layerTreeHostImpl()) : DebugColors::SurfaceBorderWidth(m_owningLayer->l
ayerTreeHostImpl()); |
215 int blue = forReplica ? debugReplicaBorderColorBlue : debugSurfaceBorder
ColorBlue; | 207 quadSink.append(DebugBorderDrawQuad::create(sharedQuadState, contentRect
(), color, width).PassAs<DrawQuad>(), appendQuadsData); |
216 SkColor color = SkColorSetARGB(debugSurfaceBorderAlpha, red, green, blue
); | |
217 quadSink.append(DebugBorderDrawQuad::create(sharedQuadState, contentRect
(), color, debugSurfaceBorderWidth).PassAs<DrawQuad>(), appendQuadsData); | |
218 } | 208 } |
219 | 209 |
220 // FIXME: By using the same RenderSurfaceImpl for both the content and its r
eflection, | 210 // FIXME: By using the same RenderSurfaceImpl for both the content and its r
eflection, |
221 // it's currently not possible to apply a separate mask to the reflection la
yer | 211 // it's currently not possible to apply a separate mask to the reflection la
yer |
222 // or correctly handle opacity in reflections (opacity must be applied after
drawing | 212 // or correctly handle opacity in reflections (opacity must be applied after
drawing |
223 // both the layer and its reflection). The solution is to introduce yet anot
her RenderSurfaceImpl | 213 // both the layer and its reflection). The solution is to introduce yet anot
her RenderSurfaceImpl |
224 // to draw the layer and its reflection in. For now we only apply a separate
reflection | 214 // to draw the layer and its reflection in. For now we only apply a separate
reflection |
225 // mask if the contents don't have a mask of their own. | 215 // mask if the contents don't have a mask of their own. |
226 LayerImpl* maskLayer = m_owningLayer->maskLayer(); | 216 LayerImpl* maskLayer = m_owningLayer->maskLayer(); |
227 if (maskLayer && (!maskLayer->drawsContent() || maskLayer->bounds().IsEmpty(
))) | 217 if (maskLayer && (!maskLayer->drawsContent() || maskLayer->bounds().IsEmpty(
))) |
(...skipping 17 matching lines...) Expand all Loading... |
245 } | 235 } |
246 | 236 |
247 ResourceProvider::ResourceId maskResourceId = maskLayer ? maskLayer->content
sResourceId() : 0; | 237 ResourceProvider::ResourceId maskResourceId = maskLayer ? maskLayer->content
sResourceId() : 0; |
248 gfx::Rect contentsChangedSinceLastFrame = contentsChanged() ? m_contentRect
: gfx::Rect(); | 238 gfx::Rect contentsChangedSinceLastFrame = contentsChanged() ? m_contentRect
: gfx::Rect(); |
249 | 239 |
250 quadSink.append(RenderPassDrawQuad::create(sharedQuadState, contentRect(), r
enderPassId, forReplica, maskResourceId, contentsChangedSinceLastFrame, | 240 quadSink.append(RenderPassDrawQuad::create(sharedQuadState, contentRect(), r
enderPassId, forReplica, maskResourceId, contentsChangedSinceLastFrame, |
251 maskTexCoordScaleX, maskTexCoor
dScaleY, maskTexCoordOffsetX, maskTexCoordOffsetY).PassAs<DrawQuad>(), appendQua
dsData); | 241 maskTexCoordScaleX, maskTexCoor
dScaleY, maskTexCoordOffsetX, maskTexCoordOffsetY).PassAs<DrawQuad>(), appendQua
dsData); |
252 } | 242 } |
253 | 243 |
254 } // namespace cc | 244 } // namespace cc |
OLD | NEW |