| 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/layers/render_surface_impl.h" | 5 #include "cc/layers/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/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "cc/base/math_util.h" | 11 #include "cc/base/math_util.h" |
| 12 #include "cc/debug/debug_colors.h" | 12 #include "cc/debug/debug_colors.h" |
| 13 #include "cc/layers/delegated_renderer_layer_impl.h" | 13 #include "cc/layers/delegated_renderer_layer_impl.h" |
| 14 #include "cc/layers/layer_impl.h" | 14 #include "cc/layers/layer_impl.h" |
| 15 #include "cc/layers/quad_sink.h" | |
| 16 #include "cc/layers/render_pass_sink.h" | 15 #include "cc/layers/render_pass_sink.h" |
| 17 #include "cc/quads/debug_border_draw_quad.h" | 16 #include "cc/quads/debug_border_draw_quad.h" |
| 18 #include "cc/quads/render_pass.h" | 17 #include "cc/quads/render_pass.h" |
| 19 #include "cc/quads/render_pass_draw_quad.h" | 18 #include "cc/quads/render_pass_draw_quad.h" |
| 20 #include "cc/quads/shared_quad_state.h" | 19 #include "cc/quads/shared_quad_state.h" |
| 21 #include "cc/trees/damage_tracker.h" | 20 #include "cc/trees/damage_tracker.h" |
| 21 #include "cc/trees/occlusion_tracker.h" |
| 22 #include "third_party/skia/include/core/SkImageFilter.h" | 22 #include "third_party/skia/include/core/SkImageFilter.h" |
| 23 #include "ui/gfx/rect_conversions.h" | 23 #include "ui/gfx/rect_conversions.h" |
| 24 #include "ui/gfx/transform.h" | 24 #include "ui/gfx/transform.h" |
| 25 | 25 |
| 26 namespace cc { | 26 namespace cc { |
| 27 | 27 |
| 28 RenderSurfaceImpl::RenderSurfaceImpl(LayerImpl* owning_layer) | 28 RenderSurfaceImpl::RenderSurfaceImpl(LayerImpl* owning_layer) |
| 29 : owning_layer_(owning_layer), | 29 : owning_layer_(owning_layer), |
| 30 surface_property_changed_(false), | 30 surface_property_changed_(false), |
| 31 draw_opacity_is_animating_(false), | 31 draw_opacity_is_animating_(false), |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 scoped_ptr<RenderPass> pass = RenderPass::Create(layer_list_.size()); | 130 scoped_ptr<RenderPass> pass = RenderPass::Create(layer_list_.size()); |
| 131 pass->SetNew(RenderPassId(), | 131 pass->SetNew(RenderPassId(), |
| 132 content_rect_, | 132 content_rect_, |
| 133 gfx::IntersectRects(content_rect_, | 133 gfx::IntersectRects(content_rect_, |
| 134 damage_tracker_->current_damage_rect()), | 134 damage_tracker_->current_damage_rect()), |
| 135 screen_space_transform_); | 135 screen_space_transform_); |
| 136 pass_sink->AppendRenderPass(pass.Pass()); | 136 pass_sink->AppendRenderPass(pass.Pass()); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void RenderSurfaceImpl::AppendQuads(QuadSink* quad_sink, | 139 void RenderSurfaceImpl::AppendQuads( |
| 140 AppendQuadsData* append_quads_data, | 140 RenderPass* render_pass, |
| 141 bool for_replica, | 141 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 142 RenderPass::Id render_pass_id) { | 142 AppendQuadsData* append_quads_data, |
| 143 bool for_replica, |
| 144 RenderPass::Id render_pass_id) { |
| 143 DCHECK(!for_replica || owning_layer_->has_replica()); | 145 DCHECK(!for_replica || owning_layer_->has_replica()); |
| 144 | 146 |
| 145 const gfx::Transform& draw_transform = | 147 const gfx::Transform& draw_transform = |
| 146 for_replica ? replica_draw_transform_ : draw_transform_; | 148 for_replica ? replica_draw_transform_ : draw_transform_; |
| 147 gfx::Rect visible_content_rect = | 149 gfx::Rect visible_content_rect = |
| 148 quad_sink->UnoccludedContributingSurfaceContentRect( | 150 occlusion_tracker.UnoccludedContributingSurfaceContentRect( |
| 149 owning_layer_, content_rect_, draw_transform); | 151 owning_layer_, content_rect_, draw_transform); |
| 150 if (visible_content_rect.IsEmpty()) | 152 if (visible_content_rect.IsEmpty()) |
| 151 return; | 153 return; |
| 152 | 154 |
| 153 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); | 155 SharedQuadState* shared_quad_state = |
| 156 render_pass->CreateAndAppendSharedQuadState(); |
| 154 shared_quad_state->SetAll(draw_transform, | 157 shared_quad_state->SetAll(draw_transform, |
| 155 content_rect_.size(), | 158 content_rect_.size(), |
| 156 content_rect_, | 159 content_rect_, |
| 157 clip_rect_, | 160 clip_rect_, |
| 158 is_clipped_, | 161 is_clipped_, |
| 159 draw_opacity_, | 162 draw_opacity_, |
| 160 owning_layer_->blend_mode()); | 163 owning_layer_->blend_mode()); |
| 161 | 164 |
| 162 if (owning_layer_->ShowDebugBorders()) { | 165 if (owning_layer_->ShowDebugBorders()) { |
| 163 SkColor color = for_replica ? | 166 SkColor color = for_replica ? |
| 164 DebugColors::SurfaceReplicaBorderColor() : | 167 DebugColors::SurfaceReplicaBorderColor() : |
| 165 DebugColors::SurfaceBorderColor(); | 168 DebugColors::SurfaceBorderColor(); |
| 166 float width = for_replica ? | 169 float width = for_replica ? |
| 167 DebugColors::SurfaceReplicaBorderWidth( | 170 DebugColors::SurfaceReplicaBorderWidth( |
| 168 owning_layer_->layer_tree_impl()) : | 171 owning_layer_->layer_tree_impl()) : |
| 169 DebugColors::SurfaceBorderWidth( | 172 DebugColors::SurfaceBorderWidth( |
| 170 owning_layer_->layer_tree_impl()); | 173 owning_layer_->layer_tree_impl()); |
| 171 scoped_ptr<DebugBorderDrawQuad> debug_border_quad = | 174 scoped_ptr<DebugBorderDrawQuad> debug_border_quad = |
| 172 DebugBorderDrawQuad::Create(); | 175 DebugBorderDrawQuad::Create(); |
| 173 debug_border_quad->SetNew( | 176 debug_border_quad->SetNew( |
| 174 shared_quad_state, content_rect_, visible_content_rect, color, width); | 177 shared_quad_state, content_rect_, visible_content_rect, color, width); |
| 175 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>()); | 178 render_pass->AppendDrawQuad(debug_border_quad.PassAs<DrawQuad>()); |
| 176 } | 179 } |
| 177 | 180 |
| 178 // TODO(shawnsingh): By using the same RenderSurfaceImpl for both the content | 181 // TODO(shawnsingh): By using the same RenderSurfaceImpl for both the content |
| 179 // and its reflection, it's currently not possible to apply a separate mask to | 182 // and its reflection, it's currently not possible to apply a separate mask to |
| 180 // the reflection layer or correctly handle opacity in reflections (opacity | 183 // the reflection layer or correctly handle opacity in reflections (opacity |
| 181 // must be applied after drawing both the layer and its reflection). The | 184 // must be applied after drawing both the layer and its reflection). The |
| 182 // solution is to introduce yet another RenderSurfaceImpl to draw the layer | 185 // solution is to introduce yet another RenderSurfaceImpl to draw the layer |
| 183 // and its reflection in. For now we only apply a separate reflection mask if | 186 // and its reflection in. For now we only apply a separate reflection mask if |
| 184 // the contents don't have a mask of their own. | 187 // the contents don't have a mask of their own. |
| 185 LayerImpl* mask_layer = owning_layer_->mask_layer(); | 188 LayerImpl* mask_layer = owning_layer_->mask_layer(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 quad->SetNew(shared_quad_state, | 228 quad->SetNew(shared_quad_state, |
| 226 content_rect_, | 229 content_rect_, |
| 227 visible_content_rect, | 230 visible_content_rect, |
| 228 render_pass_id, | 231 render_pass_id, |
| 229 for_replica, | 232 for_replica, |
| 230 mask_resource_id, | 233 mask_resource_id, |
| 231 contents_changed_since_last_frame, | 234 contents_changed_since_last_frame, |
| 232 mask_uv_rect, | 235 mask_uv_rect, |
| 233 owning_layer_->filters(), | 236 owning_layer_->filters(), |
| 234 owning_layer_->background_filters()); | 237 owning_layer_->background_filters()); |
| 235 quad_sink->Append(quad.PassAs<DrawQuad>()); | 238 render_pass->AppendDrawQuad(quad.PassAs<DrawQuad>()); |
| 236 } | 239 } |
| 237 | 240 |
| 238 } // namespace cc | 241 } // namespace cc |
| OLD | NEW |